Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
moab::TreeLayoutPrinter Class Reference
+ Inheritance diagram for moab::TreeLayoutPrinter:
+ Collaboration diagram for moab::TreeLayoutPrinter:

Public Member Functions

 TreeLayoutPrinter (std::ostream &stream, Interface *instance)
 
virtual ErrorCode visit (EntityHandle node, int depth, 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...
 
- Public Member Functions inherited from moab::OrientedBoxTreeTool::Op
virtual ~Op ()
 

Private Attributes

Interfaceinstance
 
std::ostream & outputStream
 
std::vector< bool > path
 

Detailed Description

Definition at line 1417 of file OrientedBoxTreeTool.cpp.

Constructor & Destructor Documentation

◆ TreeLayoutPrinter()

moab::TreeLayoutPrinter::TreeLayoutPrinter ( std::ostream &  stream,
Interface instance 
)

Definition at line 1431 of file OrientedBoxTreeTool.cpp.

1432  : instance( interface ), outputStream( stream )
1433 {
1434 }

Member Function Documentation

◆ leaf()

ErrorCode moab::TreeLayoutPrinter::leaf ( EntityHandle  node)
virtual

Process a leaf node during tree traversal.

Implements moab::OrientedBoxTreeTool::Op.

Definition at line 1469 of file OrientedBoxTreeTool.cpp.

1470 {
1471  return MB_SUCCESS;
1472 }

References MB_SUCCESS.

◆ visit()

ErrorCode moab::TreeLayoutPrinter::visit ( EntityHandle  node,
int  depth,
bool &  descend 
)
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 1436 of file OrientedBoxTreeTool.cpp.

1437 {
1438  descend = true;
1439 
1440  if( (unsigned)depth > path.size() )
1441  {
1442  // assert(depth+1 == path.size); // preorder traversal
1443  path.push_back( true );
1444  }
1445  else
1446  {
1447  path.resize( depth );
1448  if( depth ) path.back() = false;
1449  }
1450 
1451  for( unsigned i = 0; i + 1 < path.size(); ++i )
1452  {
1453  if( path[i] )
1454  outputStream << "| ";
1455  else
1456  outputStream << " ";
1457  }
1458  if( depth )
1459  {
1460  if( path.back() )
1461  outputStream << "+---";
1462  else
1463  outputStream << "\\---";
1464  }
1465  outputStream << instance->id_from_handle( node ) << std::endl;
1466  return MB_SUCCESS;
1467 }

References moab::Interface::id_from_handle(), instance, MB_SUCCESS, outputStream, and path.

Member Data Documentation

◆ instance

Interface* moab::TreeLayoutPrinter::instance
private

Definition at line 1426 of file OrientedBoxTreeTool.cpp.

Referenced by visit().

◆ outputStream

std::ostream& moab::TreeLayoutPrinter::outputStream
private

Definition at line 1427 of file OrientedBoxTreeTool.cpp.

Referenced by visit().

◆ path

std::vector< bool > moab::TreeLayoutPrinter::path
private

Definition at line 1428 of file OrientedBoxTreeTool.cpp.

Referenced by visit().


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