[MOAB-dev] r5014 - in MOAB/trunk: src test

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Jun 16 08:14:03 CDT 2011


Author: kraftche
Date: 2011-06-16 08:13:58 -0500 (Thu, 16 Jun 2011)
New Revision: 5014

Modified:
   MOAB/trunk/src/MeshSet.cpp
   MOAB/trunk/test/MBTest.cpp
Log:
fix bug compacting ranges during insertion into a MESHSET_SET type entity set

Modified: MOAB/trunk/src/MeshSet.cpp
===================================================================
--- MOAB/trunk/src/MeshSet.cpp	2011-06-15 22:23:04 UTC (rev 5013)
+++ MOAB/trunk/src/MeshSet.cpp	2011-06-16 13:13:58 UTC (rev 5014)
@@ -400,6 +400,13 @@
   }
 }
 
+typedef std::pair<EntityHandle,EntityHandle> MeshSetRange;
+
+class MeshSetRComp {
+  public: bool operator()( const MeshSetRange& r, EntityHandle h )
+    { return r.second < h; }
+};
+
 template <typename pair_iter_t> inline ErrorCode
 range_tool<pair_iter_t>::ranged_insert_entities( MeshSet::Count& count, 
                                                  MeshSet::CompactList& clist, 
@@ -408,47 +415,55 @@
                                                  EntityHandle my_handle, 
                                                  AEntityFactory* adj )
 {
-    //first pass:
+     //first pass:
     // 1) merge existing ranges 
     // 2) count number of new ranges that must be inserted
-  ptrdiff_t insert_count = 0;
-  EntityHandle *list;
+  EntityHandle *list_ptr;
   size_t list_size;
   if (count < MeshSet::MANY) {
-    list = clist.hnd;
+    list_ptr = clist.hnd;
     list_size = count;
   }
   else {
-    list = clist.ptr[0];
+    list_ptr = clist.ptr[0];
     list_size = clist.ptr[1] - clist.ptr[0];
   }
-
-  EntityHandle* list_write = list;
-  EntityHandle *const list_end = list + list_size, *list_read = list;
+  
+  MeshSetRange* list = reinterpret_cast<MeshSetRange*>(list_ptr);
+  assert(0 == list_size % 2);
+  assert(2*sizeof(EntityHandle) == sizeof(MeshSetRange));
+  list_size /= 2;
+  MeshSetRange *const list_end = list + list_size;
+  MeshSetRange *list_read = list, *list_write = list;
   pair_iter_t i = begin;


More information about the moab-dev mailing list