moab
ReadTetGen.hpp
Go to the documentation of this file.
00001 #ifndef READ_TET_GEN_HPP
00002 #define READ_TET_GEN_HPP
00003 
00004 #include <iosfwd>
00005 #include "moab/Forward.hpp"
00006 #include "moab/ReaderIface.hpp"
00007 #include <string>
00008 
00009 namespace moab {
00010 
00011 class ReadUtilIface;
00012 
00013 /* TetGen mesh data is typically split into two or three files:
00014  * name.node : node data
00015  * name.ele  : tet data
00016  * name.face : tri data
00017  * The reader will attempt to guess the correct file names from
00018  * the single input file name unless explicit file names are
00019  * specified using file options as described below.
00020  *
00021  * File options:
00022  *   NODE_FILE=filename   : node file name
00023  *   ELE_FILE[=filename]  : require tet file and optionally specify file name
00024  *   FACE_FILE[=filename] : reequire tri file and optionally specify file name
00025  *   EDGE_FILE[=filename] : reequire edge file and optionally specify file name
00026  *   NODE_ATTR_LIST=name[,name[,...]] : List of tag names in which to store
00027  *                                     attribute values.  If the same name
00028  *                                     is repeated multiple times, multiple
00029  *                                     attribute values will be stored in the
00030  *                                     same tag as array values in the order
00031  *                                     they are read from the file.  If a 
00032  *                                     name is zero-length, the attribute data
00033  *                                     will be disgarded.  
00034  */
00035 class ReadTetGen : public ReaderIface
00036 {
00037    
00038 public:
00039 
00040   static ReaderIface* factory( Interface* );
00041 
00043   ErrorCode load_file( const char* file_name,
00044                        const EntityHandle* file_set,
00045                        const FileOptions& opts,
00046                        const SubsetList* subset_list = 0,
00047                        const Tag* file_id_tag = 0 );
00048 
00049   ErrorCode read_tag_values( const char* file_name,
00050                              const char* tag_name,
00051                              const FileOptions& opts,
00052                              std::vector<int>& tag_values_out,
00053                              const SubsetList* subset_list = 0 );
00054   
00056   ReadTetGen(Interface* impl = NULL);
00057 
00059   virtual ~ReadTetGen();
00060 
00061 private:
00062 
00063   Interface* mbIface;
00064   ReadUtilIface* readTool;
00065 
00080   ErrorCode open_file( const std::string& input_file_name,
00081                          const std::string& input_name_base,
00082                          const std::string& input_name_suffix,
00083                          const char* file_type_suffix,
00084                          const char* file_name_option,
00085                          const FileOptions& opts,
00086                          std::ifstream& file_stream,
00087                          bool file_required = false );
00088 
00097   ErrorCode read_line( std::istream& file, std::string& line, int& lineno );
00098 
00101   ErrorCode read_line( std::istream& file, 
00102                          double* values_out, int num_values,
00103                          int& lineno );
00104 
00121   ErrorCode parse_attr_list( const std::string& option_str,
00122                                std::vector<Tag>& tag_list,
00123                                std::vector<int>& index_list,
00124                                const char* group_designator = 0 );
00125 
00126   ErrorCode read_node_file( std::istream& file, 
00127                               const Tag* attr_tag_list,
00128                               const int* attr_tag_index,
00129                               int attr_tag_list_len,
00130                               std::vector<EntityHandle>& nodes );
00131 
00132   ErrorCode read_elem_file( EntityType type,
00133                               std::istream& file, 
00134                               const std::vector<EntityHandle>& nodes,
00135                               Range& elems );
00136 };
00137 
00138 } // namespace moab
00139 
00140 #endif // defined(READ_TET_GEN_HPP)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines