moab
|
00001 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 class ReadUtilIface; 00031 class AffineXform; 00032 00038 class ReadSmf : public ReaderIface 00039 { 00040 00041 public: 00042 00043 static ReaderIface* factory( Interface* ); 00044 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 00059 ReadSmf(Interface* impl = NULL); 00060 00062 virtual ~ReadSmf(); 00063 00064 00065 typedef ErrorCode (ReadSmf::*read_cmd)( std::vector<std::string> & argv); 00066 struct cmd_entry { const char* name; read_cmd cmd; }; 00067 void init(); 00068 00069 protected: 00070 00071 00072 ErrorCode annotation(char *cmd, std::vector<std::string> & argv); 00073 void bad_annotation(const char* cmd); 00074 00075 ErrorCode vertex(std::vector<std::string> &); 00076 ErrorCode v_normal( std::vector<std::string> &); 00077 ErrorCode v_color(std::vector<std::string> &); 00078 ErrorCode f_color(std::vector<std::string> &); 00079 ErrorCode face(std::vector<std::string> &); 00080 00081 ErrorCode begin(std::vector<std::string> &); 00082 ErrorCode end(std::vector<std::string> &); 00083 ErrorCode set(std::vector<std::string> &); 00084 ErrorCode inc(std::vector<std::string> &); 00085 ErrorCode dec(std::vector<std::string> &); 00086 00087 ErrorCode trans(std::vector<std::string> &); 00088 ErrorCode scale(std::vector<std::string> &); 00089 ErrorCode rot(std::vector<std::string> &); 00090 ErrorCode mmult(std::vector<std::string> &); 00091 ErrorCode mload(std::vector<std::string> &); 00092 00093 ErrorCode parse_line(char *line); 00094 00095 ErrorCode parse_doubles( int count, 00096 const std::vector<std::string> & argv, 00097 double results[] ); 00098 ErrorCode parse_mat( const std::vector<std::string> & argv, 00099 AffineXform& mat_out ); 00100 ErrorCode check_length( int count, const std::vector<std::string> & argv ); 00101 00102 private: 00103 00104 ReadUtilIface* readMeshIface; 00105 00106 //------------member variables ------------// 00107 00108 00111 Interface* mdbImpl; 00112 00114 EntityHandle mCurrentMeshHandle; 00115 00117 std::string mPartitionTagName; 00118 00119 // these are from SMF_reader from qslim/gfx/SMF/smf.h 00120 static cmd_entry read_cmds[]; 00121 char line[SMF_MAXLINE]; 00122 std::vector<SMF_State> state; 00123 SMF_ivars ivar; 00124 int _numNodes; 00125 int _numFaces; 00126 std::vector<double> _coords; // 3*numNodes; we might not know the number of nodes 00127 std::vector<int> _connec; // 3*num of elements; we might not know them; 00128 int _numNodesInFile; 00129 int _numElementsInFile; 00130 size_t lineNo; 00131 size_t commandNo; 00132 int versionMajor, versionMinor; 00133 00134 }; 00135 00136 } // namespace moab 00137 00138 #endif 00139 00140 00141 00142