[MOAB-dev] r1571 - MOAB/trunk

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Thu Jan 31 13:56:52 CST 2008


Author: kraftche
Date: 2008-01-31 13:56:52 -0600 (Thu, 31 Jan 2008)
New Revision: 1571

Modified:
   MOAB/trunk/MBBits.hpp
   MOAB/trunk/TagServer.cpp
Log:
More bit tag fixes:  
  - Make low-level code fail to get non-existant tag values.
  - Make higher-level code test for failure and return default 
    value if available or zero otherwise.


Default value now works for bit tags, but old behavior (implicit default 
value of zero) is kept if no default value is specified.



Modified: MOAB/trunk/MBBits.hpp
===================================================================
--- MOAB/trunk/MBBits.hpp	2008-01-31 19:37:10 UTC (rev 1570)
+++ MOAB/trunk/MBBits.hpp	2008-01-31 19:56:52 UTC (rev 1571)
@@ -401,7 +401,7 @@
   if(which_page >= mBitPagesSize)
   {
     bits = 0;
-    return MB_SUCCESS;
+    return MB_TAG_NOT_FOUND;
   }
 
   // return bits from bit page

Modified: MOAB/trunk/TagServer.cpp
===================================================================
--- MOAB/trunk/TagServer.cpp	2008-01-31 19:37:10 UTC (rev 1570)
+++ MOAB/trunk/TagServer.cpp	2008-01-31 19:56:52 UTC (rev 1571)
@@ -226,7 +226,18 @@
 {
   if(TYPE_FROM_HANDLE(entity_handle) >= MBMAXTYPE)
     return MB_TYPE_OUT_OF_RANGE;
-  return mBitServer->get_bits(ID_FROM_TAG_HANDLE(tag_handle), entity_handle, data);
+  MBErrorCode rval = mBitServer->get_bits(ID_FROM_TAG_HANDLE(tag_handle), entity_handle, data);
+  if (MB_TAG_NOT_FOUND == rval) {
+    const TagInfo* info = get_tag_info( tag_handle );
+    if (!info)
+      return MB_FAILURE;
+    if (info->default_value())
+      data = *reinterpret_cast<const unsigned char*>(info->default_value());
+    else 
+      data = '\0';
+    return MB_SUCCESS;
+  }
+  return rval;    
 }
 
 MBErrorCode TagServer::set_mesh_data( const MBTag tag_handle,




More information about the moab-dev mailing list