Commit | Line | Data |
---|---|---|
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> | |
d660a72a | 32 | #include <Geom2dEvaluator_Curve.hxx> |
33 | ||
42cf5bc1 | 34 | class Geom2d_Curve; |
35 | class Adaptor2d_HCurve2d; | |
36 | class Standard_NoSuchObject; | |
37 | class Standard_ConstructionError; | |
38 | class Standard_OutOfRange; | |
39 | class Standard_DomainError; | |
40 | class gp_Pnt2d; | |
41 | class gp_Vec2d; | |
42 | class gp_Lin2d; | |
43 | class gp_Circ2d; | |
44 | class gp_Elips2d; | |
45 | class gp_Hypr2d; | |
46 | class gp_Parab2d; | |
47 | class Geom2d_BezierCurve; | |
48 | class Geom2d_BSplineCurve; | |
49 | ||
50 | ||
51 | //! An interface between the services provided by any | |
52 | //! curve from the package Geom2d and those required | |
53 | //! of the curve by algorithms which use it. | |
34e4e9f2 BB |
54 | //! |
55 | //! Polynomial coefficients of BSpline curves used for their evaluation are | |
56 | //! cached for better performance. Therefore these evaluations are not | |
57 | //! thread-safe and parallel evaluations need to be prevented. | |
42cf5bc1 | 58 | class Geom2dAdaptor_Curve : public Adaptor2d_Curve2d |
59 | { | |
60 | public: | |
61 | ||
62 | DEFINE_STANDARD_ALLOC | |
63 | ||
64 | ||
65 | Standard_EXPORT Geom2dAdaptor_Curve(); | |
66 | ||
67 | Standard_EXPORT Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C); | |
68 | ||
69 | //! ConstructionError is raised if Ufirst>Ulast | |
70 | Standard_EXPORT Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast); | |
71 | ||
72 | void Load (const Handle(Geom2d_Curve)& C); | |
73 | ||
74 | //! ConstructionError is raised if Ufirst>Ulast | |
75 | void Load (const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast); | |
76 | ||
77 | const Handle(Geom2d_Curve)& Curve() const; | |
78 | ||
79 | Standard_Real FirstParameter() const Standard_OVERRIDE; | |
80 | ||
81 | Standard_Real LastParameter() const Standard_OVERRIDE; | |
82 | ||
83 | Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; | |
84 | ||
85 | //! If necessary, breaks the curve in intervals of | |
86 | //! continuity <S>. And returns the number of | |
87 | //! intervals. | |
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 | //! | |
93 | //! The array must provide enough room to accomodate | |
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> | |
101 | Standard_EXPORT Handle(Adaptor2d_HCurve2d) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; | |
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_Pnt2d 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_Pnt2d& P) const Standard_OVERRIDE; | |
114 | ||
115 | //! Computes the point of parameter U on the curve with its | |
116 | //! first derivative. | |
117 | //! Raised if the continuity of the current interval | |
118 | //! is not C1. | |
119 | Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V) const Standard_OVERRIDE; | |
120 | ||
121 | ||
122 | //! Returns the point P of parameter U, the first and second | |
123 | //! derivatives V1 and V2. | |
124 | //! Raised if the continuity of the current interval | |
125 | //! is not C2. | |
126 | Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE; | |
127 | ||
128 | ||
129 | //! Returns the point P of parameter U, the first, the second | |
130 | //! and the third derivative. | |
131 | //! Raised if the continuity of the current interval | |
132 | //! is not C3. | |
133 | Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE; | |
134 | ||
135 | ||
136 | //! The returned vector gives the value of the derivative for the | |
137 | //! order of derivation N. | |
138 | //! Raised if the continuity of the current interval | |
139 | //! is not CN. | |
140 | //! Raised if N < 1. | |
141 | Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; | |
142 | ||
143 | //! returns the parametric resolution | |
144 | Standard_EXPORT Standard_Real Resolution (const Standard_Real Ruv) const Standard_OVERRIDE; | |
145 | ||
146 | GeomAbs_CurveType GetType() const Standard_OVERRIDE; | |
147 | ||
148 | Standard_EXPORT gp_Lin2d Line() const Standard_OVERRIDE; | |
149 | ||
150 | Standard_EXPORT gp_Circ2d Circle() const Standard_OVERRIDE; | |
151 | ||
152 | Standard_EXPORT gp_Elips2d Ellipse() const Standard_OVERRIDE; | |
153 | ||
154 | Standard_EXPORT gp_Hypr2d Hyperbola() const Standard_OVERRIDE; | |
155 | ||
156 | Standard_EXPORT gp_Parab2d Parabola() const Standard_OVERRIDE; | |
157 | ||
158 | Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE; | |
159 | ||
160 | Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE; | |
161 | ||
162 | Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE; | |
163 | ||
164 | Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE; | |
165 | ||
166 | Standard_EXPORT virtual Standard_Integer NbSamples() const Standard_OVERRIDE; | |
167 | ||
168 | Standard_EXPORT Handle(Geom2d_BezierCurve) Bezier() const Standard_OVERRIDE; | |
169 | ||
170 | Standard_EXPORT Handle(Geom2d_BSplineCurve) BSpline() const Standard_OVERRIDE; | |
171 | ||
172 | ||
173 | ||
174 | ||
175 | protected: | |
176 | ||
177 | ||
178 | ||
179 | ||
180 | ||
181 | private: | |
182 | ||
42cf5bc1 | 183 | Standard_EXPORT GeomAbs_Shape LocalContinuity (const Standard_Real U1, const Standard_Real U2) const; |
184 | ||
185 | Standard_EXPORT void load (const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast); | |
d660a72a | 186 | |
187 | //! Check theU relates to start or finish point of B-spline curve and return indices of span the point is located | |
188 | Standard_Boolean IsBoundary(const Standard_Real theU, Standard_Integer& theSpanStart, Standard_Integer& theSpanFinish) const; | |
189 | ||
42cf5bc1 | 190 | //! Rebuilds B-spline cache |
191 | //! \param theParameter the value on the knot axis which identifies the caching span | |
d660a72a | 192 | void RebuildCache (const Standard_Real theParameter) const; |
42cf5bc1 | 193 | |
194 | ||
195 | Handle(Geom2d_Curve) myCurve; | |
196 | GeomAbs_CurveType myTypeCurve; | |
197 | Standard_Real myFirst; | |
198 | Standard_Real myLast; | |
3b25c0e8 IC |
199 | |
200 | Handle(Geom2d_BSplineCurve) myBSplineCurve; ///< B-spline representation to prevent castings | |
81093856 | 201 | mutable Handle(BSplCLib_Cache) myCurveCache; ///< Cached data for B-spline or Bezier curve |
d660a72a | 202 | Handle(Geom2dEvaluator_Curve) myNestedEvaluator; ///< Calculates value of offset curve |
42cf5bc1 | 203 | |
204 | ||
205 | }; | |
206 | ||
207 | ||
208 | #include <Geom2dAdaptor_Curve.lxx> | |
209 | ||
210 | ||
211 | ||
212 | ||
213 | ||
214 | #endif // _Geom2dAdaptor_Curve_HeaderFile |