Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::OrientedBoxTreeTool::TrvStats Class Reference

Traversal statistics structure. More...

#include <OrientedBoxTreeTool.hpp>

+ Collaboration diagram for moab::OrientedBoxTreeTool::TrvStats:

Public Member Functions

const std::vector< unsigned > & nodes_visited () const
 return counts of nodes visited, indexed by tree depth. the counts include both leaves and interior nodes More...
 
const std::vector< unsigned > & leaves_visited () const
 return counts of tree leaves visited, indexed by tree depth More...
 
const std::vector< unsigned > & traversals_ended () const
 return counts of traversals ended, indexed by tree depth More...
 
unsigned int ray_tri_tests () const
 return total number of ray-triangle intersection tests performed in calls made with this TrvStats More...
 
void reset ()
 reset all counters on this structure More...
 
void print (std::ostream &str) const
 print the contents of this structure to given stream More...
 
 TrvStats ()
 

Private Member Functions

void increment (unsigned depth)
 
void increment_leaf (unsigned depth)
 
void end_traversal (unsigned depth)
 

Private Attributes

std::vector< unsigned > nodes_visited_count
 
std::vector< unsigned > leaves_visited_count
 
std::vector< unsigned > traversals_ended_count
 
unsigned int ray_tri_tests_count
 

Friends

class OrientedBoxTreeTool
 

Detailed Description

Traversal statistics structure.

Structure to accumulate statistics on traversal performance. Passed optionally to query functions, this structure contains the count of nodes visited at each level in a tree, and the count of traversals that ended at each level. One TrvStats structure can be used with multiple OBB trees or multiple queries, or used on only a single tree or a single query.

Note that these traversal statistics are not related to the stats() query below, which calculates static information about a tree. These statistics relate to a tree's dynamic behavior on particular operations.

Definition at line 151 of file OrientedBoxTreeTool.hpp.

Constructor & Destructor Documentation

◆ TrvStats()

moab::OrientedBoxTreeTool::TrvStats::TrvStats ( )
inline

Definition at line 181 of file OrientedBoxTreeTool.hpp.

181 : ray_tri_tests_count( 0 ) {}

Member Function Documentation

◆ end_traversal()

void moab::OrientedBoxTreeTool::TrvStats::end_traversal ( unsigned  depth)
private

Definition at line 1695 of file OrientedBoxTreeTool.cpp.

1696 {
1697  // assume safe depth, because increment is always called on a given
1698  // tree level first
1699  traversals_ended_count[depth] += 1;
1700 }

Referenced by moab::OrientedBoxTreeTool::closest_to_location(), moab::OrientedBoxTreeTool::preorder_traverse(), and moab::OrientedBoxTreeTool::sphere_intersect_triangles().

◆ increment()

void moab::OrientedBoxTreeTool::TrvStats::increment ( unsigned  depth)
private

Definition at line 1677 of file OrientedBoxTreeTool.cpp.

1678 {
1679 
1680  while( nodes_visited_count.size() <= depth )
1681  {
1682  nodes_visited_count.push_back( 0 );
1683  leaves_visited_count.push_back( 0 );
1684  traversals_ended_count.push_back( 0 );
1685  }
1686  nodes_visited_count[depth] += 1;
1687 }

Referenced by moab::OrientedBoxTreeTool::closest_to_location(), moab::OrientedBoxTreeTool::preorder_traverse(), and moab::OrientedBoxTreeTool::sphere_intersect_triangles().

◆ increment_leaf()

void moab::OrientedBoxTreeTool::TrvStats::increment_leaf ( unsigned  depth)
private

Definition at line 1689 of file OrientedBoxTreeTool.cpp.

1690 {
1691  // assume safe depth, because increment is called first
1692  leaves_visited_count[depth] += 1;
1693 }

Referenced by moab::OrientedBoxTreeTool::closest_to_location(), moab::OrientedBoxTreeTool::preorder_traverse(), and moab::OrientedBoxTreeTool::sphere_intersect_triangles().

◆ leaves_visited()

const std::vector< unsigned >& moab::OrientedBoxTreeTool::TrvStats::leaves_visited ( ) const
inline

return counts of tree leaves visited, indexed by tree depth

Definition at line 161 of file OrientedBoxTreeTool.hpp.

162  {
163  return leaves_visited_count;
164  }

References leaves_visited_count.

