Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
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. More...
 
virtual ErrorCode leaf (EntityHandle node)
 Process a leaf node during tree traversal. More...
 
std::string commafy (int num)
 
void write_results (std::ostream &out)
 
- Public Member Functions inherited from moab::OrientedBoxTreeTool::Op
virtual ~Op ()
 

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::TriStats ( Interface mbi_p,
OrientedBoxTreeTool tool_p,
EntityHandle  root 
)
inline

Definition at line 238 of file obb_analysis.cpp.

239  : OrientedBoxTreeTool::Op(), sum( 0 ), leaves( 0 ), sqr( 0 ), mbi( mbi_p ), tool( tool_p )
240  {
241  min = std::numeric_limits< unsigned >::max();
242  max = std::numeric_limits< unsigned >::min();
243 
244  for( unsigned i = 0; i < ten_buckets_max; ++i )
245  {
246  ten_buckets[i] = 0;
247  ten_buckets_vol[i] = 0.;
248  }
249 
250  OrientedBox box;
251  ErrorCode rval = tool->box( root, box );
252  CHECKERR( mbi, rval );
253  tot_vol = box.volume();
254  }

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

Member Function Documentation

◆ commafy()

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

Definition at line 292 of file obb_analysis.cpp.

293  {
294  std::stringstream str;
295  str << num;
296  std::string s = str.str();
297 
298  int n = s.size();
299  for( int i = n - 3; i >= 1; i -= 3 )
300  {
301  s.insert( i, 1, ',' );
302  n++;
303  }
304 
305  return s;
306  }

◆ leaf()

virtual ErrorCode TriStats::leaf ( EntityHandle  node)
inlinevirtual

Process a leaf node during tree traversal.

Implements moab::OrientedBoxTreeTool::Op.

Definition at line 263 of file obb_analysis.cpp.

264  {
265 
266  Range tris;
267  ErrorCode rval = tool->get_moab_instance()->get_entities_by_type( node, MBTRI, tris );
268  unsigned count = tris.size();
269 
270  sum += count;
271  sqr += ( count * count );
272  if( min > count ) min = count;
273  if( max < count ) max = count;
274 
275  for( unsigned i = 0; i < ten_buckets_max; ++i )
276  {
277  if( count > std::pow( (double)10, (int)( i + 1 ) ) )
278  {
279  ten_buckets[i] += 1;
280  OrientedBox box;
281  rval = tool->box( node, box );
282  CHECKERR( mbi, rval );
283  ten_buckets_vol[i] += box.volume();
284  }
285  }
286 
287  leaves++;
288 
289  return rval;
290  }

References moab::OrientedBoxTreeTool::box(), CHECKERR, ErrorCode, moab::Interface::get_entities_by_type(), moab::OrientedBoxTreeTool::get_moab_instance(), MBTRI, moab::Range::size(), moab::sum(), and moab::OrientedBox::volume().

◆ visit()

virtual ErrorCode TriStats::visit ( EntityHandle  node,
int  depth,
bool &  descend 
)
inlinevirtual

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.

257  {
258 
259  descend = true;
260  return MB_SUCCESS;
261  }

References MB_SUCCESS.

◆ write_results()

void TriStats::write_results ( std::ostream &  out)
inline

Definition at line 308 of file obb_analysis.cpp.

309  {
310 
311  out << commafy( sum ) << " triangles in " << commafy( leaves ) << " leaves." << std::endl;
312 
313  double avg = sum / (double)leaves;
314  double stddev = std_dev( sqr, sum, leaves );
315 
316  out << "Tris per leaf: Min " << min << ", Max " << max << ", avg " << avg << ", stddev " << stddev << std::endl;
317 
318  for( unsigned i = 0; i < ten_buckets_max; ++i )
319  {
320  if( ten_buckets[i] )
321  {
322  out << "Leaves exceeding " << std::pow( (double)10, (int)( i + 1 ) )
323  << " triangles: " << ten_buckets[i];
324 
325  double frac_total_vol = ten_buckets_vol[i] / tot_vol;
326  double avg_ftv = frac_total_vol / ten_buckets[i];
327 
328  out << " (avg " << avg_ftv * 100.0 << "% of OBB volume)" << std::endl;
329  }
330  }
331  }

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

Referenced by obbstat_write().

Member Data Documentation

◆ leaves

unsigned TriStats::leaves

Definition at line 226 of file obb_analysis.cpp.

◆ max

unsigned TriStats::max

Definition at line 226 of file obb_analysis.cpp.

◆ mbi

Interface* TriStats::mbi

Definition at line 233 of file obb_analysis.cpp.

◆ min

unsigned TriStats::min

Definition at line 226 of file obb_analysis.cpp.

◆ sqr

double TriStats::sqr

Definition at line 227 of file obb_analysis.cpp.

◆ sum

unsigned TriStats::sum

Definition at line 226 of file obb_analysis.cpp.

◆ ten_buckets

unsigned TriStats::ten_buckets[ten_buckets_max]

Definition at line 230 of file obb_analysis.cpp.

◆ ten_buckets_max

const unsigned TriStats::ten_buckets_max = 5
static

Definition at line 229 of file obb_analysis.cpp.

◆ ten_buckets_vol

double TriStats::ten_buckets_vol[ten_buckets_max]

Definition at line 231 of file obb_analysis.cpp.

◆ tool

OrientedBoxTreeTool* TriStats::tool

Definition at line 234 of file obb_analysis.cpp.

◆ tot_vol

double TriStats::tot_vol

Definition at line 236 of file obb_analysis.cpp.


The documentation for this class was generated from the following file: