[MOAB-dev] r4574 - MOAB/trunk/itaps/imesh

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Mar 10 16:11:34 CST 2011


Author: kraftche
Date: 2011-03-10 16:11:34 -0600 (Thu, 10 Mar 2011)
New Revision: 4574

Modified:
   MOAB/trunk/itaps/imesh/MBiMesh.hpp
   MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
Log:
o Try to hide variable length tags from users of iMesh interface
o Keep track of whether or not MB_TYPE_HANDLE tags are iBase_ENTITY_SET_HANDLE
o For tags read from file guess iBase_ENTITY_SET_HANDLE vs iBase_ENTITY_HANDLE

Notes:

Variable length tags are never passed back from any iMesh call that returns
a tag handle.  However, iMesh apps cannot create a tag with the same name
as an existing variable-length tag.  That is obviously suboptimal, but no
worse that before this change as previously the app would have failed as
soon as it tried to do anything with such a tag handle anyway.

iBase_ENTITY_SET_HANDLE vs. iBase_ENTITY_HANDLE is tracked using lists of
tag handles in MBiMesh.  This leaves open the possibility that a tag could
be deleted from underneath the iMesh API by using the MOAB API directly.
That isn't a serious problem because the tag lists stored in MBiMesh are
only compared with known good tag handles.  But it is possible that a tag
could get deleted and then the handle re-used.  I think this scenario is 
fairly unlikely, though.  As MOAB tag handles are now pointers, the chance
of one getting re-used is slim.  And there will never be a problem unless
there is mixed use of both the MOAB and iMesh APIs anyway.

If a tag of type MB_TYPE_HANDLE is created by reading from a file or
using the MOAB API directly, then the iMesh code must guess whether or
not it is iBase_ENTITY_SET_HANDLE or iBase_ENTITY_HANDLE.  This is done
using a potentially expensive check of all the tag values (including 
the global/mesh value and the default value.)  If all the values are
of one type or the other then the type will be noted for future reference.
If there are no tag values or the values are mixed, then iBase_ENTITY_HANDLE
will be returned but the type will not be noted.  Subsequent queries for
the tag data type will re-do the check in that case (with the hope that 
at least for the no-value case it will be less ambiguous in the future).



Modified: MOAB/trunk/itaps/imesh/MBiMesh.hpp
===================================================================
--- MOAB/trunk/itaps/imesh/MBiMesh.hpp	2011-03-10 20:59:32 UTC (rev 4573)
+++ MOAB/trunk/itaps/imesh/MBiMesh.hpp	2011-03-10 22:11:34 UTC (rev 4574)
@@ -2,6 +2,9 @@
 #define MBIMESH_HPP
 
 #include "moab/Core.hpp"
+#include <vector>
+#include <algorithm>
+
 using namespace moab;
 
 class MBiMesh
@@ -9,6 +12,7 @@
 private:
   bool haveDeletedEntities;
   bool iCreatedInterface;
+  std::vector<Tag> setHandleTags, entHandleTags;
 public:
   MBiMesh(moab::Interface *mbImpl = NULL);
 
@@ -25,6 +29,12 @@
   virtual ErrorCode delete_entities( const Range& );
   int AdjTable[16];
   moab::Interface *mbImpl;
+  
+  inline void note_set_handle_tag( Tag );
+  inline void note_ent_handle_tag( Tag );
+  inline void note_tag_destroyed( Tag );
+  inline bool is_set_handle_tag( Tag ) const;
+  inline bool is_ent_handle_tag( Tag ) const;
 };
 
 static inline MBiMesh *mbimeshi_instance(iMesh_Instance instance) {return reinterpret_cast<MBiMesh*>(instance);}
@@ -72,4 +82,48 @@
   return mbImpl->delete_entities( r );
 }
 
+
+void MBiMesh::note_set_handle_tag( Tag t )
+{
+  std::vector<Tag>::iterator i;
+  i = std::lower_bound( entHandleTags.begin(), entHandleTags.end(), t );
+  if (i != entHandleTags.end() && *i == t)
+    entHandleTags.erase(i);
+  i = std::lower_bound( setHandleTags.begin(), setHandleTags.end(), t );
+  if (i == setHandleTags.end() || *i != t)
+    setHandleTags.insert( i, t );
+}
+


More information about the moab-dev mailing list