◆ nodes_visited()

const std::vector< unsigned >& moab::OrientedBoxTreeTool::TrvStats::nodes_visited ( ) const
inline

return counts of nodes visited, indexed by tree depth. the counts include both leaves and interior nodes

Definition at line 156 of file OrientedBoxTreeTool.hpp.

157  {
158  return nodes_visited_count;
159  }

References nodes_visited_count.

◆ print()

void moab::OrientedBoxTreeTool::TrvStats::print ( std::ostream &  str) const

print the contents of this structure to given stream

Definition at line 1702 of file OrientedBoxTreeTool.cpp.

1703 {
1704 
1705  const std::string h1 = "OBBTree Depth";
1706  const std::string h2 = " - NodesVisited";
1707  const std::string h3 = " - LeavesVisited";
1708  const std::string h4 = " - TraversalsEnded";
1709 
1710  str << h1 << h2 << h3 << h4 << std::endl;
1711 
1712  unsigned num_visited = 0, num_leaves = 0, num_traversals = 0;
1713  for( unsigned i = 0; i < traversals_ended_count.size(); ++i )
1714  {
1715 
1716  num_visited += nodes_visited_count[i];
1717  num_leaves += leaves_visited_count[i];
1718  num_traversals += traversals_ended_count[i];
1719 
1720  str << std::setw( h1.length() ) << i << std::setw( h2.length() ) << nodes_visited_count[i]
1721  << std::setw( h3.length() ) << leaves_visited_count[i] << std::setw( h4.length() )
1722  << traversals_ended_count[i] << std::endl;
1723  }
1724 
1725  str << std::setw( h1.length() ) << "---- Totals:" << std::setw( h2.length() ) << num_visited
1726  << std::setw( h3.length() ) << num_leaves << std::setw( h4.length() ) << num_traversals << std::endl;
1727 
1728  if( ray_tri_tests_count )
1729  {
1730  str << std::setw( h1.length() ) << "---- Total ray-tri tests: " << ray_tri_tests_count << std::endl;
1731  }
1732 }

◆ ray_tri_tests()

unsigned int moab::OrientedBoxTreeTool::TrvStats::ray_tri_tests ( ) const
inline

return total number of ray-triangle intersection tests performed in calls made with this TrvStats

Definition at line 172 of file OrientedBoxTreeTool.hpp.

173  {
174  return ray_tri_tests_count;
175  }

References ray_tri_tests_count.

◆ reset()

void moab::OrientedBoxTreeTool::TrvStats::reset ( )

reset all counters on this structure

Definition at line 1669 of file OrientedBoxTreeTool.cpp.

1670 {
1671  nodes_visited_count.clear();
1672  leaves_visited_count.clear();
1673  traversals_ended_count.clear();
1674  ray_tri_tests_count = 0;
1675 }

References leaves_visited_count, nodes_visited_count, ray_tri_tests_count, and traversals_ended_count.

◆ traversals_ended()

const std::vector< unsigned >& moab::OrientedBoxTreeTool::TrvStats::traversals_ended ( ) const
inline

return counts of traversals ended, indexed by tree depth

Definition at line 166 of file OrientedBoxTreeTool.hpp.

167  {
168  return traversals_ended_count;
169  }

References traversals_ended_count.

Friends And Related Function Documentation

◆ OrientedBoxTreeTool

friend class OrientedBoxTreeTool
friend

Definition at line 193 of file OrientedBoxTreeTool.hpp.

Member Data Documentation

◆ leaves_visited_count

std::vector< unsigned > moab::OrientedBoxTreeTool::TrvStats::leaves_visited_count
private

Definition at line 185 of file OrientedBoxTreeTool.hpp.

Referenced by leaves_visited(), and reset().

◆ nodes_visited_count

std::vector< unsigned > moab::OrientedBoxTreeTool::TrvStats::nodes_visited_count
private

Definition at line 184 of file OrientedBoxTreeTool.hpp.

Referenced by nodes_visited(), and reset().

◆ ray_tri_tests_count

unsigned int moab::OrientedBoxTreeTool::TrvStats::ray_tri_tests_count
private

◆ traversals_ended_count

std::vector< unsigned > moab::OrientedBoxTreeTool::TrvStats::traversals_ended_count
private

Definition at line 186 of file OrientedBoxTreeTool.hpp.

Referenced by reset(), and traversals_ended().


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