[MOAB-dev] r2780 - in MOAB/trunk: . parallel

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Mon Mar 30 17:12:09 CDT 2009


Author: kraftche
Date: 2009-03-30 17:12:09 -0500 (Mon, 30 Mar 2009)
New Revision: 2780

Modified:
   MOAB/trunk/MBCore.cpp
   MOAB/trunk/MBWriteUtil.cpp
   MOAB/trunk/MBWriteUtil.hpp
   MOAB/trunk/MBWriteUtilIface.hpp
   MOAB/trunk/MBWriterIface.hpp
   MOAB/trunk/WriteAns.cpp
   MOAB/trunk/WriteAns.hpp
   MOAB/trunk/WriteGMV.cpp
   MOAB/trunk/WriteGMV.hpp
   MOAB/trunk/WriteGmsh.cpp
   MOAB/trunk/WriteGmsh.hpp
   MOAB/trunk/WriteHDF5.cpp
   MOAB/trunk/WriteHDF5.hpp
   MOAB/trunk/WriteNCDF.cpp
   MOAB/trunk/WriteNCDF.hpp
   MOAB/trunk/WriteSLAC.cpp
   MOAB/trunk/WriteSLAC.hpp
   MOAB/trunk/WriteSTL.cpp
   MOAB/trunk/WriteSTL.hpp
   MOAB/trunk/WriteTemplate.cpp
   MOAB/trunk/WriteTemplate.hpp
   MOAB/trunk/WriteVtk.cpp
   MOAB/trunk/WriteVtk.hpp
   MOAB/trunk/exodus_test.cc
   MOAB/trunk/parallel/WriteHDF5Parallel.cpp
   MOAB/trunk/parallel/WriteHDF5Parallel.hpp
Log:
o Consolidate code for getting list of tags to write, moving it from
  VTK and HDF5 writers to MBWriteUtil

o Fixes bug: VTK writer writes tags beginning with '--'

o Fixes bug: VTK writer creates invalid files if database contains anonymous tags.

o Change MBWriterIface and all writers such that user-specified tag list is 
  passed from MBCore::write_file to individual writers.

o Add support for user-specified tag list in VTK and HDF5 writers.



Modified: MOAB/trunk/MBCore.cpp
===================================================================
--- MOAB/trunk/MBCore.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/MBCore.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -504,7 +504,8 @@
     // write the file
   std::vector<std::string> qa_records;
   const MBEntityHandle* list_ptr = list.empty() ? (MBEntityHandle*)0 : &list[0];
-  rval = writer->write_file(file_name, overwrite, opts, list_ptr, list.size(), qa_records );
+  rval = writer->write_file(file_name, overwrite, opts, list_ptr, list.size(), qa_records,
+                            tag_list, num_tags );
   delete writer;
   
   return rval;

Modified: MOAB/trunk/MBWriteUtil.cpp
===================================================================
--- MOAB/trunk/MBWriteUtil.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/MBWriteUtil.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -722,3 +722,77 @@
 {
   return mMB->a_entity_factory()->get_adjacencies( entity, adj_array, num_adj );
 }
+
+MBErrorCode MBWriteUtil::get_tag_list( std::vector<MBTag>& result_list,
+                                       const MBTag* user_tag_list, 
+                                       int user_tag_list_length,
+                                       bool include_variable_length_tags )
+{
+  MBErrorCode rval;
+  
+  if (user_tag_list) {
+    result_list.clear();
+    result_list.reserve( user_tag_list_length );
+    for (int i = 0; i < user_tag_list_length; ++i) {
+      std::string name;
+      rval = mMB->tag_get_name( user_tag_list[i], name );
+      if (MB_SUCCESS != rval) {
+        report_error( "Error %d getting name for tag.  Invalid input tag handle?", (int)rval );
+        return rval;
+      }
+      
+      if (name.empty()) {
+        report_error( "Explicit request to save anonymous tag." );
+        return MB_TAG_NOT_FOUND;
+      }
+      
+      int size;
+      if (!include_variable_length_tags &&
+          MB_VARIABLE_DATA_LENGTH == mMB->tag_get_size( user_tag_list[i], size )) {
+        report_error( "File format cannot store variable-length tag: \"%s\".", name.c_str() );
+        return MB_TYPE_OUT_OF_RANGE;
+      }
+      
+      result_list.push_back( user_tag_list[i] );
+    }
+  }
+  else {
+    std::vector<MBTag> temp_list;
+    rval = mMB->tag_get_tags( temp_list );
+    if (MB_SUCCESS != rval) {
+      report_error( "MBInterface::tag_get_tags failed!" );
+      return rval;
+    }
+
+    result_list.clear();
+    result_list.reserve( temp_list.size() );
+    
+    std::vector<MBTag>::iterator i;
+    for (i = temp_list.begin(); i != temp_list.end(); ++i) {
+      std::string name;
+      rval = mMB->tag_get_name( *i, name );
+      if (MB_SUCCESS != rval) {
+        report_error( "Error %d getting name for tag.  Stale tag handle?", (int)rval );
+        return rval;
+      }
+      
+        // skip anonymous tags
+      if (name.empty())
+        continue;
+      
+        // skip private/internal tags
+      if (name.size() >= 2 && name[0] == '_' && name[1] == '_')
+        continue;
+      
+        // if reqested, skip variable-length tags
+      int size;
+      if (!include_variable_length_tags &&
+          MB_VARIABLE_DATA_LENGTH == mMB->tag_get_size( *i, size ))
+        continue;
+      
+       result_list.push_back( *i );
+    }
+  }
+  
+  return MB_SUCCESS;  
+}

