cgma
VirtualQueryEngine.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : VirtualQueryEngine.hpp
00003 //
00004 // Purpose       : Interface for creation/destruction of CompositeEntities.
00005 //
00006 // Special Notes : This is not a complete modeling engine.  This class is
00007 //                 a container of functions for interaction with 
00008 //                 CompositeEntities
00009 //
00010 // Creator       : Jason Kraftcheck
00011 //
00012 // Creation Date : 7/31/97
00013 //-------------------------------------------------------------------------
00014 
00015 #ifndef VIRTUAL_GEOMETRY_ENGINE_HPP
00016 #define VIRTUAL_GEOMETRY_ENGINE_HPP
00017 
00018 // ********** BEGIN STANDARD INCLUDES         **********
00019 // ********** END STANDARD INCLUDES           **********
00020 
00021 // ********** BEGIN MOTIF INCLUDES            **********
00022 // ********** END MOTIF INCLUDES              **********
00023 
00024 // ********** BEGIN OPEN INVENTOR INCLUDES    **********
00025 // ********** END OPEN INVENTOR INCLUDES      **********
00026 
00027 // ********** BEGIN CUBIT INCLUDES            **********
00028 
00029 #include "GeometryQueryEngine.hpp"
00030 #include "CubitDefines.h"
00031 #include "GeometryDefines.h"
00032 #include "CubitString.hpp"
00033 #include "CubitVector.hpp"
00034 
00035 // ********** END CUBIT INCLUDES              **********
00036 
00037 // ********** BEGIN FORWARD DECLARATIONS      **********
00038 class BasicTopologyEntity;
00039 class Body;
00040 class RefVolume;
00041 class RefEdge;
00042 class RefFace;
00043 class RefVertex;
00044 class TBPoint;
00045 class Curve;
00046 class GMem;
00047 template <class X> class DLIList;
00048 class RefEntity;
00049 class Body;
00050 class CubitVector;
00051 class TopologyEntity;
00052 class CoEdge;
00053 
00054 class CompositeCurve;
00055 class CompositeSurface;
00056 class PartitionCurve;
00057 class PartitionSurface;
00058 
00059 // ********** END FORWARD DECLARATIONS        **********
00060 
00061 // ********** BEGIN MACRO DEFINITIONS         **********
00062 // ********** END MACRO DEFINITIONS           **********
00063 
00064 // ********** BEGIN ENUM DEFINITIONS          **********
00065 
00066 class VirtualQueryEngine : public GeometryQueryEngine
00067 {
00068   
00069 public:
00070   
00071   virtual int curve_is_on_ignored_surface(Curve *curve,
00072                     Surface *surf);
00073   void remove_virtual_geometry( RefEntity* entity_ptr,
00074                                 CubitBoolean all_children );
00075   void remove_virtual_geometry( Body* body, bool all_children );
00076   void remove_virtual_geometry( RefVolume* vol, bool all_children );
00077   void remove_virtual_geometry( RefFace* face );
00078     //- Remove all possible virtual geometry from the passed
00079     //- entity and its children.
00080     
00081   
00082   static const double param_epsilon_fraction;
00083     //- This value is used to determine epsilon for
00084     //- compensating for rounding error in parameter
00085     //- conversion between virtaul geometry and real
00086     //- geometry.
00087   
00088   inline static VirtualQueryEngine* instance();
00089     //R CompositeModelingeEngine
00090     //R- A pointer to the single instance of this class
00091     //- Access to VirtualQueryEngine must be through this function.
00092     //- This forces single instance of the class. (constructor is protected)
00093   
00094   static void delete_instance();
00095 
00096   void register_attributes();
00097    //-  VGE registers attributes required for virtual geometry
00098    // -- only call this once per session
00099 
00100   ~VirtualQueryEngine( );
00101     //- Destructor
00102   
00103   virtual const std::type_info& entity_type_info( ) const
00104     { return typeid(VirtualQueryEngine); }
00105     //R- The type of this entity
00106     //- This function returns the type of this class.
00107 
00108 const char * modeler_type()
00109    { return "virtual"; }
00110 
00111   
00112   virtual int get_major_version();
00113   virtual int get_minor_version();
00114   virtual int get_subminor_version();
00115   virtual CubitString get_engine_version_string();
00116 
00117   virtual bool is_intermediate_engine() {return TRUE;}
00118 
00119   virtual CubitStatus get_graphics( Surface* surface_ptr,
00120                                     GMem *gmem,
00121                                     std::vector<TopologyBridge*> &vertex_edge_to_point_vector,
00122                                     std::vector<std::pair<TopologyBridge*, std::pair<int,int> > > &facet_edges_on_curves,
00123                                     unsigned short normal_tolerance, 
00124                                     double distance_tolerance, 
00125                                     double max_edge_length ) const;
00126   
00127   virtual CubitStatus get_graphics( Surface* surface_ptr,
00128                                            GMem* gMem,
00129                                            unsigned short normal_tolerance,
00130                                            double distance_tolerance,
00131                                            double max_edge_length ) const;
00132     //R CubitStatus
00133     //R- CUBIT_SUCCESS/CUBIT_FAILURE
00134     //I ref_face_ptr
00135     //I- The RefFAce for which hoops facetting information will be 
00136     //I- gathered.
00137     //O- The number of polygons (triangles) needed for facetting.
00138     //O number_points
00139     //O- The number of points needed for facetting
00140     //O number_Facets
00141     //O- The number of facets needed for facetting.
00142     //O gMem
00143     //O- The sturage place for facets (and points).
00144     //= This function gathersw and outputs  facet (and point)
00145     //- information for hoops involved in facetting an RefFace.  If
00146     //- all goes well, CUBIT_Success is retuned.
00147   
00148   virtual CubitStatus get_graphics( Curve* curve_ptr,
00149                                     GMem* gMem, 
00150                                     double angle_tolerance=0,
00151                                     double distance_tolerance=0,
00152                                     double max_edge_length=0 ) const;
00153     //R CubitStatus
00154     //R- CUBIT_SUCCESS/CUBIT_FAILURE
00155     //I ref_edge_ptr
00156     //I- The RefEdge for which hoops facetting information will be
00157     //I- gathered/
00158     //O numSteps
00159     //O- The number of edges gathered.
00160     //O gMem
00161     //O- The sturage place for edges involved in facetting.
00162     //I tolerance
00163     //I- The tolerance deviation used when facetting the curve (optional
00164     //I- and currently IGNORED by this engine).
00165     //- This function gathers and outputs  edge information for
00166     //- hoops involved in facetting a RefEdge.  If all goes well,
00167     //- CUBIT_SUCCESS is returned. Otherwise, CUBIT_FAILURE is retuned.
00168     
00169 
00170   virtual CubitStatus get_isoparametric_points(Surface* ref_face_ptr,
00171                                                int &nu, int &nv,
00172                                                GMem *&gMem) const;
00173   
00174   virtual CubitStatus get_u_isoparametric_points(Surface* ref_face_ptr,
00175                                                  double v, int &n,
00176                                                  GMem *&gMem) const;
00177   
00178   virtual CubitStatus get_v_isoparametric_points(Surface* ref_face_ptr,
00179                                                  double u, int &n,
00180                                                  GMem *&gMem) const;
00181   
00182   virtual CubitStatus transform_vec_position( 
00183     CubitVector const& position_vector,
00184     BodySM *OSME_ptr,
00185     CubitVector &transformed_vector ) const;
00186 
00187 
00188   CubitStatus translate( BodySM* body, const CubitVector& offset );
00189   CubitStatus rotate   ( BodySM* body, const CubitVector& axis, double angle );
00190   CubitStatus scale    ( BodySM* body, double factor );
00191   CubitStatus scale    ( BodySM* body, const CubitVector& factors );
00192   CubitStatus reflect  ( BodySM* body, const CubitVector& axis );
00193   CubitStatus restore_transform( BodySM* body );
00194 
00195   CubitStatus translate( GeometryEntity* ent, const CubitVector& offset );
00196   CubitStatus rotate   ( GeometryEntity* ent, const CubitVector& axis, double degrees );
00197   CubitStatus scale    ( GeometryEntity* ent, double factor );
00198   CubitStatus scale    ( GeometryEntity* ent, const CubitVector& factors );
00199   CubitStatus reflect  ( GeometryEntity* ent, const CubitVector& axis );
00200 
00201   static void get_VEs( RefVolume* volume_ptr,
00202                 DLIList<TopologyBridge*>& ve_list,
00203                 CubitBoolean visible = CUBIT_FALSE,
00204                 const CubitBoolean children_too = CUBIT_TRUE);
00205   static void get_VEs( RefFace* face_ptr, 
00206                 DLIList<TopologyBridge*>& ve_list,
00207                 CubitBoolean visible = CUBIT_FALSE,
00208                 const CubitBoolean children_too = CUBIT_TRUE );
00209   static void get_VEs( RefEdge* edge_ptr,
00210                 DLIList<TopologyBridge*>& ve_list,
00211                 CubitBoolean visible = CUBIT_FALSE,
00212                 const CubitBoolean children_too = CUBIT_TRUE );
00213   static void get_VEs( RefVertex* vertex_ptr,
00214                 DLIList<TopologyBridge*>& ve_list,
00215                 CubitBoolean visible = CUBIT_FALSE,
00216                 const CubitBoolean children_too = CUBIT_TRUE );
00217   static void get_VEs( TopologyEntity* te_ptr,
00218                 DLIList<TopologyBridge*>& ve_list,
00219                 CubitBoolean visible = CUBIT_FALSE,
00220                 const CubitBoolean children_too = CUBIT_TRUE );
00221     //R void
00222     //I te_ptr, volume_ptr, face_ptr, edge_ptr
00223     //I- Entity to query.
00224     //O ve_list
00225     //O- result set.
00226     //I visible
00227     //I- Return only entities visible in the model.
00228     //- Get any virtual geometry of the passed entity or its children.
00229 
00230   virtual CubitStatus get_visible_entities( TopologyBridge *hidden_tb, 
00231                                             DLIList<TopologyBridge*> &real_tbs );
00232   
00233   virtual TopologyBridge* get_visible_entity_at_point(TopologyBridge* hidden_tb, CubitVector* point);
00234    //R TopologyBridge*
00235    //I hidden_tb, point
00236    //I- Returns the lowest level visible entity that contains 'point.' (used for fire_ray())
00237 
00238   CubitBoolean virtuals_created() const;
00239     //- returns CUBIT_TRUE if there are virtual entities in the model
00240   
00241   static CubitBoolean has_virtual( TopologyEntity* entity);
00242   
00243   static CubitBoolean is_virtual(TopologyEntity *entity,
00244                                  const CubitBoolean children_too = CUBIT_FALSE);
00245   static CubitBoolean is_virtual(DLIList<Body*> &entity_list,
00246                                  const CubitBoolean children_too = CUBIT_FALSE);
00247     //- returns CUBIT_TRUE if the entities passed in are virtual or
00248     //- contain any virtual entities
00249   
00250   static CubitBoolean is_virtual(DLIList<RefEntity*> &entity_list,
00251                           const CubitBoolean children_too = CUBIT_FALSE);
00252     //- returns CUBIT_TRUE if the entities passed in are virtual or
00253     //- contain any virtual entities
00254 
00255   CubitBoolean is_partition( RefEntity *ref_entity );
00256 
00257   CubitStatus get_sister_partitions( RefEntity *ref_entity,
00258                                      DLIList<RefEntity*> &sisters);
00259   
00260   CubitStatus sort_edges( DLIList<RefEdge*>& edge_list ) const;
00261     //R CubitStatus
00262     //R- CUBIT_SUCCESS/CUBIT_FAILURE
00263     //I edge_list
00264     //I- Input: The list of RefEdges to sort.
00265     //I- Output: The list of sorted RefEdges.
00266     //O composite_sense_wrt_first
00267     //O- The sense of the CompositeCurve relative to the first RefEdge's
00268     //O- Curve geometry object.  NOT w.r.t. the RefEdge.
00269     //O- in the SORTED list of RefEdges RETURNED.
00270     //- This function sorts a list of RefEdges using topological
00271     //- information.  The RefEdges are sorted such that they form a
00272     //- consecutive chain of edges.  CUBIT_SUCCESS is returned if the
00273     //- RefEdges are C0 continous, and CUBIT_FAILURE if they are not.
00274     //- The C0 continuity is checked topologically, which assumes the
00275     //- model is manifold.
00276         
00277   static CubitStatus associate_curves( DLIList<Curve*>& target_set,  
00278                                        RefEdge* edge_ptr,
00279                                        DLIList<Curve*>& reset_set );
00280   //- Find the subset of target_set that correspond to the curves contained
00281   //- in the passed edge_ptr OR any hosts of the passed edge_ptr.
00282 
00283   virtual CubitStatus get_underlying_curves(Curve *curve_ptr, 
00284                              DLIList<TopologyBridge*>& curve_list);
00285   virtual CubitStatus get_underlying_surfaces(Surface * surf_ptr,
00286                                  DLIList<TopologyBridge*>& surf_list)  ;
00287   virtual CubitStatus get_underlying_bridges(TopologyBridge* bridge_ptr,
00288                                         DLIList<TopologyBridge*>& bridge_list);
00289 
00290   virtual CubitBoolean bodies_overlap (BodySM *body_ptr_1, BodySM *body_ptr_2 ) const;
00291   virtual CubitBoolean volumes_overlap (Lump *lump1, Lump *lump2 ) const;
00292 
00293 protected:
00294   
00295   VirtualQueryEngine(); 
00296     //- Constructor.
00297   
00298   static VirtualQueryEngine* instance_;
00299 
00300 //**** Display related methods
00301   
00302   CubitStatus get_composite_curve_facetting( CompositeCurve* ccurve_ptr,
00303                                              GMem* gMem, 
00304                                              double angle_tolerance=0,
00305                                              double distance_tolerance=0,
00306                                              double max_edge_length=0 ) const;
00307 
00308   CubitStatus get_partition_curve_facetting( PartitionCurve* pcurve_ptr,
00309                                              GMem* gMem,
00310                                              double angle_tolerance=0,
00311                                              double distance_tolerance=0,
00312                                              double max_edge_length=0 ) const;
00313   
00314   CubitStatus get_composite_surface_facetting( CompositeSurface* surf_ptr,
00315                                                GMem* gMem,
00316                                                std::vector<TopologyBridge*> *vertex_edge_to_point_vector,
00317                                                std::vector<std::pair<TopologyBridge*, std::pair<int,int> > > *facet_edges_on_curves,
00318                                                unsigned short normal_tol,
00319                                                double absolute_tol,
00320                                                double longest_edge ) const;
00321 
00322   CubitStatus get_partition_surface_facetting( PartitionSurface* surf_ptr,
00323                                                GMem* gMem,
00324                                                std::vector<TopologyBridge*> *vertex_edge_to_point_vector,
00325                                                std::vector<std::pair<TopologyBridge*, std::pair<int,int> > > *facet_edges_on_curves,
00326                                                unsigned short normal_tol,
00327                                                double absolute_tol,
00328                                                double longest_edge ) const;
00329   
00330   virtual CubitStatus export_solid_model( DLIList<TopologyBridge*>& bridge_list,
00331                                           const char* file_name,
00332                                           Model_File_Type file_type,
00333                                           const CubitString &cubit_version,
00334                                           ModelExportOptions &export_options );
00335 
00336   virtual CubitStatus export_solid_model( DLIList<TopologyBridge*>& bridge_list,
00337                                           char*& p_buffer,
00338                                           int& n_buffer_size,
00339                                           bool b_export_buffer)
00340 {return CUBIT_FAILURE;}
00341 
00342   virtual CubitStatus save_temp_geom_file(DLIList<TopologyBridge*>& bridge_list,
00343                                           const char *file_name,
00344                                           const CubitString &cubit_version,
00345                                           CubitString &created_file,
00346                                           CubitString &created_file_type);
00347 
00348   virtual CubitStatus import_solid_model(
00349                              const char* file_name,
00350                              Model_File_Type file_type,
00351                              DLIList<TopologyBridge*>& imported_entities,
00352                              ModelImportOptions &import_options ); 
00353 
00354   virtual CubitStatus import_solid_model(DLIList<TopologyBridge*> &imported_entities,
00355                                          const char* pBuffer,
00356                                          const int n_buffer_size)
00357 {return CUBIT_FAILURE;}
00358 
00359   virtual void delete_solid_model_entities(DLIList<BodySM*>&) const;
00360   virtual CubitStatus delete_solid_model_entities( BodySM* body_ptr ) const;
00361   virtual CubitStatus delete_solid_model_entities(Surface* surf_ptr ) const;
00362   virtual CubitStatus delete_solid_model_entities( Curve* curve_ptr ) const;
00363   virtual CubitStatus delete_solid_model_entities( TBPoint* point_ptr ) const;
00364 
00365   virtual CubitStatus fire_ray( CubitVector &origin,
00366                                 CubitVector &direction,
00367                                 DLIList<TopologyBridge*> &at_entity_list,
00368                                 DLIList<double> &ray_params,
00369                                 int max_hits,
00370                                 double ray_radius,
00371                                 DLIList<TopologyBridge*> *hit_entity_list=0 ) const;
00372     //- Fire a ray at specified entities, returning the parameters (distances)
00373     //- along the ray and optionally the entities hit.  Returned lists are
00374     //- appended to.  Input entities can be any of bodies, volumes, faces,
00375     //- edges or vertices.  Optionally you can specify the maximum number of
00376     //- hits to return (default = 0 = unlimited), and the ray radius to use for
00377     //- intersecting the entities (default = 0.0 = use modeller default).
00378     //- NOTE: returned entities hit might be "hidden" beneath virtual entities.
00379     //-       To resolve to visible entities, use "get_visible_ents_for_hits"
00380     //-       in GeometryQueryTool.
00381 
00382   virtual double get_sme_resabs_tolerance() const;
00383   virtual double set_sme_resabs_tolerance( double new_resabs );
00384 
00385   virtual CubitStatus set_int_option( const char* opt_name, int val );
00386   virtual CubitStatus set_dbl_option( const char* opt_name, double val );
00387   virtual CubitStatus set_str_option( const char* opt_name, const char* val );
00388 
00389 private:
00390   
00391   void default_error_message( const char callers_name[] ) const;
00392     //- Error message for inhereted functions which are not implemented.
00393   
00394   static const int VGE_MAJOR_VERSION;
00395   static const int VGE_MINOR_VERSION;
00396   static const int VGE_SUBMINOR_VERSION;
00397 
00398 public: 
00399   virtual CubitStatus get_intersections(Curve* curve, CubitVector &point1,
00400                                          CubitVector &point2,
00401                                          DLIList<CubitVector>& intersection_list,
00402                                          CubitBoolean bounded,
00403                                          CubitBoolean closest );
00404 
00405   virtual CubitStatus get_intersections( Curve* ref_edge1, Curve* ref_edge2,
00406                                          DLIList<CubitVector>& intersection_list,
00407                                          bool bounded = CUBIT_FALSE,
00408                                          bool closest = CUBIT_FALSE );
00409   //- Finds the intersections of the two curves.  If the bounded flag is
00410   //- true, it finds only those intersections within the parameter range
00411   //- of both curves; otherwise it uses the extensions of the curves.  The
00412   //- closest option is currently valid only if both curves are straight,
00413   //- in which case it will return the 2 closest intersection locations,
00414   //- if the straight lines don't actually intersect. The function allocates 
00415   //- the CubitVectors in the returned list, so be sure to free them.
00416   //- NOT DEFINED YET IN THIS GEOMETRY ENGINE.
00417 
00418   virtual CubitStatus get_intersections( Curve* ref_edge, Surface* ref_face,
00419                                          DLIList<CubitVector>& intersection_list,
00420                                          bool bounded = CUBIT_FALSE );
00421   //- Finds the intersections of the curve and surface.  The curve is extended
00422   //- if the bounded flag is not false.  The function allocates the CubitVectors 
00423   //- in the returned list, so be sure to free them.
00424   //- NOT DEFINED YET IN THIS GEOMETRY ENGINE.
00425 
00426   virtual CubitStatus entity_extrema( DLIList<GeometryEntity*> &ref_entity_list, 
00427                                       const CubitVector *dir1, 
00428                                       const CubitVector *dir2,
00429                                       const CubitVector *dir3, 
00430                                       CubitVector &extrema,
00431                                       GeometryEntity *&extrema_entity_ptr );
00432   //- Gets the extrema position along the first given direction. If there 
00433   //- is more than one extrema position, the other directions will be used 
00434   //- to determine a unique position.  Directions 2 and 3 can be NULL.
00435   //- Entities supported include bodies, volumes, surfaces, curves and
00436   //- vertices.  The entity the extrema is found on is also returned.
00437   //- NOT DEFINED YET IN THIS GEOMETRY ENGINE.
00438 
00439   virtual CubitStatus entity_entity_distance( GeometryEntity *ref_entity_ptr1,
00440                                               GeometryEntity *ref_entity_ptr2,
00441                                               CubitVector &pos1, CubitVector &pos2,
00442                                               double &distance );
00443   //- Gets the minimum distance between two entities and the closest positions 
00444   //- on those entities. Supports vertices, curves, surfaces, volumes and bodies.
00445   //- NOT DEFINED YET IN THIS GEOMETRY ENGINE.
00446 
00447 };
00448 
00449 
00450 // ********** BEGIN INLINE FUNCTIONS          **********
00451 inline VirtualQueryEngine* VirtualQueryEngine::instance()
00452 {
00453   if( instance_ == NULL )
00454   {
00455     instance_ = new VirtualQueryEngine;
00456     assert( instance_ != NULL );
00457   }
00458   
00459   return instance_;
00460 }
00461 
00462 // ********** END INLINE FUNCTIONS            **********
00463 
00464 // ********** BEGIN FRIEND FUNCTIONS          **********
00465 // ********** END FRIEND FUNCTIONS            **********
00466 
00467 // ********** BEGIN EXTERN FUNCTIONS          **********
00468 // ********** END EXTERN FUNCTIONS            **********
00469 
00470 // ********** BEGIN HELPER CLASS DECLARATIONS **********
00471 // ********** END HELPER CLASS DECLARATIONS   **********
00472 
00473 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines