moab
ReadNASTRAN.hpp
Go to the documentation of this file.
00001 
00016 //-------------------------------------------------------------------------    
00017 // Filename      : ReadNASTRAN.hpp                        
00018 //                                
00019 // Purpose       : NASTRAN file reader
00020 //                                             
00021 // Creator       : Brandon Smith             
00022 //                                   
00023 // Date          : 08/2009                
00024 //                                                  
00025 //-------------------------------------------------------------------------     
00026                                     
00027 #ifndef READNASTRAN_HPP                     
00028 #define READNASTRAN_HPP              
00029                                      
00030 #ifndef IS_BUILDING_MB                   
00031   #error "ReadNASTRAN.hpp isn't supposed to be included into an application"
00032 #endif   
00033 
00034 #include <iostream>
00035 #include <fstream>
00036 #include <sstream>
00037 #include <vector>
00038 
00039 #include "moab/Interface.hpp"
00040 #include "moab/ReaderIface.hpp"
00041 #include "FileTokenizer.hpp"
00042 #include "moab/RangeMap.hpp"
00043 
00044 namespace moab {
00045 
00046 class ReadUtilIface;
00047 
00048 class ReadNASTRAN : public ReaderIface
00049 {
00050 
00051 public:
00052   // factory method
00053   static ReaderIface* factory( Interface* );
00054   
00055   ErrorCode load_file( const char* file_name,
00056                        const EntityHandle* file_set,
00057                        const FileOptions& opts,
00058                        const SubsetList* subset_list = 0,
00059                        const Tag* file_id_tag = 0 );
00060   // constructor
00061   ReadNASTRAN(Interface* impl = NULL);
00062 
00063   // destructor
00064   virtual ~ReadNASTRAN();
00065 
00066   ErrorCode read_tag_values( const char* file_name,
00067                              const char* tag_name,
00068                              const FileOptions& opts,
00069                              std::vector<int>& tag_values_out,
00070                              const SubsetList* subset_list = 0 );
00071 
00072 protected:
00073   
00074 private:  
00075   // read mesh interface
00076   ReadUtilIface* readMeshIface;
00077   
00078   // MOAB Interface
00079   Interface* MBI;
00080   
00081   RangeMap<int, EntityHandle> nodeIdMap, elemIdMap;
00082 
00083   enum line_format { SMALL_FIELD,                     
00084                      LARGE_FIELD,                 
00085                      FREE_FIELD }; 
00086 
00087   ErrorCode determine_line_format( const std::string line, 
00088                                      line_format &format );
00089   
00090   ErrorCode tokenize_line( const std::string line, 
00091                              const line_format format,
00092                              std::vector<std::string> &tokens );  
00093 
00094   ErrorCode determine_entity_type( const std::string token, EntityType &type); 
00095 
00096   ErrorCode get_real( const std::string, double &real );
00097 
00098   ErrorCode read_node(const std::vector<std::string> tokens, 
00099                         const bool           debug, 
00100                         double*              coord_arrays[3], 
00101                         int                  &node_id);
00102 
00103   ErrorCode read_element(const std::vector<std::string> tokens, 
00104                            std::vector<Range>           &materials,
00105                            const EntityType             element_type,
00106                            const bool                     debug );
00107 
00108   ErrorCode create_materials( const std::vector<Range> &materials );
00109 
00110   ErrorCode assign_ids( const Tag* file_id_tag );
00111 };
00112 
00113 } // namespace moab
00114 
00115 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines