moab
|
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] |
Interface * | mbi |
OrientedBoxTreeTool * | tool |
double | tot_vol |
Static Public Attributes | |
static const unsigned | ten_buckets_max = 5 |
Definition at line 189 of file obb_analysis.cpp.
TriStats::TriStats | ( | Interface * | mbi_p, |
OrientedBoxTreeTool * | tool_p, | ||
EntityHandle | root | ||
) | [inline] |
Definition at line 205 of file obb_analysis.cpp.
: 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(); }
std::string TriStats::commafy | ( | int | num | ) | [inline] |
Definition at line 256 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 230 of file obb_analysis.cpp.
{ 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.
node | The EntityHandle for the entity set for the tree node. |
depth | The current depth in the tree. |
descend | Output: 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 223 of file obb_analysis.cpp.
{ descend = true; return MB_SUCCESS; }
void TriStats::write_results | ( | std::ostream & | out | ) | [inline] |
Definition at line 271 of file obb_analysis.cpp.
{ 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; } } }
unsigned TriStats::leaves |
Definition at line 193 of file obb_analysis.cpp.
unsigned TriStats::max |
Definition at line 193 of file obb_analysis.cpp.
Definition at line 200 of file obb_analysis.cpp.
unsigned TriStats::min |
Definition at line 193 of file obb_analysis.cpp.
double TriStats::sqr |
Definition at line 194 of file obb_analysis.cpp.
unsigned TriStats::sum |
Definition at line 193 of file obb_analysis.cpp.
unsigned TriStats::ten_buckets[ten_buckets_max] |
Definition at line 197 of file obb_analysis.cpp.
const unsigned TriStats::ten_buckets_max = 5 [static] |
Definition at line 196 of file obb_analysis.cpp.
Definition at line 198 of file obb_analysis.cpp.
Definition at line 201 of file obb_analysis.cpp.
double TriStats::tot_vol |
Definition at line 203 of file obb_analysis.cpp.