Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
TriStats Class Reference
+ Inheritance diagram for TriStats:
+ Collaboration diagram for TriStats:

Public Member Functions

 TriStats (Interface *mbi_p, OrientedBoxTreeTool *tool_p, EntityHandle root)
virtual ErrorCode visit (EntityHandle, int, bool &descend)
 Visit a node in the tree during a traversal.
virtual ErrorCode leaf (EntityHandle node)
 Process a leaf node during tree traversal.
std::string commafy (int num)
void write_results (std::ostream &out)

Public Attributes

unsigned min
unsigned max
unsigned sum
unsigned leaves
double sqr
unsigned ten_buckets [ten_buckets_max]
double ten_buckets_vol [ten_buckets_max]
Interfacembi
OrientedBoxTreeTooltool
double tot_vol

Static Public Attributes

static const unsigned ten_buckets_max = 5

Detailed Description

Definition at line 222 of file obb_analysis.cpp.


Constructor & Destructor Documentation

TriStats::TriStats ( Interface mbi_p,
OrientedBoxTreeTool tool_p,
EntityHandle  root 
) [inline]

Definition at line 238 of file obb_analysis.cpp.

References CHECKERR, ErrorCode, and moab::OrientedBox::volume().

        : OrientedBoxTreeTool::Op(), sum( 0 ), leaves( 0 ), sqr( 0 ), mbi( mbi_p ), tool( tool_p )
    {
        min = std::numeric_limits< unsigned >::max();
        max = std::numeric_limits< unsigned >::min();

        for( unsigned i = 0; i < ten_buckets_max; ++i )
        {
            ten_buckets[i]     = 0;
            ten_buckets_vol[i] = 0.;
        }

        OrientedBox box;
        ErrorCode rval = tool->box( root, box );
        CHECKERR( mbi, rval );
        tot_vol = box.volume();
    }

Member Function Documentation

std::string TriStats::commafy ( int  num) [inline]

Definition at line 292 of file obb_analysis.cpp.

    {
        std::stringstream str;
        str << num;
        std::string s = str.str();

        int n = s.size();
        for( int i = n - 3; i >= 1; i -= 3 )
        {
            s.insert( i, 1, ',' );
            n++;
        }

        return s;
    }
virtual ErrorCode TriStats::leaf ( EntityHandle  node) [inline, virtual]

Process a leaf node during tree traversal.

Implements moab::OrientedBoxTreeTool::Op.

Definition at line 263 of file obb_analysis.cpp.

References CHECKERR, ErrorCode, MBTRI, moab::Range::size(), moab::sum(), and moab::OrientedBox::volume().

    {

        Range tris;
        ErrorCode rval = tool->get_moab_instance()->get_entities_by_type( node, MBTRI, tris );
        unsigned count = tris.size();

        sum += count;
        sqr += ( count * count );
        if( min > count ) min = count;
        if( max < count ) max = count;

        for( unsigned i = 0; i < ten_buckets_max; ++i )
        {
            if( count > std::pow( (double)10, (int)( i + 1 ) ) )
            {
                ten_buckets[i] += 1;
                OrientedBox box;
                rval = tool->box( node, box );
                CHECKERR( mbi, rval );
                ten_buckets_vol[i] += box.volume();
            }
        }

        leaves++;

        return rval;
    }
virtual ErrorCode TriStats::visit ( EntityHandle  node,
int  depth,
bool &  descend 
) [inline, virtual]

Visit a node in the tree during a traversal.

This method is called for each node in the tree visited during a pre-order traversal.

Parameters:
nodeThe EntityHandle for the entity set for the tree node.
depthThe current depth in the tree.
descendOutput: if false, traversal will skip children of the current node, or if the current node is a leaf, the 'leaf' method will not be called.

Implements moab::OrientedBoxTreeTool::Op.

Definition at line 256 of file obb_analysis.cpp.

References MB_SUCCESS.

    {

        descend = true;
        return MB_SUCCESS;
    }
void TriStats::write_results ( std::ostream &  out) [inline]

Definition at line 308 of file obb_analysis.cpp.

References moab::std_dev(), and moab::sum().

    {

        out << commafy( sum ) << " triangles in " << commafy( leaves ) << " leaves." << std::endl;

        double avg    = sum / (double)leaves;
        double stddev = std_dev( sqr, sum, leaves );

        out << "Tris per leaf: Min " << min << ", Max " << max << ", avg " << avg << ", stddev " << stddev << std::endl;

        for( unsigned i = 0; i < ten_buckets_max; ++i )
        {
            if( ten_buckets[i] )
            {
                out << "Leaves exceeding " << std::pow( (double)10, (int)( i + 1 ) )
                    << " triangles: " << ten_buckets[i];

                double frac_total_vol = ten_buckets_vol[i] / tot_vol;
                double avg_ftv        = frac_total_vol / ten_buckets[i];

                out << " (avg " << avg_ftv * 100.0 << "% of OBB volume)" << std::endl;
            }
        }
    }

Member Data Documentation

unsigned TriStats::leaves

Definition at line 226 of file obb_analysis.cpp.

unsigned TriStats::max

Definition at line 226 of file obb_analysis.cpp.

Definition at line 233 of file obb_analysis.cpp.

unsigned TriStats::min

Definition at line 226 of file obb_analysis.cpp.

double TriStats::sqr

Definition at line 227 of file obb_analysis.cpp.

unsigned TriStats::sum

Definition at line 226 of file obb_analysis.cpp.

Definition at line 230 of file obb_analysis.cpp.

const unsigned TriStats::ten_buckets_max = 5 [static]

Definition at line 229 of file obb_analysis.cpp.

Definition at line 231 of file obb_analysis.cpp.

Definition at line 236 of file obb_analysis.cpp.

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines