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