Modified: MOAB/trunk/MBWriteUtil.hpp
===================================================================
--- MOAB/trunk/MBWriteUtil.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/MBWriteUtil.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -248,6 +248,19 @@
                                int& num_adj );
 
 
+  /**\brief Get list of tags to write.
+   *
+   * Get the list of tags to write to the file, possibly using
+   * an optional user-specifed tag list.
+   *
+   *\author Jason Kraftcheck
+   */
+  virtual MBErrorCode 
+  get_tag_list( std::vector<MBTag>& result_list,
+                const MBTag* user_tag_list = 0, 
+                int user_tag_list_length = 0,
+                bool include_variable_length_tags = true );
+
   //! tell MB there was an error when writing the mesh
   //! it makes sense to have this as long as MBInterface has a write_mesh function
   MBErrorCode report_error( const std::string& error );

Modified: MOAB/trunk/MBWriteUtilIface.hpp
===================================================================
--- MOAB/trunk/MBWriteUtilIface.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/MBWriteUtilIface.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -299,6 +299,20 @@
   template <typename T> static inline 
   void reorder( const int* order, T* conn, int num_elem, int node_per_elem );
 
+
+  /**\brief Get list of tags to write.
+   *
+   * Get the list of tags to write to the file, possibly using
+   * an optional user-specifed tag list.
+   *
+   *\author Jason Kraftcheck
+   */
+  virtual MBErrorCode 
+  get_tag_list( std::vector<MBTag>& result_list,
+                const MBTag* user_tag_list = 0, 
+                int user_tag_list_length = 0,
+                bool include_variable_length_tags = true ) = 0;
+
     //! if an error occured when reading the mesh, report it to MB
     //! it makes sense to have this as long as MBInterface has a write_mesh function
     //! \return status Return status

Modified: MOAB/trunk/MBWriterIface.hpp
===================================================================
--- MOAB/trunk/MBWriterIface.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/MBWriterIface.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -49,6 +49,9 @@
      *\param num_sets       The length of <code>meshset_list</code> or zero
      *                      if the whole mesh is to be exported.
      *\param qa_records     File history metadata
+     *\param tag_list       Array of handles for tags to write.  If null,
+     *                      write all tags.  If non-NULL but num_tags is
+     *                      zero, write no tags.
      *\param requseted_output_dimension  The geometric dimension of the
      *                      output mesh (coord values per vertex.)  If
      *                      zero, the dimension of the mesh as returned
@@ -61,6 +64,8 @@
                                     const MBEntityHandle* meshset_list,
                                     const int num_sets,
                                     const std::vector<std::string>& qa_records,
+                                    const MBTag* tag_list,
+                                    int num_tags,
                                     int requested_output_dimension = 0 ) = 0;
 };
 

Modified: MOAB/trunk/WriteAns.cpp
===================================================================
--- MOAB/trunk/WriteAns.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteAns.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -90,7 +90,10 @@
                                       const FileOptions&,
                                       const MBEntityHandle *ent_handles,
                                       const int num_sets,
