Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
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 
00012 class ReadUtilIface;
00013 
00014 /* TetGen mesh data is typically split into two or three files:
00015  * name.node : node data
00016  * name.ele  : tet data
00017  * name.face : tri data
00018  * The reader will attempt to guess the correct file names from
00019  * the single input file name unless explicit file names are
00020  * specified using file options as described below.
00021  *
00022  * File options:
00023  *   NODE_FILE=filename   : node file name
00024  *   ELE_FILE[=filename]  : require tet file and optionally specify file name
00025  *   FACE_FILE[=filename] : reequire tri file and optionally specify file name
00026  *   EDGE_FILE[=filename] : reequire edge file and optionally specify file name
00027  *   NODE_ATTR_LIST=name[,name[,...]] : List of tag names in which to store
00028  *                                     attribute values.  If the same name
00029  *                                     is repeated multiple times, multiple
00030  *                                     attribute values will be stored in the
00031  *                                     same tag as array values in the order
00032  *                                     they are read from the file.  If a
00033  *                                     name is zero-length, the attribute data
00034  *                                     will be disgarded.
00035  */
00036 class ReadTetGen : public ReaderIface
00037 {
00038 
00039   public:
00040     static ReaderIface* factory( Interface* );
00041 
00042     //! load a file
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 
00055     //! Constructor
00056     ReadTetGen( Interface* impl = NULL );
00057 
00058     //! Destructor
00059     virtual ~ReadTetGen();
00060 
00061   private:
00062     Interface* mbIface;
00063     ReadUtilIface* readTool;
00064 
00065     /**\brief Try to open one of several input files
00066      *
00067      *\param input_file_name  The file name as passed in by the application
00068      *\param input_name_base  If the input file name ends with a known suffix,
00069      *                        the portition of the input file without the suffix.
00070      *                        Otherwise equal to input_file_name.
00071      *\param input_file_suffix If the input file name ends with a known suffix,
00072      *                        the suffix.  Otherwise empty.
00073      *\param file_type_suffix The suffix for the file type that is to be opened.
00074      *\param file_name_option The FileOptions option name specifying the file
00075      *                        name to open.
00076      *\param opts             Input options list.
00077      *\param file_stream      The stream to open for the file.
00078      */
00079     ErrorCode open_file( const std::string& input_file_name,
00080                          const std::string& input_name_base,
00081                          const std::string& input_name_suffix,
00082                          const char* file_type_suffix,
00083                          const char* file_name_option,
00084                          const FileOptions& opts,
00085                          std::ifstream& file_stream,
00086                          bool file_required = false );
00087 
00088     /**\brief Read a line from a file
00089      *
00090      * Read the next non-empty line.  Strips comments.
00091      *\param file   The stream to read from
00092      *\param line   Output: the line read from the stream
00093      *\param lineno Incremented for each real line read from the stream
00094      *              (including disgarded empty and comment lines.)
00095      */
00096     ErrorCode read_line( std::istream& file, std::string& line, int& lineno );
00097 
00098     /**\brief Read a line of double values from a file.
00099      */
00100     ErrorCode read_line( std::istream& file, double* values_out, int num_values, int& lineno );
00101 
00102     /**\brief Parse option string specifying mapping from
00103      *        attributes to tags.
00104      *
00105      * Given a file option string describing the mapping from tetgen
00106      * attributes to MOAB tags, parse it and populate the passed vectors.
00107      * \param option_str  Input: The option string to parse.
00108      * \param tag_list    Output: A list tag handles, one for each attribute.
00109      *                    Tag handle value will be zero if the attribute
00110      *                    is to be interpreted as a group id.
00111      * \param index_list  Output: Which array index to store the attribute
00112      *                    value at for a multi-valued tag.  Zero for single-
00113      *                    valued tags.  -1 if the corresponding attribute value
00114      *                    is to be interpreted as a group ID.
00115      * \param group_designator Input: special tag name used to designate an
00116      *                    attribute as the group (surface or volume) ID.
00117      */
00118     ErrorCode parse_attr_list( const std::string& option_str,
00119                                std::vector< Tag >& tag_list,
00120                                std::vector< int >& index_list,
00121                                const char* group_designator = 0 );
00122 
00123     ErrorCode read_node_file( std::istream& file,
00124                               const Tag* attr_tag_list,
00125                               const int* attr_tag_index,
00126                               int attr_tag_list_len,
00127                               std::vector< EntityHandle >& nodes );
00128 
00129     ErrorCode read_elem_file( EntityType type,
00130                               std::istream& file,
00131                               const std::vector< EntityHandle >& nodes,
00132                               Range& elems );
00133 };
00134 
00135 }  // namespace moab
00136 
00137 #endif  // defined(READ_TET_GEN_HPP)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines