42cf5bc1 |
1 | // Created on: 1993-02-19 |
2 | // Created by: Remi LEQUETTE |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _BRepAdaptor_Curve_HeaderFile |
18 | #define _BRepAdaptor_Curve_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <gp_Trsf.hxx> |
25 | #include <GeomAdaptor_Curve.hxx> |
26 | #include <TopoDS_Edge.hxx> |
27 | #include <Adaptor3d_Curve.hxx> |
28 | #include <Standard_Boolean.hxx> |
29 | #include <Standard_Real.hxx> |
30 | #include <GeomAbs_Shape.hxx> |
31 | #include <Standard_Integer.hxx> |
32 | #include <TColStd_Array1OfReal.hxx> |
33 | #include <GeomAbs_CurveType.hxx> |
34 | class Adaptor3d_HCurveOnSurface; |
35 | class Standard_NullObject; |
36 | class Standard_DomainError; |
37 | class Standard_OutOfRange; |
38 | class Standard_NoSuchObject; |
39 | class TopoDS_Edge; |
40 | class TopoDS_Face; |
41 | class gp_Trsf; |
42 | class GeomAdaptor_Curve; |
43 | class Adaptor3d_CurveOnSurface; |
44 | class Adaptor3d_HCurve; |
45 | class gp_Pnt; |
46 | class gp_Vec; |
47 | class gp_Lin; |
48 | class gp_Circ; |
49 | class gp_Elips; |
50 | class gp_Hypr; |
51 | class gp_Parab; |
52 | class Geom_BezierCurve; |
53 | class Geom_BSplineCurve; |
f4dee9bb |
54 | class Geom_OffsetCurve; |
42cf5bc1 |
55 | |
56 | |
57 | //! The Curve from BRepAdaptor allows to use an Edge |
58 | //! of the BRep topology like a 3D curve. |
59 | //! |
60 | //! It has the methods the class Curve from Adaptor3d. |
61 | //! |
62 | //! It is created or Initialized with an Edge. It |
63 | //! takes into account local coordinate systems. If |
64 | //! the Edge has a 3D curve it is use with priority. |
65 | //! If the edge has no 3D curve one of the curves on |
66 | //! surface is used. It is possible to enforce using a |
67 | //! curve on surface by creating or initialising with |
68 | //! an Edge and a Face. |
69 | class BRepAdaptor_Curve : public Adaptor3d_Curve |
70 | { |
71 | public: |
72 | |
73 | DEFINE_STANDARD_ALLOC |
74 | |
75 | |
76 | //! Creates an undefined Curve with no Edge loaded. |
77 | Standard_EXPORT BRepAdaptor_Curve(); |
78 | |
79 | //! Creates a Curve to acces to the geometry of edge |
80 | //! <E>. |
81 | Standard_EXPORT BRepAdaptor_Curve(const TopoDS_Edge& E); |
82 | |
83 | //! Creates a Curve to acces to the geometry of edge |
84 | //! <E>. The geometry will be computed using the |
85 | //! parametric curve of <E> on the face <F>. An Error |
86 | //! is raised if the edge does not have a pcurve on |
87 | //! the face. |
88 | Standard_EXPORT BRepAdaptor_Curve(const TopoDS_Edge& E, const TopoDS_Face& F); |
4ba5491a |
89 | |
90 | //! Reset currently loaded curve (undone Load()). |
91 | Standard_EXPORT void Reset(); |
92 | |
42cf5bc1 |
93 | //! Sets the Curve <me> to acces to the geometry of |
94 | //! edge <E>. |
95 | Standard_EXPORT void Initialize (const TopoDS_Edge& E); |
96 | |
97 | //! Sets the Curve <me> to acces to the geometry of |
98 | //! edge <E>. The geometry will be computed using the |
99 | //! parametric curve of <E> on the face <F>. An Error |
100 | //! is raised if the edge does not have a pcurve on |
101 | //! the face. |
102 | Standard_EXPORT void Initialize (const TopoDS_Edge& E, const TopoDS_Face& F); |
103 | |
104 | //! Returns the coordinate system of the curve. |
105 | Standard_EXPORT const gp_Trsf& Trsf() const; |
106 | |
107 | //! Returns True if the edge geometry is computed from |
108 | //! a 3D curve. |
109 | Standard_EXPORT Standard_Boolean Is3DCurve() const; |
110 | |
111 | //! Returns True if the edge geometry is computed from |
112 | //! a pcurve on a surface. |
113 | Standard_EXPORT Standard_Boolean IsCurveOnSurface() const; |
114 | |
115 | //! Returns the Curve of the edge. |
116 | Standard_EXPORT const GeomAdaptor_Curve& Curve() const; |
117 | |
118 | //! Returns the CurveOnSurface of the edge. |
119 | Standard_EXPORT const Adaptor3d_CurveOnSurface& CurveOnSurface() const; |
120 | |
121 | //! Returns the edge. |
122 | Standard_EXPORT const TopoDS_Edge& Edge() const; |
123 | |
124 | //! Returns the edge tolerance. |
125 | Standard_EXPORT Standard_Real Tolerance() const; |
126 | |
127 | Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; |
128 | |
129 | Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; |
130 | |
131 | Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; |
132 | |
133 | //! Returns the number of intervals for continuity |
134 | //! <S>. May be one if Continuity(me) >= <S> |
135 | Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; |
136 | |
137 | //! Stores in <T> the parameters bounding the intervals |
138 | //! of continuity <S>. |
139 | //! |
140 | //! The array must provide enough room to accomodate |
141 | //! for the parameters. i.e. T.Length() > NbIntervals() |
142 | Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; |
143 | |
144 | //! Returns a curve equivalent of <me> between |
145 | //! parameters <First> and <Last>. <Tol> is used to |
146 | //! test for 3d points confusion. |
147 | //! If <First> >= <Last> |
148 | Standard_EXPORT Handle(Adaptor3d_HCurve) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; |
149 | |
150 | Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; |
151 | |
152 | Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; |
153 | |
154 | Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; |
155 | |
156 | //! Computes the point of parameter U on the curve |
157 | Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE; |
158 | |
159 | //! Computes the point of parameter U. |
160 | Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE; |
161 | |
162 | //! Computes the point of parameter U on the curve |
163 | //! with its first derivative. |
164 | //! Raised if the continuity of the current interval |
165 | //! is not C1. |
166 | Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V) const Standard_OVERRIDE; |
167 | |
168 | |
169 | //! Returns the point P of parameter U, the first and second |
170 | //! derivatives V1 and V2. |
171 | //! Raised if the continuity of the current interval |
172 | //! is not C2. |
173 | Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE; |
174 | |
175 | |
176 | //! Returns the point P of parameter U, the first, the second |
177 | //! and the third derivative. |
178 | //! Raised if the continuity of the current interval |
179 | //! is not C3. |
180 | Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE; |
181 | |
182 | |
183 | //! The returned vector gives the value of the derivative for the |
184 | //! order of derivation N. |
185 | //! Raised if the continuity of the current interval |
186 | //! is not CN. |
187 | //! Raised if N < 1. |
188 | Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; |
189 | |
190 | //! returns the parametric resolution |
191 | Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const Standard_OVERRIDE; |
192 | |
193 | Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE; |
194 | |
195 | Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE; |
196 | |
197 | Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE; |
198 | |
199 | Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE; |
200 | |
201 | Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE; |
202 | |
203 | Standard_EXPORT gp_Parab Parabola() const Standard_OVERRIDE; |
204 | |
205 | Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE; |
206 | |
207 | Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE; |
208 | |
209 | Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE; |
210 | |
211 | Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE; |
212 | |
213 | |
214 | //! Warning : |
215 | //! This will make a copy of the Bezier Curve |
216 | //! since it applies to it myTsrf . Be carefull when |
217 | //! using this method |
218 | Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE; |
219 | |
220 | |
221 | //! Warning : |
222 | //! This will make a copy of the BSpline Curve |
223 | //! since it applies to it myTsrf . Be carefull when |
224 | //! using this method |
225 | Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE; |
226 | |
f4dee9bb |
227 | Standard_EXPORT Handle(Geom_OffsetCurve) OffsetCurve() const Standard_OVERRIDE; |
42cf5bc1 |
228 | |
229 | |
230 | |
231 | protected: |
232 | |
233 | |
234 | |
235 | |
236 | |
237 | private: |
238 | |
239 | |
240 | |
241 | gp_Trsf myTrsf; |
242 | GeomAdaptor_Curve myCurve; |
243 | Handle(Adaptor3d_HCurveOnSurface) myConSurf; |
244 | TopoDS_Edge myEdge; |
245 | |
246 | |
247 | }; |
248 | |
249 | |
250 | |
251 | |
252 | |
253 | |
254 | |
255 | #endif // _BRepAdaptor_Curve_HeaderFile |