-                                      const std::vector<std::string>&, int )
+                                      const std::vector<std::string>&, 
+                                      const MBTag* ,
+                                      int ,
+                                      int )
 {
   assert(0 != mMaterialSetTag &&
          0 != mNeumannSetTag &&

Modified: MOAB/trunk/WriteAns.hpp
===================================================================
--- MOAB/trunk/WriteAns.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteAns.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -63,6 +63,8 @@
                           const MBEntityHandle *output_list,
                           const int num_sets,
                           const std::vector<std::string>& qa_list,
+                          const MBTag* tag_list,
+                          int num_tags,
                           int export_dimension);
   
 //! struct used to hold data for each block to be output; used by

Modified: MOAB/trunk/WriteGMV.cpp
===================================================================
--- MOAB/trunk/WriteGMV.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteGMV.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -136,6 +136,8 @@
                                   const MBEntityHandle* output_sets,
                                   const int num_output_sets,
                                   const std::vector<std::string>& ,
+                                  const MBTag*,
+                                  int,
                                   int dimension )
 {
   MBEntityHandle output_set = 0;

Modified: MOAB/trunk/WriteGMV.hpp
===================================================================
--- MOAB/trunk/WriteGMV.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteGMV.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -53,6 +53,8 @@
                           const MBEntityHandle* output_sets,
                           const int num_output_sets,
                           const std::vector<std::string>& qa_list,
+                          const MBTag* tag_list,
+                          int num_tags,
                           int requested_dimension );
 
     //! writes out a mesh file

Modified: MOAB/trunk/WriteGmsh.cpp
===================================================================
--- MOAB/trunk/WriteGmsh.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteGmsh.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -57,6 +57,8 @@
                                   const MBEntityHandle *output_list,
                                   const int num_sets,
                                   const std::vector<std::string>& ,
+                                  const MBTag* ,
+                                  int ,
                                   int )
 {
   MBErrorCode rval;
@@ -76,6 +78,7 @@
     mbImpl->tag_get_handle( GEOM_DIMENSION_TAG_NAME, geom_tag );
   mbImpl->tag_get_handle( PARALLEL_PARTITION_TAG_NAME, prtn_tag );
   
+  
     // Define arrays to hold entity sets of interest
   MBRange sets[3];
   MBTag set_tags[] = { block_tag, geom_tag, prtn_tag };

Modified: MOAB/trunk/WriteGmsh.hpp
===================================================================
--- MOAB/trunk/WriteGmsh.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteGmsh.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -57,6 +57,8 @@
                          const MBEntityHandle *output_list,
                          const int num_sets,
                          const std::vector<std::string>& qa_list,
+                         const MBTag* tag_list,
+                         int num_tags,
                          int export_dimension);  
 
 private:

Modified: MOAB/trunk/WriteHDF5.cpp
===================================================================
--- MOAB/trunk/WriteHDF5.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteHDF5.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -335,6 +335,8 @@
                                    const MBEntityHandle* set_array,
                                    const int num_sets,
                                    const std::vector<std::string>& qa_records,
+                                   const MBTag* tag_list,
+                                   int num_tags,
                                    int user_dimension )
 {
   mhdf_Status status;
@@ -350,7 +352,9 @@
     // Do actual write.
   MBErrorCode result = write_file_impl( filename, overwrite, opts, 
                                         set_array, num_sets, 
-                                        qa_records, user_dimension );
+                                        qa_records, 
+                                        tag_list, num_tags,
+                                        user_dimension );
   
     // Free memory buffer
   free( dataBuffer );
@@ -390,6 +394,8 @@
                                         const MBEntityHandle* set_array,
                                         const int num_sets,
                                         const std::vector<std::string>& qa_records,
+                                        const MBTag* tag_list, 
+                                        int num_tags,
                                         int user_dimension )
 {
   MBErrorCode result;
@@ -451,10 +457,10 @@
   if (parallelWrite) {
     int pcomm_no = 0;
     opts.get_int_option("PARALLEL_COMM", pcomm_no);
-    result = parallel_create_file( filename, overwrite, qa_records, user_dimension, pcomm_no );
+    result = parallel_create_file( filename, overwrite, qa_records, tag_list, num_tags, user_dimension, pcomm_no );
   }
   else {
-    result = serial_create_file( filename, overwrite, qa_records, user_dimension );
+    result = serial_create_file( filename, overwrite, qa_records, tag_list, num_tags, user_dimension );
   }
   if (MB_SUCCESS != result)
     return result;
@@ -1996,7 +2002,7 @@
 }
 */
 
