Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
ReadCGM.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 : ReadCGM.hpp
18 //
19 // Purpose : .step and .brep and .facet file reader
20 //
21 // Special Notes : Lots of code taken from cgm2moab implementation
22 //
23 // Creator : Jane Hu
24 //
25 // Date : 3/09
26 //
27 //-------------------------------------------------------------------------
28 
29 #ifndef READCGM_HPP
30 #define READCGM_HPP
31 
32 #include "moab/MOABConfig.h"
33 #ifndef MOAB_HAVE_CGM
34 #error "ReadCGM.hpp isn't supposed to be included without building CGM"
35 #endif
36 
37 #include <string>
38 #include "moab/ReaderIface.hpp"
39 #include "RefEntityName.hpp"
40 
41 namespace moab
42 {
43 
44 class ReadUtilIface;
45 class GeomTopoTool;
46 
47 class ReadCGM : public ReaderIface
48 {
49 
50  public:
51  static ReaderIface* factory( Interface* );
52 
53  void tokenize( const std::string& str, std::vector< std::string >& tokens, const char* delimiters );
54 
55  //! load a CGM file
56  // Supported FileOptions:
57  // * FACET_NORMAL_TOLERANCE=<int> (default: 5)
58  // * FACET_DISTANCE_TOLERANCE=<real> (default: 0.001)
59  // * MAX_FACET_EDGE_LENGTH=<real> (default: 0.0)
60  // * CGM_ATTRIBS=<yes|no> (default: no)
61  ErrorCode load_file( const char* file_name,
62  const EntityHandle* file_set,
63  const FileOptions& opts,
64  const SubsetList* subset_list = 0,
65  const Tag* file_id_tag = 0 );
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  //! Constructor
74  ReadCGM( Interface* impl = NULL );
75 
76  //! Destructor
77  virtual ~ReadCGM();
78 
79  // access private vars
82 
83  private:
84  ErrorCode set_options( const FileOptions& opts,
85  int& norm_tol,
86  double& faceting_tol,
87  double& len_tol,
88  bool& act_att,
89  bool& verbose_warnings,
90  bool& fatal_on_curves );
91 
92  ErrorCode create_entity_sets( std::map< RefEntity*, EntityHandle > ( &entmap )[5] );
93 
94  ErrorCode create_topology( std::map< RefEntity*, EntityHandle > ( &entitymap )[5] );
95 
96  ErrorCode store_surface_senses( std::map< RefEntity*, EntityHandle >& surface_map,
97  std::map< RefEntity*, EntityHandle >& volume_map );
98 
99  ErrorCode store_curve_senses( std::map< RefEntity*, EntityHandle >& curve_map,
100  std::map< RefEntity*, EntityHandle >& surface_map );
101 
102  ErrorCode store_groups( std::map< RefEntity*, EntityHandle > ( &entitymap )[5] );
103 
104  ErrorCode create_group_entsets( std::map< RefEntity*, EntityHandle >& group_map );
105 
106  ErrorCode store_group_content( std::map< RefEntity*, EntityHandle > ( &entitymap )[5] );
107 
108  void set_cgm_attributes( bool const act_attributes, bool const verbose );
109 
110  ErrorCode create_vertices( std::map< RefEntity*, EntityHandle >& vertex_map );
111 
112  ErrorCode create_curve_facets( std::map< RefEntity*, EntityHandle >& curve_map,
113  std::map< RefEntity*, EntityHandle >& vertex_map,
114  int norm_tol,
115  double faceting_tol,
116  bool verbose_warn = false,
117  bool fatal_on_curves = false );
118 
119  ErrorCode create_surface_facets( std::map< RefEntity*, EntityHandle >& surface_map,
120  std::map< RefEntity*, EntityHandle >& vertex_map,
121  int norm_tol,
122  double facet_tol,
123  double length_tol );
124  /**
125  * Dumps the failed faceting information to screen
126  */
127  void dump_fail_counts();
128 
130 
132 
133  const char* get_geom_file_type( const char* filename );
134  const char* get_geom_fptr_type( FILE* file );
135 
136  int is_cubit_file( FILE* file );
137  int is_step_file( FILE* file );
138  int is_iges_file( FILE* file );
139  int is_occ_brep_file( FILE* file );
140  int is_facet_file( FILE* file );
141 
142  //------------member variables ------------//
143 
144  //! interface instance
146 
148 
149  int failed_curve_count; // the number of curves that failed to facet
150  std::vector< int > failed_curves; // the curve ids of the curves that failed to facet
151 
152  int failed_surface_count; // the number of surfaces that have 0 facets
153  std::vector< int > failed_surfaces; // the surface ids of the surfaces that have 0 facets
154 };
155 
156 } // namespace moab
157 
158 #endif