0026196: Wrong result obtained by projection algorithm.
[occt.git] / src / GeomAdaptor / GeomAdaptor_Curve.hxx
CommitLineData
42cf5bc1 1// Created on: 1992-09-01
2// Created by: Modelistation
3// Copyright (c) 1992-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 _GeomAdaptor_Curve_HeaderFile
18#define _GeomAdaptor_Curve_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <GeomAbs_CurveType.hxx>
25#include <Standard_Real.hxx>
26#include <BSplCLib_Cache.hxx>
27#include <Adaptor3d_Curve.hxx>
28#include <GeomAbs_Shape.hxx>
29#include <Standard_Integer.hxx>
30#include <TColStd_Array1OfReal.hxx>
31#include <Standard_Boolean.hxx>
32class Geom_Curve;
33class Adaptor3d_HCurve;
34class Standard_NoSuchObject;
35class Standard_ConstructionError;
36class Standard_OutOfRange;
37class Standard_DomainError;
38class GeomAdaptor_Surface;
39class gp_Pnt;
40class gp_Vec;
41class gp_Lin;
42class gp_Circ;
43class gp_Elips;
44class gp_Hypr;
45class gp_Parab;
46class Geom_BezierCurve;
47class Geom_BSplineCurve;
48
49
50//! This class provides an interface between the services provided by any
51//! curve from the package Geom and those required of the curve by algorithms which use it.
52//! Creation of the loaded curve the curve is C1 by piece.
53class GeomAdaptor_Curve : public Adaptor3d_Curve
54{
55public:
56
57 DEFINE_STANDARD_ALLOC
58
59
60 GeomAdaptor_Curve();
61
62 GeomAdaptor_Curve(const Handle(Geom_Curve)& C);
63
64 //! ConstructionError is raised if Ufirst>Ulast
65 GeomAdaptor_Curve(const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
66
67 void Load (const Handle(Geom_Curve)& C);
68
69 //! ConstructionError is raised if Ufirst>Ulast
70 void Load (const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
71
72
73 //! Provides a curve inherited from Hcurve from Adaptor.
74 //! This is inherited to provide easy to use constructors.
75 const Handle(Geom_Curve)& Curve() const;
76
77 Standard_Real FirstParameter() const Standard_OVERRIDE;
78
79 Standard_Real LastParameter() const Standard_OVERRIDE;
80
81 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
82
83 //! Returns the number of intervals for continuity
84 //! <S>. May be one if Continuity(me) >= <S>
85 Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
86
87 //! Stores in <T> the parameters bounding the intervals
88 //! of continuity <S>.
89 //!
90 //! The array must provide enough room to accomodate
91 //! for the parameters. i.e. T.Length() > NbIntervals()
92 Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE;
93
94 //! Returns a curve equivalent of <me> between
95 //! parameters <First> and <Last>. <Tol> is used to
96 //! test for 3d points confusion.
97 //! If <First> >= <Last>
98 Standard_EXPORT Handle(Adaptor3d_HCurve) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE;
99
100 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
101
102 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
103
104 Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE;
105
106 //! Computes the point of parameter U on the curve
107 Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE;
108
109 //! Computes the point of parameter U.
110 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
111
112 //! Computes the point of parameter U on the curve
113 //! with its first derivative.
114 //!
115 //! Warning : On the specific case of BSplineCurve:
116 //! if the curve is cut in interval of continuity at least C1, the
117 //! derivatives are computed on the current interval.
118 //! else the derivatives are computed on the basis curve.
119 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V) const Standard_OVERRIDE;
120
121
122 //! Returns the point P of parameter U, the first and second
123 //! derivatives V1 and V2.
124 //!
125 //! Warning : On the specific case of BSplineCurve:
126 //! if the curve is cut in interval of continuity at least C2, the
127 //! derivatives are computed on the current interval.
128 //! else the derivatives are computed on the basis curve.
129 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE;
130
131
132 //! Returns the point P of parameter U, the first, the second
133 //! and the third derivative.
134 //!
135 //! Warning : On the specific case of BSplineCurve:
136 //! if the curve is cut in interval of continuity at least C3, the
137 //! derivatives are computed on the current interval.
138 //! else the derivatives are computed on the basis curve.
139 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE;
140
141
142 //! The returned vector gives the value of the derivative for the
143 //! order of derivation N.
144 //! Warning : On the specific case of BSplineCurve:
145 //! if the curve is cut in interval of continuity CN, the
146 //! derivatives are computed on the current interval.
147 //! else the derivatives are computed on the basis curve.
148 //! Raised if N < 1.
149 Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
150
151 //! returns the parametric resolution
152 Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const Standard_OVERRIDE;
153
154 GeomAbs_CurveType GetType() const Standard_OVERRIDE;
155
156 Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE;
157
158 Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE;
159
160 Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE;
161
162 Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE;
163
164 Standard_EXPORT gp_Parab Parabola() const Standard_OVERRIDE;
165
166
167 //! this should NEVER make a copy
168 //! of the underlying curve to read
169 //! the relevant information
170 Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE;
171
172
173 //! this should NEVER make a copy
174 //! of the underlying curve to read
175 //! the relevant information
176 Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
177
178
179 //! this should NEVER make a copy
180 //! of the underlying curve to read
181 //! the relevant information
182 Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE;
183
184
185 //! this should NEVER make a copy
186 //! of the underlying curve to read
187 //! the relevant information
188 Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE;
189
190 //! this will NOT make a copy of the
191 //! Bezier Curve : If you want to modify
192 //! the Curve please make a copy yourself
193 //! Also it will NOT trim the surface to
194 //! myFirst/Last.
195 Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE;
196
197 //! this will NOT make a copy of the
198 //! BSpline Curve : If you want to modify
199 //! the Curve please make a copy yourself
200 //! Also it will NOT trim the surface to
201 //! myFirst/Last.
202 Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE;
203
204
205friend class GeomAdaptor_Surface;
206
207
208protected:
209
210
211
212
213
214private:
215
216
217 //! Computes the point of parameter U on the B-spline curve
218 Standard_EXPORT gp_Pnt ValueBSpline (const Standard_Real U) const;
219
220 //! Computes the point of parameter U on the offset curve
221 Standard_EXPORT gp_Pnt ValueOffset (const Standard_Real U) const;
222
223 //! Computes the point of parameter U on the B-spline curve
224 Standard_EXPORT void D0BSpline (const Standard_Real theU, gp_Pnt& theP) const;
225
226 //! Computes the point of parameter U on the offset curve
227 Standard_EXPORT void D0Offset (const Standard_Real theU, gp_Pnt& theP) const;
228
229 //! Computes the point of parameter U on the B-spline curve
230 //! and its derivative
231 Standard_EXPORT void D1BSpline (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV) const;
232
233 //! Computes the point of parameter U on the offset curve
234 //! and its derivative
235 Standard_EXPORT void D1Offset (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV) const;
236
237 //! Computes the point of parameter U on the B-spline curve
238 //! and its first and second derivatives
239 Standard_EXPORT void D2BSpline (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2) const;
240
241 //! Computes the point of parameter U on the offset curve
242 //! and its first and second derivatives
243 Standard_EXPORT void D2Offset (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2) const;
244
245 //! Computes the point of parameter U on the B-spline curve
246 //! and its first, second and third derivatives
247 Standard_EXPORT void D3BSpline (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2, gp_Vec& theV3) const;
248
249 //! Computes the point of parameter U on the offset curve
250 //! and its first, second and third derivatives
251 Standard_EXPORT void D3Offset (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2, gp_Vec& theV3) const;
252
253
254 //! The returned vector gives the value of the derivative for the
255 //! order of derivation N.
256 Standard_EXPORT gp_Vec DNBSpline (const Standard_Real theU, const Standard_Integer N) const;
257
258
259 //! The returned vector gives the value of the derivative for the
260 //! order of derivation N.
261 Standard_EXPORT gp_Vec DNOffset (const Standard_Real theU, const Standard_Integer N) const;
262
263 Standard_EXPORT GeomAbs_Shape LocalContinuity (const Standard_Real U1, const Standard_Real U2) const;
264
265 Standard_EXPORT void load (const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
266
267 //! Rebuilds B-spline cache
268 //! \param theParameter the value on the knot axis which identifies the caching span
269 Standard_EXPORT void RebuildCache (const Standard_Real theParameter) const;
270
271
272 Handle(Geom_Curve) myCurve;
273 GeomAbs_CurveType myTypeCurve;
274 Standard_Real myFirst;
275 Standard_Real myLast;
276 Handle(BSplCLib_Cache) myCurveCache;
277 Handle(Adaptor3d_HCurve) myOffsetBaseCurveAdaptor;
278
279
280};
281
282
283#include <GeomAdaptor_Curve.lxx>
284
285
286
287
288
289#endif // _GeomAdaptor_Curve_HeaderFile