MOAB: Mesh Oriented datABase  (version 5.2.1)
WriteDamsel.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : WriteDamsel.hpp
00003 //
00004 // Purpose       : ExodusII writer
00005 //
00006 // Special Notes : Lots of code taken from verde implementation
00007 //
00008 // Creator       : Corey Ernst
00009 //
00010 // Date          : 8/02
00011 //
00012 // Owner         : Corey Ernst
00013 //-------------------------------------------------------------------------
00014 
00015 #ifndef WRITEDAMSEL_HPP
00016 #define WRITEDAMSEL_HPP
00017 
00018 #ifndef IS_BUILDING_MB
00019 #error "WriteDamsel.hpp isn't supposed to be included into an application"
00020 #endif
00021 
00022 #include <vector>
00023 #include <string>
00024 
00025 #include "moab/Interface.hpp"
00026 #include "moab/Range.hpp"
00027 #include "moab/WriterIface.hpp"
00028 #include "RangeSeqIntersectIter.hpp"
00029 #include "moab/FileOptions.hpp"
00030 #include "DamselUtil.hpp"
00031 
00032 #include "damsel.h"
00033 
00034 namespace moab
00035 {
00036 
00037 class WriteUtilIface;
00038 class SequenceManager;
00039 class Error;
00040 
00041 class WriteDamsel : public WriterIface
00042 {
00043   public:
00044     //! Factory function, for ReaderWriter
00045     static WriterIface* factory( Interface* iface );
00046 
00047     //! Constructor
00048     WriteDamsel( Interface* impl );
00049 
00050     //! Destructor
00051     virtual ~WriteDamsel();
00052 
00053     //! Primary interface function
00054     //! \param file_name Filename being written
00055     //! \param overwrite If true and the file exists, an error is returned
00056     //! \param opts File options, e.g. whether and how to write in parallel
00057     //! \param meshset_list If non-NULL, a vector of sets defining what is to be written
00058     //! \param num_sets The number of sets to be written, only used if meshset_list is non-NULL
00059     //! \param qa_records Strings defining provenance information
00060     //! \param tag_list If non-NULL, only these tags should be written
00061     //! \param num_tags The number of tag handles in tag_list, used only if tag_list is non-NULL
00062     //! \param requested_output_dimension Dimension used for coordinates
00063     ErrorCode write_file( const char* file_name, const bool /* overwrite */, const FileOptions& opts,
00064                           const EntityHandle* meshset_list, const int num_sets,
00065                           const std::vector< std::string >& /* qa_records */, const Tag* /* tag_list */ = NULL,
00066                           int /* num_tags */ = 0, int /* requested_output_dimension */ = 3 );
00067 
00068     enum
00069     {
00070         DAMSEL_IS_TRACKING = 0x1
00071     } DAMSEL_FLAGS;
00072 
00073   private:
00074     //! Initialize global information about dense/sparse/conventional tags, once for entire
00075     //! write_file call
00076     ErrorCode init_tag_info();
00077 
00078     //! Write a subrange of entities/sets; just a wrapper to write_[vertices, entities, sets]
00079     ErrorCode write_subrange( RangeSeqIntersectIter& rsi );
00080 
00081     //! Write the vertices in the model, for the handles in the specified RangeSeqIntersectIter
00082     //! \param rsi Range sequence iterator defining range of entities/sets to be written
00083     ErrorCode write_vertices( RangeSeqIntersectIter& rsi );
00084 
00085     //! Write the entities in the model, for the handles in the specified RangeSeqIntersectIter
00086     //! \param rsi Range sequence iterator defining range of entities/sets to be written
00087     ErrorCode write_entities( RangeSeqIntersectIter& rsi );
00088 
00089     //! Write the sets in the model, for the handles in the specified RangeSeqIntersectIter
00090     //! \param rsi Range sequence iterator defining range of entities/sets to be written
00091     ErrorCode write_sets( RangeSeqIntersectIter& rsi );
00092 
00093     //! Map dense tags for the specified entities, using the specified damsel entity container
00094     ErrorCode map_dense_tags( RangeSeqIntersectIter& rsi, damsel_container& ent_cont );
00095 
00096     //! Map sparse tags for all entities
00097     ErrorCode map_sparse_tags();
00098 
00099     //! Interface instance
00100     Interface* mbImpl;
00101 
00102     //! WriteUtil object used in this writer
00103     WriteUtilIface* mWriteIface;
00104 
00105     //! Used to initialize the RangeSeqIntersectIter
00106     SequenceManager* sequenceManager;
00107 
00108     //! File name
00109     std::string fileName;
00110 
00111     //! Utility for storing damsel-specific stuff
00112     DamselUtil dU;
00113 };
00114 
00115 inline ErrorCode WriteDamsel::write_subrange( RangeSeqIntersectIter& rsi )
00116 {
00117     ErrorCode rval = MB_SUCCESS;
00118 
00119     if( MBVERTEX == mbImpl->type_from_handle( rsi.get_start_handle() ) )
00120         rval = write_vertices( rsi );
00121     else if( MBENTITYSET > mbImpl->type_from_handle( rsi.get_start_handle() ) )
00122         rval = write_entities( rsi );
00123     // else
00124     //  rval = write_sets(rsi);
00125 
00126     return rval;
00127 }
00128 
00129 }  // namespace moab
00130 
00131 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines