MOAB: Mesh Oriented datABase  (version 5.3.1)
ReadCGM.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 //-------------------------------------------------------------------------
00017 // Filename      : ReadCGM.hpp
00018 //
00019 // Purpose       :  .step and .brep and .facet file reader
00020 //
00021 // Special Notes : Lots of code taken from cgm2moab implementation
00022 //
00023 // Creator       : Jane Hu
00024 //
00025 // Date          : 3/09
00026 //
00027 //-------------------------------------------------------------------------
00028 
00029 #ifndef READCGM_HPP
00030 #define READCGM_HPP
00031 
00032 #include "moab/MOABConfig.h"
00033 #ifndef MOAB_HAVE_CGM
00034 #error "ReadCGM.hpp isn't supposed to be included without building CGM"
00035 #endif
00036 
00037 #include <string>
00038 #include "moab/ReaderIface.hpp"
00039 #include "RefEntityName.hpp"
00040 
00041 namespace moab
00042 {
00043 
00044 class ReadUtilIface;
00045 class GeomTopoTool;
00046 
00047 class ReadCGM : public ReaderIface
00048 {
00049 
00050   public:
00051     static ReaderIface* factory( Interface* );
00052 
00053     void tokenize( const std::string& str, std::vector< std::string >& tokens, const char* delimiters );
00054 
00055     //! load a CGM file
00056     //  Supported FileOptions:
00057     //  * FACET_NORMAL_TOLERANCE=<int> (default: 5)
00058     //  * FACET_DISTANCE_TOLERANCE=<real> (default: 0.001)
00059     //  * MAX_FACET_EDGE_LENGTH=<real> (default: 0.0)
00060     //  * CGM_ATTRIBS=<yes|no>         (default: no)
00061     ErrorCode load_file( const char* file_name, const EntityHandle* file_set, const FileOptions& opts,
00062                          const SubsetList* subset_list = 0, const Tag* file_id_tag = 0 );
00063 
00064     ErrorCode read_tag_values( const char* file_name, const char* tag_name, const FileOptions& opts,
00065                                std::vector< int >& tag_values_out, const SubsetList* subset_list = 0 );
00066 
00067     //! Constructor
00068     ReadCGM( Interface* impl = NULL );
00069 
00070     //! Destructor
00071     virtual ~ReadCGM();
00072 
00073     // access private vars
00074     int get_failed_curve_count();
00075     int get_failed_surface_count();
00076 
00077   private:
00078     ErrorCode set_options( const FileOptions& opts, int& norm_tol, double& faceting_tol, double& len_tol, bool& act_att,
00079                            bool& verbose_warnings, bool& fatal_on_curves );
00080 
00081     ErrorCode create_entity_sets( std::map< RefEntity*, EntityHandle > ( &entmap )[5] );
00082 
00083     ErrorCode create_topology( std::map< RefEntity*, EntityHandle > ( &entitymap )[5] );
00084 
00085     ErrorCode store_surface_senses( std::map< RefEntity*, EntityHandle >& surface_map,
00086                                     std::map< RefEntity*, EntityHandle >& volume_map );
00087 
00088     ErrorCode store_curve_senses( std::map< RefEntity*, EntityHandle >& curve_map,
00089                                   std::map< RefEntity*, EntityHandle >& surface_map );
00090 
00091     ErrorCode store_groups( std::map< RefEntity*, EntityHandle > ( &entitymap )[5] );
00092 
00093     ErrorCode create_group_entsets( std::map< RefEntity*, EntityHandle >& group_map );
00094 
00095     ErrorCode store_group_content( std::map< RefEntity*, EntityHandle > ( &entitymap )[5] );
00096 
00097     void set_cgm_attributes( bool const act_attributes, bool const verbose );
00098 
00099     ErrorCode create_vertices( std::map< RefEntity*, EntityHandle >& vertex_map );
00100 
00101     ErrorCode create_curve_facets( std::map< RefEntity*, EntityHandle >& curve_map,
00102                                    std::map< RefEntity*, EntityHandle >& vertex_map, int norm_tol, double faceting_tol,
00103                                    bool verbose_warn = false, bool fatal_on_curves = false );
00104 
00105     ErrorCode create_surface_facets( std::map< RefEntity*, EntityHandle >& surface_map,
00106                                      std::map< RefEntity*, EntityHandle >& vertex_map, int norm_tol, double facet_tol,
00107                                      double length_tol );
00108     /**
00109      * Dumps the failed faceting information to screen
00110      */
00111     void dump_fail_counts();
00112 
00113     ReadUtilIface* readUtilIface;
00114 
00115     GeomTopoTool* myGeomTool;
00116 
00117     const char* get_geom_file_type( const char* filename );
00118     const char* get_geom_fptr_type( FILE* file );
00119 
00120     int is_cubit_file( FILE* file );
00121     int is_step_file( FILE* file );
00122     int is_iges_file( FILE* file );
00123     int is_occ_brep_file( FILE* file );
00124     int is_facet_file( FILE* file );
00125 
00126     //------------member variables ------------//
00127 
00128     //! interface instance
00129     Interface* mdbImpl;
00130 
00131     Tag geom_tag, id_tag, name_tag, category_tag, faceting_tol_tag, geometry_resabs_tag;
00132 
00133     int failed_curve_count;            // the number of curves that failed to facet
00134     std::vector< int > failed_curves;  // the curve ids of the curves that failed to facet
00135 
00136     int failed_surface_count;            // the number of surfaces that have 0 facets
00137     std::vector< int > failed_surfaces;  // the surface ids of the surfaces that have 0 facets
00138 };
00139 
00140 }  // namespace moab
00141 
00142 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines