Salome HOME
Merge remote-tracking branch 'origin/Toolbars_Management'
[modules/shaper.git] / src / GeomAPI / GeomAPI_Pln.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef GeomAPI_Pln_H_
22 #define GeomAPI_Pln_H_
23
24 #include <memory>
25 #include <GeomAPI_Interface.h>
26
27 class GeomAPI_Ax3;
28 class GeomAPI_Pnt;
29 class GeomAPI_Dir;
30 class GeomAPI_Lin;
31
32 /**\class GeomAPI_Pln
33  * \ingroup DataModel
34  * \brief 3D point defined by three coordinates
35  */
36
37 class GeomAPI_Pln : public GeomAPI_Interface
38 {
39  public:
40   /// Creation of plane by the axis placement
41   GEOMAPI_EXPORT
42   GeomAPI_Pln(const std::shared_ptr<GeomAPI_Ax3>& theAxis);
43
44   /// Creation of plane by the point and normal
45   GEOMAPI_EXPORT
46   GeomAPI_Pln(const std::shared_ptr<GeomAPI_Pnt>& thePoint,
47               const std::shared_ptr<GeomAPI_Dir>& theNormal);
48
49   /// Creation of plane by coefficients (Ax+By+Cz+D=0)
50   GEOMAPI_EXPORT
51   GeomAPI_Pln(const double theA, const double theB, const double theC, const double theD);
52
53   /// Returns a point of this plane
54   GEOMAPI_EXPORT
55   std::shared_ptr<GeomAPI_Pnt> location() const;
56
57   /// Returns a plane normal
58   GEOMAPI_EXPORT
59   std::shared_ptr<GeomAPI_Dir> direction() const;
60
61   /// Returns a plane x direction
62   GEOMAPI_EXPORT
63   std::shared_ptr<GeomAPI_Dir> xDirection() const;
64
65   /// Returns the plane coefficients (Ax+By+Cz+D=0)
66   GEOMAPI_EXPORT
67   void coefficients(double& theA, double& theB, double& theC, double& theD);
68
69   /// Returns true if planes are coincident.
70   GEOMAPI_EXPORT
71   bool isCoincident(const std::shared_ptr<GeomAPI_Pln> thePlane, const double theTolerance = 1.e-7);
72
73   /// Returns intersection point or empty if no intersections
74   GEOMAPI_EXPORT
75   std::shared_ptr<GeomAPI_Pnt> intersect(const std::shared_ptr<GeomAPI_Lin>& theLine) const;
76
77   /// Returns projection of the given point onto the plane
78   GEOMAPI_EXPORT
79   std::shared_ptr<GeomAPI_Pnt> project(const std::shared_ptr<GeomAPI_Pnt>& thePoint) const;
80
81   /// \return distance between planes.
82   GEOMAPI_EXPORT
83   double distance(const std::shared_ptr<GeomAPI_Pln> thePlane) const;
84
85   /// \return distance from a point to this plane.
86   GEOMAPI_EXPORT
87   double distance(const std::shared_ptr<GeomAPI_Pnt> thePoint) const;
88
89   /// Translates the plane along direction theDir on distance theDist
90   GEOMAPI_EXPORT
91   void translate(const std::shared_ptr<GeomAPI_Dir> theDir, const double theDist);
92
93   /// \return intersection line of two planes. Empty if they are parallel.
94   GEOMAPI_EXPORT
95   std::shared_ptr<GeomAPI_Lin> intersect(const std::shared_ptr<GeomAPI_Pln> thePlane) const;
96 };
97
98 //! Pointer on the object
99 typedef std::shared_ptr<GeomAPI_Pln> GeomPlanePtr;
100
101 #endif
102