Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 09:16:20

0001 // Created on: 1992-08-06
0002 // Created by: Laurent BUCHARD
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _IntAna_QuadQuadGeo_HeaderFile
0018 #define _IntAna_QuadQuadGeo_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <IntAna_ResultType.hxx>
0025 #include <gp_Pnt.hxx>
0026 #include <gp_Dir.hxx>
0027 class gp_Pln;
0028 class gp_Cylinder;
0029 class gp_Sphere;
0030 class gp_Cone;
0031 class gp_Torus;
0032 class gp_Lin;
0033 class gp_Circ;
0034 class gp_Elips;
0035 class gp_Parab;
0036 class gp_Hypr;
0037 
0038 //! Geometric intersections between two natural quadrics
0039 //! (Sphere , Cylinder , Cone , Pln from gp).
0040 //! The possible intersections are :
0041 //! - 1 point
0042 //! - 1 or 2 line(s)
0043 //! - 1 Point and 1 Line
0044 //! - 1 circle
0045 //! - 1 ellipse
0046 //! - 1 parabola
0047 //! - 1 or 2 hyperbola(s).
0048 //! - Empty : there is no intersection between the two quadrics.
0049 //! - Same  : the quadrics are identical
0050 //! - NoGeometricSolution : there may be an intersection, but it
0051 //! is necessary to use an analytic algorithm to determine
0052 //! it. See class IntQuadQuad from IntAna.
0053 class IntAna_QuadQuadGeo
0054 {
0055 public:
0056   DEFINE_STANDARD_ALLOC
0057 
0058   //! Empty constructor.
0059   Standard_EXPORT IntAna_QuadQuadGeo();
0060 
0061   //! Creates the intersection between two planes.
0062   //! TolAng is the angular tolerance used to determine
0063   //! if the planes are parallel.
0064   //! Tol is the tolerance used to determine if the planes
0065   //! are identical (only when they are parallel).
0066   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Pln& P1,
0067                                      const gp_Pln& P2,
0068                                      const double  TolAng,
0069                                      const double  Tol);
0070 
0071   //! Intersects two planes.
0072   //! TolAng is the angular tolerance used to determine
0073   //! if the planes are parallel.
0074   //! Tol is the tolerance used to determine if the planes
0075   //! are identical (only when they are parallel).
0076   Standard_EXPORT void Perform(const gp_Pln& P1,
0077                                const gp_Pln& P2,
0078                                const double  TolAng,
0079                                const double  Tol);
0080 
0081   //! Creates the intersection between a plane and a cylinder.
0082   //! TolAng is the angular tolerance used to determine
0083   //! if the axis of the cylinder is parallel to the plane.
0084   //! Tol is the tolerance used to determine if the result
0085   //! is a circle or an ellipse. If the maximum distance between
0086   //! the ellipse solution and the circle centered at the ellipse
0087   //! center is less than Tol, the result will be the circle.
0088   //! H is the height of the cylinder <Cyl>. It is used to check
0089   //! whether the plane and cylinder are parallel.
0090   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Pln&      P,
0091                                      const gp_Cylinder& C,
0092                                      const double       Tolang,
0093                                      const double       Tol,
0094                                      const double       H = 0);
0095 
0096   //! Intersects a plane and a cylinder.
0097   //! TolAng is the angular tolerance used to determine
0098   //! if the axis of the cylinder is parallel to the plane.
0099   //! Tol is the tolerance used to determine if the result
0100   //! is a circle or an ellipse. If the maximum distance between
0101   //! the ellipse solution and the circle centered at the ellipse
0102   //! center is less than Tol, the result will be the circle.
0103   //! H is the height of the cylinder <Cyl>. It is used to check
0104   //! whether the plane and cylinder are parallel.
0105   Standard_EXPORT void Perform(const gp_Pln&      P,
0106                                const gp_Cylinder& C,
0107                                const double       Tolang,
0108                                const double       Tol,
0109                                const double       H = 0);
0110 
0111   //! Creates the intersection between a plane and a sphere.
0112   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Pln& P, const gp_Sphere& S);
0113 
0114   //! Intersects a plane and a sphere.
0115   Standard_EXPORT void Perform(const gp_Pln& P, const gp_Sphere& S);
0116 
0117   //! Creates the intersection between a plane and a cone.
0118   //! TolAng is the angular tolerance used to determine
0119   //! if the axis of the cone is parallel or perpendicular
0120   //! to the plane, and if the generating line of the cone
0121   //! is parallel to the plane.
0122   //! Tol is the tolerance used to determine if the apex
0123   //! of the cone is in the plane.
0124   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Pln&  P,
0125                                      const gp_Cone& C,
0126                                      const double   Tolang,
0127                                      const double   Tol);
0128 
0129   //! Intersects a plane and a cone.
0130   //! TolAng is the angular tolerance used to determine
0131   //! if the axis of the cone is parallel or perpendicular
0132   //! to the plane, and if the generating line of the cone
0133   //! is parallel to the plane.
0134   //! Tol is the tolerance used to determine if the apex
0135   //! of the cone is in the plane.
0136   Standard_EXPORT void Perform(const gp_Pln&  P,
0137                                const gp_Cone& C,
0138                                const double   Tolang,
0139                                const double   Tol);
0140 
0141   //! Creates the intersection between two cylinders.
0142   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Cylinder& Cyl1,
0143                                      const gp_Cylinder& Cyl2,
0144                                      const double       Tol);
0145 
0146   //! Intersects two cylinders
0147   Standard_EXPORT void Perform(const gp_Cylinder& Cyl1, const gp_Cylinder& Cyl2, const double Tol);
0148 
0149   //! Creates the intersection between a Cylinder and a Sphere.
0150   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Cylinder& Cyl,
0151                                      const gp_Sphere&   Sph,
0152                                      const double       Tol);
0153 
0154   //! Intersects a cylinder and a sphere.
0155   Standard_EXPORT void Perform(const gp_Cylinder& Cyl, const gp_Sphere& Sph, const double Tol);
0156 
0157   //! Creates the intersection between a Cylinder and a Cone
0158   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Cylinder& Cyl, const gp_Cone& Con, const double Tol);
0159 
0160   //! Intersects a cylinder and a cone.
0161   Standard_EXPORT void Perform(const gp_Cylinder& Cyl, const gp_Cone& Con, const double Tol);
0162 
0163   //! Creates the intersection between two Spheres.
0164   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Sphere& Sph1,
0165                                      const gp_Sphere& Sph2,
0166                                      const double     Tol);
0167 
0168   //! Intersects a two spheres.
0169   Standard_EXPORT void Perform(const gp_Sphere& Sph1, const gp_Sphere& Sph2, const double Tol);
0170 
0171   //! Creates the intersection between a Sphere and a Cone.
0172   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Sphere& Sph, const gp_Cone& Con, const double Tol);
0173 
0174   //! Intersects a sphere and a cone.
0175   Standard_EXPORT void Perform(const gp_Sphere& Sph, const gp_Cone& Con, const double Tol);
0176 
0177   //! Creates the intersection between two cones.
0178   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Cone& Con1, const gp_Cone& Con2, const double Tol);
0179 
0180   //! Intersects two cones.
0181   Standard_EXPORT void Perform(const gp_Cone& Con1, const gp_Cone& Con2, const double Tol);
0182 
0183   //! Creates the intersection between plane and torus.
0184   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Pln& Pln, const gp_Torus& Tor, const double Tol);
0185 
0186   //! Intersects plane and torus.
0187   Standard_EXPORT void Perform(const gp_Pln& Pln, const gp_Torus& Tor, const double Tol);
0188 
0189   //! Creates the intersection between cylinder and torus.
0190   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Cylinder& Cyl, const gp_Torus& Tor, const double Tol);
0191 
0192   //! Intersects cylinder and torus.
0193   Standard_EXPORT void Perform(const gp_Cylinder& Cyl, const gp_Torus& Tor, const double Tol);
0194 
0195   //! Creates the intersection between cone and torus.
0196   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Cone& Con, const gp_Torus& Tor, const double Tol);
0197 
0198   //! Intersects cone and torus.
0199   Standard_EXPORT void Perform(const gp_Cone& Con, const gp_Torus& Tor, const double Tol);
0200 
0201   //! Creates the intersection between sphere and torus.
0202   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Sphere& Sph, const gp_Torus& Tor, const double Tol);
0203 
0204   //! Intersects sphere and torus.
0205   Standard_EXPORT void Perform(const gp_Sphere& Sph, const gp_Torus& Tor, const double Tol);
0206 
0207   //! Creates the intersection between two toruses.
0208   Standard_EXPORT IntAna_QuadQuadGeo(const gp_Torus& Tor1, const gp_Torus& Tor2, const double Tol);
0209 
0210   //! Intersects two toruses.
0211   Standard_EXPORT void Perform(const gp_Torus& Tor1, const gp_Torus& Tor2, const double Tol);
0212 
0213   //! Returns true if the computation was successful.
0214   bool IsDone() const;
0215 
0216   //! Returns the type of intersection.
0217   IntAna_ResultType TypeInter() const;
0218 
0219   //! Returns the number of intersections.
0220   //! The possible intersections are :
0221   //! - 1 point
0222   //! - 1 or 2 line(s)
0223   //! - 1 Point and 1 Line
0224   //! - 1 circle
0225   //! - 1 ellipse
0226   //! - 1 parabola
0227   //! - 1 or 2 hyperbola(s).
0228   int NbSolutions() const;
0229 
0230   //! Returns the point solution of range Num.
0231   Standard_EXPORT gp_Pnt Point(const int Num) const;
0232 
0233   //! Returns the line solution of range Num.
0234   Standard_EXPORT gp_Lin Line(const int Num) const;
0235 
0236   //! Returns the circle solution of range Num.
0237   Standard_EXPORT gp_Circ Circle(const int Num) const;
0238 
0239   //! Returns the ellipse solution of range Num.
0240   Standard_EXPORT gp_Elips Ellipse(const int Num) const;
0241 
0242   //! Returns the parabola solution of range Num.
0243   Standard_EXPORT gp_Parab Parabola(const int Num) const;
0244 
0245   //! Returns the hyperbola solution of range Num.
0246   Standard_EXPORT gp_Hypr Hyperbola(const int Num) const;
0247 
0248   Standard_EXPORT bool HasCommonGen() const;
0249 
0250   Standard_EXPORT const gp_Pnt& PChar() const;
0251 
0252 protected:
0253   //! Initialize the values of inner tolerances.
0254   Standard_EXPORT void InitTolerances();
0255 
0256   bool              done;
0257   int               nbint;
0258   IntAna_ResultType typeres;
0259   gp_Pnt            pt1;
0260   gp_Pnt            pt2;
0261   gp_Pnt            pt3;
0262   gp_Pnt            pt4;
0263   gp_Dir            dir1;
0264   gp_Dir            dir2;
0265   gp_Dir            dir3;
0266   gp_Dir            dir4;
0267   double            param1;
0268   double            param2;
0269   double            param3;
0270   double            param4;
0271   double            param1bis;
0272   double            param2bis;
0273   double            myEPSILON_DISTANCE;
0274   double            myEPSILON_ANGLE_CONE;
0275   double            myEPSILON_MINI_CIRCLE_RADIUS;
0276   double            myEPSILON_CYLINDER_DELTA_RADIUS;
0277   double            myEPSILON_CYLINDER_DELTA_DISTANCE;
0278   double            myEPSILON_AXES_PARA;
0279   bool              myCommonGen;
0280   gp_Pnt            myPChar;
0281 };
0282 
0283 #include <IntAna_QuadQuadGeo.lxx>
0284 
0285 #endif // _IntAna_QuadQuadGeo_HeaderFile