[MOAB-dev] r4841 - in MOAB/trunk: src src/moab test

iulian at mcs.anl.gov iulian at mcs.anl.gov
Wed May 18 01:20:37 CDT 2011


Author: iulian
Date: 2011-05-18 01:20:37 -0500 (Wed, 18 May 2011)
New Revision: 4841

Modified:
   MOAB/trunk/src/GeomTopoTool.cpp
   MOAB/trunk/src/moab/GeomTopoTool.hpp
   MOAB/trunk/test/gttool_test.cpp
Log:
add a method to duplicate a model, by copying the geo sets 
the entities are copied to the new sets, but they are not duplicated 
the sense tags are set in the new model by using restore_topology method
 


Modified: MOAB/trunk/src/GeomTopoTool.cpp
===================================================================
--- MOAB/trunk/src/GeomTopoTool.cpp	2011-05-18 03:47:02 UTC (rev 4840)
+++ MOAB/trunk/src/GeomTopoTool.cpp	2011-05-18 06:20:37 UTC (rev 4841)
@@ -1059,6 +1059,86 @@
   return MB_SUCCESS;
 }
 
+// this would be a deep copy, into a new geom topo tool
+  // sets will be duplicated, but entities not
+  // modelSet will be a new one
+GeomTopoTool * GeomTopoTool::duplicate_model()
+{
+  // will
+  EntityHandle rootModelSet;
+  ErrorCode rval = mdbImpl->create_meshset(MESHSET_SET, rootModelSet);
+  if (MB_SUCCESS!=rval)
+    return NULL;
+  if (0 == geomTag) {
+    rval = mdbImpl->tag_get_handle(GEOM_DIMENSION_TAG_NAME, geomTag);
+    if (MB_SUCCESS != rval)
+      return NULL;
+  }
+  if (0 == gidTag) {
+    rval = mdbImpl->tag_get_handle(GLOBAL_ID_TAG_NAME, gidTag);
+    if (MB_SUCCESS != rval)
+      return NULL;
+  }
+  // add to the root model set copies of the gsets, with correct sets
+  // keep a map between sets to help in copying parent/child relations
+  std::map <EntityHandle, EntityHandle> relate;
+  // each set will get the same entities as the original
+  for (int dim=0; dim<4; dim++)
+  {
+    int gid = 0;
+    for (Range::iterator it=geomRanges[dim].begin(); it!=geomRanges[dim].end(); it++)
+    {
+      EntityHandle set=*it;
+      EntityHandle newSet;
+      rval = mdbImpl->create_meshset(MESHSET_SET, newSet);
+      if (MB_SUCCESS!=rval)
+        return NULL;
+      relate[set] = newSet;
+      rval = mdbImpl->add_entities(rootModelSet, &newSet, 1);
+      if (MB_SUCCESS!=rval)
+        return NULL;
+      // make it a geo set, and give also global id in order
+      rval = mdbImpl->tag_set_data(geomTag, &newSet, 1, &dim);
+      if (MB_SUCCESS!=rval)
+        return NULL;
+      gid++;// increment global id, everything starts with 1 in the new model!


More information about the moab-dev mailing list