[MOAB-dev] r1582 - MOAB/trunk

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Mon Feb 4 15:30:51 CST 2008


Author: kraftche
Date: 2008-02-04 15:30:50 -0600 (Mon, 04 Feb 2008)
New Revision: 1582

Modified:
   MOAB/trunk/MBCore.cpp
   MOAB/trunk/TagServer.cpp
   MOAB/trunk/TagServer.hpp
Log:
fix bugs getting tag value for mesh by reference

Modified: MOAB/trunk/MBCore.cpp
===================================================================
--- MOAB/trunk/MBCore.cpp	2008-02-04 21:08:15 UTC (rev 1581)
+++ MOAB/trunk/MBCore.cpp	2008-02-04 21:30:50 UTC (rev 1582)
@@ -1337,8 +1337,7 @@
                                     void *tag_data) const
 {
   if (NULL == entity_handles && 0 == num_entities) {
-    int size;
-    return tagServer->get_mesh_data(tag_handle, tag_data, size);
+    return tagServer->get_mesh_data(tag_handle, tag_data);
   }
 
   else return tagServer->get_data(tag_handle, entity_handles, num_entities, tag_data);
@@ -1398,7 +1397,7 @@
 {
   if (NULL == entity_handles && 0 == num_entities) {
     int size;
-    return tagServer->get_mesh_data(tag_handle, tag_data, tag_sizes ? *tag_sizes : size );
+    return tagServer->get_mesh_data(tag_handle, tag_data[0], tag_sizes ? tag_sizes[0] : size );
   }
 
   else return tagServer->get_data(tag_handle, entity_handles, num_entities, tag_data, tag_sizes);
@@ -1421,7 +1420,7 @@
                                    const int* tag_sizes )
 {
   if (NULL == entity_handles && 0 == num_entities)
-    return tagServer->set_mesh_data(tag_handle, tag_data, tag_sizes ? *tag_sizes : 0);
+    return tagServer->set_mesh_data(tag_handle, tag_data[0], tag_sizes ? tag_sizes[0] : 0);
 
   //verify handles
   const EntitySequence* seq;

Modified: MOAB/trunk/TagServer.cpp
===================================================================
--- MOAB/trunk/TagServer.cpp	2008-02-04 21:08:15 UTC (rev 1581)
+++ MOAB/trunk/TagServer.cpp	2008-02-04 21:30:50 UTC (rev 1582)
@@ -384,7 +384,27 @@
 
 
 MBErrorCode TagServer::get_mesh_data( const MBTag tag_handle,
-                                      void* data,
+                                      void* data ) const
+{
+  const TagInfo* info = get_tag_info( tag_handle );
+  if (!info)
+    return MB_TAG_NOT_FOUND;
+  
+  if (info->get_size() == MB_VARIABLE_LENGTH)
+    return MB_VARIABLE_DATA_LENGTH;
+  
+  if (info->get_mesh_value())
+    memcpy( data, info->get_mesh_value(), info->get_mesh_value_size() );
+  else if (info->default_value())
+    memcpy( data, info->default_value(), info->default_value_size() );
+  else
+    return MB_TAG_NOT_FOUND;
+  
+  return MB_SUCCESS;
+}
+
+MBErrorCode TagServer::get_mesh_data( MBTag tag_handle,
+                                      const void*& data,
                                       int& size ) const
 {
   const TagInfo* info = get_tag_info( tag_handle );
@@ -393,13 +413,15 @@
   
   if (info->get_mesh_value()) {
     size = info->get_mesh_value_size();
-    memcpy( data, info->get_mesh_value(), size );
+    data = info->get_mesh_value();
   }
   else if (info->default_value()) {
     size = info->default_value_size();
-    memcpy( data, info->default_value(), size );
+    data = info->default_value();
   }
   else {
+    data = 0;
+    size = 0;
     return MB_TAG_NOT_FOUND;
   }
     

Modified: MOAB/trunk/TagServer.hpp
===================================================================
--- MOAB/trunk/TagServer.hpp	2008-02-04 21:08:15 UTC (rev 1581)
+++ MOAB/trunk/TagServer.hpp	2008-02-04 21:30:50 UTC (rev 1582)
@@ -152,8 +152,11 @@
                         const int* lengths = 0 );
 
   //! get global/mesh value of tag
-  MBErrorCode get_mesh_data( const MBTag tag_handle, void* data, int& size ) const;
+  MBErrorCode get_mesh_data( const MBTag tag_handle, void* data ) const;
 
+  //! get pointer/reference to mesh data
+  MBErrorCode get_mesh_data( MBTag tag_handle, const void*& data_ptr, int& size ) const;
+
   /**\Brief Get tag value
    *
    * Get the value for a {MBTag,MBEntityHandle} tuple.




More information about the moab-dev mailing list