Commit | Line | Data |
---|---|---|
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> | |
d660a72a | 32 | #include <GeomEvaluator_Curve.hxx> |
33 | ||
42cf5bc1 | 34 | class Geom_Curve; |
35 | class Adaptor3d_HCurve; | |
36 | class Standard_NoSuchObject; | |
37 | class Standard_ConstructionError; | |
38 | class Standard_OutOfRange; | |
39 | class Standard_DomainError; | |
40 | class GeomAdaptor_Surface; | |
41 | class gp_Pnt; | |
42 | class gp_Vec; | |
43 | class gp_Lin; | |
44 | class gp_Circ; | |
45 | class gp_Elips; | |
46 | class gp_Hypr; | |
47 | class gp_Parab; | |
48 | class Geom_BezierCurve; | |
49 | class Geom_BSplineCurve; | |
50 | ||
51 | ||
52 | //! This class provides an interface between the services provided by any | |
53 | //! curve from the package Geom and those required of the curve by algorithms which use it. | |
54 | //! Creation of the loaded curve the curve is C1 by piece. | |
34e4e9f2 BB |
55 | //! |
56 | //! Polynomial coefficients of BSpline curves used for their evaluation are | |
57 | //! cached for better performance. Therefore these evaluations are not | |
58 | //! thread-safe and parallel evaluations need to be prevented. | |
42cf5bc1 | 59 | class GeomAdaptor_Curve : public Adaptor3d_Curve |
60 | { | |
61 | public: | |
62 | ||
63 | DEFINE_STANDARD_ALLOC | |
64 | ||
65 | ||
66 | GeomAdaptor_Curve(); | |
67 | ||
68 | GeomAdaptor_Curve(const Handle(Geom_Curve)& C); | |
69 | ||
70 | //! ConstructionError is raised if Ufirst>Ulast | |
71 | GeomAdaptor_Curve(const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast); | |
72 | ||
73 | void Load (const Handle(Geom_Curve)& C); | |
74 | ||
75 | //! ConstructionError is raised if Ufirst>Ulast | |
76 | void Load (const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast); | |
77 | ||
78 | ||
79 | //! Provides a curve inherited from Hcurve from Adaptor. | |
80 | //! This is inherited to provide easy to use constructors. | |
81 | const Handle(Geom_Curve)& Curve() const; | |
82 | ||
83 | Standard_Real FirstParameter() const Standard_OVERRIDE; | |
84 | ||
85 | Standard_Real LastParameter() const Standard_OVERRIDE; | |
86 | ||
87 | Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; | |
88 | ||
89 | //! Returns the number of intervals for continuity | |
90 | //! <S>. May be one if Continuity(me) >= <S> | |
91 | Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; | |
92 | ||
93 | //! Stores in <T> the parameters bounding the intervals | |
94 | //! of continuity <S>. | |
95 | //! | |
96 | //! The array must provide enough room to accomodate | |
97 | //! for the parameters. i.e. T.Length() > NbIntervals() | |
98 | Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; | |
99 | ||
100 | //! Returns a curve equivalent of <me> between | |
101 | //! parameters <First> and <Last>. <Tol> is used to | |
102 | //! test for 3d points confusion. | |
103 | //! If <First> >= <Last> | |
104 | Standard_EXPORT Handle(Adaptor3d_HCurve) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; | |
105 | ||
106 | Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; | |
107 | ||
108 | Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; | |
109 | ||
110 | Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; | |
111 | ||
112 | //! Computes the point of parameter U on the curve | |
113 | Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE; | |
114 | ||
115 | //! Computes the point of parameter U. | |
116 | Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE; | |
117 | ||
118 | //! Computes the point of parameter U on the curve | |
119 | //! with its first derivative. | |
120 | //! | |
121 | //! Warning : On the specific case of BSplineCurve: | |
122 | //! if the curve is cut in interval of continuity at least C1, the | |
123 | //! derivatives are computed on the current interval. | |
124 | //! else the derivatives are computed on the basis curve. | |
125 | Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V) const Standard_OVERRIDE; | |
126 | ||
127 | ||
128 | //! Returns the point P of parameter U, the first and second | |
129 | //! derivatives V1 and V2. | |
130 | //! | |
131 | //! Warning : On the specific case of BSplineCurve: | |
132 | //! if the curve is cut in interval of continuity at least C2, the | |
133 | //! derivatives are computed on the current interval. | |
134 | //! else the derivatives are computed on the basis curve. | |
135 | Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE; | |
136 | ||
137 | ||
138 | //! Returns the point P of parameter U, the first, the second | |
139 | //! and the third derivative. | |
140 | //! | |
141 | //! Warning : On the specific case of BSplineCurve: | |
142 | //! if the curve is cut in interval of continuity at least C3, the | |
143 | //! derivatives are computed on the current interval. | |
144 | //! else the derivatives are computed on the basis curve. | |
145 | Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE; | |
146 | ||
147 | ||
148 | //! The returned vector gives the value of the derivative for the | |
149 | //! order of derivation N. | |
150 | //! Warning : On the specific case of BSplineCurve: | |
151 | //! if the curve is cut in interval of continuity CN, the | |
152 | //! derivatives are computed on the current interval. | |
153 | //! else the derivatives are computed on the basis curve. | |
154 | //! Raised if N < 1. | |
155 | Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; | |
156 | ||
157 | //! returns the parametric resolution | |
158 | Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const Standard_OVERRIDE; | |
159 | ||
160 | GeomAbs_CurveType GetType() const Standard_OVERRIDE; | |
161 | ||
162 | Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE; | |
163 | ||
164 | Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE; | |
165 | ||
166 | Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE; | |
167 | ||
168 | Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE; | |
169 | ||
170 | Standard_EXPORT gp_Parab Parabola() 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_Integer Degree() 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_Boolean IsRational() 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 NbPoles() const Standard_OVERRIDE; | |
189 | ||
190 | ||
191 | //! this should NEVER make a copy | |
192 | //! of the underlying curve to read | |
193 | //! the relevant information | |
194 | Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE; | |
195 | ||
196 | //! this will NOT make a copy of the | |
197 | //! Bezier Curve : If you want to modify | |
198 | //! the Curve please make a copy yourself | |
199 | //! Also it will NOT trim the surface to | |
200 | //! myFirst/Last. | |
201 | Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE; | |
202 | ||
203 | //! this will NOT make a copy of the | |
204 | //! BSpline Curve : If you want to modify | |
205 | //! the Curve please make a copy yourself | |
206 | //! Also it will NOT trim the surface to | |
207 | //! myFirst/Last. | |
208 | Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE; | |
209 | ||
210 | ||
211 | friend class GeomAdaptor_Surface; | |
212 | ||
213 | ||
214 | protected: | |
215 | ||
216 | ||
217 | ||
218 | ||
219 | ||
220 | private: | |
221 | ||
42cf5bc1 | 222 | Standard_EXPORT GeomAbs_Shape LocalContinuity (const Standard_Real U1, const Standard_Real U2) const; |
223 | ||
224 | Standard_EXPORT void load (const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast); | |
225 | ||
d660a72a | 226 | //! Check theU relates to start or finish point of B-spline curve and return indices of span the point is located |
227 | Standard_Boolean IsBoundary(const Standard_Real theU, Standard_Integer& theSpanStart, Standard_Integer& theSpanFinish) const; | |
228 | ||
42cf5bc1 | 229 | //! Rebuilds B-spline cache |
230 | //! \param theParameter the value on the knot axis which identifies the caching span | |
d660a72a | 231 | void RebuildCache (const Standard_Real theParameter) const; |
42cf5bc1 | 232 | |
233 | ||
234 | Handle(Geom_Curve) myCurve; | |
235 | GeomAbs_CurveType myTypeCurve; | |
236 | Standard_Real myFirst; | |
237 | Standard_Real myLast; | |
3b25c0e8 IC |
238 | |
239 | Handle(Geom_BSplineCurve) myBSplineCurve; ///< B-spline representation to prevent castings | |
d660a72a | 240 | Handle(BSplCLib_Cache) myCurveCache; ///< Cached data for B-spline or Bezier curve |
241 | Handle(GeomEvaluator_Curve) myNestedEvaluator; ///< Calculates value of offset curve | |
42cf5bc1 | 242 | |
243 | ||
244 | }; | |
245 | ||
246 | ||
247 | #include <GeomAdaptor_Curve.lxx> | |
248 | ||
249 | ||
250 | ||
251 | ||
252 | ||
253 | #endif // _GeomAdaptor_Curve_HeaderFile |