-MBErrorCode WriteHDF5::gather_tags()
+MBErrorCode WriteHDF5::gather_tags( const MBTag* user_tag_list, int num_tags )
 {
   MBErrorCode result;
   std::string tagname;
@@ -2005,23 +2011,12 @@
   MBRange range;
     
     // Get list of Tags to write
-  result = iFace->tag_get_tags( tag_list );
+  result = writeUtil->get_tag_list( tag_list, user_tag_list, num_tags );
   CHK_MB_ERR_0(result);
 
     // Get list of tags
   for (t_itor = tag_list.begin(); t_itor != tag_list.end(); ++t_itor)
   {
-      // Don't write tags that have name beginning with "__"
-    result = iFace->tag_get_name( *t_itor, tagname );
-    if (MB_SUCCESS != result)
-      return result;
-      // Skip anonymous tags
-    if (tagname.empty())
-      continue;
-      // skip tags for which the name begins with two underscores
-    if (tagname.size() >= 2 && tagname[0] == '_' && tagname[1] == '_')
-      continue;
-  
       // Add tag to export list
     SparseTag tag_data;
     tag_data.tag_id = *t_itor;
@@ -2105,7 +2100,9 @@
 MBErrorCode WriteHDF5::parallel_create_file( const char* ,
                                     bool ,
                                     const std::vector<std::string>& ,
+                                    const MBTag*,
                                     int ,
+                                    int,
                                     int  )
 {
   return MB_NOT_IMPLEMENTED;
@@ -2114,6 +2111,8 @@
 MBErrorCode WriteHDF5::serial_create_file( const char* filename,
                                     bool overwrite,
                                     const std::vector<std::string>& qa_records,
+                                    const MBTag* user_tag_list,
+                                    int num_user_tags,
                                     int dimension )
 {
   long first_id;
@@ -2236,7 +2235,7 @@
   
 DEBUGOUT( "Gathering Tags\n" );
   
-  rval = gather_tags();
+  rval = gather_tags( user_tag_list, num_user_tags );
   CHK_MB_ERR_0(rval);
 
     // Create the tags and tag data tables

Modified: MOAB/trunk/WriteHDF5.hpp
===================================================================
--- MOAB/trunk/WriteHDF5.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteHDF5.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -66,6 +66,8 @@
                           const MBEntityHandle* export_sets,
                           const int export_set_count,
                           const std::vector<std::string>& qa_records,
+                          const MBTag* tag_list = 0,
+                          int num_tags = 0,
                           int user_dimension = 3 );
 
   /** Create attributes holding the HDF5 type handle for the 
@@ -78,6 +80,8 @@
   MBErrorCode serial_create_file( const char* filename,
                                   bool overwrite,
                                   const std::vector<std::string>& qa_records,
+                                  const MBTag* tag_list,
+                                  int num_tags,
                                   int dimension = 3 );
 
   /** Function to create the file.  Virtual to allow override
@@ -86,6 +90,8 @@
   virtual MBErrorCode parallel_create_file( const char* filename,
                                             bool overwrite,
                                             const std::vector<std::string>& qa_records,
+                                            const MBTag* tag_list,
+                                            int num_tags,
                                             int dimension = 3,
                                             int pcomm_no = 0 );
 
@@ -103,7 +109,7 @@
 
  
   //! Gather tags
-  MBErrorCode gather_tags();
+  MBErrorCode gather_tags( const MBTag* user_tag_list, int user_tag_list_length );
 
   /** Helper function for create-file
    *
@@ -268,6 +274,8 @@
                                const MBEntityHandle* export_sets,
                                const int export_set_count,
                                const std::vector<std::string>& qa_records,
+                               const MBTag* tag_list,
+                               int num_tags,
                                int user_dimension = 3 );
 
   MBErrorCode init();

Modified: MOAB/trunk/WriteNCDF.cpp
===================================================================
--- MOAB/trunk/WriteNCDF.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteNCDF.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -156,6 +156,8 @@
                                     const MBEntityHandle *ent_handles,
                                     const int num_sets,
                                     const std::vector<std::string> &qa_records,
+                                    const MBTag*,
+                                    int,
                                     int user_dimension)
 {
   assert(0 != mMaterialSetTag &&

Modified: MOAB/trunk/WriteNCDF.hpp
===================================================================
--- MOAB/trunk/WriteNCDF.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteNCDF.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -102,6 +102,8 @@
                           const MBEntityHandle *output_list,
                           const int num_sets,
                           const std::vector<std::string> &qa_records, 
+                          const MBTag*,
+                          int,
                           int user_dimension);
   
 protected:

Modified: MOAB/trunk/WriteSLAC.cpp
===================================================================
--- MOAB/trunk/WriteSLAC.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteSLAC.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -128,7 +128,10 @@
                                   const FileOptions&,
                                   const MBEntityHandle *ent_handles,
                                   const int num_sets,
-                                  const std::vector<std::string>&, int )
+                                  const std::vector<std::string>&, 
+                                  const MBTag*,
+                                  int,
+                                  int )
 {
   assert(0 != mMaterialSetTag &&
          0 != mNeumannSetTag &&

Modified: MOAB/trunk/WriteSLAC.hpp
===================================================================
--- MOAB/trunk/WriteSLAC.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteSLAC.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -65,6 +65,8 @@
                           const MBEntityHandle *output_list,
                           const int num_sets,
                           const std::vector<std::string>& qa_list,
+                          const MBTag* tag_list,
+                          int num_tags,
                           int export_dimension);
   
 //! struct used to hold data for each block to be output; used by

Modified: MOAB/trunk/WriteSTL.cpp
===================================================================
--- MOAB/trunk/WriteSTL.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteSTL.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -83,12 +83,19 @@
                                  const MBEntityHandle *ent_handles,
                                  const int num_sets,
                                  const std::vector<std::string>& qa_list, 
+                                 const MBTag* tag_list,
+                                 int num_tags,
                                  int  )
 {
   char header[81];
   MBRange triangles;
   MBErrorCode rval;
   
+  if (tag_list && num_tags) {
+    mWriteIface->report_error( "STL file does not support tag data\n" );
+    return MB_TYPE_OUT_OF_RANGE;
+  }
+  
   rval = make_header( header, qa_list );
   if (MB_SUCCESS != rval)
     return rval;

Modified: MOAB/trunk/WriteSTL.hpp
===================================================================
--- MOAB/trunk/WriteSTL.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteSTL.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -60,6 +60,8 @@
                          const MBEntityHandle *output_list,
                          const int num_sets,
                          const std::vector<std::string>& qa_list,
+                         const MBTag* tag_list,
+                         int num_tags,
                          int export_dimension);  
 
 protected:

Modified: MOAB/trunk/WriteTemplate.cpp
===================================================================
--- MOAB/trunk/WriteTemplate.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteTemplate.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -122,7 +122,10 @@
                                       const FileOptions& opts,
                                       const MBEntityHandle *ent_handles,
                                       const int num_sets,
-                                      const std::vector<std::string>&, int )
+                                      const std::vector<std::string>&,
+                                      const MBTag* ,
+                                      int ,
+                                      int )
 {
   assert(0 != mMaterialSetTag &&
          0 != mNeumannSetTag &&

Modified: MOAB/trunk/WriteTemplate.hpp
===================================================================
--- MOAB/trunk/WriteTemplate.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteTemplate.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -64,6 +64,8 @@
                           const MBEntityHandle *output_list,
                           const int num_sets,
                           const std::vector<std::string>& qa_list,
+                          const MBTag* tag_list,
+                          int num_tags,
                           int export_dimension);
   
 //! struct used to hold data for each block to be output; used by

Modified: MOAB/trunk/WriteVtk.cpp
===================================================================
--- MOAB/trunk/WriteVtk.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteVtk.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -72,6 +72,8 @@
                                  const MBEntityHandle *output_list,
                                  const int num_sets,
                                  const std::vector<std::string>& ,
+                                 const MBTag* tag_list,
+                                 int num_tags,
                                  int )
 {
   MBErrorCode rval;
@@ -115,8 +117,8 @@
   if ((rval = write_header(file              )) != MB_SUCCESS ||
       (rval = write_nodes( file, nodes       )) != MB_SUCCESS ||
       (rval = write_elems( file, nodes, elems)) != MB_SUCCESS ||
-      (rval = write_tags ( file, true,  nodes)) != MB_SUCCESS ||
-      (rval = write_tags ( file, false, elems)) != MB_SUCCESS)
+      (rval = write_tags ( file, true,  nodes, tag_list, num_tags)) != MB_SUCCESS ||
+      (rval = write_tags ( file, false, elems, tag_list, num_tags)) != MB_SUCCESS)
   {
     file.close();
     remove( file_name );
@@ -316,7 +318,11 @@
 
 
 
-MBErrorCode WriteVtk::write_tags( std::ostream& stream, bool nodes, const MBRange& entities )
+MBErrorCode WriteVtk::write_tags( std::ostream& stream, 
+                                  bool nodes, 
+                                  const MBRange& entities,
+                                  const MBTag* tag_list,
+                                  int num_tags )
 {
   MBErrorCode rval;
   
@@ -341,7 +347,8 @@
 
     // Get all defined tags
   std::vector<MBTag> tags;
-  rval = mbImpl->tag_get_tags( tags );
+  std::vector<MBTag>::iterator i;
+  rval = writeTool->get_tag_list( tags, tag_list, num_tags, false );
   if (MB_SUCCESS != rval)
     return rval;
   
@@ -357,10 +364,12 @@
     if (type == MB_TYPE_HANDLE)
       continue;
       
-      // Skip variable-length tags -- not supported by VTK format
+      // Get size.  Variable-length tags should have been filtered
+      // out by MBWriteUtil already.
     int size;
-    if (MB_VARIABLE_DATA_LENGTH == mbImpl->tag_get_size( *i, size ))
-      continue;    
+    rval = mbImpl->tag_get_size( *i, size );
+    if (MB_SUCCESS != rval)
+      return rval;
     
       // If in strict mode, don't write tags that do not fit in any 
       // attribute type (SCALAR : 1 to 4 values, VECTOR : 3 values, TENSOR : 9 values)

Modified: MOAB/trunk/WriteVtk.hpp
===================================================================
--- MOAB/trunk/WriteVtk.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/WriteVtk.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -45,6 +45,8 @@
                          const MBEntityHandle *output_list,
                          const int num_sets,
                          const std::vector<std::string>& qa_list,
+                         const MBTag* tag_list,
+                         int num_tags,
                          int export_dimension);
 
 private:
@@ -65,7 +67,8 @@
   MBErrorCode write_elems( std::ostream& stream, const MBRange& nodes, const MBRange& elems );
   
     //! Write all tags on either the list of nodes or the list of elements
-  MBErrorCode write_tags( std::ostream& stream, bool nodes, const MBRange& entities );
+  MBErrorCode write_tags( std::ostream& stream, bool nodes, const MBRange& entities,
+                          const MBTag* tag_list, int num_tags );
   
     //! Write the tad description for the passed tag and call the template
     //! \ref write_tag function to write the tag data.

Modified: MOAB/trunk/exodus_test.cc
===================================================================
--- MOAB/trunk/exodus_test.cc	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/exodus_test.cc	2009-03-30 22:12:09 UTC (rev 2780)
@@ -98,7 +98,7 @@
   std::vector<std::string> qa_records;
   rval = writer.write_file( tmp_file, true, opts, 
                             write_set_list, write_set_list_len,
-                            qa_records, 3 );
+                            qa_records, NULL, 0, 3 );
   if (MB_SUCCESS != rval) 
     remove(tmp_file);
   CHECK_ERR(rval);

Modified: MOAB/trunk/parallel/WriteHDF5Parallel.cpp
===================================================================
--- MOAB/trunk/parallel/WriteHDF5Parallel.cpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/parallel/WriteHDF5Parallel.cpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -368,6 +368,8 @@
 MBErrorCode WriteHDF5Parallel::parallel_create_file( const char* filename,
                                             bool overwrite,
                                             const std::vector<std::string>& qa_records,
+                                            const MBTag* user_tag_list,
+                                            int user_tag_count,
                                             int dimension,
                                             int pcomm_no)
 {
@@ -460,7 +462,7 @@
       parallel_sets.insert( psiter->handle );
   
   setSet.range.merge( parallel_sets );
-  rval = gather_tags();
+  rval = gather_tags( user_tag_list, user_tag_count );
   if (MB_SUCCESS != rval)
     return rval;
   range_remove( setSet.range, parallel_sets );   

Modified: MOAB/trunk/parallel/WriteHDF5Parallel.hpp
===================================================================
--- MOAB/trunk/parallel/WriteHDF5Parallel.hpp	2009-03-30 22:02:52 UTC (rev 2779)
+++ MOAB/trunk/parallel/WriteHDF5Parallel.hpp	2009-03-30 22:12:09 UTC (rev 2780)
@@ -103,6 +103,8 @@
     virtual MBErrorCode parallel_create_file( const char* filename,
                                      bool overwrite,
                                      const std::vector<std::string>& qa_records,
+                                     const MBTag* user_tag_list = 0,
+                                     int user_tag_count = 0,
                                      int dimension = 3,
                                      int pcomm_no = 0);
     



More information about the moab-dev mailing list