1 // Created on: 1993-07-06
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _BRepBuilderAPI_MakeEdge_HeaderFile
18 #define _BRepBuilderAPI_MakeEdge_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <BRepLib_MakeEdge.hxx>
25 #include <BRepBuilderAPI_MakeShape.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <BRepBuilderAPI_EdgeError.hxx>
29 class StdFail_NotDone;
43 //! Provides methods to build edges.
45 //! The methods have the following syntax, where
46 //! TheCurve is one of Lin, Circ, ...
48 //! Create(C : TheCurve)
50 //! Makes an edge on the whole curve. Add vertices
53 //! Create(C : TheCurve; p1,p2 : Real)
55 //! Make an edge on the curve between parameters p1
56 //! and p2. if p2 < p1 the edge will be REVERSED. If
57 //! p1 or p2 is infinite the curve will be open in
58 //! that direction. Vertices are created for finite
59 //! values of p1 and p2.
61 //! Create(C : TheCurve; P1, P2 : Pnt from gp)
63 //! Make an edge on the curve between the points P1
64 //! and P2. The points are projected on the curve
65 //! and the previous method is used. An error is
66 //! raised if the points are not on the curve.
68 //! Create(C : TheCurve; V1, V2 : Vertex from TopoDS)
70 //! Make an edge on the curve between the vertices
71 //! V1 and V2. Same as the previous but no vertices
72 //! are created. If a vertex is Null the curve will
73 //! be open in this direction.
74 class BRepBuilderAPI_MakeEdge : public BRepBuilderAPI_MakeShape
81 Standard_EXPORT BRepBuilderAPI_MakeEdge();
83 Standard_EXPORT BRepBuilderAPI_MakeEdge(const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
85 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Pnt& P1, const gp_Pnt& P2);
87 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L);
89 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L, const Standard_Real p1, const Standard_Real p2);
91 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L, const gp_Pnt& P1, const gp_Pnt& P2);
93 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Lin& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
95 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L);
97 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L, const Standard_Real p1, const Standard_Real p2);
99 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L, const gp_Pnt& P1, const gp_Pnt& P2);
101 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Circ& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
103 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L);
105 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L, const Standard_Real p1, const Standard_Real p2);
107 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L, const gp_Pnt& P1, const gp_Pnt& P2);
109 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Elips& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
111 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L);
113 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L, const Standard_Real p1, const Standard_Real p2);
115 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L, const gp_Pnt& P1, const gp_Pnt& P2);
117 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Hypr& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
119 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L);
121 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L, const Standard_Real p1, const Standard_Real p2);
123 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L, const gp_Pnt& P1, const gp_Pnt& P2);
125 Standard_EXPORT BRepBuilderAPI_MakeEdge(const gp_Parab& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
127 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L);
129 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const Standard_Real p1, const Standard_Real p2);
131 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const gp_Pnt& P1, const gp_Pnt& P2);
133 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
135 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);
137 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom_Curve)& L, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);
139 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S);
141 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const Standard_Real p1, const Standard_Real p2);
143 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2);
145 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
147 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);
149 //! The general method to directly create an edge is to give
150 //! - a 3D curve C as the support (geometric domain) of the edge,
151 //! - two vertices V1 and V2 to limit the curve (definition of the restriction of
153 //! - two real values p1 and p2 which are the parameters for the vertices V1 and V2
155 //! The curve may be defined as a 2d curve in the parametric space of a surface: a
156 //! pcurve. The surface on which the edge is built is then kept at the level of the edge.
157 //! The default tolerance will be associated with this edge.
158 //! Rules applied to the arguments:
160 //! - The curve must not be a 'null handle'.
161 //! - If the curve is a trimmed curve the basis curve is used.
162 //! For the vertices:
163 //! - Vertices may be null shapes. When V1 or V2 is null the edge is open in the
164 //! corresponding direction and the parameter value p1 or p2 must be infinite
165 //! (remember that Precision::Infinite() defines an infinite value).
166 //! - The two vertices must be identical if they have the same 3D location.
167 //! Identical vertices are used in particular when the curve is closed.
168 //! For the parameters:
169 //! - The parameters must be in the parametric range of the curve (or the basis
170 //! curve if the curve is trimmed). If this condition is not satisfied the edge is not
171 //! built, and the Error function will return BRepAPI_ParameterOutOfRange.
172 //! - Parameter values must not be equal. If this condition is not satisfied (i.e.
173 //! if | p1 - p2 | ) the edge is not built, and the Error function will return
174 //! BRepAPI_LineThroughIdenticPoints.
175 //! Parameter values are expected to be given in increasing order:
176 //! C->FirstParameter()
177 //! - If the parameter values are given in decreasing order the vertices are switched,
178 //! i.e. the "first vertex" is on the point of parameter p2 and the "second vertex" is
179 //! on the point of parameter p1. In such a case, to keep the original intent of the
180 //! construction, the edge will be oriented "reversed".
181 //! - On a periodic curve the parameter values p1 and p2 are adjusted by adding or
182 //! subtracting the period to obtain p1 in the parametric range of the curve, and p2]
183 //! such that [ p1 , where Period is the period of the curve.
184 //! - A parameter value may be infinite. The edge is open in the corresponding
185 //! direction. However the corresponding vertex must be a null shape. If this condition
186 //! is not satisfied the edge is not built, and the Error function will return
187 //! BRepAPI_PointWithInfiniteParameter.
188 //! - The distance between the vertex and the point evaluated on the curve with the
189 //! parameter, must be lower than the precision of the vertex. If this condition is not
190 //! satisfied the edge is not built, and the Error function will return
191 //! BRepAPI_DifferentsPointAndParameter.
192 //! Other edge constructions
193 //! - The parameter values can be omitted, they will be computed by projecting the
194 //! vertices on the curve. Note that projection is the only way to evaluate the
195 //! parameter values of the vertices on the curve: vertices must be given on the curve,
196 //! i.e. the distance from a vertex to the curve must be less than or equal to the
197 //! precision of the vertex. If this condition is not satisfied the edge is not built,
198 //! and the Error function will return BRepAPI_PointProjectionFailed.
199 //! - 3D points can be given in place of vertices. Vertices will be created from the
200 //! points (with the default topological precision Precision::Confusion()).
202 //! - Giving vertices is useful when creating a connected edge.
203 //! - If the parameter values correspond to the extremities of a closed curve,
204 //! points must be identical, or at least coincident. If this condition is not
205 //! satisfied the edge is not built, and the Error function will return
206 //! BRepAPI_DifferentPointsOnClosedCurve.
207 //! - The vertices or points can be omitted if the parameter values are given. The
208 //! points will be computed from the parameters on the curve.
209 //! The vertices or points and the parameter values can be omitted. The first and last
210 //! parameters of the curve will then be used.
212 //! Auxiliary methods
213 Standard_EXPORT BRepBuilderAPI_MakeEdge(const Handle(Geom2d_Curve)& L, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);
215 Standard_EXPORT void Init (const Handle(Geom_Curve)& C);
217 Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const Standard_Real p1, const Standard_Real p2);
219 Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const gp_Pnt& P1, const gp_Pnt& P2);
221 Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
223 Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);
225 Standard_EXPORT void Init (const Handle(Geom_Curve)& C, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);
227 Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S);
229 Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const Standard_Real p1, const Standard_Real p2);
231 Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2);
233 Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
235 Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const gp_Pnt& P1, const gp_Pnt& P2, const Standard_Real p1, const Standard_Real p2);
237 //! Defines or redefines the arguments for the construction of an edge.
238 //! This function is currently used after the empty constructor BRepAPI_MakeEdge().
239 Standard_EXPORT void Init (const Handle(Geom2d_Curve)& C, const Handle(Geom_Surface)& S, const TopoDS_Vertex& V1, const TopoDS_Vertex& V2, const Standard_Real p1, const Standard_Real p2);
241 //! Returns true if the edge is built.
242 Standard_EXPORT virtual Standard_Boolean IsDone() const Standard_OVERRIDE;
244 //! Returns the construction status
245 //! - BRepBuilderAPI_EdgeDone if the edge is built, or
246 //! - another value of the BRepBuilderAPI_EdgeError
247 //! enumeration indicating the reason of construction failure.
248 Standard_EXPORT BRepBuilderAPI_EdgeError Error() const;
251 //! Returns the constructed edge.
252 //! Exceptions StdFail_NotDone if the edge is not built.
253 Standard_EXPORT const TopoDS_Edge& Edge();
254 Standard_EXPORT operator TopoDS_Edge();
256 //! Returns the first vertex of the edge. May be Null.
257 Standard_EXPORT const TopoDS_Vertex& Vertex1() const;
259 //! Returns the second vertex of the edge. May be Null.
262 //! The returned vertex in each function corresponds respectively to
264 //! - the highest parameter on the curve along which the edge is built.
265 //! It does not correspond to the first or second vertex
266 //! given at the time of the construction, if the edge is oriented reversed.
268 //! StdFail_NotDone if the edge is not built.
269 Standard_EXPORT const TopoDS_Vertex& Vertex2() const;
284 BRepLib_MakeEdge myMakeEdge;
295 #endif // _BRepBuilderAPI_MakeEdge_HeaderFile