cgma
|
00001 //------------------------------------------------------------------------- 00002 // Filename : GeoemtricQueryEngine.hpp 00003 // 00004 // Purpose : Define the interface for all solid model query 00005 // engines. 00006 // 00007 // Special Notes : This is an abstract base class. 00008 // 00009 // Creator : Tim Tautges 00010 // 00011 // Creation Date : 2/01 00012 // 00013 // Owner : Tim Tautges 00014 //------------------------------------------------------------------------- 00015 00016 #ifndef GEOMETRIC_QUERY_ENGINE_HPP 00017 #define GEOMETRIC_QUERY_ENGINE_HPP 00018 00019 #include "CubitObserver.hpp" 00020 #include "CubitDefines.h" 00021 #include "GeometryDefines.h" 00022 #include "CubitMessage.hpp" 00023 #include "CGMGeomConfigure.h" 00024 #include "CubitCompat.h" 00025 00026 class CubitString; 00027 class CubitVector; 00028 template <class X> class DLIList; 00029 class Body; 00030 class GMem; 00031 00032 class TopologyBridge; 00033 class TopologyEntity; 00034 class GeometryEntity; 00035 class BodySM; 00036 class Lump; 00037 class Surface; 00038 class Curve; 00039 class TBPoint; 00040 class Loop; 00041 class RefFace; 00042 00043 enum Model_File_Type { 00044 MFT_NOT_DEFINED = 0, 00045 IGES_TYPE, 00046 CATIA_TYPE, 00047 STEP_TYPE, 00048 PROE_TYPE, 00049 GRANITE_TYPE, 00050 GRANITE_G_TYPE, 00051 GRANITE_SAT_TYPE, 00052 GRANITE_PROE_PART_TYPE, 00053 GRANITE_PROE_ASM_TYPE, 00054 GRANITE_NEUTRAL_TYPE, 00055 NCGM_TYPE, 00056 CATIA_NCGM_TYPE, 00057 CATPART_TYPE, 00058 CATPRODUCT_TYPE, 00059 FACET_TYPE, 00060 SOLIDWORKS_TYPE, 00061 OCC_TYPE, 00062 KCM_TYPE 00063 }; 00064 00065 00066 extern const char* 00067 get_MFT_string(Model_File_Type); 00068 00069 inline const char* 00070 get_MFT_string(Model_File_Type type) 00071 { 00072 switch (type) 00073 { 00074 case MFT_NOT_DEFINED : 00075 return "Model File Type NOT DEFINED"; 00076 case IGES_TYPE : 00077 return "IGES"; 00078 case CATIA_TYPE : 00079 return "CATIA"; 00080 case STEP_TYPE : 00081 return "STEP"; 00082 case PROE_TYPE : 00083 return "PROE"; 00084 case GRANITE_TYPE : 00085 return "GRANITE"; 00086 case GRANITE_G_TYPE : 00087 return "GRANITE_G"; 00088 case GRANITE_SAT_TYPE : 00089 return "GRANITE_SAT"; 00090 case GRANITE_PROE_PART_TYPE : 00091 return "GRANITE_PROE_PART"; 00092 case GRANITE_PROE_ASM_TYPE : 00093 return "GRANITE_PROE_ASM"; 00094 case GRANITE_NEUTRAL_TYPE : 00095 return "GRANITE_NEUTRAL"; 00096 case NCGM_TYPE : 00097 return "NCGM"; 00098 case CATIA_NCGM_TYPE : 00099 return "CATIA_NCGM"; 00100 case CATPART_TYPE : 00101 return "CATPART"; 00102 case CATPRODUCT_TYPE : 00103 return "CATPRODUCT"; 00104 case FACET_TYPE : 00105 return "FACET"; 00106 case SOLIDWORKS_TYPE : 00107 return "SOLIDWORKS"; 00108 case OCC_TYPE: 00109 return "OCC"; 00110 case KCM_TYPE: 00111 return "KCM"; 00112 default : 00113 PRINT_ERROR("Model_File_Type index %i is not handled properly in get_MFT_string()\n", type); 00114 } 00115 00116 return ""; 00117 } // get_MFT_string() 00118 00119 00120 static const char* const GRANITE_G = ".g"; 00121 static const char* const GRANITE_PROE_PART = ".prt"; 00122 static const char* const GRANITE_PROE_ASM = ".asm"; 00123 static const char* const GRANITE_PROE_NEUTRAL = ".neu"; 00124 static const char* const STEP_IMPORT_DEFAULT_LOG = "step_import.log"; 00125 static const char* const IGES_IMPORT_DEFAULT_LOG = "iges_import.log"; 00126 static const char* const CATIA_IMPORT_DEFAULT_LOG = "catia_import.log"; 00127 static const char* const GRANITE_EXPORT_DEFAULT_LOG = "granite_export.log"; 00128 static const char* const STEP_EXPORT_DEFAULT_LOG = "step_export.log"; 00129 static const char* const IGES_EXPORT_DEFAULT_LOG = "iges_export.log"; 00130 static const char* const OCC_EXPORT_DEFAULT_LOG = "occ_export.log"; 00131 static const char* const KCM_EXPORT_DEFAULT_LOG = "kcm_export.log"; 00132 static const char* const STEP_IGES_TRANSLATOR = "step_iges_translator"; 00133 static const char* const TRANSLATOR_DIR = "/translator/"; 00134 00135 class CUBIT_GEOM_EXPORT GeometryQueryEngine 00136 { 00137 00138 public: 00139 00141 virtual ~GeometryQueryEngine() {} 00142 00165 virtual CubitStatus export_solid_model( 00166 DLIList<TopologyBridge*>& bridge_list, 00167 const char* file_name, 00168 Model_File_Type file_type, 00169 const CubitString &cubit_version, 00170 ModelExportOptions &export_options ) = 0; 00171 00172 virtual CubitStatus export_solid_model( 00173 DLIList<TopologyBridge*>& bridge_list, 00174 char*& p_buffer, 00175 int& n_buffer_size, 00176 bool b_export_buffer) = 0; 00177 00180 virtual CubitStatus save_temp_geom_file( 00181 DLIList<TopologyBridge*> &ref_entity_list, 00182 const char *filename, 00183 const CubitString &cubit_version, 00184 CubitString &created_file, 00185 CubitString &created_file_type ) = 0; 00186 00211 virtual CubitStatus import_solid_model( 00212 const char* file_name, 00213 Model_File_Type file_type, 00214 DLIList<TopologyBridge*>& imported_entities, 00215 ModelImportOptions &import_options ) = 0; 00216 00217 virtual CubitStatus import_solid_model(DLIList<TopologyBridge*> &imported_entities, 00218 const char* pBuffer, 00219 const int n_buffer_size) = 0; 00220 00221 //O imported_entities 00222 //O- List of top-level entities read from file 00223 //I print_results 00224 //I- If false, fail silently (don't write error messages to stdout or stderr) 00225 00226 virtual CubitStatus get_underlying_curves(Curve * curve_ptr, 00227 DLIList<TopologyBridge*>& curve_list) ; 00228 // -currently used only by VirtualGeometryEngine to get the underlying 00229 // - curves from virtual curves. 00230 virtual CubitStatus get_underlying_surfaces(Surface * surf_ptr, 00231 DLIList<TopologyBridge*>& surf_list) ; 00232 virtual CubitStatus get_underlying_bridges(TopologyBridge* bridge_ptr, 00233 DLIList<TopologyBridge*>& bridge_list); 00234 00235 virtual CubitStatus get_intersections( 00236 Curve* ref_edge1, CubitVector& point1, 00237 CubitVector& point2, 00238 DLIList<CubitVector>& intersection_list, 00239 bool bounded = false, 00240 bool closest = false ) = 0; 00241 00242 virtual CubitStatus get_intersections( 00243 Curve* ref_edge1, Curve* ref_edge2, 00244 DLIList<CubitVector>& intersection_list, 00245 bool bounded = false, 00246 bool closest = false ) = 0; 00247 //- Finds the intersections of the two curves. If the bounded flag is 00248 //- true, it finds only those intersections within the parameter range 00249 //- of both curves; otherwise it uses the extensions of the curves. The 00250 //- closest option is currently valid only if both curves are straight, 00251 //- in which case it will return the 2 closest intersection locations, 00252 //- if the straight lines don't actually intersect. The function allocates 00253 //- the CubitVectors in the returned list, so be sure to free them. 00254 00255 virtual CubitStatus get_intersections( 00256 Curve* curve, 00257 Surface* surface, 00258 DLIList<CubitVector>& intersection_list, 00259 bool bounded = false ) = 0; 00260 //- Finds the intersections of the curve and surface. The curve is extended 00261 //- if the bounded flag is not false. The function allocates the CubitVectors 00262 //- in the returned list, so be sure to free them. 00263 00264 virtual CubitStatus entity_extrema( 00265 DLIList<GeometryEntity*> &ref_entity_list, 00266 const CubitVector *dir1, 00267 const CubitVector *dir2, 00268 const CubitVector *dir3, 00269 CubitVector &extrema, 00270 GeometryEntity *&extrema_entity_ptr ) = 0; 00271 //- Gets the extrema position along the first given direction. If there 00272 //- is more than one extrema position, the other directions will be used 00273 //- to determine a unique position. Directions 2 and 3 can be NULL. 00274 //- Entities supported include bodies, volumes, surfaces, curves and 00275 //- vertices. The entity the extrema is found on is also returned. 00276 00277 virtual CubitStatus entity_entity_distance( 00278 GeometryEntity *ref_entity_ptr1, 00279 GeometryEntity *ref_entity_ptr2, 00280 CubitVector &pos1, 00281 CubitVector &pos2, 00282 double &distance ) = 0; 00283 //- Gets the minimum distance between two entities and the closest positions 00284 //- on those entities. Supports vertices, curves, surfaces, volumes and bodies. 00285 00286 virtual void validate_geometry_database() const {}; 00287 00288 virtual void delete_solid_model_entities(DLIList<BodySM*>& body_list) const = 0; 00289 virtual CubitStatus delete_solid_model_entities(GeometryEntity* ref_entity_ptr) const; 00290 virtual CubitStatus delete_solid_model_entities( BodySM* body_ptr ) const = 0; 00291 virtual CubitStatus delete_solid_model_entities(Surface* surf_ptr ) const = 0; 00292 virtual CubitStatus delete_solid_model_entities( Curve* curve_ptr ) const = 0; 00293 virtual CubitStatus delete_solid_model_entities( TBPoint* point_ptr ) const = 0; 00294 virtual CubitStatus delete_topology_bridge (TopologyBridge* bridge) const; 00295 //- Deletes the solid model entities associcated with the input 00296 //- free-floating RefEntity. If the input RefEntity is not free-floating, 00297 //- then its underlying ENTITYs are not deleted and CUBIT_FAILURE 00298 //- is returned. 00299 //- Returns CUBIT_SUCCESS if all went well, otherwise, CUBIT_FAILURE. 00300 00301 virtual CubitStatus fire_ray( CubitVector &origin, 00302 CubitVector &direction, 00303 DLIList<TopologyBridge*> &at_entity_list, 00304 DLIList<double> &ray_params, 00305 int max_hits = 0, 00306 double ray_radius = 0.0, 00307 DLIList<TopologyBridge*> *hit_entity_list=0 ) const = 0; 00308 //- Fire a ray at specified entities, returning the parameters (distances) 00309 //- along the ray and optionally the entities hit. Returned lists are 00310 //- appended to. Input entities can be any of bodies, volumes, faces, 00311 //- edges or vertices. Optionally you can specify the maximum number of 00312 //- hits to return (default = 0 = unlimited), and the ray radius to use for 00313 //- intersecting the entities (default = 0.0 = use modeller default). 00314 00315 virtual void get_ordered_loops(RefFace* /*face*/, DLIList<Loop*> &/*loop_list*/) const {}; 00316 00317 virtual CubitStatus get_isoparametric_points(Surface* ref_face_ptr, 00318 int &nu, int &nv, 00319 GMem *&gMem) const = 0; 00320 00321 virtual CubitStatus get_u_isoparametric_points(Surface* ref_face_ptr, 00322 double v, int &n, 00323 GMem *&gMem) const = 0; 00324 00325 virtual CubitStatus get_v_isoparametric_points(Surface* ref_face_ptr, 00326 double u, int &n, 00327 GMem *&gMem) const = 0; 00328 00329 virtual CubitStatus transform_vec_position( 00330 CubitVector const& position_vector, 00331 BodySM *OSME_ptr, 00332 CubitVector &transform_vector ) const = 0; 00333 //R CubitStatus 00334 //R- CUBIT_SUCCESS/CUBIT_FAILURE 00335 //I position_vector on body, body that was transformed 00336 //O vector showning transform. 00337 //O-Computes the transform from the transformed body. 00338 00339 virtual int curve_is_on_ignored_surface(Curve * /*curve*/, 00340 Surface * /*surf*/) { return 0; } 00341 00342 virtual const char* modeler_type() = 0; 00343 virtual int get_major_version() = 0; 00344 virtual int get_minor_version() = 0; 00345 virtual int get_subminor_version() = 0; 00346 virtual int get_allint_version(); 00347 virtual CubitString get_engine_version_string() = 0; 00348 00349 virtual bool is_intermediate_engine() {return FALSE;} 00350 00351 //- pass a string back identifying this query engine 00352 virtual CubitStatus set_export_version(const int major, 00353 const int minor); 00354 virtual CubitStatus set_export_allint_version(const int version); 00355 virtual CubitStatus list_engine_versions(CubitString &versions); 00356 //- gets, sets, and lists choices for solid modeling engine version(s) 00357 00358 virtual double get_sme_resabs_tolerance() const = 0; // Gets solid modeler's resolution absolute tolerance 00359 virtual double set_sme_resabs_tolerance( double new_resabs ) = 0; 00360 00361 virtual CubitStatus set_int_option( const char* opt_name, int val ) = 0; 00362 virtual CubitStatus set_dbl_option( const char* opt_name, double val ) = 0; 00363 virtual CubitStatus set_str_option( const char* opt_name, const char* val ) = 0; 00364 //- Set solid modeler options 00365 00366 virtual CubitStatus get_graphics( BodySM *bodysm, GMem* g_mem, 00367 std::vector<Surface*> &surface_to_facets_vector, 00368 std::vector<TopologyBridge*> &vertex_edge_to_point_vector, 00369 std::vector<std::pair<TopologyBridge*, std::pair<int,int> > > &facet_edges_on_curves, 00370 unsigned short normal_tolerance, 00371 double distance_tolerance, double max_edge_length ) const; 00372 //I bodysm -- body you want to facet 00373 //O g_mem -- structure containing all the points and facet connectivity 00374 //O surfaces_to_facets_vector -- the ith facet in g_mem is on the ith Surface in this vector 00375 //O vertex_edge_to_point_vector -- the ith point in the g_mem in on the ith surface/edge/vertex in this vector 00376 //O facet_edges_on_curves -- the TopologyBri dges are the Curves in bodysm and the pair is the indices to the 00377 // facet points in the g_mem's point array that make a single facet edge on the Curve. 00378 //I various input tolerances. 00379 00380 00381 virtual CubitStatus get_graphics( Surface* surface_ptr, 00382 GMem* gMem, 00383 unsigned short normal_tolerance=15, 00384 double distance_tolerance=0, 00385 double longest_edge = 0 ) const = 0; 00386 00387 virtual CubitStatus get_graphics( Surface* surface_ptr, 00388 GMem *gmem, 00389 std::vector<TopologyBridge*> &vertex_edge_to_point_vector, 00390 std::vector<std::pair<TopologyBridge*, std::pair<int,int> > > &facet_edges_on_curves, 00391 unsigned short normal_tolerance = 15, 00392 double distance_tolerance = 0.0, 00393 double max_edge_length = 0.0 ) const; 00394 00395 //R CubitStatus 00396 //R- CUBIT_SUCCESS/CUBIT_FAILURE 00397 //I ref_face_ptr 00398 //I- The RefFAce for which hoops facetting information will be 00399 //I- gathered. 00400 //O gMem 00401 //O- The sturage place for facets (and points). 00402 //= This function gathers and outputs facet (and point) 00403 //- information for hoops involved in facetting an RefFace. If 00404 //- all goes well, CUBIT_Success is retuned. 00405 00406 virtual CubitStatus get_graphics( Curve* curve_ptr, 00407 GMem* gMem, 00408 double angle_tolerance=0, 00409 double distance_tolerance=0, 00410 double max_edge_length=0 ) const = 0; 00411 //R CubitStatus 00412 //R- CUBIT_SUCCESS/CUBIT_FAILURE 00413 //I ref_edge_ptr 00414 //I- The RefEdge for which hoops facetting information will be 00415 //I- gathered/ 00416 //O numSteps 00417 //O- The number of edges gathered. 00418 //O gMem 00419 //O- The sturage place for edges involved in facetting. 00420 //I tolerance 00421 //I- The tolerance deviation used when facetting the curve. 00422 //- This function tessellates the edge which is typically needed 00423 //- for graphically displaying the edge. If all goes well, 00424 //- CUBIT_SUCCESS is returned. Otherwise, CUBIT_FAILURE is returned. 00425 00426 00427 virtual CubitStatus translate( BodySM* body, const CubitVector& offset ) = 0; 00428 virtual CubitStatus rotate ( BodySM* body, const CubitVector& axis, double angle ) = 0; 00429 virtual CubitStatus scale ( BodySM* body, double factor ) = 0; 00430 virtual CubitStatus scale ( BodySM* body, const CubitVector& factors ) = 0; 00431 virtual CubitStatus reflect ( BodySM* body, const CubitVector& axis ) = 0; 00432 virtual CubitStatus restore_transform( BodySM* body ) = 0; 00433 00434 virtual CubitStatus translate( GeometryEntity* ent, const CubitVector& offset ) = 0; 00435 virtual CubitStatus rotate ( GeometryEntity* ent, const CubitVector& axis, double degrees ) = 0; 00436 virtual CubitStatus scale ( GeometryEntity* ent, double factor ) = 0; 00437 virtual CubitStatus scale ( GeometryEntity* ent, const CubitVector& factors ) = 0; 00438 virtual CubitStatus reflect ( GeometryEntity* ent, const CubitVector& axis ) = 0; 00439 00440 virtual CubitBoolean bodies_overlap (BodySM *body_ptr_1, 00441 BodySM *body_ptr_2 ) const = 0; 00442 00443 virtual CubitBoolean volumes_overlap (Lump *lump1, Lump *lump2 ) const = 0; 00444 00445 virtual TopologyBridge* get_visible_entity_at_point(TopologyBridge* /*hidden_tb*/, CubitVector* /*point*/){return NULL;}; 00446 00447 virtual CubitStatus get_visible_entities( TopologyBridge *hidden_tb, DLIList<TopologyBridge*> &real_tbs ); 00448 00449 virtual CubitStatus get_point_containment( DLIList<BodySM*> &body_list, 00450 DLIList<CubitVector> &point_list, 00451 double tolerance, 00452 bool allow_pts_in_multiple_bodies, 00453 std::vector< std::pair<BodySM*, std::vector<int> > > &bodysm_to_pt_indices ); 00454 00455 protected: 00456 00457 private: 00458 00459 } ; 00460 00461 #endif