Loading [MathJax]/extensions/tex2jax.js
Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
moab::TreeNodePrinter Class Reference
+ Inheritance diagram for moab::TreeNodePrinter:
+ Collaboration diagram for moab::TreeNodePrinter:

Public Member Functions

 TreeNodePrinter (std::ostream &stream, bool list_contents, bool list_box, const char *id_tag_name, OrientedBoxTreeTool *tool_ptr)
 
virtual ErrorCode visit (EntityHandle node, int depth, bool &descend)
 Visit a node in the tree during a traversal. More...
 
virtual ErrorCode leaf (EntityHandle)
 Process a leaf node during tree traversal. More...
 
- Public Member Functions inherited from moab::OrientedBoxTreeTool::Op
virtual ~Op ()
 

Private Member Functions

ErrorCode print_geometry (EntityHandle node)
 
ErrorCode print_contents (EntityHandle node)
 
ErrorCode print_counts (EntityHandle node)
 

Private Attributes

bool printContents
 
bool printGeometry
 
bool haveTag
 
Tag tag
 
Tag gidTag
 
Tag geomTag
 
Interfaceinstance
 
OrientedBoxTreeTooltool
 
std::ostream & outputStream
 

Detailed Description

Definition at line 1474 of file OrientedBoxTreeTool.cpp.

Constructor & Destructor Documentation

◆ TreeNodePrinter()

moab::TreeNodePrinter::TreeNodePrinter ( std::ostream &  stream,
bool  list_contents,
bool  list_box,
const char *  id_tag_name,
OrientedBoxTreeTool tool_ptr 
)

Definition at line 1504 of file OrientedBoxTreeTool.cpp.

1509  : printContents( list_contents ), printGeometry( list_box ), haveTag( false ), tag( 0 ), gidTag( 0 ), geomTag( 0 ), 1510  instance( tool_ptr->get_moab_instance() ), tool( tool_ptr ), outputStream( stream ) 1511 { 1512  ErrorCode rval; 1513  if( id_tag_name ) 1514  { 1515  rval = instance->tag_get_handle( id_tag_name, 1, MB_TYPE_INTEGER, tag ); 1516  if( !rval ) 1517  { 1518  std::cerr << "Could not get tag \"" << id_tag_name << "\"\n"; 1519  stream << "Could not get tag \"" << id_tag_name << "\"\n"; 1520  } 1521  else 1522  { 1523  haveTag = true; 1524  } 1525  } 1526  1527  gidTag = instance->globalId_tag(); 1528  1529  rval = instance->tag_get_handle( GEOM_DIMENSION_TAG_NAME, 1, MB_TYPE_INTEGER, geomTag ); 1530  if( MB_SUCCESS != rval ) geomTag = 0; 1531 }

References ErrorCode, GEOM_DIMENSION_TAG_NAME, geomTag, gidTag, moab::Interface::globalId_tag(), haveTag, instance, MB_SUCCESS, MB_TYPE_INTEGER, tag, and moab::Interface::tag_get_handle().

Member Function Documentation

◆ leaf()

virtual ErrorCode moab::TreeNodePrinter::leaf ( EntityHandle  node)
inlinevirtual

Process a leaf node during tree traversal.

Implements moab::OrientedBoxTreeTool::Op.

Definition at line 1485 of file OrientedBoxTreeTool.cpp.

1486  { 1487  return MB_SUCCESS; 1488  }

References MB_SUCCESS.

◆ print_contents()

ErrorCode moab::TreeNodePrinter::print_contents ( EntityHandle  node)
private

Definition at line 1597 of file OrientedBoxTreeTool.cpp.

1598 { 1599  // list contents 1600  for( EntityType type = MBVERTEX; type != MBMAXTYPE; ++type ) 1601  { 1602  Range range; 1603  ErrorCode rval = instance->get_entities_by_type( node, type, range ); 1604  if( MB_SUCCESS != rval ) return rval; 1605  if( range.empty() ) continue; 1606  outputStream << " " << CN::EntityTypeName( type ) << " "; 1607  std::vector< int > ids( range.size() ); 1608  if( haveTag ) 1609  { 1610  rval = instance->tag_get_data( tag, range, &ids[0] ); 1611  std::sort( ids.begin(), ids.end() ); 1612  } 1613  else 1614  { 1615  Range::iterator ri = range.begin(); 1616  std::vector< int >::iterator vi = ids.begin(); 1617  while( ri != range.end() ) 1618  { 1619  *vi = instance->id_from_handle( *ri ); 1620  ++ri; 1621  ++vi; 1622  } 1623  } 1624  1625  unsigned i = 0; 1626  for( ;; ) 1627  { 1628  unsigned beg = i, end; 1629  do 1630  { 1631  end = i++; 1632  } while( i < ids.size() && ids[end] + 1 == ids[i] ); 1633  if( end == beg ) 1634  outputStream << ids[end]; 1635  else if( end == beg + 1 ) 1636  outputStream << ids[beg] << ", " << ids[end]; 1637  else 1638  outputStream << ids[beg] << "-" << ids[end]; 1639  1640  if( i == ids.size() ) 1641  { 1642  outputStream << std::endl; 1643  break; 1644  } 1645  else 1646  outputStream << ", "; 1647  } 1648  } 1649  1650  return MB_SUCCESS; 1651 }

References moab::Range::begin(), moab::Range::empty(), moab::Range::end(), moab::CN::EntityTypeName(), ErrorCode, moab::Interface::get_entities_by_type(), haveTag, moab::Interface::id_from_handle(), instance, MB_SUCCESS, MBMAXTYPE, MBVERTEX, outputStream, moab::Range::size(), tag, and moab::Interface::tag_get_data().

Referenced by visit().

◆ print_counts()

ErrorCode moab::TreeNodePrinter::print_counts ( EntityHandle  node)
private

Definition at line 1585 of file OrientedBoxTreeTool.cpp.

1586 { 1587  for( EntityType type = MBVERTEX; type != MBMAXTYPE; ++type ) 1588  { 1589  int count = 0; 1590  ErrorCode rval = instance->get_number_entities_by_type( node, type, count ); 1591  if( MB_SUCCESS != rval ) return rval; 1592  if( count > 0 ) outputStream << " " << count << " " << CN::EntityTypeName( type ) << std::endl; 1593  } 1594  return MB_SUCCESS; 1595 }

References moab::CN::EntityTypeName(), ErrorCode, moab::Interface::get_number_entities_by_type(), instance, MB_SUCCESS, MBMAXTYPE, MBVERTEX, and outputStream.

Referenced by visit().

◆ print_geometry()

ErrorCode moab::TreeNodePrinter::print_geometry ( EntityHandle  node)
private

Definition at line 1570 of file OrientedBoxTreeTool.cpp.

1571 { 1572  OrientedBox box; 1573  ErrorCode rval = tool->box( node, box ); 1574  if( MB_SUCCESS != rval ) return rval; 1575  1576  CartVect length = box.dimensions(); 1577  1578  outputStream << box.center << " Radius: " << box.inner_radius() << " - " << box.outer_radius() << std::endl 1579  << '+' << box.axis( 0 ) << " : " << length[0] << std::endl 1580  << 'x' << box.axis( 1 ) << " : " << length[1] << std::endl 1581  << 'x' << box.axis( 2 ) << " : " << length[2] << std::endl; 1582  return MB_SUCCESS; 1583 }

References moab::OrientedBox::axis(), moab::OrientedBoxTreeTool::box(), moab::OrientedBox::center, moab::OrientedBox::dimensions(), ErrorCode, moab::OrientedBox::inner_radius(), length(), MB_SUCCESS, moab::OrientedBox::outer_radius(), outputStream, and tool.

Referenced by visit().

◆ visit()

ErrorCode moab::TreeNodePrinter::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 1533 of file OrientedBoxTreeTool.cpp.

1534 { 1535  descend = true; 1536  EntityHandle setid = instance->id_from_handle( node ); 1537  outputStream << setid << ":" << std::endl; 1538  1539  Range surfs; 1540  ErrorCode r3 = MB_SUCCESS; 1541  if( geomTag ) 1542  { 1543  const int two = 2; 1544  const void* tagdata[] = { &two }; 1545  r3 = instance->get_entities_by_type_and_tag( node, MBENTITYSET, &geomTag, tagdata, 1, surfs ); 1546  1547  if( MB_SUCCESS == r3 && surfs.size() == 1 ) 1548  { 1549  EntityHandle surf = *surfs.begin(); 1550  int id; 1551  if( gidTag && MB_SUCCESS == instance->tag_get_data( gidTag, &surf, 1, &id ) ) 1552  outputStream << " Surface " << id << std::endl; 1553  else 1554  outputStream << " Surface w/ unknown ID (" << surf << ")" << std::endl; 1555  } 1556  } 1557  1558  ErrorCode r1 = printGeometry ? print_geometry( node ) : MB_SUCCESS; 1559  ErrorCode r2 = printContents ? print_contents( node ) : print_counts( node ); 1560  outputStream << std::endl; 1561  1562  if( MB_SUCCESS != r1 ) 1563  return r1; 1564  else if( MB_SUCCESS != r2 ) 1565  return r2; 1566  else 1567  return r3; 1568 }

References moab::Range::begin(), ErrorCode, geomTag, moab::Interface::get_entities_by_type_and_tag(), gidTag, moab::Interface::id_from_handle(), instance, MB_SUCCESS, MBENTITYSET, outputStream, print_contents(), print_counts(), print_geometry(), printContents, printGeometry, moab::Range::size(), and moab::Interface::tag_get_data().

Member Data Documentation

◆ geomTag

Tag moab::TreeNodePrinter::geomTag
private

Definition at line 1498 of file OrientedBoxTreeTool.cpp.

Referenced by TreeNodePrinter(), and visit().

◆ gidTag

Tag moab::TreeNodePrinter::gidTag
private

Definition at line 1498 of file OrientedBoxTreeTool.cpp.

Referenced by TreeNodePrinter(), and visit().

◆ haveTag

bool moab::TreeNodePrinter::haveTag
private

Definition at line 1497 of file OrientedBoxTreeTool.cpp.

Referenced by print_contents(), and TreeNodePrinter().

◆ instance

Interface* moab::TreeNodePrinter::instance
private

Definition at line 1499 of file OrientedBoxTreeTool.cpp.

Referenced by print_contents(), print_counts(), TreeNodePrinter(), and visit().

◆ outputStream

std::ostream& moab::TreeNodePrinter::outputStream
private

Definition at line 1501 of file OrientedBoxTreeTool.cpp.

Referenced by print_contents(), print_counts(), print_geometry(), and visit().

◆ printContents

bool moab::TreeNodePrinter::printContents
private

Definition at line 1495 of file OrientedBoxTreeTool.cpp.

Referenced by visit().

◆ printGeometry

bool moab::TreeNodePrinter::printGeometry
private

Definition at line 1496 of file OrientedBoxTreeTool.cpp.

Referenced by visit().

◆ tag

Tag moab::TreeNodePrinter::tag
private

Definition at line 1498 of file OrientedBoxTreeTool.cpp.

Referenced by print_contents(), and TreeNodePrinter().

◆ tool

OrientedBoxTreeTool* moab::TreeNodePrinter::tool
private

Definition at line 1500 of file OrientedBoxTreeTool.cpp.

Referenced by print_geometry().


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