#include "moab/Core.hpp" #include "moab/ReorderTool.hpp" using namespace moab; int main(int argc, char *argv[]) { ErrorCode rval; moab::Core mb_instance; moab::Interface& moab = mb_instance; const char *option; option = ""; rval = moab.load_file("4seasons.h5m", 0, option); const char GLOBAL_ID_NAME[] = "GLOBAL_ID"; Range meshsets; rval = moab.get_entities_by_type(0,MBENTITYSET,meshsets,true); // get/create various tags Tag th_gid; rval = moab.tag_get_handle(GLOBAL_ID_NAME,1,MB_TYPE_INTEGER,th_gid,MB_TAG_DENSE); Range ents,to_delete; rval = moab.get_entities_by_handle(0,ents); int gid = 0; // Set gid and select ents to delete bool del = false; for(Range::iterator eit = ents.begin();eit!=ents.end();eit++) { if(del) { del = false; to_delete.insert(*eit); } else { del = true; } } for(Range::iterator mit = meshsets.begin();mit!=meshsets.end();mit++) { rval = moab.remove_entities(*mit,to_delete); } rval = moab.delete_entities(to_delete); for(int dd=3;dd>=0;dd--) { Range dim_ents = ents.subset_by_dimension(dd); int gid = 0; for(Range::iterator tit = ents.begin();tit!=ents.end();tit++) { del = true; rval = moab.tag_set_data(th_gid,&*tit,1,&gid); gid++; } } // do reorder ReorderTool tool(&mb_instance); Tag mapping; rval = tool.handle_order_from_int_tag(th_gid, -1, mapping ); rval = tool.reorder_entities( mapping ); return 0; }