MOAB: Mesh Oriented datABase  (version 5.2.1)
ReadTemplate.hpp
Go to the documentation of this file.
00001 #ifndef READ_TEMPLATE_HPP
00002 #define READ_TEMPLATE_HPP
00003 
00004 #include "moab/ReaderIface.hpp"
00005 #include "moab/Range.hpp"
00006 
00007 namespace moab
00008 {
00009 
00010 class ReadUtilIface;
00011 class Interface;
00012 
00013 /**
00014  * \brief Template for implementing new file readers in MOAB
00015  * This class is a template for writing new file readers in MOAB.  This shows how to efficiently
00016  * create vertices and elements using the ReadUtilIface class, and to translate indices in
00017  * connectivity lists into vertex handles created during the read.
00018  *
00019  * After writing the new reader class, you should also modify src/ReaderWriterSet.cpp, to register
00020  * the new reader along with the file extensions that it reads.  This will turn on automatic
00021  * creating of this reader based on file extension, which is done in Core::serial_load_file.
00022  */
00023 class ReadTemplate : public ReaderIface
00024 {
00025 
00026   public:
00027     //! factory method
00028     static ReaderIface* factory( Interface* );
00029 
00030     ErrorCode load_file( const char* file_name, const EntityHandle* file_set, const FileOptions& opts,
00031                          const SubsetList* subset_list = 0, const Tag* file_id_tag = 0 );
00032 
00033     ErrorCode read_tag_values( const char* file_name, const char* tag_name, const FileOptions& opts,
00034                                std::vector< int >& tag_values_out, const SubsetList* subset_list = 0 );
00035 
00036     //! Constructor
00037     ReadTemplate( Interface* impl = NULL );
00038 
00039     //! Destructor
00040     virtual ~ReadTemplate();
00041 
00042   private:
00043     /** \brief Read vertex data and create vertices in MOAB database
00044      * \param num_verts Number of vertices to be read
00045      * \param start_vertex Starting vertex handle; used later to offset connectivity indices
00046      * \param read_ents Range storing all entities read from this file
00047      */
00048     ErrorCode read_vertices( int num_verts, EntityHandle& start_vertex, Range& read_ents );
00049 
00050     /** \brief Read element data and create elements in MOAB database
00051      * \param num_elems Number of elements to be read
00052      * \param start_vertex Starting vertex handle; used to offset connectivity indices
00053      * \param start_elem Starting element handle; may be used later to offset set entities
00054      * \param read_ents Range storing all entities read from this file
00055      */
00056     ErrorCode read_elements( int num_elems, EntityHandle start_vertex, EntityHandle& start_elem, Range& read_ents );
00057 
00058     /** \brief Read entity set data and create/populate sets in MOAB database
00059      * \param num_sets Number of sets to be read
00060      * \param start_vertex Starting vertex handle
00061      * \param num_verts Total number of vertices read from file
00062      * \param start_elem Starting element handle
00063      * \param num_elems Total number of elements read from file
00064      * \param read_ents Range storing all entities read from this file
00065      */
00066     ErrorCode create_sets( int num_sets, EntityHandle start_vertex, int num_verts, EntityHandle start_elem,
00067                            int num_elems, Range& read_ents );
00068 
00069     /** \brief Process options passed into the reader
00070      * \param opts Options passed into this read
00071      */
00072     ErrorCode process_options( const FileOptions& opts );
00073 
00074     ReadUtilIface* readMeshIface;
00075 
00076     //! interface instance
00077     Interface* mbImpl;
00078 
00079     const char* fileName;
00080 };
00081 
00082 }  // namespace moab
00083 
00084 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines