42cf5bc1 |
1 | // Created on: 1993-03-09 |
2 | // Created by: JCV |
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 _Geom_BSplineCurve_HeaderFile |
18 | #define _Geom_BSplineCurve_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
6fd9bdf2 |
23 | #include <Precision.hxx> |
42cf5bc1 |
24 | #include <Standard_Boolean.hxx> |
25 | #include <GeomAbs_BSplKnotDistribution.hxx> |
26 | #include <GeomAbs_Shape.hxx> |
27 | #include <Standard_Integer.hxx> |
28 | #include <TColgp_HArray1OfPnt.hxx> |
29 | #include <TColStd_HArray1OfReal.hxx> |
30 | #include <TColStd_HArray1OfInteger.hxx> |
31 | #include <Standard_Real.hxx> |
32 | #include <Geom_BoundedCurve.hxx> |
33 | #include <TColgp_Array1OfPnt.hxx> |
34 | #include <TColStd_Array1OfReal.hxx> |
35 | #include <TColStd_Array1OfInteger.hxx> |
36 | class Standard_ConstructionError; |
37 | class Standard_DimensionError; |
38 | class Standard_DomainError; |
39 | class Standard_OutOfRange; |
40 | class Standard_RangeError; |
41 | class Standard_NoSuchObject; |
42 | class Geom_UndefinedDerivative; |
43 | class gp_Pnt; |
44 | class gp_Vec; |
45 | class gp_Trsf; |
46 | class Geom_Geometry; |
47 | |
48 | |
49 | class Geom_BSplineCurve; |
50 | DEFINE_STANDARD_HANDLE(Geom_BSplineCurve, Geom_BoundedCurve) |
51 | |
52 | //! Definition of the B_spline curve. |
53 | //! A B-spline curve can be |
54 | //! Uniform or non-uniform |
55 | //! Rational or non-rational |
56 | //! Periodic or non-periodic |
57 | //! |
58 | //! a b-spline curve is defined by : |
59 | //! its degree; the degree for a |
60 | //! Geom_BSplineCurve is limited to a value (25) |
61 | //! which is defined and controlled by the system. |
62 | //! This value is returned by the function MaxDegree; |
63 | //! - its periodic or non-periodic nature; |
64 | //! - a table of poles (also called control points), with |
65 | //! their associated weights if the BSpline curve is |
66 | //! rational. The poles of the curve are "control |
67 | //! points" used to deform the curve. If the curve is |
68 | //! non-periodic, the first pole is the start point of |
69 | //! the curve, and the last pole is the end point of |
70 | //! the curve. The segment which joins the first pole |
71 | //! to the second pole is the tangent to the curve at |
72 | //! its start point, and the segment which joins the |
73 | //! last pole to the second-from-last pole is the |
74 | //! tangent to the curve at its end point. If the curve |
75 | //! is periodic, these geometric properties are not |
76 | //! verified. It is more difficult to give a geometric |
77 | //! signification to the weights but are useful for |
78 | //! providing exact representations of the arcs of a |
79 | //! circle or ellipse. Moreover, if the weights of all the |
80 | //! poles are equal, the curve has a polynomial |
81 | //! equation; it is therefore a non-rational curve. |
82 | //! - a table of knots with their multiplicities. For a |
83 | //! Geom_BSplineCurve, the table of knots is an |
84 | //! increasing sequence of reals without repetition; |
85 | //! the multiplicities define the repetition of the knots. |
86 | //! A BSpline curve is a piecewise polynomial or |
87 | //! rational curve. The knots are the parameters of |
88 | //! junction points between two pieces. The |
89 | //! multiplicity Mult(i) of the knot Knot(i) of |
90 | //! the BSpline curve is related to the degree of |
91 | //! continuity of the curve at the knot Knot(i), |
92 | //! which is equal to Degree - Mult(i) |
93 | //! where Degree is the degree of the BSpline curve. |
94 | //! If the knots are regularly spaced (i.e. the difference |
95 | //! between two consecutive knots is a constant), three |
96 | //! specific and frequently used cases of knot |
97 | //! distribution can be identified: |
98 | //! - "uniform" if all multiplicities are equal to 1, |
99 | //! - "quasi-uniform" if all multiplicities are equal to 1, |
100 | //! except the first and the last knot which have a |
101 | //! multiplicity of Degree + 1, where Degree is |
102 | //! the degree of the BSpline curve, |
103 | //! - "Piecewise Bezier" if all multiplicities are equal to |
104 | //! Degree except the first and last knot which |
105 | //! have a multiplicity of Degree + 1, where |
106 | //! Degree is the degree of the BSpline curve. A |
107 | //! curve of this type is a concatenation of arcs of Bezier curves. |
108 | //! If the BSpline curve is not periodic: |
109 | //! - the bounds of the Poles and Weights tables are 1 |
110 | //! and NbPoles, where NbPoles is the number |
111 | //! of poles of the BSpline curve, |
112 | //! - the bounds of the Knots and Multiplicities tables |
113 | //! are 1 and NbKnots, where NbKnots is the |
114 | //! number of knots of the BSpline curve. |
115 | //! If the BSpline curve is periodic, and if there are k |
116 | //! periodic knots and p periodic poles, the period is: |
117 | //! period = Knot(k + 1) - Knot(1) |
118 | //! and the poles and knots tables can be considered |
119 | //! as infinite tables, verifying: |
120 | //! - Knot(i+k) = Knot(i) + period |
121 | //! - Pole(i+p) = Pole(i) |
122 | //! Note: data structures of a periodic BSpline curve |
123 | //! are more complex than those of a non-periodic one. |
124 | //! Warning |
125 | //! In this class, weight value is considered to be zero if |
126 | //! the weight is less than or equal to gp::Resolution(). |
127 | //! |
128 | //! References : |
129 | //! . A survey of curve and surface methods in CADG Wolfgang BOHM |
130 | //! CAGD 1 (1984) |
131 | //! . On de Boor-like algorithms and blossoming Wolfgang BOEHM |
132 | //! cagd 5 (1988) |
133 | //! . Blossoming and knot insertion algorithms for B-spline curves |
134 | //! Ronald N. GOLDMAN |
135 | //! . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA |
136 | //! . Curves and Surfaces for Computer Aided Geometric Design, |
137 | //! a practical guide Gerald Farin |
138 | class Geom_BSplineCurve : public Geom_BoundedCurve |
139 | { |
140 | |
141 | public: |
142 | |
143 | |
144 | //! Creates a non-rational B_spline curve on the |
145 | //! basis <Knots, Multiplicities> of degree <Degree>. |
146 | Standard_EXPORT Geom_BSplineCurve(const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Multiplicities, const Standard_Integer Degree, const Standard_Boolean Periodic = Standard_False); |
147 | |
148 | //! Creates a rational B_spline curve on the basis |
149 | //! <Knots, Multiplicities> of degree <Degree>. |
150 | //! Raises ConstructionError subject to the following conditions |
151 | //! 0 < Degree <= MaxDegree. |
152 | //! |
153 | //! Weights.Length() == Poles.Length() |
154 | //! |
155 | //! Knots.Length() == Mults.Length() >= 2 |
156 | //! |
157 | //! Knots(i) < Knots(i+1) (Knots are increasing) |
158 | //! |
159 | //! 1 <= Mults(i) <= Degree |
160 | //! |
161 | //! On a non periodic curve the first and last multiplicities |
162 | //! may be Degree+1 (this is even recommanded if you want the |
163 | //! curve to start and finish on the first and last pole). |
164 | //! |
165 | //! On a periodic curve the first and the last multicities |
166 | //! must be the same. |
167 | //! |
168 | //! on non-periodic curves |
169 | //! |
170 | //! Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2 |
171 | //! |
172 | //! on periodic curves |
173 | //! |
174 | //! Poles.Length() == Sum(Mults(i)) except the first or last |
175 | Standard_EXPORT Geom_BSplineCurve(const TColgp_Array1OfPnt& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Multiplicities, const Standard_Integer Degree, const Standard_Boolean Periodic = Standard_False, const Standard_Boolean CheckRational = Standard_True); |
176 | |
177 | //! Increases the degree of this BSpline curve to |
178 | //! Degree. As a result, the poles, weights and |
179 | //! multiplicities tables are modified; the knots table is |
180 | //! not changed. Nothing is done if Degree is less than |
181 | //! or equal to the current degree. |
182 | //! Exceptions |
183 | //! Standard_ConstructionError if Degree is greater than |
184 | //! Geom_BSplineCurve::MaxDegree(). |
185 | Standard_EXPORT void IncreaseDegree (const Standard_Integer Degree); |
186 | |
187 | //! Increases the multiplicity of the knot <Index> to |
188 | //! <M>. |
189 | //! |
190 | //! If <M> is lower or equal to the current |
191 | //! multiplicity nothing is done. If <M> is higher than |
192 | //! the degree the degree is used. |
193 | //! If <Index> is not in [FirstUKnotIndex, LastUKnotIndex] |
194 | Standard_EXPORT void IncreaseMultiplicity (const Standard_Integer Index, const Standard_Integer M); |
195 | |
196 | //! Increases the multiplicities of the knots in |
197 | //! [I1,I2] to <M>. |
198 | //! |
199 | //! For each knot if <M> is lower or equal to the |
200 | //! current multiplicity nothing is done. If <M> is |
201 | //! higher than the degree the degree is used. |
202 | //! If <I1,I2> are not in [FirstUKnotIndex, LastUKnotIndex] |
203 | Standard_EXPORT void IncreaseMultiplicity (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer M); |
204 | |
205 | //! Increment the multiplicities of the knots in |
206 | //! [I1,I2] by <M>. |
207 | //! |
208 | //! If <M> is not positive nithing is done. |
209 | //! |
210 | //! For each knot the resulting multiplicity is |
211 | //! limited to the Degree. |
212 | //! If <I1,I2> are not in [FirstUKnotIndex, LastUKnotIndex] |
213 | Standard_EXPORT void IncrementMultiplicity (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer M); |
214 | |
215 | //! Inserts a knot value in the sequence of knots. If |
216 | //! <U> is an existing knot the multiplicity is |
217 | //! increased by <M>. |
218 | //! |
219 | //! If U is not on the parameter range nothing is |
220 | //! done. |
221 | //! |
222 | //! If the multiplicity is negative or null nothing is |
223 | //! done. The new multiplicity is limited to the |
224 | //! degree. |
225 | //! |
226 | //! The tolerance criterion for knots equality is |
227 | //! the max of Epsilon(U) and ParametricTolerance. |
228 | Standard_EXPORT void InsertKnot (const Standard_Real U, const Standard_Integer M = 1, const Standard_Real ParametricTolerance = 0.0, const Standard_Boolean Add = Standard_True); |
229 | |
230 | //! Inserts a set of knots values in the sequence of |
231 | //! knots. |
232 | //! |
233 | //! For each U = Knots(i), M = Mults(i) |
234 | //! |
235 | //! If <U> is an existing knot the multiplicity is |
236 | //! increased by <M> if <Add> is True, increased to |
237 | //! <M> if <Add> is False. |
238 | //! |
239 | //! If U is not on the parameter range nothing is |
240 | //! done. |
241 | //! |
242 | //! If the multiplicity is negative or null nothing is |
243 | //! done. The new multiplicity is limited to the |
244 | //! degree. |
245 | //! |
246 | //! The tolerance criterion for knots equality is |
247 | //! the max of Epsilon(U) and ParametricTolerance. |
248 | Standard_EXPORT void InsertKnots (const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Mults, const Standard_Real ParametricTolerance = 0.0, const Standard_Boolean Add = Standard_False); |
249 | |
250 | //! Reduces the multiplicity of the knot of index Index |
251 | //! to M. If M is equal to 0, the knot is removed. |
252 | //! With a modification of this type, the array of poles is also modified. |
253 | //! Two different algorithms are systematically used to |
254 | //! compute the new poles of the curve. If, for each |
255 | //! pole, the distance between the pole calculated |
256 | //! using the first algorithm and the same pole |
257 | //! calculated using the second algorithm, is less than |
258 | //! Tolerance, this ensures that the curve is not |
259 | //! modified by more than Tolerance. Under these |
260 | //! conditions, true is returned; otherwise, false is returned. |
261 | //! A low tolerance is used to prevent modification of |
262 | //! the curve. A high tolerance is used to "smooth" the curve. |
263 | //! Exceptions |
264 | //! Standard_OutOfRange if Index is outside the |
265 | //! bounds of the knots table. |
266 | //! pole insertion and pole removing |
267 | //! this operation is limited to the Uniform or QuasiUniform |
268 | //! BSplineCurve. The knot values are modified . If the BSpline is |
269 | //! NonUniform or Piecewise Bezier an exception Construction error |
270 | //! is raised. |
271 | Standard_EXPORT Standard_Boolean RemoveKnot (const Standard_Integer Index, const Standard_Integer M, const Standard_Real Tolerance); |
272 | |
273 | |
274 | //! Changes the direction of parametrization of <me>. The Knot |
275 | //! sequence is modified, the FirstParameter and the |
276 | //! LastParameter are not modified. The StartPoint of the |
277 | //! initial curve becomes the EndPoint of the reversed curve |
278 | //! and the EndPoint of the initial curve becomes the StartPoint |
279 | //! of the reversed curve. |
79104795 |
280 | Standard_EXPORT void Reverse() Standard_OVERRIDE; |
42cf5bc1 |
281 | |
282 | //! Returns the parameter on the reversed curve for |
283 | //! the point of parameter U on <me>. |
284 | //! |
285 | //! returns UFirst + ULast - U |
79104795 |
286 | Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE; |
42cf5bc1 |
287 | |
288 | //! Modifies this BSpline curve by segmenting it between |
289 | //! U1 and U2. Either of these values can be outside the |
290 | //! bounds of the curve, but U2 must be greater than U1. |
291 | //! All data structure tables of this BSpline curve are |
292 | //! modified, but the knots located between U1 and U2 |
293 | //! are retained. The degree of the curve is not modified. |
6fd9bdf2 |
294 | //! |
295 | //! Parameter theTolerance defines the possible proximity of the segment |
296 | //! boundaries and B-spline knots to treat them as equal. |
297 | //! |
42cf5bc1 |
298 | //! Warnings : |
299 | //! Even if <me> is not closed it can become closed after the |
300 | //! segmentation for example if U1 or U2 are out of the bounds |
301 | //! of the curve <me> or if the curve makes loop. |
302 | //! After the segmentation the length of a curve can be null. |
303 | //! raises if U2 < U1. |
369a38aa |
304 | //! Standard_DomainError if U2 - U1 exceeds the period for periodic curves. |
305 | //! i.e. ((U2 - U1) - Period) > Precision::PConfusion(). |
6fd9bdf2 |
306 | Standard_EXPORT void Segment (const Standard_Real U1, const Standard_Real U2, |
307 | const Standard_Real theTolerance = Precision::PConfusion()); |
42cf5bc1 |
308 | |
309 | //! Modifies this BSpline curve by assigning the value K |
310 | //! to the knot of index Index in the knots table. This is a |
311 | //! relatively local modification because K must be such that: |
312 | //! Knots(Index - 1) < K < Knots(Index + 1) |
313 | //! The second syntax allows you also to increase the |
314 | //! multiplicity of the knot to M (but it is not possible to |
315 | //! decrease the multiplicity of the knot with this function). |
316 | //! Standard_ConstructionError if: |
317 | //! - K is not such that: |
318 | //! Knots(Index - 1) < K < Knots(Index + 1) |
319 | //! - M is greater than the degree of this BSpline curve |
320 | //! or lower than the previous multiplicity of knot of |
321 | //! index Index in the knots table. |
322 | //! Standard_OutOfRange if Index is outside the bounds of the knots table. |
323 | Standard_EXPORT void SetKnot (const Standard_Integer Index, const Standard_Real K); |
324 | |
325 | //! Modifies this BSpline curve by assigning the array |
326 | //! K to its knots table. The multiplicity of the knots is not modified. |
327 | //! Exceptions |
328 | //! Standard_ConstructionError if the values in the |
329 | //! array K are not in ascending order. |
330 | //! Standard_OutOfRange if the bounds of the array |
331 | //! K are not respectively 1 and the number of knots of this BSpline curve. |
332 | Standard_EXPORT void SetKnots (const TColStd_Array1OfReal& K); |
333 | |
334 | |
335 | //! Changes the knot of range Index with its multiplicity. |
336 | //! You can increase the multiplicity of a knot but it is |
337 | //! not allowed to decrease the multiplicity of an existing knot. |
338 | //! |
339 | //! Raised if K >= Knots(Index+1) or K <= Knots(Index-1). |
340 | //! Raised if M is greater than Degree or lower than the previous |
341 | //! multiplicity of knot of range Index. |
342 | //! Raised if Index < 1 || Index > NbKnots |
343 | Standard_EXPORT void SetKnot (const Standard_Integer Index, const Standard_Real K, const Standard_Integer M); |
344 | |
345 | //! returns the parameter normalized within |
346 | //! the period if the curve is periodic : otherwise |
347 | //! does not do anything |
348 | Standard_EXPORT void PeriodicNormalization (Standard_Real& U) const; |
349 | |
350 | //! Changes this BSpline curve into a periodic curve. |
351 | //! To become periodic, the curve must first be closed. |
352 | //! Next, the knot sequence must be periodic. For this, |
353 | //! FirstUKnotIndex and LastUKnotIndex are used |
354 | //! to compute I1 and I2, the indexes in the knots |
355 | //! array of the knots corresponding to the first and |
356 | //! last parameters of this BSpline curve. |
357 | //! The period is therefore: Knots(I2) - Knots(I1). |
358 | //! Consequently, the knots and poles tables are modified. |
359 | //! Exceptions |
360 | //! Standard_ConstructionError if this BSpline curve is not closed. |
361 | Standard_EXPORT void SetPeriodic(); |
362 | |
363 | //! Assigns the knot of index Index in the knots table as |
364 | //! the origin of this periodic BSpline curve. As a |
365 | //! consequence, the knots and poles tables are modified. |
366 | //! Exceptions |
367 | //! Standard_NoSuchObject if this curve is not periodic. |
368 | //! Standard_DomainError if Index is outside the bounds of the knots table. |
369 | Standard_EXPORT void SetOrigin (const Standard_Integer Index); |
370 | |
371 | //! Set the origin of a periodic curve at Knot U. If U |
372 | //! is not a knot of the BSpline a new knot is |
373 | //! inseted. KnotVector and poles are modified. |
374 | //! Raised if the curve is not periodic |
375 | Standard_EXPORT void SetOrigin (const Standard_Real U, const Standard_Real Tol); |
376 | |
377 | //! Changes this BSpline curve into a non-periodic |
378 | //! curve. If this curve is already non-periodic, it is not modified. |
379 | //! Note: the poles and knots tables are modified. |
380 | //! Warning |
381 | //! If this curve is periodic, as the multiplicity of the first |
382 | //! and last knots is not modified, and is not equal to |
383 | //! Degree + 1, where Degree is the degree of |
384 | //! this BSpline curve, the start and end points of the |
385 | //! curve are not its first and last poles. |
386 | Standard_EXPORT void SetNotPeriodic(); |
387 | |
388 | //! Modifies this BSpline curve by assigning P to the pole |
389 | //! of index Index in the poles table. |
390 | //! Exceptions |
391 | //! Standard_OutOfRange if Index is outside the |
392 | //! bounds of the poles table. |
393 | //! Standard_ConstructionError if Weight is negative or null. |
394 | Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt& P); |
395 | |
396 | //! Modifies this BSpline curve by assigning P to the pole |
397 | //! of index Index in the poles table. |
398 | //! This syntax also allows you to modify the |
399 | //! weight of the modified pole, which becomes Weight. |
400 | //! In this case, if this BSpline curve is non-rational, it |
401 | //! can become rational and vice versa. |
402 | //! Exceptions |
403 | //! Standard_OutOfRange if Index is outside the |
404 | //! bounds of the poles table. |
405 | //! Standard_ConstructionError if Weight is negative or null. |
406 | Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt& P, const Standard_Real Weight); |
407 | |
408 | |
409 | //! Changes the weight for the pole of range Index. |
410 | //! If the curve was non rational it can become rational. |
411 | //! If the curve was rational it can become non rational. |
412 | //! |
413 | //! Raised if Index < 1 || Index > NbPoles |
414 | //! Raised if Weight <= 0.0 |
415 | Standard_EXPORT void SetWeight (const Standard_Integer Index, const Standard_Real Weight); |
416 | |
417 | //! Moves the point of parameter U of this BSpline curve |
418 | //! to P. Index1 and Index2 are the indexes in the table |
419 | //! of poles of this BSpline curve of the first and last |
420 | //! poles designated to be moved. |
421 | //! FirstModifiedPole and LastModifiedPole are the |
422 | //! indexes of the first and last poles which are effectively modified. |
423 | //! In the event of incompatibility between Index1, Index2 and the value U: |
424 | //! - no change is made to this BSpline curve, and |
425 | //! - the FirstModifiedPole and LastModifiedPole are returned null. |
426 | //! Exceptions |
427 | //! Standard_OutOfRange if: |
428 | //! - Index1 is greater than or equal to Index2, or |
429 | //! - Index1 or Index2 is less than 1 or greater than the |
430 | //! number of poles of this BSpline curve. |
431 | Standard_EXPORT void MovePoint (const Standard_Real U, const gp_Pnt& P, const Standard_Integer Index1, const Standard_Integer Index2, Standard_Integer& FirstModifiedPole, Standard_Integer& LastModifiedPole); |
432 | |
433 | |
434 | //! Move a point with parameter U to P. |
435 | //! and makes it tangent at U be Tangent. |
436 | //! StartingCondition = -1 means first can move |
437 | //! EndingCondition = -1 means last point can move |
438 | //! StartingCondition = 0 means the first point cannot move |
439 | //! EndingCondition = 0 means the last point cannot move |
440 | //! StartingCondition = 1 means the first point and tangent cannot move |
441 | //! EndingCondition = 1 means the last point and tangent cannot move |
442 | //! and so forth |
443 | //! ErrorStatus != 0 means that there are not enought degree of freedom |
444 | //! with the constrain to deform the curve accordingly |
445 | Standard_EXPORT void MovePointAndTangent (const Standard_Real U, const gp_Pnt& P, const gp_Vec& Tangent, const Standard_Real Tolerance, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, Standard_Integer& ErrorStatus); |
446 | |
447 | |
448 | //! Returns the continuity of the curve, the curve is at least C0. |
449 | //! Raised if N < 0. |
79104795 |
450 | Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE; |
42cf5bc1 |
451 | |
452 | |
453 | //! Check if curve has at least G1 continuity in interval [theTf, theTl] |
454 | //! Returns true if IsCN(1) |
455 | //! or |
456 | //! angle betweem "left" and "right" first derivatives at |
457 | //! knots with C0 continuity is less then theAngTol |
458 | //! only knots in interval [theTf, theTl] is checked |
459 | Standard_EXPORT Standard_Boolean IsG1 (const Standard_Real theTf, const Standard_Real theTl, const Standard_Real theAngTol) const; |
460 | |
461 | |
462 | //! Returns true if the distance between the first point and the |
463 | //! last point of the curve is lower or equal to Resolution |
464 | //! from package gp. |
465 | //! Warnings : |
466 | //! The first and the last point can be different from the first |
467 | //! pole and the last pole of the curve. |
79104795 |
468 | Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; |
42cf5bc1 |
469 | |
470 | //! Returns True if the curve is periodic. |
79104795 |
471 | Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; |
42cf5bc1 |
472 | |
473 | |
474 | //! Returns True if the weights are not identical. |
475 | //! The tolerance criterion is Epsilon of the class Real. |
476 | Standard_EXPORT Standard_Boolean IsRational() const; |
477 | |
478 | |
479 | //! Returns the global continuity of the curve : |
480 | //! C0 : only geometric continuity, |
481 | //! C1 : continuity of the first derivative all along the Curve, |
482 | //! C2 : continuity of the second derivative all along the Curve, |
483 | //! C3 : continuity of the third derivative all along the Curve, |
484 | //! CN : the order of continuity is infinite. |
485 | //! For a B-spline curve of degree d if a knot Ui has a |
486 | //! multiplicity p the B-spline curve is only Cd-p continuous |
487 | //! at Ui. So the global continuity of the curve can't be greater |
488 | //! than Cd-p where p is the maximum multiplicity of the interior |
489 | //! Knots. In the interior of a knot span the curve is infinitely |
490 | //! continuously differentiable. |
79104795 |
491 | Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; |
42cf5bc1 |
492 | |
493 | //! Returns the degree of this BSpline curve. |
494 | //! The degree of a Geom_BSplineCurve curve cannot |
495 | //! be greater than Geom_BSplineCurve::MaxDegree(). |
496 | //! Computation of value and derivatives |
497 | Standard_EXPORT Standard_Integer Degree() const; |
498 | |
499 | //! Returns in P the point of parameter U. |
79104795 |
500 | Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE; |
42cf5bc1 |
501 | |
502 | //! Raised if the continuity of the curve is not C1. |
79104795 |
503 | Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const Standard_OVERRIDE; |
42cf5bc1 |
504 | |
505 | //! Raised if the continuity of the curve is not C2. |
79104795 |
506 | Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE; |
42cf5bc1 |
507 | |
508 | //! Raised if the continuity of the curve is not C3. |
79104795 |
509 | Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE; |
42cf5bc1 |
510 | |
511 | //! For the point of parameter U of this BSpline curve, |
512 | //! computes the vector corresponding to the Nth derivative. |
513 | //! Warning |
514 | //! On a point where the continuity of the curve is not the |
515 | //! one requested, this function impacts the part defined |
516 | //! by the parameter with a value greater than U, i.e. the |
517 | //! part of the curve to the "right" of the singularity. |
518 | //! Exceptions |
519 | //! Standard_RangeError if N is less than 1. |
520 | //! |
521 | //! The following functions compute the point of parameter U |
522 | //! and the derivatives at this point on the B-spline curve |
523 | //! arc defined between the knot FromK1 and the knot ToK2. |
524 | //! U can be out of bounds [Knot (FromK1), Knot (ToK2)] but |
525 | //! for the computation we only use the definition of the curve |
526 | //! between these two knots. This method is useful to compute |
527 | //! local derivative, if the order of continuity of the whole |
528 | //! curve is not greater enough. Inside the parametric |
529 | //! domain Knot (FromK1), Knot (ToK2) the evaluations are |
530 | //! the same as if we consider the whole definition of the |
531 | //! curve. Of course the evaluations are different outside |
532 | //! this parametric domain. |
79104795 |
533 | Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; |
42cf5bc1 |
534 | |
535 | //! Raised if FromK1 = ToK2. |
42cf5bc1 |
536 | Standard_EXPORT gp_Pnt LocalValue (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2) const; |
537 | |
538 | //! Raised if FromK1 = ToK2. |
42cf5bc1 |
539 | Standard_EXPORT void LocalD0 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt& P) const; |
540 | |
541 | |
542 | //! Raised if the local continuity of the curve is not C1 |
543 | //! between the knot K1 and the knot K2. |
544 | //! Raised if FromK1 = ToK2. |
42cf5bc1 |
545 | Standard_EXPORT void LocalD1 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt& P, gp_Vec& V1) const; |
546 | |
547 | |
548 | //! Raised if the local continuity of the curve is not C2 |
549 | //! between the knot K1 and the knot K2. |
550 | //! Raised if FromK1 = ToK2. |
42cf5bc1 |
551 | Standard_EXPORT void LocalD2 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const; |
552 | |
553 | |
554 | //! Raised if the local continuity of the curve is not C3 |
555 | //! between the knot K1 and the knot K2. |
556 | //! Raised if FromK1 = ToK2. |
42cf5bc1 |
557 | Standard_EXPORT void LocalD3 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const; |
558 | |
559 | |
560 | //! Raised if the local continuity of the curve is not CN |
561 | //! between the knot K1 and the knot K2. |
562 | //! Raised if FromK1 = ToK2. |
563 | //! Raised if N < 1. |
42cf5bc1 |
564 | Standard_EXPORT gp_Vec LocalDN (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, const Standard_Integer N) const; |
565 | |
566 | |
567 | //! Returns the last point of the curve. |
568 | //! Warnings : |
569 | //! The last point of the curve is different from the last |
570 | //! pole of the curve if the multiplicity of the last knot |
571 | //! is lower than Degree. |
79104795 |
572 | Standard_EXPORT gp_Pnt EndPoint() const Standard_OVERRIDE; |
42cf5bc1 |
573 | |
574 | //! Returns the index in the knot array of the knot |
575 | //! corresponding to the first or last parameter of this BSpline curve. |
576 | //! For a BSpline curve, the first (or last) parameter |
577 | //! (which gives the start (or end) point of the curve) is a |
578 | //! knot value. However, if the multiplicity of the first (or |
579 | //! last) knot is less than Degree + 1, where |
580 | //! Degree is the degree of the curve, it is not the first |
581 | //! (or last) knot of the curve. |
582 | Standard_EXPORT Standard_Integer FirstUKnotIndex() const; |
583 | |
584 | //! Returns the value of the first parameter of this |
585 | //! BSpline curve. This is a knot value. |
586 | //! The first parameter is the one of the start point of the BSpline curve. |
79104795 |
587 | Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; |
42cf5bc1 |
588 | |
589 | |
590 | //! Returns the knot of range Index. When there is a knot |
591 | //! with a multiplicity greater than 1 the knot is not repeated. |
592 | //! The method Multiplicity can be used to get the multiplicity |
593 | //! of the Knot. |
594 | //! Raised if Index < 1 or Index > NbKnots |
595 | Standard_EXPORT Standard_Real Knot (const Standard_Integer Index) const; |
596 | |
597 | //! returns the knot values of the B-spline curve; |
598 | //! Warning |
599 | //! A knot with a multiplicity greater than 1 is not |
600 | //! repeated in the knot table. The Multiplicity function |
601 | //! can be used to obtain the multiplicity of each knot. |
602 | //! |
369a38aa |
603 | //! Raised K.Lower() is less than number of first knot or |
604 | //! K.Upper() is more than number of last knot. |
42cf5bc1 |
605 | Standard_EXPORT void Knots (TColStd_Array1OfReal& K) const; |
606 | |
607 | //! returns the knot values of the B-spline curve; |
608 | //! Warning |
609 | //! A knot with a multiplicity greater than 1 is not |
610 | //! repeated in the knot table. The Multiplicity function |
611 | //! can be used to obtain the multiplicity of each knot. |
612 | Standard_EXPORT const TColStd_Array1OfReal& Knots() const; |
613 | |
614 | //! Returns K, the knots sequence of this BSpline curve. |
615 | //! In this sequence, knots with a multiplicity greater than 1 are repeated. |
616 | //! In the case of a non-periodic curve the length of the |
617 | //! sequence must be equal to the sum of the NbKnots |
618 | //! multiplicities of the knots of the curve (where |
619 | //! NbKnots is the number of knots of this BSpline |
620 | //! curve). This sum is also equal to : NbPoles + Degree + 1 |
621 | //! where NbPoles is the number of poles and |
622 | //! Degree the degree of this BSpline curve. |
623 | //! In the case of a periodic curve, if there are k periodic |
624 | //! knots, the period is Knot(k+1) - Knot(1). |
625 | //! The initial sequence is built by writing knots 1 to k+1, |
626 | //! which are repeated according to their corresponding multiplicities. |
627 | //! If Degree is the degree of the curve, the degree of |
628 | //! continuity of the curve at the knot of index 1 (or k+1) |
629 | //! is equal to c = Degree + 1 - Mult(1). c |
630 | //! knots are then inserted at the beginning and end of |
631 | //! the initial sequence: |
632 | //! - the c values of knots preceding the first item |
633 | //! Knot(k+1) in the initial sequence are inserted |
634 | //! at the beginning; the period is subtracted from these c values; |
635 | //! - the c values of knots following the last item |
636 | //! Knot(1) in the initial sequence are inserted at |
637 | //! the end; the period is added to these c values. |
638 | //! The length of the sequence must therefore be equal to: |
639 | //! NbPoles + 2*Degree - Mult(1) + 2. |
640 | //! Example |
641 | //! For a non-periodic BSpline curve of degree 2 where: |
642 | //! - the array of knots is: { k1 k2 k3 k4 }, |
643 | //! - with associated multiplicities: { 3 1 2 3 }, |
644 | //! the knot sequence is: |
645 | //! K = { k1 k1 k1 k2 k3 k3 k4 k4 k4 } |
646 | //! For a periodic BSpline curve of degree 4 , which is |
647 | //! "C1" continuous at the first knot, and where : |
648 | //! - the periodic knots are: { k1 k2 k3 (k4) } |
649 | //! (3 periodic knots: the points of parameter k1 and k4 |
650 | //! are identical, the period is p = k4 - k1), |
651 | //! - with associated multiplicities: { 3 1 2 (3) }, |
652 | //! the degree of continuity at knots k1 and k4 is: |
653 | //! Degree + 1 - Mult(i) = 2. |
654 | //! 2 supplementary knots are added at the beginning |
655 | //! and end of the sequence: |
656 | //! - at the beginning: the 2 knots preceding k4 minus |
657 | //! the period; in this example, this is k3 - p both times; |
658 | //! - at the end: the 2 knots following k1 plus the period; |
659 | //! in this example, this is k2 + p and k3 + p. |
660 | //! The knot sequence is therefore: |
661 | //! K = { k3-p k3-p k1 k1 k1 k2 k3 k3 |
662 | //! k4 k4 k4 k2+p k3+p } |
663 | //! Exceptions |
369a38aa |
664 | //! Raised if K.Lower() is less than number of first knot |
665 | //! in knot sequence with repetitions or K.Upper() is more |
666 | //! than number of last knot in knot sequence with repetitions. |
42cf5bc1 |
667 | Standard_EXPORT void KnotSequence (TColStd_Array1OfReal& K) const; |
668 | |
669 | //! returns the knots of the B-spline curve. |
670 | //! Knots with multiplicit greater than 1 are repeated |
671 | Standard_EXPORT const TColStd_Array1OfReal& KnotSequence() const; |
672 | |
673 | |
674 | //! Returns NonUniform or Uniform or QuasiUniform or PiecewiseBezier. |
675 | //! If all the knots differ by a positive constant from the |
676 | //! preceding knot the BSpline Curve can be : |
677 | //! - Uniform if all the knots are of multiplicity 1, |
678 | //! - QuasiUniform if all the knots are of multiplicity 1 except for |
679 | //! the first and last knot which are of multiplicity Degree + 1, |
680 | //! - PiecewiseBezier if the first and last knots have multiplicity |
681 | //! Degree + 1 and if interior knots have multiplicity Degree |
682 | //! A piecewise Bezier with only two knots is a BezierCurve. |
683 | //! else the curve is non uniform. |
684 | //! The tolerance criterion is Epsilon from class Real. |
685 | Standard_EXPORT GeomAbs_BSplKnotDistribution KnotDistribution() const; |
686 | |
687 | |
688 | //! For a BSpline curve the last parameter (which gives the |
689 | //! end point of the curve) is a knot value but if the |
690 | //! multiplicity of the last knot index is lower than |
691 | //! Degree + 1 it is not the last knot of the curve. This |
692 | //! method computes the index of the knot corresponding to |
693 | //! the last parameter. |
694 | Standard_EXPORT Standard_Integer LastUKnotIndex() const; |
695 | |
696 | |
697 | //! Computes the parametric value of the end point of the curve. |
698 | //! It is a knot value. |
79104795 |
699 | Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; |
42cf5bc1 |
700 | |
701 | |
702 | //! Locates the parametric value U in the sequence of knots. |
703 | //! If "WithKnotRepetition" is True we consider the knot's |
704 | //! representation with repetition of multiple knot value, |
705 | //! otherwise we consider the knot's representation with |
706 | //! no repetition of multiple knot values. |
707 | //! Knots (I1) <= U <= Knots (I2) |
708 | //! . if I1 = I2 U is a knot value (the tolerance criterion |
709 | //! ParametricTolerance is used). |
710 | //! . if I1 < 1 => U < Knots (1) - Abs(ParametricTolerance) |
711 | //! . if I2 > NbKnots => U > Knots (NbKnots) + Abs(ParametricTolerance) |
712 | Standard_EXPORT void LocateU (const Standard_Real U, const Standard_Real ParametricTolerance, Standard_Integer& I1, Standard_Integer& I2, const Standard_Boolean WithKnotRepetition = Standard_False) const; |
713 | |
714 | |
715 | //! Returns the multiplicity of the knots of range Index. |
716 | //! Raised if Index < 1 or Index > NbKnots |
717 | Standard_EXPORT Standard_Integer Multiplicity (const Standard_Integer Index) const; |
718 | |
719 | |
720 | //! Returns the multiplicity of the knots of the curve. |
721 | //! |
722 | //! Raised if the length of M is not equal to NbKnots. |
723 | Standard_EXPORT void Multiplicities (TColStd_Array1OfInteger& M) const; |
724 | |
725 | //! returns the multiplicity of the knots of the curve. |
726 | Standard_EXPORT const TColStd_Array1OfInteger& Multiplicities() const; |
727 | |
728 | |
729 | //! Returns the number of knots. This method returns the number of |
730 | //! knot without repetition of multiple knots. |
731 | Standard_EXPORT Standard_Integer NbKnots() const; |
732 | |
733 | //! Returns the number of poles |
734 | Standard_EXPORT Standard_Integer NbPoles() const; |
735 | |
736 | //! Returns the pole of range Index. |
737 | //! Raised if Index < 1 or Index > NbPoles. |
81093856 |
738 | Standard_EXPORT const gp_Pnt& Pole(const Standard_Integer Index) const; |
42cf5bc1 |
739 | |
740 | //! Returns the poles of the B-spline curve; |
741 | //! |
742 | //! Raised if the length of P is not equal to the number of poles. |
743 | Standard_EXPORT void Poles (TColgp_Array1OfPnt& P) const; |
744 | |
745 | //! Returns the poles of the B-spline curve; |
746 | Standard_EXPORT const TColgp_Array1OfPnt& Poles() const; |
747 | |
748 | |
749 | //! Returns the start point of the curve. |
750 | //! Warnings : |
751 | //! This point is different from the first pole of the curve if the |
752 | //! multiplicity of the first knot is lower than Degree. |
79104795 |
753 | Standard_EXPORT gp_Pnt StartPoint() const Standard_OVERRIDE; |
42cf5bc1 |
754 | |
755 | //! Returns the weight of the pole of range Index . |
756 | //! Raised if Index < 1 or Index > NbPoles. |
757 | Standard_EXPORT Standard_Real Weight (const Standard_Integer Index) const; |
758 | |
759 | //! Returns the weights of the B-spline curve; |
760 | //! |
761 | //! Raised if the length of W is not equal to NbPoles. |
762 | Standard_EXPORT void Weights (TColStd_Array1OfReal& W) const; |
763 | |
764 | //! Returns the weights of the B-spline curve; |
0e14656b |
765 | Standard_EXPORT const TColStd_Array1OfReal* Weights() const; |
42cf5bc1 |
766 | |
767 | //! Applies the transformation T to this BSpline curve. |
79104795 |
768 | Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE; |
42cf5bc1 |
769 | |
770 | |
771 | //! Returns the value of the maximum degree of the normalized |
772 | //! B-spline basis functions in this package. |
773 | Standard_EXPORT static Standard_Integer MaxDegree(); |
774 | |
775 | //! Computes for this BSpline curve the parametric |
776 | //! tolerance UTolerance for a given 3D tolerance Tolerance3D. |
777 | //! If f(t) is the equation of this BSpline curve, |
778 | //! UTolerance ensures that: |
779 | //! | t1 - t0| < Utolerance ===> |
780 | //! |f(t1) - f(t0)| < Tolerance3D |
781 | Standard_EXPORT void Resolution (const Standard_Real Tolerance3D, Standard_Real& UTolerance); |
782 | |
783 | //! Creates a new object which is a copy of this BSpline curve. |
79104795 |
784 | Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE; |
42cf5bc1 |
785 | |
786 | //! Comapare two Bspline curve on identity; |
787 | Standard_EXPORT Standard_Boolean IsEqual (const Handle(Geom_BSplineCurve)& theOther, const Standard_Real thePreci) const; |
788 | |
bc73b006 |
789 | //! Dumps the content of me into the stream |
790 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
791 | |
42cf5bc1 |
792 | |
793 | |
794 | |
92efcf78 |
795 | DEFINE_STANDARD_RTTIEXT(Geom_BSplineCurve,Geom_BoundedCurve) |
42cf5bc1 |
796 | |
797 | protected: |
798 | |
799 | |
800 | |
801 | |
802 | private: |
803 | |
804 | |
805 | //! Recompute the flatknots, the knotsdistribution, the continuity. |
806 | Standard_EXPORT void UpdateKnots(); |
807 | |
808 | Standard_Boolean rational; |
809 | Standard_Boolean periodic; |
810 | GeomAbs_BSplKnotDistribution knotSet; |
811 | GeomAbs_Shape smooth; |
812 | Standard_Integer deg; |
813 | Handle(TColgp_HArray1OfPnt) poles; |
814 | Handle(TColStd_HArray1OfReal) weights; |
815 | Handle(TColStd_HArray1OfReal) flatknots; |
816 | Handle(TColStd_HArray1OfReal) knots; |
817 | Handle(TColStd_HArray1OfInteger) mults; |
818 | Standard_Real maxderivinv; |
819 | Standard_Boolean maxderivinvok; |
820 | |
821 | |
822 | }; |
823 | |
824 | |
825 | |
826 | |
827 | |
828 | |
829 | |
830 | #endif // _Geom_BSplineCurve_HeaderFile |