[MOAB-dev] r1647 - MOAB/trunk

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Wed Mar 12 18:05:09 CDT 2008


Author: kraftche
Date: 2008-03-12 18:05:09 -0500 (Wed, 12 Mar 2008)
New Revision: 1647

Modified:
   MOAB/trunk/SequenceManager.cpp
   MOAB/trunk/TagTest.cpp
Log:
Fix off-by-one error getting entities by variable-length tag.


Modified: MOAB/trunk/SequenceManager.cpp
===================================================================
--- MOAB/trunk/SequenceManager.cpp	2008-03-12 22:13:32 UTC (rev 1646)
+++ MOAB/trunk/SequenceManager.cpp	2008-03-12 23:05:09 UTC (rev 1647)
@@ -1334,7 +1334,7 @@
       data = reinterpret_cast<const VarLenTag*>((*i)->data()->get_tag_data(tag_id));
       if (!data)
         continue;
-      end = data + (*i)->end_handle() - (*i)->data()->start_handle();
+      end = data + (*i)->end_handle() - (*i)->data()->start_handle() + 1;
       iter = data + (*i)->start_handle() - (*i)->data()->start_handle();
       MBEntityHandle handle = (*i)->start_handle();
       for (; iter != end; ++iter, ++handle)

Modified: MOAB/trunk/TagTest.cpp
===================================================================
--- MOAB/trunk/TagTest.cpp	2008-03-12 22:13:32 UTC (rev 1646)
+++ MOAB/trunk/TagTest.cpp	2008-03-12 23:05:09 UTC (rev 1647)
@@ -27,6 +27,8 @@
 void test_get_set_variable_length_dense();
 void test_get_set_variable_length_mesh();
 
+void regression_one_entity_by_var_tag();
+
 int main()
 {
   int failures = 0;
@@ -55,6 +57,7 @@
   failures += RUN_TEST( test_get_set_variable_length_sparse );
   failures += RUN_TEST( test_get_set_variable_length_dense );
   failures += RUN_TEST( test_get_set_variable_length_mesh );  
+  failures += RUN_TEST( regression_one_entity_by_var_tag );
   
   return failures;
 }
@@ -1625,6 +1628,35 @@
   CHECK_ERR(rval);
 }
 
+/* Found bug where last entity in sequence is not
+   returned for get entity by tag for a variable-
+   length tag.  Test to make sure that it remains
+   fixed.
+ */
+void regression_one_entity_by_var_tag()
+{
+  MBCore moab;
+  MBErrorCode rval;
+  
+  MBEntityHandle vertex;
+  const double coords[] = { 0, 0, 0 };
+  rval = moab.create_vertex( coords, vertex );
+  CHECK_ERR(rval);
 
+  MBTag tag;
+  rval = moab.tag_create_variable_length( "testtag", MB_TAG_DENSE, MB_TYPE_INTEGER, tag );
+  CHECK_ERR(rval);
   
-                                   
+  int taglen = sizeof(int);
+  const void* ptrarr[1] = { &taglen };
+  rval = moab.tag_set_data( tag, &vertex, 1, ptrarr, &taglen );
+  CHECK_ERR(rval);
+  
+  MBRange ents;
+  rval = moab.get_entities_by_type_and_tag( 0, MBVERTEX, &tag, 0, 1, ents );
+  CHECK_ERR(rval);
+  
+  CHECK_EQUAL( 1ul, ents.size() );
+  CHECK_EQUAL( vertex, ents.front() );
+}
+




More information about the moab-dev mailing list