Salome HOME
e270ea74783e1486e7f6fec2e00c91e473f001af
[modules/shaper.git] / src / GeomAPI / GeomAPI_Ellipse.h
1 // Copyright (C) 2017-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 // File:        GeomAPI_Ellipse.h
21 // Created:     25 April 2017
22 // Author:      Vitaly Smetannikov
23
24 #ifndef GeomAPI_Ellipse_H_
25 #define GeomAPI_Ellipse_H_
26
27 #include <GeomAPI_Interface.h>
28 #include <memory>
29
30 class GeomAPI_Ax2;
31 class GeomAPI_Curve;
32 class GeomAPI_Dir;
33 class GeomAPI_Pnt;
34
35
36 /**\class GeomAPI_Ellipse
37  * \ingroup DataModel
38  * \brief Ellipse in 3D
39  */
40 class GeomAPI_Ellipse : public GeomAPI_Interface
41 {
42 public:
43
44   /// \brief Constructs an epty ellipse
45   GEOMAPI_EXPORT GeomAPI_Ellipse() : GeomAPI_Interface() {}
46
47   /** \brief Constructs an ellipse with major and minor radiuses,
48    *  where theAx2 locates the ellipse and defines its orientation in 3D space such that:\n
49    *  - the center of the circle is the origin of theAx2;\n
50    *  - the origin, "X Direction" and "Y Direction" of theAx2 define the plane of the circle;\n
51    *  - theAx2 is the local coordinate system of the circle.\n
52    *    Note: It is possible to create a circle where Radius is equal to 0.0. raised if Radius < 0.
53    */
54   GEOMAPI_EXPORT GeomAPI_Ellipse(const std::shared_ptr<GeomAPI_Ax2>& theAx2,
55                                  double theMajorRadius, double theMinorRadius);
56
57   GEOMAPI_EXPORT GeomAPI_Ellipse(std::shared_ptr<GeomAPI_Curve> theCurve);
58
59   /// Returns center of the ellipse
60   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> center() const;
61
62   /// Returns first focus of the ellipse
63   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> firstFocus() const;
64
65   /// Returns second focus of the ellipse
66   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> secondFocus() const;
67
68   /// Return orthogonal direction to the ellipse's plane
69   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> normal() const;
70
71   /// Returns minor radius of the ellipse
72   GEOMAPI_EXPORT double minorRadius() const;
73
74   /// Returns major radius of the ellipse
75   GEOMAPI_EXPORT double majorRadius() const;
76
77   /// Project point on ellipse
78   GEOMAPI_EXPORT const std::shared_ptr<GeomAPI_Pnt> project(
79       const std::shared_ptr<GeomAPI_Pnt>& thePoint) const;
80
81   /** \brief Computes the parameter of a given point on an ellipse. The point must be
82    *         located either on the circle itself or relatively to the latter
83    *         at a distance less than the tolerance value. Return FALSE if the point
84    *         is beyond the tolerance limit or if computation fails.
85    *         Max Tolerance value is currently limited to 1.e-4
86    *  \param[in]  thePoint point of origin.
87    *  \param[in]  theTolerance tolerance of computation.
88    *  \param[out] theParameter resulting parameter.
89    */
90   GEOMAPI_EXPORT const bool parameter(const std::shared_ptr<GeomAPI_Pnt> thePoint,
91                                       const double theTolerance,
92                                       double& theParameter) const;
93 };
94
95 //! Pointer on the object
96 typedef std::shared_ptr<GeomAPI_Ellipse> GeomEllipsePtr;
97
98 #endif