0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / Geom2dAdaptor / Geom2dAdaptor_Curve.hxx
CommitLineData
42cf5bc1 1// Created on: 1993-06-03
2// Created by: Bruno DUMORTIER
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 _Geom2dAdaptor_Curve_HeaderFile
18#define _Geom2dAdaptor_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 <Adaptor2d_Curve2d.hxx>
28#include <GeomAbs_Shape.hxx>
29#include <Standard_Integer.hxx>
30#include <TColStd_Array1OfReal.hxx>
31#include <Standard_Boolean.hxx>
32class Geom2d_Curve;
33class Adaptor2d_HCurve2d;
34class Standard_NoSuchObject;
35class Standard_ConstructionError;
36class Standard_OutOfRange;
37class Standard_DomainError;
38class gp_Pnt2d;
39class gp_Vec2d;
40class gp_Lin2d;
41class gp_Circ2d;
42class gp_Elips2d;
43class gp_Hypr2d;
44class gp_Parab2d;
45class Geom2d_BezierCurve;
46class Geom2d_BSplineCurve;
47
48
49//! An interface between the services provided by any
50//! curve from the package Geom2d and those required
51//! of the curve by algorithms which use it.
52class Geom2dAdaptor_Curve : public Adaptor2d_Curve2d
53{
54public:
55
56 DEFINE_STANDARD_ALLOC
57
58
59 Standard_EXPORT Geom2dAdaptor_Curve();
60
61 Standard_EXPORT Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C);
62
63 //! ConstructionError is raised if Ufirst>Ulast
64 Standard_EXPORT Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
65
66 void Load (const Handle(Geom2d_Curve)& C);
67
68 //! ConstructionError is raised if Ufirst>Ulast
69 void Load (const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
70
71 const Handle(Geom2d_Curve)& Curve() const;
72
73 Standard_Real FirstParameter() const Standard_OVERRIDE;
74
75 Standard_Real LastParameter() const Standard_OVERRIDE;
76
77 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
78
79 //! If necessary, breaks the curve in intervals of
80 //! continuity <S>. And returns the number of
81 //! intervals.
82 Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
83
84 //! Stores in <T> the parameters bounding the intervals
85 //! of continuity <S>.
86 //!
87 //! The array must provide enough room to accomodate
88 //! for the parameters. i.e. T.Length() > NbIntervals()
89 Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE;
90
91 //! Returns a curve equivalent of <me> between
92 //! parameters <First> and <Last>. <Tol> is used to
93 //! test for 3d points confusion.
94 //! If <First> >= <Last>
95 Standard_EXPORT Handle(Adaptor2d_HCurve2d) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE;
96
97 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
98
99 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
100
101 Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE;
102
103 //! Computes the point of parameter U on the curve
104 Standard_EXPORT gp_Pnt2d Value (const Standard_Real U) const Standard_OVERRIDE;
105
106 //! Computes the point of parameter U.
107 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
108
109 //! Computes the point of parameter U on the curve with its
110 //! first derivative.
111 //! Raised if the continuity of the current interval
112 //! is not C1.
113 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V) const Standard_OVERRIDE;
114
115
116 //! Returns the point P of parameter U, the first and second
117 //! derivatives V1 and V2.
118 //! Raised if the continuity of the current interval
119 //! is not C2.
120 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
121
122
123 //! Returns the point P of parameter U, the first, the second
124 //! and the third derivative.
125 //! Raised if the continuity of the current interval
126 //! is not C3.
127 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
128
129
130 //! The returned vector gives the value of the derivative for the
131 //! order of derivation N.
132 //! Raised if the continuity of the current interval
133 //! is not CN.
134 //! Raised if N < 1.
135 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
136
137 //! returns the parametric resolution
138 Standard_EXPORT Standard_Real Resolution (const Standard_Real Ruv) const Standard_OVERRIDE;
139
140 GeomAbs_CurveType GetType() const Standard_OVERRIDE;
141
142 Standard_EXPORT gp_Lin2d Line() const Standard_OVERRIDE;
143
144 Standard_EXPORT gp_Circ2d Circle() const Standard_OVERRIDE;
145
146 Standard_EXPORT gp_Elips2d Ellipse() const Standard_OVERRIDE;
147
148 Standard_EXPORT gp_Hypr2d Hyperbola() const Standard_OVERRIDE;
149
150 Standard_EXPORT gp_Parab2d Parabola() const Standard_OVERRIDE;
151
152 Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE;
153
154 Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
155
156 Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE;
157
158 Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE;
159
160 Standard_EXPORT virtual Standard_Integer NbSamples() const Standard_OVERRIDE;
161
162 Standard_EXPORT Handle(Geom2d_BezierCurve) Bezier() const Standard_OVERRIDE;
163
164 Standard_EXPORT Handle(Geom2d_BSplineCurve) BSpline() const Standard_OVERRIDE;
165
166
167
168
169protected:
170
171
172
173
174
175private:
176
177
178 //! Computes the point of parameter U on the B-spline curve
179 Standard_EXPORT gp_Pnt2d ValueBSpline (const Standard_Real U) const;
180
181 //! Computes the point of parameter U on the offset curve
182 Standard_EXPORT gp_Pnt2d ValueOffset (const Standard_Real U) const;
183
184 //! Computes the point of parameter U on the B-spline curve
185 Standard_EXPORT void D0BSpline (const Standard_Real theU, gp_Pnt2d& theP) const;
186
187 //! Computes the point of parameter U on the offset curve
188 Standard_EXPORT void D0Offset (const Standard_Real theU, gp_Pnt2d& theP) const;
189
190 //! Computes the point of parameter U on the B-spline curve
191 //! and its derivative
192 Standard_EXPORT void D1BSpline (const Standard_Real theU, gp_Pnt2d& theP, gp_Vec2d& theV) const;
193
194 //! Computes the point of parameter U on the offset curve
195 //! and its derivative
196 Standard_EXPORT void D1Offset (const Standard_Real theU, gp_Pnt2d& theP, gp_Vec2d& theV) const;
197
198 //! Computes the point of parameter U on the B-spline curve
199 //! and its first and second derivatives
200 Standard_EXPORT void D2BSpline (const Standard_Real theU, gp_Pnt2d& theP, gp_Vec2d& theV1, gp_Vec2d& theV2) const;
201
202 //! Computes the point of parameter U on the offset curve
203 //! and its first and second derivatives
204 Standard_EXPORT void D2Offset (const Standard_Real theU, gp_Pnt2d& theP, gp_Vec2d& theV1, gp_Vec2d& theV2) const;
205
206 //! Computes the point of parameter U on the B-spline curve
207 //! and its first, second and third derivatives
208 Standard_EXPORT void D3BSpline (const Standard_Real theU, gp_Pnt2d& theP, gp_Vec2d& theV1, gp_Vec2d& theV2, gp_Vec2d& theV3) const;
209
210 //! Computes the point of parameter U on the offset curve
211 //! and its first, second and third derivatives
212 Standard_EXPORT void D3Offset (const Standard_Real theU, gp_Pnt2d& theP, gp_Vec2d& theV1, gp_Vec2d& theV2, gp_Vec2d& theV3) const;
213
214
215 //! The returned vector gives the value of the derivative for the
216 //! order of derivation N.
217 Standard_EXPORT gp_Vec2d DNBSpline (const Standard_Real theU, const Standard_Integer N) const;
218
219
220 //! The returned vector gives the value of the derivative for the
221 //! order of derivation N.
222 Standard_EXPORT gp_Vec2d DNOffset (const Standard_Real theU, const Standard_Integer N) const;
223
224 Standard_EXPORT GeomAbs_Shape LocalContinuity (const Standard_Real U1, const Standard_Real U2) const;
225
226 Standard_EXPORT void load (const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
227
228 //! Rebuilds B-spline cache
229 //! \param theParameter the value on the knot axis which identifies the caching span
230 Standard_EXPORT void RebuildCache (const Standard_Real theParameter) const;
231
232
233 Handle(Geom2d_Curve) myCurve;
234 GeomAbs_CurveType myTypeCurve;
235 Standard_Real myFirst;
236 Standard_Real myLast;
237 Handle(BSplCLib_Cache) myCurveCache;
238 Handle(Adaptor2d_HCurve2d) myOffsetBaseCurveAdaptor;
239
240
241};
242
243
244#include <Geom2dAdaptor_Curve.lxx>
245
246
247
248
249
250#endif // _Geom2dAdaptor_Curve_HeaderFile