Salome HOME
2bed53862871a0d868ba5747b437574620aad341
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Circ2dBuilder.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 GeomAlgoAPI_Circ2dBuilder_H_
21 #define GeomAlgoAPI_Circ2dBuilder_H_
22
23 #include <GeomAlgoAPI.h>
24
25 #include <memory>
26 #include <vector>
27
28 class GeomAPI_Ax3;
29 class GeomAPI_Circ2d;
30 class GeomAPI_Pnt2d;
31 class GeomAPI_Shape;
32
33 /// \class GeomAlgoAPI_Circ2dBuilder
34 /// \ingroup DataAlgo
35 /// \brief Creates circle in 2D space satisfying combination of the following constraints:
36 ///        * center of a circle
37 ///        * passing through the point
38 ///        * tangent to a curve
39 ///        * fixed radius
40 class GeomAlgoAPI_Circ2dBuilder
41 {
42 public:
43   /// \brief Create a builder object.
44   ///        Constraints should be applied separately.
45   /// \param thePlane [in]  plane to project tangent curves
46   GEOMALGOAPI_EXPORT
47   GeomAlgoAPI_Circ2dBuilder(const std::shared_ptr<GeomAPI_Ax3>& thePlane);
48
49   /// \brief Set fixed radius of the circle
50   GEOMALGOAPI_EXPORT
51   void setRadius(const double theRadius);
52
53   /// \brief Set fixed center of the circle
54   GEOMALGOAPI_EXPORT
55   void setCenter(const std::shared_ptr<GeomAPI_Pnt2d>& theCenter);
56
57   /// \brief Constrain circle to be tangent to the given edge
58   GEOMALGOAPI_EXPORT
59   void addTangentCurve(const std::shared_ptr<GeomAPI_Shape>& theEdge);
60
61   /// \brief Constrain circle to be orthogonal to the given edge
62   GEOMALGOAPI_EXPORT
63   void setTransversalLine(const std::shared_ptr<GeomAPI_Shape>& theEdge);
64
65   /// \brief Constrain circle to pass through the given point
66   GEOMALGOAPI_EXPORT
67   void addPassingPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
68
69   /// \brief Optional constraint to find circle closest to the given point
70   GEOMALGOAPI_EXPORT
71   void setClosestPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
72
73   /// \brief Build circle
74   GEOMALGOAPI_EXPORT
75   std::shared_ptr<GeomAPI_Circ2d> circle();
76
77   /// \brief Create a circle passing through three points
78   GEOMALGOAPI_EXPORT
79   static std::shared_ptr<GeomAPI_Circ2d>
80       circle(const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPoint,
81              const std::shared_ptr<GeomAPI_Pnt2d>& theSecondPoint,
82              const std::shared_ptr<GeomAPI_Pnt2d>& theThirdPoint);
83
84 private:
85   std::shared_ptr<GeomAPI_Ax3>                  myPlane;
86   std::shared_ptr<GeomAPI_Pnt2d>                myCenter;
87   std::vector< std::shared_ptr<GeomAPI_Pnt2d> > myPassingPoints;
88   std::vector< std::shared_ptr<GeomAPI_Shape> > myTangentShapes;
89   std::shared_ptr<GeomAPI_Shape>                myTransversalLine;
90   std::shared_ptr<GeomAPI_Pnt2d>                myClosestPoint;
91   double                                        myRadius;
92 };
93
94 #endif