Salome HOME
39ce301ffaffb0fbf175c65a4c91979754ba7ce6
[modules/shaper.git] / src / GeomAPI / GeomAPI_Ellipse2d.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_Ellipse2d.h
21 // Created:     26 April 2017
22 // Author:      Artem ZHIDKOV
23
24 #ifndef GeomAPI_Ellipse2d_H_
25 #define GeomAPI_Ellipse2d_H_
26
27 #include <GeomAPI_Interface.h>
28
29 class GeomAPI_Circ2d;
30 class GeomAPI_Dir2d;
31 class GeomAPI_Lin2d;
32 class GeomAPI_Pnt2d;
33
34 /**\class GeomAPI_Ellipse2d
35  * \ingroup DataModel
36  * \brief Ellipse in 2D
37  */
38 class GeomAPI_Ellipse2d : public GeomAPI_Interface
39 {
40 public:
41   /// \brief Constructs ellipse by center, X-axis and given radii
42   GEOMAPI_EXPORT GeomAPI_Ellipse2d(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
43                                    const std::shared_ptr<GeomAPI_Dir2d>& theXAxis,
44                                    const double theMajorRadius,
45                                    const double theMinorRadius);
46
47   /// \brief Constructs ellipse by center and two points lying on the ellipse:
48   ///        first of them defines an axis of the ellipse
49   ///        and another is just placed on the ellipse.
50   GEOMAPI_EXPORT GeomAPI_Ellipse2d(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
51                                    const std::shared_ptr<GeomAPI_Pnt2d>& theAxisPoint,
52                                    const std::shared_ptr<GeomAPI_Pnt2d>& thePassingPoint);
53
54   /// Returns center of the ellipse
55   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt2d> center() const;
56
57   /// Returns first focus of the ellipse
58   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt2d> firstFocus() const;
59
60   /// Returns second focus of the ellipse
61   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt2d> secondFocus() const;
62
63   /// Returns minor radius of the ellipse
64   GEOMAPI_EXPORT double minorRadius() const;
65
66   /// Returns major radius of the ellipse
67   GEOMAPI_EXPORT double majorRadius() const;
68
69   /// Project point on ellipse
70   GEOMAPI_EXPORT const std::shared_ptr<GeomAPI_Pnt2d> project(
71       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint) const;
72
73   /** \brief Computes the parameter of a given point on an ellipse. The point must be
74    *         located either on the circle itself or relatively to the latter
75    *         at a distance less than the tolerance value. Return FALSE if the point
76    *         is beyond the tolerance limit or if computation fails.
77    *         Max Tolerance value is currently limited to 1.e-4
78    *  \param[in]  thePoint point of origin.
79    *  \param[in]  theTolerance tolerance of computation.
80    *  \param[out] theParameter resulting parameter.
81    */
82   GEOMAPI_EXPORT const bool parameter(const std::shared_ptr<GeomAPI_Pnt2d> thePoint,
83                                       const double theTolerance,
84                                       double& theParameter) const;
85
86   /// Calculate minimal distance between the ellipse and a line.
87   /// Return corresponding points on the ellipse and on the line.
88   GEOMAPI_EXPORT double distance(const std::shared_ptr<GeomAPI_Lin2d>& theLine,
89                                  std::shared_ptr<GeomAPI_Pnt2d>& thePointOnMe,
90                                  std::shared_ptr<GeomAPI_Pnt2d>& thePointOnLine);
91
92   /// Calculate minimal distance between the ellipse and a circle.
93   /// Return corresponding points on the ellipse and on the circle.
94   GEOMAPI_EXPORT double distance(const std::shared_ptr<GeomAPI_Circ2d>& theCircle,
95                                  std::shared_ptr<GeomAPI_Pnt2d>& thePointOnMe,
96                                  std::shared_ptr<GeomAPI_Pnt2d>& thePointOnCircle);
97
98   /// Calculate minimal distance between two ellipses.
99   /// Return corresponding points on the ellipses.
100   GEOMAPI_EXPORT double distance(const std::shared_ptr<GeomAPI_Ellipse2d>& theEllipse,
101                                  std::shared_ptr<GeomAPI_Pnt2d>& thePointOnMe,
102                                  std::shared_ptr<GeomAPI_Pnt2d>& thePointOnEllipse);
103 };
104
105 #endif