Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
ReadTemplate.hpp
Go to the documentation of this file.
1 #ifndef READ_TEMPLATE_HPP
2 #define READ_TEMPLATE_HPP
3 
4 #include "moab/ReaderIface.hpp"
5 #include "moab/Range.hpp"
6 
7 namespace moab
8 {
9 
10 class ReadUtilIface;
11 class Interface;
12 
13 /**
14  * \brief Template for implementing new file readers in MOAB
15  * This class is a template for writing new file readers in MOAB. This shows how to efficiently
16  * create vertices and elements using the ReadUtilIface class, and to translate indices in
17  * connectivity lists into vertex handles created during the read.
18  *
19  * After writing the new reader class, you should also modify src/ReaderWriterSet.cpp, to register
20  * the new reader along with the file extensions that it reads. This will turn on automatic
21  * creating of this reader based on file extension, which is done in Core::serial_load_file.
22  */
23 class ReadTemplate : public ReaderIface
24 {
25 
26  public:
27  //! factory method
28  static ReaderIface* factory( Interface* );
29 
30  ErrorCode load_file( const char* file_name,
31  const EntityHandle* file_set,
32  const FileOptions& opts,
33  const SubsetList* subset_list = 0,
34  const Tag* file_id_tag = 0 );
35 
36  ErrorCode read_tag_values( const char* file_name,
37  const char* tag_name,
38  const FileOptions& opts,
39  std::vector< int >& tag_values_out,
40  const SubsetList* subset_list = 0 );
41 
42  //! Constructor
43  ReadTemplate( Interface* impl = NULL );
44 
45  //! Destructor
46  virtual ~ReadTemplate();
47 
48  private:
49  /** \brief Read vertex data and create vertices in MOAB database
50  * \param num_verts Number of vertices to be read
51  * \param start_vertex Starting vertex handle; used later to offset connectivity indices
52  * \param read_ents Range storing all entities read from this file
53  */
54  ErrorCode read_vertices( int num_verts, EntityHandle& start_vertex, Range& read_ents );
55 
56  /** \brief Read element data and create elements in MOAB database
57  * \param num_elems Number of elements to be read
58  * \param start_vertex Starting vertex handle; used to offset connectivity indices
59  * \param start_elem Starting element handle; may be used later to offset set entities
60  * \param read_ents Range storing all entities read from this file
61  */
62  ErrorCode read_elements( int num_elems, EntityHandle start_vertex, EntityHandle& start_elem, Range& read_ents );
63 
64  /** \brief Read entity set data and create/populate sets in MOAB database
65  * \param num_sets Number of sets to be read
66  * \param start_vertex Starting vertex handle
67  * \param num_verts Total number of vertices read from file
68  * \param start_elem Starting element handle
69  * \param num_elems Total number of elements read from file
70  * \param read_ents Range storing all entities read from this file
71  */
72  ErrorCode create_sets( int num_sets,
73  EntityHandle start_vertex,
74  int num_verts,
75  EntityHandle start_elem,
76  int num_elems,
77  Range& read_ents );
78 
79  /** \brief Process options passed into the reader
80  * \param opts Options passed into this read
81  */
82  ErrorCode process_options( const FileOptions& opts );
83 
85 
86  //! interface instance
88 
89  const char* fileName;
90 };
91 
92 } // namespace moab
93 
94 #endif