Template for implementing new file readers in MOAB This class is a template for writing new file readers in MOAB. This shows how to efficiently create vertices and elements using the ReadUtilIface class, and to translate indices in connectivity lists into vertex handles created during the read. More...
#include <ReadTemplate.hpp>
Public Member Functions | |
ErrorCode | load_file (const char *file_name, const EntityHandle *file_set, const FileOptions &opts, const SubsetList *subset_list=0, const Tag *file_id_tag=0) |
Load mesh from a file. More... | |
ErrorCode | read_tag_values (const char *file_name, const char *tag_name, const FileOptions &opts, std::vector< int > &tag_values_out, const SubsetList *subset_list=0) |
Read tag values from a file. More... | |
ReadTemplate (Interface *impl=NULL) | |
Constructor. More... | |
virtual | ~ReadTemplate () |
Destructor. More... | |
Public Member Functions inherited from moab::ReaderIface | |
virtual | ~ReaderIface () |
Static Public Member Functions | |
static ReaderIface * | factory (Interface *) |
factory method More... | |
Private Member Functions | |
ErrorCode | read_vertices (int num_verts, EntityHandle &start_vertex, Range &read_ents) |
Read vertex data and create vertices in MOAB database. More... | |
ErrorCode | read_elements (int num_elems, EntityHandle start_vertex, EntityHandle &start_elem, Range &read_ents) |
Read element data and create elements in MOAB database. More... | |
ErrorCode | create_sets (int num_sets, EntityHandle start_vertex, int num_verts, EntityHandle start_elem, int num_elems, Range &read_ents) |
Read entity set data and create/populate sets in MOAB database. More... | |
ErrorCode | process_options (const FileOptions &opts) |
Process options passed into the reader. More... | |
Private Attributes | |
ReadUtilIface * | readMeshIface |
Interface * | mbImpl |
interface instance More... | |
const char * | fileName |
Template for implementing new file readers in MOAB This class is a template for writing new file readers in MOAB. This shows how to efficiently create vertices and elements using the ReadUtilIface class, and to translate indices in connectivity lists into vertex handles created during the read.
After writing the new reader class, you should also modify src/ReaderWriterSet.cpp, to register the new reader along with the file extensions that it reads. This will turn on automatic creating of this reader based on file extension, which is done in Core::serial_load_file.
Definition at line 23 of file ReadTemplate.hpp.
ReadTemplate::ReadTemplate | ( | Interface * | impl = NULL | ) |
Constructor.
Definition at line 24 of file ReadTemplate.cpp.
References mbImpl, moab::Interface::query_interface(), and readMeshIface.
Referenced by factory().
|
virtual |
Destructor.
Definition at line 29 of file ReadTemplate.cpp.
References mbImpl, readMeshIface, and moab::Interface::release_interface().
|
private |
Read entity set data and create/populate sets in MOAB database.
Read/create sets.
num_sets | Number of sets to be read |
start_vertex | Starting vertex handle |
num_verts | Total number of vertices read from file |
start_elem | Starting element handle |
num_elems | Total number of elements read from file |
read_ents | Range storing all entities read from this file |
Definition at line 208 of file ReadTemplate.cpp.
References moab::Interface::add_entities(), moab::Interface::create_meshset(), ErrorCode, fileName, moab::Range::insert(), MB_CHK_SET_ERR, MB_SUCCESS, mbImpl, and MESHSET_SET.
Referenced by load_file().
|
static |
factory method
Definition at line 19 of file ReadTemplate.cpp.
References iface, and ReadTemplate().
Referenced by moab::ReaderWriterSet::ReaderWriterSet().
|
virtual |
Load mesh from a file.
Method all readers must provide to import a mesh.
file_name | The file to read. |
file_set | Optional pointer to entity set representing file. If this is not NULL, reader may optionally tag the pointed-to set with format-specific meta-data. |
subset_list | An optional struct pointer specifying the tags identifying entity sets to be read. |
file_id_tag | If specified, reader should store for each entity it reads, a unique integer ID for this tag. |
Implements moab::ReaderIface.
Definition at line 47 of file ReadTemplate.cpp.
References moab::Interface::add_entities(), create_sets(), ErrorCode, fileName, MB_CHK_SET_ERR, MB_FILE_DOES_NOT_EXIST, MB_SET_ERR, MB_SUCCESS, mbImpl, process_options(), read_elements(), and read_vertices().
|
private |
Process options passed into the reader.
opts | Options passed into this read |
Definition at line 236 of file ReadTemplate.cpp.
References moab::FileOptions::mark_all_seen(), and MB_SUCCESS.
Referenced by load_file().
|
private |
Read element data and create elements in MOAB database.
Read/create elements.
num_elems | Number of elements to be read |
start_vertex | Starting vertex handle; used to offset connectivity indices |
start_elem | Starting element handle; may be used later to offset set entities |
read_ents | Range storing all entities read from this file |
Definition at line 157 of file ReadTemplate.cpp.
References ErrorCode, fileName, moab::ReadUtilIface::get_element_connect(), moab::Range::insert(), MB_CHK_SET_ERR, MB_SUCCESS, MBHEX, moab::Range::rbegin(), readMeshIface, and moab::ReadUtilIface::update_adjacencies().
Referenced by load_file().
|
virtual |
Read tag values from a file.
Read the list if all integer tag values from the file for a tag that is a single integer value per entity.
file_name | The file to read. |
tag_name | The tag for which to read values |
tag_values_out | Output: The list of tag values. |
subset_list | An array of tag name and value sets specifying the subset of the file to read. If multiple tags are specified, the sets that match all tags (intersection) should be read. |
subset_list_length | The length of the 'subset_list' array. |
Implements moab::ReaderIface.
Definition at line 38 of file ReadTemplate.cpp.
References MB_NOT_IMPLEMENTED.
|
private |
Read vertex data and create vertices in MOAB database.
num_verts | Number of vertices to be read |
start_vertex | Starting vertex handle; used later to offset connectivity indices |
read_ents | Range storing all entities read from this file |
Definition at line 133 of file ReadTemplate.cpp.
References ErrorCode, fileName, moab::ReadUtilIface::get_node_coords(), moab::Range::insert(), MB_CHK_SET_ERR, and readMeshIface.
Referenced by load_file().
|
private |
Definition at line 89 of file ReadTemplate.hpp.
Referenced by create_sets(), load_file(), read_elements(), and read_vertices().
|
private |
interface instance
Definition at line 87 of file ReadTemplate.hpp.
Referenced by create_sets(), load_file(), ReadTemplate(), and ~ReadTemplate().
|
private |
Definition at line 84 of file ReadTemplate.hpp.
Referenced by read_elements(), read_vertices(), ReadTemplate(), and ~ReadTemplate().