MOAB: Mesh Oriented datABase  (version 5.3.0)
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, const EntityHandle* file_set, const FileOptions& opts,
00047                          const SubsetList* subset_list = 0, const Tag* file_id_tag = 0 );
00048 
00049     ErrorCode read_tag_values( const char* file_name, const char* tag_name, const FileOptions& opts,
00050                                std::vector< int >& tag_values_out, const SubsetList* subset_list = 0 );
00051 
00052     //! Constructor
00053     ReadSmf( Interface* impl = NULL );
00054 
00055     //! Destructor
00056     virtual ~ReadSmf();
00057 
00058     typedef ErrorCode ( ReadSmf::*read_cmd )( std::vector< std::string >& argv );
00059     struct cmd_entry
00060     {
00061         const char* name;
00062         read_cmd cmd;
00063     };
00064     void init();
00065 
00066   protected:
00067     ErrorCode annotation( char* cmd, std::vector< std::string >& argv );
00068     void bad_annotation( const char* cmd );
00069 
00070     ErrorCode vertex( std::vector< std::string >& );
00071     ErrorCode v_normal( std::vector< std::string >& );
00072     ErrorCode v_color( std::vector< std::string >& );
00073     ErrorCode f_color( std::vector< std::string >& );
00074     ErrorCode face( std::vector< std::string >& );
00075 
00076     ErrorCode begin( std::vector< std::string >& );
00077     ErrorCode end( std::vector< std::string >& );
00078     ErrorCode set( std::vector< std::string >& );
00079     ErrorCode inc( std::vector< std::string >& );
00080     ErrorCode dec( std::vector< std::string >& );
00081 
00082     ErrorCode trans( std::vector< std::string >& );
00083     ErrorCode scale( std::vector< std::string >& );
00084     ErrorCode rot( std::vector< std::string >& );
00085     ErrorCode mmult( std::vector< std::string >& );
00086     ErrorCode mload( std::vector< std::string >& );
00087 
00088     ErrorCode parse_line( char* line );
00089 
00090     ErrorCode parse_doubles( int count, const std::vector< std::string >& argv, double results[] );
00091     ErrorCode parse_mat( const std::vector< std::string >& argv, AffineXform& mat_out );
00092     ErrorCode check_length( int count, const std::vector< std::string >& argv );
00093 
00094   private:
00095     ReadUtilIface* readMeshIface;
00096 
00097     //------------member variables ------------//
00098 
00099     //! interface instance
00100     //! interface instance
00101     Interface* mdbImpl;
00102 
00103     //! Meshset Handle for the mesh that is currently being read
00104     EntityHandle mCurrentMeshHandle;
00105 
00106     //! A field which, if present and having a single integer for storage, should be used to
00107     //! partition the mesh by range. Defaults to MATERIAL_SET_TAG_NAME
00108     std::string mPartitionTagName;
00109 
00110     // these are from SMF_reader from qslim/gfx/SMF/smf.h
00111     static cmd_entry read_cmds[];
00112     char line[SMF_MAXLINE];
00113     std::vector< SMF_State > state;
00114     SMF_ivars ivar;
00115     int _numNodes;
00116     int _numFaces;
00117     std::vector< double > _coords;  // 3*numNodes; we might not know the number of nodes
00118     std::vector< int > _connec;     // 3*num of elements; we might not know them;
00119     int _numNodesInFile;
00120     int _numElementsInFile;
00121     size_t lineNo;
00122     size_t commandNo;
00123     int versionMajor, versionMinor;
00124 };
00125 
00126 }  // namespace moab
00127 
00128 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines