Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAPI / GeomAPI_Circ.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_Circ_H_
21 #define GeomAPI_Circ_H_
22
23 #include <GeomAPI_Interface.h>
24 #include <GeomAPI_Curve.h>
25 #include <memory>
26
27 class GeomAPI_Ax2;
28 class GeomAPI_Pnt;
29 class GeomAPI_Dir;
30
31 /**\class GeomAPI_Circ
32  * \ingroup DataModel
33  * \brief Circle in 3D
34  */
35
36 class GeomAPI_Circ : public GeomAPI_Interface
37 {
38  public:
39
40   /** \brief Constructs a circle of radius Radius, where theAx2 locates
41    *  the circle and defines its orientation in 3D space such that:\n
42    *  - the center of the circle is the origin of theAx2;\n
43    *  - the origin, "X Direction" and "Y Direction" of theAx2 define the plane of the circle;\n
44    *  - theAx2 is the local coordinate system of the circle.\n
45    *    Note: It is possible to create a circle where Radius is equal to 0.0. raised if Radius < 0.
46    */
47   GEOMAPI_EXPORT GeomAPI_Circ(const std::shared_ptr<GeomAPI_Ax2> theAx2,
48                               const double theRadius);
49
50   /// Creation of circle defined by center point, direction and circle radius
51   GEOMAPI_EXPORT GeomAPI_Circ(const std::shared_ptr<GeomAPI_Pnt>& theCenter,
52                const std::shared_ptr<GeomAPI_Dir>& theDir, double theRadius);
53
54   /// Creation of circle defined by a curve
55   GEOMAPI_EXPORT GeomAPI_Circ(const GeomCurvePtr& theCurve);
56
57   /// Return center of the circle
58   GEOMAPI_EXPORT const std::shared_ptr<GeomAPI_Pnt> center() const;
59
60   /// Return radius of the circle
61   GEOMAPI_EXPORT double radius() const;
62
63   /// Return orthogonal direction to the circle's plane
64   GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> normal() const;
65
66   /// Project point on circle
67   GEOMAPI_EXPORT const std::shared_ptr<GeomAPI_Pnt> project(
68       const std::shared_ptr<GeomAPI_Pnt>& thePoint) const;
69
70   /** \brief Computes the parameter of a given point on a circle. The point must be
71    *         located either on the circle itself or relatively to the latter
72    *         at a distance less than the tolerance value. Return FALSE if the point
73    *         is beyond the tolerance limit or if computation fails.
74    *         Max Tolerance value is currently limited to 1.e-4
75    *  \param[in] thePoint point of origin.
76    *  \param[in] theTolerance tolerance of computation.
77    *  \param[out] theParameter resulting parameter.
78    */
79   GEOMAPI_EXPORT const bool parameter(const std::shared_ptr<GeomAPI_Pnt> thePoint,
80                                       const double theTolerance,
81                                       double& theParameter) const;
82 };
83
84 //! Pointer on the object
85 typedef std::shared_ptr<GeomAPI_Circ> GeomCirclePtr;
86
87 #endif
88