Salome HOME
25f1dabf5077875302985ed1f6a072f57833da26
[modules/shaper.git] / src / GeomAPI / GeomAPI_Pnt.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_Pnt_H_
21 #define GeomAPI_Pnt_H_
22
23 #include <GeomAPI_Interface.h>
24 #include <memory>
25
26 class GeomAPI_Ax1;
27 class GeomAPI_XYZ;
28 class GeomAPI_Pnt2d;
29 class GeomAPI_Dir;
30 class GeomAPI_Pln;
31
32 /**\class GeomAPI_Pnt
33  * \ingroup DataModel
34  * \brief 3D point defined by three coordinates
35  */
36
37 class GeomAPI_Pnt : public GeomAPI_Interface
38 {
39  public:
40   /// Creation of point by coordinates
41   GEOMAPI_EXPORT
42   GeomAPI_Pnt(const double theX, const double theY, const double theZ);
43   /// Creation of point by coordinates
44   GEOMAPI_EXPORT
45   GeomAPI_Pnt(const std::shared_ptr<GeomAPI_XYZ>& theCoords);
46
47   /// returns X coordinate
48   GEOMAPI_EXPORT
49   double x() const;
50   /// returns Y coordinate
51   GEOMAPI_EXPORT
52   double y() const;
53   /// returns Z coordinate
54   GEOMAPI_EXPORT
55   double z() const;
56
57   /// sets X coordinate
58   GEOMAPI_EXPORT
59   void setX(const double theX);
60   /// sets Y coordinate
61   GEOMAPI_EXPORT
62   void setY(const double theY);
63   /// sets Z coordinate
64   GEOMAPI_EXPORT
65   void setZ(const double theZ);
66
67   /// returns coordinates of the point
68   GEOMAPI_EXPORT
69   const std::shared_ptr<GeomAPI_XYZ> xyz();
70
71   /// Distance between two points
72   GEOMAPI_EXPORT
73   double distance(const std::shared_ptr<GeomAPI_Pnt>& theOther) const;
74
75   /// Returns whether the distance between two points is less then precision confusion
76   GEOMAPI_EXPORT
77   bool isEqual(const std::shared_ptr<GeomAPI_Pnt>& theOther) const;
78
79   /// Returns \c true, if the current point is less than theOther.
80   /// The point is less than other, if X coordinate is less.
81   /// In case of X's are equal, if Y is less than other.
82   /// If Y's are equal too, compare Z's.
83   GEOMAPI_EXPORT
84   bool isLess(const std::shared_ptr<GeomAPI_Pnt>& theOther,
85               const double theTolerance = 1.e-7) const;
86
87   /// Projects a point to the plane defined by the origin and 2 axes vectors in this plane
88   GEOMAPI_EXPORT
89   std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
90                                         const std::shared_ptr<GeomAPI_Dir>& theDirX,
91                                         const std::shared_ptr<GeomAPI_Dir>& theDirY);
92
93   /// Projects a point to the plane defined by the origin and 2 axes vectors in this plane
94   GEOMAPI_EXPORT
95   std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pln>& thePln) const;
96
97   /// Translates the point along direction theDir on distance theDist
98   GEOMAPI_EXPORT
99   void translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist);
100
101   /// Rotates the point along axis for the given angle (in degrees)
102   GEOMAPI_EXPORT void rotate(const std::shared_ptr<GeomAPI_Ax1>& theAxis, double theAngle);
103 };
104
105 //! Pointer on the object
106 typedef std::shared_ptr<GeomAPI_Pnt> GeomPointPtr;
107
108 #endif