moab
moab::OrientedBoxTreeTool::TrvStats Class Reference

Traversal statistics structure. More...

#include <OrientedBoxTreeTool.hpp>

List of all members.

Public Member Functions

const std::vector< unsigned > & nodes_visited () const
const std::vector< unsigned > & leaves_visited () const
 return counts of tree leaves visited, indexed by tree depth
const std::vector< unsigned > & traversals_ended () const
 return counts of traversals ended, indexed by tree depth
unsigned int ray_tri_tests () const
void reset ()
 reset all counters on this structure
void print (std::ostream &str) const
 print the contents of this structure to given stream
 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 144 of file OrientedBoxTreeTool.hpp.


Constructor & Destructor Documentation


Member Function Documentation

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

Definition at line 1990 of file OrientedBoxTreeTool.cpp.

                                                               {
  // assume safe depth, because increment is always called on a given 
  // tree level first
  traversals_ended_count[depth] += 1;
}
void moab::OrientedBoxTreeTool::TrvStats::increment ( unsigned  depth) [private]

Definition at line 1975 of file OrientedBoxTreeTool.cpp.

                                                           {

  while( nodes_visited_count.size() <= depth ){
    nodes_visited_count.push_back(0);
    leaves_visited_count.push_back(0);
    traversals_ended_count.push_back(0);
  }
  nodes_visited_count[depth] += 1;
}
void moab::OrientedBoxTreeTool::TrvStats::increment_leaf ( unsigned  depth) [private]

Definition at line 1985 of file OrientedBoxTreeTool.cpp.

                                                                {
  //assume safe depth, because increment is called first
  leaves_visited_count[depth] += 1;
}
const std::vector< unsigned >& moab::OrientedBoxTreeTool::TrvStats::leaves_visited ( ) const [inline]

return counts of tree leaves visited, indexed by tree depth

Definition at line 152 of file OrientedBoxTreeTool.hpp.

        { return leaves_visited_count; }
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 149 of file OrientedBoxTreeTool.hpp.

        { return nodes_visited_count; }
void moab::OrientedBoxTreeTool::TrvStats::print ( std::ostream &  str) const

print the contents of this structure to given stream

Definition at line 1996 of file OrientedBoxTreeTool.cpp.

                                                               {

  const std::string h1 = "OBBTree Depth";
  const std::string h2 = " - NodesVisited";
  const std::string h3 = " - LeavesVisited";
  const std::string h4 = " - TraversalsEnded";

  str << h1 << h2 << h3 << h4 << std::endl;

  unsigned num_visited = 0, num_leaves = 0, num_traversals = 0;
  for( unsigned i = 0; i < traversals_ended_count.size(); ++i){

    num_visited    += nodes_visited_count[i];
    num_leaves     += leaves_visited_count[i];
    num_traversals += traversals_ended_count[i];
   
    str << std::setw(h1.length()) << i 
        << std::setw(h2.length()) << nodes_visited_count[i] 
        << std::setw(h3.length()) << leaves_visited_count[i]
        << std::setw(h4.length()) << traversals_ended_count[i] 
        << std::endl;
  }
  
  str << std::setw(h1.length()) << "---- Totals:" 
      << std::setw(h2.length()) << num_visited 
      << std::setw(h3.length()) << num_leaves
      << std::setw(h4.length()) << num_traversals 
      << std::endl;
  
  if( ray_tri_tests_count ){
    str << std::setw(h1.length()) << "---- Total ray-tri tests: " 
    << ray_tri_tests_count << std::endl;
  }

}
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 159 of file OrientedBoxTreeTool.hpp.

        { return ray_tri_tests_count; }

reset all counters on this structure

Definition at line 1968 of file OrientedBoxTreeTool.cpp.

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

return counts of traversals ended, indexed by tree depth

Definition at line 155 of file OrientedBoxTreeTool.hpp.


Friends And Related Function Documentation

friend class OrientedBoxTreeTool [friend]

Definition at line 179 of file OrientedBoxTreeTool.hpp.


Member Data Documentation

Definition at line 171 of file OrientedBoxTreeTool.hpp.

Definition at line 170 of file OrientedBoxTreeTool.hpp.

Definition at line 173 of file OrientedBoxTreeTool.hpp.

Definition at line 172 of file OrientedBoxTreeTool.hpp.


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