Salome HOME
33ef57cd645e8f7fa7dec79994341a696faf31fa
[modules/shaper.git] / src / GeomAPI / GeomAPI_Pln.h
1 // Copyright (C) 2014-2023  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef GeomAPI_Pln_H_
21 #define GeomAPI_Pln_H_
22
23 #include <memory>
24 #include <GeomAPI_Interface.h>
25
26 class GeomAPI_Ax3;
27 class GeomAPI_Pnt;
28 class GeomAPI_Dir;
29 class GeomAPI_Lin;
30
31 /**\class GeomAPI_Pln
32  * \ingroup DataModel
33  * \brief 3D point defined by three coordinates
34  */
35
36 class GeomAPI_Pln : public GeomAPI_Interface
37 {
38  public:
39   /// Creation of plane by the axis placement
40   GEOMAPI_EXPORT
41   GeomAPI_Pln(const std::shared_ptr<GeomAPI_Ax3>& theAxis);
42
43   /// Creation of plane by the point and normal
44   GEOMAPI_EXPORT
45   GeomAPI_Pln(const std::shared_ptr<GeomAPI_Pnt>& thePoint,
46               const std::shared_ptr<GeomAPI_Dir>& theNormal);
47
48   /// Creation of plane by coefficients (Ax+By+Cz+D=0)
49   GEOMAPI_EXPORT
50   GeomAPI_Pln(const double theA, const double theB, const double theC, const double theD);
51
52   /// Returns a point of this plane
53   GEOMAPI_EXPORT
54   std::shared_ptr<GeomAPI_Pnt> location() const;
55
56   /// Returns a plane normal
57   GEOMAPI_EXPORT
58   std::shared_ptr<GeomAPI_Dir> direction() const;
59
60   /// Returns a plane x direction
61   GEOMAPI_EXPORT
62   std::shared_ptr<GeomAPI_Dir> xDirection() const;
63
64   /// Returns the plane coefficients (Ax+By+Cz+D=0)
65   GEOMAPI_EXPORT
66   void coefficients(double& theA, double& theB, double& theC, double& theD);
67
68   /// Returns true if planes are coincident.
69   GEOMAPI_EXPORT
70   bool isCoincident(const std::shared_ptr<GeomAPI_Pln> thePlane, const double theTolerance = 1.e-7);
71
72   /// Returns intersection point or empty if no intersections
73   GEOMAPI_EXPORT
74   std::shared_ptr<GeomAPI_Pnt> intersect(const std::shared_ptr<GeomAPI_Lin>& theLine) const;
75
76   /// Returns projection of the given point onto the plane
77   GEOMAPI_EXPORT
78   std::shared_ptr<GeomAPI_Pnt> project(const std::shared_ptr<GeomAPI_Pnt>& thePoint) const;
79
80   /// \return distance between planes.
81   GEOMAPI_EXPORT
82   double distance(const std::shared_ptr<GeomAPI_Pln> thePlane) const;
83
84   /// \return distance from a point to this plane.
85   GEOMAPI_EXPORT
86   double distance(const std::shared_ptr<GeomAPI_Pnt> thePoint) const;
87
88   /// Translates the plane along direction theDir on distance theDist
89   GEOMAPI_EXPORT
90   void translate(const std::shared_ptr<GeomAPI_Dir> theDir, const double theDist);
91
92   /// \return intersection line of two planes. Empty if they are parallel.
93   GEOMAPI_EXPORT
94   std::shared_ptr<GeomAPI_Lin> intersect(const std::shared_ptr<GeomAPI_Pln> thePlane) const;
95 };
96
97 //! Pointer on the object
98 typedef std::shared_ptr<GeomAPI_Pln> GeomPlanePtr;
99
100 #endif
101