Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
ReadSmf.hpp
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  */
00015 
00016 #ifndef READ_SMF_HPP
00017 #define READ_SMF_HPP
00018 
00019 #define SMF_MAXLINE 4096
00020 
00021 #include "moab/Forward.hpp"
00022 #include "moab/ReaderIface.hpp"
00023 
00024 #include "SMF_State.hpp"
00025 #include <iosfwd>
00026 #include <fstream>
00027 
00028 namespace moab
00029 {
00030 
00031 class ReadUtilIface;
00032 class AffineXform;
00033 
00034 /**\brief Read SMF (Simple Model Format) files.
00035  *
00036  * File format is documented at:
00037  * http://people.sc.fsu.edu/~burkardt/data/smf/smf.txt
00038  */
00039 class ReadSmf : public ReaderIface
00040 {
00041 
00042   public:
00043     static ReaderIface* factory( Interface* );
00044 
00045     //! load a file
00046     ErrorCode load_file( const char* file_name,
00047                          const EntityHandle* file_set,
00048                          const FileOptions& opts,
00049                          const SubsetList* subset_list = 0,
00050                          const Tag* file_id_tag        = 0 );
00051 
00052     ErrorCode read_tag_values( const char* file_name,
00053                                const char* tag_name,
00054                                const FileOptions& opts,
00055                                std::vector< int >& tag_values_out,
00056                                const SubsetList* subset_list = 0 );
00057 
00058     //! Constructor
00059     ReadSmf( Interface* impl = NULL );
00060 
00061     //! Destructor
00062     virtual ~ReadSmf();
00063 
00064     typedef ErrorCode ( ReadSmf::*read_cmd )( std::vector< std::string >& argv );
00065     struct cmd_entry
00066     {
00067         const char* name;
00068         read_cmd cmd;
00069     };
00070     void init();
00071 
00072   protected:
00073     ErrorCode annotation( char* cmd, std::vector< std::string >& argv );
00074     void bad_annotation( const char* cmd );
00075 
00076     ErrorCode vertex( std::vector< std::string >& );
00077     ErrorCode v_normal( std::vector< std::string >& );
00078     ErrorCode v_color( std::vector< std::string >& );
00079     ErrorCode f_color( std::vector< std::string >& );
00080     ErrorCode face( std::vector< std::string >& );
00081 
00082     ErrorCode begin( std::vector< std::string >& );
00083     ErrorCode end( std::vector< std::string >& );
00084     ErrorCode set( std::vector< std::string >& );
00085     ErrorCode inc( std::vector< std::string >& );
00086     ErrorCode dec( std::vector< std::string >& );
00087 
00088     ErrorCode trans( std::vector< std::string >& );
00089     ErrorCode scale( std::vector< std::string >& );
00090     ErrorCode rot( std::vector< std::string >& );
00091     ErrorCode mmult( std::vector< std::string >& );
00092     ErrorCode mload( std::vector< std::string >& );
00093 
00094     ErrorCode parse_line( char* line );
00095 
00096     ErrorCode parse_doubles( int count, const std::vector< std::string >& argv, double results[] );
00097     ErrorCode parse_mat( const std::vector< std::string >& argv, AffineXform& mat_out );
00098     ErrorCode check_length( int count, const std::vector< std::string >& argv );
00099 
00100   private:
00101     ReadUtilIface* readMeshIface;
00102 
00103     //------------member variables ------------//
00104 
00105     //! interface instance
00106     //! interface instance
00107     Interface* mdbImpl;
00108 
00109     //! Meshset Handle for the mesh that is currently being read
00110     EntityHandle mCurrentMeshHandle;
00111 
00112     //! A field which, if present and having a single integer for storage, should be used to
00113     //! partition the mesh by range. Defaults to MATERIAL_SET_TAG_NAME
00114     std::string mPartitionTagName;
00115 
00116     // these are from SMF_reader from qslim/gfx/SMF/smf.h
00117     static cmd_entry read_cmds[];
00118     char line[SMF_MAXLINE];
00119     std::vector< SMF_State > state;
00120     SMF_ivars ivar;
00121     int _numNodes;
00122     int _numFaces;
00123     std::vector< double > _coords;  // 3*numNodes; we might not know the number of nodes
00124     std::vector< int > _connec;     // 3*num of elements; we might not know them;
00125     int _numNodesInFile;
00126     int _numElementsInFile;
00127     size_t lineNo;
00128     size_t commandNo;
00129     int versionMajor, versionMinor;
00130 };
00131 
00132 }  // namespace moab
00133 
00134 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines