moab
|
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. | |
virtual ErrorCode | leaf (EntityHandle) |
Process a leaf node during tree traversal. | |
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 |
Interface * | instance |
OrientedBoxTreeTool * | tool |
std::ostream & | outputStream |
Definition at line 1773 of file OrientedBoxTreeTool.cpp.
moab::TreeNodePrinter::TreeNodePrinter | ( | std::ostream & | stream, |
bool | list_contents, | ||
bool | list_box, | ||
const char * | id_tag_name, | ||
OrientedBoxTreeTool * | tool_ptr | ||
) |
Definition at line 1803 of file OrientedBoxTreeTool.cpp.
: printContents( list_contents ), printGeometry( list_box ), haveTag( false ), tag( 0 ), gidTag(0), geomTag(0), instance( tool_ptr->get_moab_instance() ), tool(tool_ptr), outputStream( stream ) { ErrorCode rval; if (id_tag_name) { rval = instance->tag_get_handle( id_tag_name, 1, MB_TYPE_INTEGER, tag ); if (!rval) { std::cerr << "Could not get tag \"" << id_tag_name << "\"\n"; stream << "Could not get tag \"" << id_tag_name << "\"\n"; } else { haveTag = true; } } rval = instance->tag_get_handle( GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, gidTag ); if (MB_SUCCESS != rval) gidTag = 0; rval = instance->tag_get_handle( GEOM_DIMENSION_TAG_NAME, 1, MB_TYPE_INTEGER, geomTag ); if (MB_SUCCESS != rval) geomTag = 0; }
virtual ErrorCode moab::TreeNodePrinter::leaf | ( | EntityHandle | node | ) | [inline, virtual] |
Process a leaf node during tree traversal.
Implements moab::OrientedBoxTreeTool::Op.
Definition at line 1786 of file OrientedBoxTreeTool.cpp.
{ return MB_SUCCESS; }
ErrorCode moab::TreeNodePrinter::print_contents | ( | EntityHandle | node | ) | [private] |
Definition at line 1902 of file OrientedBoxTreeTool.cpp.
{ // list contents for (EntityType type = MBVERTEX; type != MBMAXTYPE; ++type) { Range range; ErrorCode rval = instance->get_entities_by_type( node, type, range ); if (MB_SUCCESS != rval) return rval; if (range.empty()) continue; outputStream << " " << CN::EntityTypeName(type) << " "; std::vector<int> ids( range.size() ); if (haveTag) { rval = instance->tag_get_data( tag, range, &ids[0] ); std::sort( ids.begin(), ids.end() ); } else { Range::iterator ri = range.begin(); std::vector<int>::iterator vi = ids.begin(); while (ri != range.end()) { *vi = instance->id_from_handle( *ri ); ++ri; ++vi; } } unsigned i = 0; for(;;) { unsigned beg = i, end; do { end = i++; } while (i < ids.size() && ids[end]+1 == ids[i]); if (end == beg) outputStream << ids[end]; else if (end == beg+1) outputStream << ids[beg] << ", " << ids[end]; else outputStream << ids[beg] << "-" << ids[end]; if (i == ids.size()) { outputStream << std::endl; break; } else outputStream << ", "; } } return MB_SUCCESS; }
ErrorCode moab::TreeNodePrinter::print_counts | ( | EntityHandle | node | ) | [private] |
Definition at line 1889 of file OrientedBoxTreeTool.cpp.
{ for (EntityType type = MBVERTEX; type != MBMAXTYPE; ++type) { int count = 0; ErrorCode rval = instance->get_number_entities_by_type( node, type, count ); if (MB_SUCCESS != rval) return rval; if(count > 0) outputStream << " " << count << " " << CN::EntityTypeName(type) << std::endl; } return MB_SUCCESS; }
ErrorCode moab::TreeNodePrinter::print_geometry | ( | EntityHandle | node | ) | [private] |
Definition at line 1872 of file OrientedBoxTreeTool.cpp.
{ OrientedBox box; ErrorCode rval= tool->box( node, box ); if (MB_SUCCESS != rval) return rval; CartVect length = box.dimensions(); outputStream << box.center << " Radius: " << box.inner_radius() << " - " << box.outer_radius() << std::endl << '+' << box.axis[0] << " : " << length[0] << std::endl << 'x' << box.axis[1] << " : " << length[1] << std::endl << 'x' << box.axis[2] << " : " << length[2] << std::endl; return MB_SUCCESS; }
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.
node | The EntityHandle for the entity set for the tree node. |
depth | The current depth in the tree. |
descend | Output: 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 1837 of file OrientedBoxTreeTool.cpp.
{ descend = true; EntityHandle setid = instance->id_from_handle( node ); outputStream << setid << ":" << std::endl; Range surfs; ErrorCode r3 = MB_SUCCESS; if (geomTag) { const int two = 2; const void* tagdata[] = {&two}; r3 = instance->get_entities_by_type_and_tag( node, MBENTITYSET, &geomTag, tagdata, 1, surfs ); if (MB_SUCCESS == r3 && surfs.size() == 1) { EntityHandle surf = *surfs.begin(); int id; if (gidTag && MB_SUCCESS == instance->tag_get_data( gidTag, &surf, 1, &id )) outputStream << " Surface " << id << std::endl; else outputStream << " Surface w/ unknown ID (" << surf << ")" << std::endl; } } ErrorCode r1 = printGeometry ? print_geometry( node ) : MB_SUCCESS; ErrorCode r2 = printContents ? print_contents( node ) : print_counts( node ); outputStream << std::endl; if (MB_SUCCESS != r1) return r1; else if (MB_SUCCESS != r2) return r2; else return r3; }
Tag moab::TreeNodePrinter::geomTag [private] |
Definition at line 1796 of file OrientedBoxTreeTool.cpp.
Tag moab::TreeNodePrinter::gidTag [private] |
Definition at line 1796 of file OrientedBoxTreeTool.cpp.
bool moab::TreeNodePrinter::haveTag [private] |
Definition at line 1795 of file OrientedBoxTreeTool.cpp.
Interface* moab::TreeNodePrinter::instance [private] |
Definition at line 1797 of file OrientedBoxTreeTool.cpp.
std::ostream& moab::TreeNodePrinter::outputStream [private] |
Definition at line 1799 of file OrientedBoxTreeTool.cpp.
bool moab::TreeNodePrinter::printContents [private] |
Definition at line 1793 of file OrientedBoxTreeTool.cpp.
bool moab::TreeNodePrinter::printGeometry [private] |
Definition at line 1794 of file OrientedBoxTreeTool.cpp.
Tag moab::TreeNodePrinter::tag [private] |
Definition at line 1796 of file OrientedBoxTreeTool.cpp.
OrientedBoxTreeTool* moab::TreeNodePrinter::tool [private] |
Definition at line 1798 of file OrientedBoxTreeTool.cpp.