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