Salome HOME
Updated copyright comment
[modules/shaper.git] / src / GeomAPI / GeomAPI_Edge.h
1 // Copyright (C) 2014-2024  CEA, EDF
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_Edge_H_
21 #define GeomAPI_Edge_H_
22
23 #include <GeomAPI_Shape.h>
24
25 class GeomAPI_Pln;
26 class GeomAPI_Pnt;
27 class GeomAPI_Circ;
28 class GeomAPI_Lin;
29 class GeomAPI_Ellipse;
30 class GeomAPI_Vertex;
31
32 /**\class GeomAPI_Edge
33 * \ingroup DataModel
34  * \brief Interface to the edge object
35  */
36
37 class GeomAPI_Edge : public GeomAPI_Shape
38 {
39 public:
40    /// Makes an undefined Edge (no geometry).
41   GEOMAPI_EXPORT
42    GeomAPI_Edge();
43
44    /// Creation of edge by the edge-shape
45   GEOMAPI_EXPORT
46    GeomAPI_Edge(const std::shared_ptr<GeomAPI_Shape>& theShape);
47
48   /// Return vertices of the edge;
49   GEOMAPI_EXPORT
50   void vertices(std::shared_ptr<GeomAPI_Vertex>& theStartVertex,
51                 std::shared_ptr<GeomAPI_Vertex>& theEndVertex) const;
52
53   /// Returns \c true if edges have same underlying curve
54   GEOMAPI_EXPORT
55   virtual bool isSameGeometry(const std::shared_ptr<GeomAPI_Shape> theShape) const;
56
57   /// Verifies that the edge is a line
58   GEOMAPI_EXPORT
59   bool isLine() const;
60
61   /// Verifies that the edge is a circle
62   GEOMAPI_EXPORT
63   bool isCircle() const;
64
65   /// Verifies that the edge is an arc of circle
66   GEOMAPI_EXPORT
67   bool isArc() const;
68
69   /// Verifies that the edge is an arc of circle
70   GEOMAPI_EXPORT
71   bool isEllipse() const;
72
73   /// Verifies that the edge is based on a B-spline curve
74   GEOMAPI_EXPORT
75   bool isBSpline() const;
76
77   /// Returns the first vertex coordinates of the edge
78   GEOMAPI_EXPORT
79   std::shared_ptr<GeomAPI_Pnt> firstPoint();
80
81   /// Returns the Last vertex coordinates of the edge
82   GEOMAPI_EXPORT
83   std::shared_ptr<GeomAPI_Pnt> lastPoint();
84
85   /// Returns a circle if edge is based on the circle curve
86   GEOMAPI_EXPORT
87   std::shared_ptr<GeomAPI_Circ> circle() const;
88
89   /// Returns an ellipse if edge is based on the ellipse curve
90   GEOMAPI_EXPORT
91   std::shared_ptr<GeomAPI_Ellipse> ellipse() const;
92
93   /// Returns a line if edge is based on the linear curve
94   GEOMAPI_EXPORT
95   std::shared_ptr<GeomAPI_Lin> line() const;
96
97   /// Returns true if the current edge is geometrically equal to the given edge
98   GEOMAPI_EXPORT
99   bool isEqual(const std::shared_ptr<GeomAPI_Shape> theEdge) const;
100
101   /// Change parametric range of the curve
102   GEOMAPI_EXPORT
103   void setRange(const double& theFirst, const double& theLast);
104
105   /// Returns range of parameter on the curve
106   GEOMAPI_EXPORT
107   void getRange(double& theFirst, double& theLast) const;
108
109   /// Returns true, if the edge is fully placed in the specified plane
110   /// \param thePlane a plane for intersection
111   GEOMAPI_EXPORT
112   bool isInPlane(const std::shared_ptr<GeomAPI_Pln> thePlane) const;
113
114   /// Returns list of intersection points if the edge has intersections with the given plane
115   /// \param thePlane a plane for intersection
116   GEOMAPI_EXPORT
117   void intersectWithPlane(const std::shared_ptr<GeomAPI_Pln> thePlane,
118                           std::list<std::shared_ptr<GeomAPI_Pnt> >& theResult) const;
119
120   /// Returns edge length.
121   GEOMAPI_EXPORT
122   double length() const;
123
124   /// Returns true if the edge is closed (like full circle)
125   GEOMAPI_EXPORT
126   bool isClosed() const;
127
128   /// Returns true if the edge is degenerated (has no 3D curve)
129   GEOMAPI_EXPORT
130   bool isDegenerated() const;
131
132   GEOMAPI_EXPORT
133   void setFirstPointTolerance(const double theTolerance);
134
135   GEOMAPI_EXPORT
136   void setLastPointTolerance(const double theTolerance);
137
138   GEOMAPI_EXPORT double firstPointTolerance() const;
139
140   GEOMAPI_EXPORT double lastPointTolerance() const;
141
142   /// Return middle point on the edge
143   GEOMAPI_EXPORT
144   virtual std::shared_ptr<GeomAPI_Pnt> middlePoint() const;
145 };
146
147 //! Pointer on object
148 typedef std::shared_ptr<GeomAPI_Edge> GeomEdgePtr;
149
150 #endif
151