ErrorCode leaf( EntityHandle node ) { OrientedBox box; ErrorCode rval = mTool->box( node, box ); if (MB_SUCCESS !=rval) return rval; EntityHandle h; rval = box.make_hex( h, mOut ); if (MB_SUCCESS !=rval) return rval; int i = hash_handle( node ); return mOut->tag_set_data( mTag, &h, 1, &i ); }
// a visit to a node, will create an OrientedBox object for that node, get a hex from that box and tag it with // an integer tag representing it's depth in the tree, and add it to the list of *hexes* for this tree ErrorCode OBBHexWriter::visit( EntityHandle node, int depth, bool& descend) { ErrorCode rval; //create a new tag for the tree depth of the obb std::string depth_tag_name = "TREE_DEPTH"; rval = mbi2->tag_get_handle( depth_tag_name.c_str(), 1, MB_TYPE_INTEGER, depth_tag, MB_TAG_DENSE|MB_TAG_CREAT); assert( MB_SUCCESS == rval ); if( MB_SUCCESS != rval ) return rval; OrientedBox box; rval = tool->box( node, box ); assert(MB_SUCCESS == rval ); if ( MB_SUCCESS != rval ) return rval; rval = box.make_hex( new_hex, mbi2 ); assert( MB_SUCCESS == rval ); if( MB_SUCCESS != rval ) return rval; void *ptr = &depth; rval = mbi2-> tag_set_data( depth_tag, &new_hex, 1, ptr); assert( MB_SUCCESS == rval ); if( MB_SUCCESS != rval ) return rval; if(w_tris) { //get the triangles contained by this node std::vector<EntityHandle> tris; rval = tool->get_moab_instance()->get_entities_by_type( node, MBTRI, tris); assert(MB_SUCCESS == rval ); if ( MB_SUCCESS != rval ) return rval; rval = transfer_tri_inst( tool->get_moab_instance(), mbi2, tris); assert( MB_SUCCESS == rval ); //add the data to the class attributes tri_map[new_hex] = tris; } //add the hex and go to the next tree depth hexes.push_back(new_hex); descend = true; return MB_SUCCESS; }