Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
ReadNASTRAN.hpp
Go to the documentation of this file.
1 /**
2  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3  * storing and accessing finite element mesh data.
4  *
5  * Copyright 2004 Sandia Corporation. Under the terms of Contract
6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7  * retains certain rights in this software.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  */
15 
16 //-------------------------------------------------------------------------
17 // Filename : ReadNASTRAN.hpp
18 //
19 // Purpose : NASTRAN file reader
20 //
21 // Creator : Brandon Smith
22 //
23 // Date : 08/2009
24 //
25 //-------------------------------------------------------------------------
26 
27 #ifndef READNASTRAN_HPP
28 #define READNASTRAN_HPP
29 
30 #ifndef IS_BUILDING_MB
31 #error "ReadNASTRAN.hpp isn't supposed to be included into an application"
32 #endif
33 
34 #include <iostream>
35 #include <fstream>
36 #include <sstream>
37 #include <vector>
38 
39 #include "moab/Interface.hpp"
40 #include "moab/ReaderIface.hpp"
41 #include "FileTokenizer.hpp"
42 #include "moab/RangeMap.hpp"
43 
44 namespace moab
45 {
46 
47 class ReadUtilIface;
48 
49 class ReadNASTRAN : public ReaderIface
50 {
51 
52  public:
53  // factory method
54  static ReaderIface* factory( Interface* );
55 
56  ErrorCode load_file( const char* file_name,
57  const EntityHandle* file_set,
58  const FileOptions& opts,
59  const SubsetList* subset_list = 0,
60  const Tag* file_id_tag = 0 );
61  // constructor
62  ReadNASTRAN( Interface* impl = NULL );
63 
64  // destructor
65  virtual ~ReadNASTRAN();
66 
67  ErrorCode read_tag_values( const char* file_name,
68  const char* tag_name,
69  const FileOptions& opts,
70  std::vector< int >& tag_values_out,
71  const SubsetList* subset_list = 0 );
72 
73  protected:
74  private:
75  // read mesh interface
77 
78  // MOAB Interface
80 
82 
84  {
88  };
89 
90  ErrorCode determine_line_format( const std::string& line, line_format& format );
91 
92  ErrorCode tokenize_line( const std::string& line, const line_format format, std::vector< std::string >& tokens );
93 
94  ErrorCode determine_entity_type( const std::string& token, EntityType& type );
95 
96  ErrorCode get_real( const std::string&, double& real );
97 
98  ErrorCode read_node( const std::vector< std::string >& tokens,
99  const bool debug,
100  double* coord_arrays[3],
101  int& node_id );
102 
103  ErrorCode read_element( const std::vector< std::string >& tokens,
104  std::vector< Range >& materials,
105  const EntityType element_type,
106  const bool debug );
107 
108  ErrorCode create_materials( const std::vector< Range >& materials );
109 
110  ErrorCode assign_ids( const Tag* file_id_tag );
111 };
112 
113 } // namespace moab
114 
115 #endif