MOAB: Mesh Oriented datABase  (version 5.2.1)
ReadDamsel.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : ReadDamsel.hpp
00003 //
00004 // Purpose       : Damsel file reader
00005 //
00006 // Creator       : Tim Tautges
00007 //-------------------------------------------------------------------------
00008 
00009 #ifndef READDAMSEL_HPP
00010 #define READDAMSEL_HPP
00011 
00012 #ifndef IS_BUILDING_MB
00013 //#error "ReadDamsel.hpp isn't supposed to be included into an application"
00014 #endif
00015 
00016 #include <vector>
00017 #include <map>
00018 #include <string>
00019 
00020 #include "moab/Forward.hpp"
00021 #include "moab/ReaderIface.hpp"
00022 #include "moab/Range.hpp"
00023 #include "moab/RangeMap.hpp"
00024 #include "DebugOutput.hpp"
00025 #include "DamselUtil.hpp"
00026 
00027 #include "damsel.h"
00028 
00029 namespace moab
00030 {
00031 
00032 class ReadUtilIface;
00033 class ParallelComm;
00034 class Error;
00035 
00036 class ReadDamsel : public ReaderIface
00037 {
00038   public:
00039     static ReaderIface* factory( Interface* );
00040 
00041     //! Load an NC file
00042     ErrorCode load_file( const char* file_name, const EntityHandle* file_set, const FileOptions& opts,
00043                          const SubsetList* subset_list = 0, const Tag* file_id_tag = 0 );
00044 
00045     //! Constructor
00046     ReadDamsel( Interface* impl = NULL );
00047 
00048     //! Destructor
00049     virtual ~ReadDamsel();
00050 
00051     virtual ErrorCode read_tag_values( const char* file_name, const char* tag_name, const FileOptions& opts,
00052                                        std::vector< int >& tag_values_out, const SubsetList* subset_list = 0 );
00053 
00054   private:
00055     //! Get contents of the container (containing file-side handles) and translate to moab-side
00056     //! handles
00057     ErrorCode get_contents( damsel_model m, damsel_container c, Range& ents );
00058 
00059     //! Get contents of the container (containing file-side handles) and translate to moab-side
00060     //! handles ents argument should point to already-allocated space
00061     ErrorCode get_contents( damsel_model m, damsel_container c, EntityHandle* ents );
00062 
00063     ErrorCode init();
00064 
00065     ErrorCode parse_options( const FileOptions& opts, bool& parallel );
00066 
00067     ErrorCode process_tags( std::vector< damsel_tag_buf_type >& tag_infos );
00068 
00069     ErrorCode process_ent_info( const damsel_entity_buf_type& einfo );
00070 
00071     ErrorCode process_entity_tags( int count, damsel_container tag_container, damsel_container app_cont,
00072                                    Range& these_ents );
00073 
00074     ErrorCode process_coll_infos( std::vector< damsel_collection_buf_type >& coll_infos );
00075 
00076     //! Convert handles in a container into handle pairs, one pair per contiguous sequence of
00077     //! handles in the container
00078     ErrorCode container_to_handle_pairs( damsel_container& cont, std::vector< damsel_handle >& handle_pairs );
00079 
00080     //! Store MOAB handles starting from start_handle, corresponding to store handles in
00081     //! handle_pairs, into the entity map
00082     ErrorCode insert_into_map( std::vector< damsel_handle >& handle_pairs, EntityHandle start_handle );
00083 
00084     class subrange
00085     {
00086       public:
00087         subrange( damsel_handle ch, EntityHandle s, int c ) : collh( ch ), seth( s ), count( c ) {}
00088         damsel_handle collh;
00089         EntityHandle seth;
00090         int count;
00091     };
00092 
00093     //------------member variables ------------//
00094 
00095     //! Interface instance
00096     Interface* mbImpl;
00097 
00098     //! UtilIface
00099     ReadUtilIface* readMeshIface;
00100 
00101     //! File name
00102     std::string fileName;
00103 
00104     //! Whether this reader natively supports parallel semantics
00105     bool nativeParallel;
00106 
00107     //! Parallel info
00108     ParallelComm* myPcomm;
00109 
00110     //! Used to track file handles
00111     Tag mGlobalIdTag;
00112 
00113     //! map from damsel to moab handles
00114     RangeMap< damsel_handle, EntityHandle, 0 > dmHandleRMap;
00115 
00116     //! Keep various damsel data
00117     DamselUtil dU;
00118 };
00119 
00120 inline const bool operator==( const damsel_err_t& lhs, const damsel_err_t& rhs )
00121 {
00122     return lhs.id == rhs.id;
00123 }
00124 
00125 }  // namespace moab
00126 
00127 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines