1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Geom2d_BSplineCurve_HeaderFile
18 #define _Geom2d_BSplineCurve_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Boolean.hxx>
24 #include <GeomAbs_BSplKnotDistribution.hxx>
25 #include <GeomAbs_Shape.hxx>
26 #include <Standard_Integer.hxx>
27 #include <TColgp_HArray1OfPnt2d.hxx>
28 #include <TColStd_HArray1OfReal.hxx>
29 #include <TColStd_HArray1OfInteger.hxx>
30 #include <Standard_Real.hxx>
31 #include <Geom2d_BoundedCurve.hxx>
32 #include <TColgp_Array1OfPnt2d.hxx>
33 #include <TColStd_Array1OfReal.hxx>
34 #include <TColStd_Array1OfInteger.hxx>
35 class Standard_ConstructionError;
36 class Standard_DimensionError;
37 class Standard_DomainError;
38 class Standard_OutOfRange;
39 class Standard_RangeError;
40 class Standard_NoSuchObject;
41 class Geom2d_UndefinedDerivative;
45 class Geom2d_Geometry;
48 class Geom2d_BSplineCurve;
49 DEFINE_STANDARD_HANDLE(Geom2d_BSplineCurve, Geom2d_BoundedCurve)
51 //! Describes a BSpline curve.
52 //! A BSpline curve can be:
53 //! - uniform or non-uniform,
54 //! - rational or non-rational,
55 //! - periodic or non-periodic.
56 //! A BSpline curve is defined by:
57 //! - its degree; the degree for a
58 //! Geom2d_BSplineCurve is limited to a value (25)
59 //! which is defined and controlled by the system. This
60 //! value is returned by the function MaxDegree;
61 //! - its periodic or non-periodic nature;
62 //! - a table of poles (also called control points), with
63 //! their associated weights if the BSpline curve is
64 //! rational. The poles of the curve are "control points"
65 //! used to deform the curve. If the curve is
66 //! non-periodic, the first pole is the start point of the
67 //! curve, and the last pole is the end point of the
68 //! curve. The segment, which joins the first pole to the
69 //! second pole, is the tangent to the curve at its start
70 //! point, and the segment, which joins the last pole to
71 //! the second-from-last pole, is the tangent to the
72 //! curve at its end point. If the curve is periodic, these
73 //! geometric properties are not verified. It is more
74 //! difficult to give a geometric signification to the
75 //! weights but they are useful for providing exact
76 //! representations of the arcs of a circle or ellipse.
77 //! Moreover, if the weights of all the poles are equal,
78 //! the curve has a polynomial equation; it is
79 //! therefore a non-rational curve.
80 //! - a table of knots with their multiplicities. For a
81 //! Geom2d_BSplineCurve, the table of knots is an
82 //! increasing sequence of reals without repetition; the
83 //! multiplicities define the repetition of the knots. A
84 //! BSpline curve is a piecewise polynomial or rational
85 //! curve. The knots are the parameters of junction
86 //! points between two pieces. The multiplicity
87 //! Mult(i) of the knot Knot(i) of the BSpline
88 //! curve is related to the degree of continuity of the
89 //! curve at the knot Knot(i), which is equal to
90 //! Degree - Mult(i) where Degree is the
91 //! degree of the BSpline curve.
92 //! If the knots are regularly spaced (i.e. the difference
93 //! between two consecutive knots is a constant), three
94 //! specific and frequently used cases of knot distribution
95 //! can be identified:
96 //! - "uniform" if all multiplicities are equal to 1,
97 //! - "quasi-uniform" if all multiplicities are equal to 1,
98 //! except the first and the last knot which have a
99 //! multiplicity of Degree + 1, where Degree is
100 //! the degree of the BSpline curve,
101 //! - "Piecewise Bezier" if all multiplicities are equal to
102 //! Degree except the first and last knot which have
103 //! a multiplicity of Degree + 1, where Degree is
104 //! the degree of the BSpline curve. A curve of this
105 //! type is a concatenation of arcs of Bezier curves.
106 //! If the BSpline curve is not periodic:
107 //! - the bounds of the Poles and Weights tables are 1
108 //! and NbPoles, where NbPoles is the number of
109 //! poles of the BSpline curve,
110 //! - the bounds of the Knots and Multiplicities tables are
111 //! 1 and NbKnots, where NbKnots is the number
112 //! of knots of the BSpline curve.
113 //! If the BSpline curve is periodic, and if there are k
114 //! periodic knots and p periodic poles, the period is:
115 //! period = Knot(k + 1) - Knot(1)
116 //! and the poles and knots tables can be considered as
117 //! infinite tables, such that:
118 //! - Knot(i+k) = Knot(i) + period
119 //! - Pole(i+p) = Pole(i)
120 //! Note: data structures of a periodic BSpline curve are
121 //! more complex than those of a non-periodic one.
123 //! In this class we consider that a weight value is zero if
124 //! Weight <= Resolution from package gp.
125 //! For two parametric values (or two knot values) U1, U2 we
126 //! consider that U1 = U2 if Abs (U2 - U1) <= Epsilon (U1).
127 //! For two weights values W1, W2 we consider that W1 = W2 if
128 //! Abs (W2 - W1) <= Epsilon (W1). The method Epsilon is
129 //! defined in the class Real from package Standard.
132 //! . A survey of curve and surface methods in CADG Wolfgang BOHM
134 //! . On de Boor-like algorithms and blossoming Wolfgang BOEHM
136 //! . Blossoming and knot insertion algorithms for B-spline curves
137 //! Ronald N. GOLDMAN
138 //! . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA
139 //! . Curves and Surfaces for Computer Aided Geometric Design,
140 //! a practical guide Gerald Farin
141 class Geom2d_BSplineCurve : public Geom2d_BoundedCurve
147 //! Creates a non-rational B_spline curve on the
148 //! basis <Knots, Multiplicities> of degree <Degree>.
149 //! The following conditions must be verified.
150 //! 0 < Degree <= MaxDegree.
152 //! Knots.Length() == Mults.Length() >= 2
154 //! Knots(i) < Knots(i+1) (Knots are increasing)
156 //! 1 <= Mults(i) <= Degree
158 //! On a non periodic curve the first and last multiplicities
159 //! may be Degree+1 (this is even recommanded if you want the
160 //! curve to start and finish on the first and last pole).
162 //! On a periodic curve the first and the last multicities
163 //! must be the same.
165 //! on non-periodic curves
167 //! Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2
169 //! on periodic curves
171 //! Poles.Length() == Sum(Mults(i)) except the first or last
172 Standard_EXPORT Geom2d_BSplineCurve(const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Multiplicities, const Standard_Integer Degree, const Standard_Boolean Periodic = Standard_False);
174 //! Creates a rational B_spline curve on the basis
175 //! <Knots, Multiplicities> of degree <Degree>.
176 //! The following conditions must be verified.
177 //! 0 < Degree <= MaxDegree.
179 //! Knots.Length() == Mults.Length() >= 2
181 //! Knots(i) < Knots(i+1) (Knots are increasing)
183 //! 1 <= Mults(i) <= Degree
185 //! On a non periodic curve the first and last multiplicities
186 //! may be Degree+1 (this is even recommanded if you want the
187 //! curve to start and finish on the first and last pole).
189 //! On a periodic curve the first and the last multicities
190 //! must be the same.
192 //! on non-periodic curves
194 //! Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2
196 //! on periodic curves
198 //! Poles.Length() == Sum(Mults(i)) except the first or last
199 Standard_EXPORT Geom2d_BSplineCurve(const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal& Weights, const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Multiplicities, const Standard_Integer Degree, const Standard_Boolean Periodic = Standard_False);
201 //! Increases the degree of this BSpline curve to
202 //! Degree. As a result, the poles, weights and
203 //! multiplicities tables are modified; the knots table is
204 //! not changed. Nothing is done if Degree is less than
205 //! or equal to the current degree.
207 //! Standard_ConstructionError if Degree is greater than
208 //! Geom2d_BSplineCurve::MaxDegree().
209 Standard_EXPORT void IncreaseDegree (const Standard_Integer Degree);
211 //! Increases the multiplicity of the knot <Index> to
214 //! If <M> is lower or equal to the current
215 //! multiplicity nothing is done. If <M> is higher than
216 //! the degree the degree is used.
217 //! If <Index> is not in [FirstUKnotIndex, LastUKnotIndex]
218 Standard_EXPORT void IncreaseMultiplicity (const Standard_Integer Index, const Standard_Integer M);
220 //! Increases the multiplicities of the knots in
223 //! For each knot if <M> is lower or equal to the
224 //! current multiplicity nothing is done. If <M> is
225 //! higher than the degree the degree is used.
226 //! As a result, the poles and weights tables of this curve are modified.
228 //! It is forbidden to modify the multiplicity of the first or
229 //! last knot of a non-periodic curve. Be careful as
230 //! Geom2d does not protect against this.
232 //! Standard_OutOfRange if either Index, I1 or I2 is
233 //! outside the bounds of the knots table.
234 Standard_EXPORT void IncreaseMultiplicity (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer M);
236 //! Increases by M the multiplicity of the knots of indexes
237 //! I1 to I2 in the knots table of this BSpline curve. For
238 //! each knot, the resulting multiplicity is limited to the
239 //! degree of this curve. If M is negative, nothing is done.
240 //! As a result, the poles and weights tables of this
241 //! BSpline curve are modified.
243 //! It is forbidden to modify the multiplicity of the first or
244 //! last knot of a non-periodic curve. Be careful as
245 //! Geom2d does not protect against this.
247 //! Standard_OutOfRange if I1 or I2 is outside the
248 //! bounds of the knots table.
249 Standard_EXPORT void IncrementMultiplicity (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer M);
251 //! Inserts a knot value in the sequence of knots. If
252 //! <U> is an existing knot the multiplicity is
253 //! increased by <M>.
255 //! If U is not on the parameter range nothing is
258 //! If the multiplicity is negative or null nothing is
259 //! done. The new multiplicity is limited to the
262 //! The tolerance criterion for knots equality is
263 //! the max of Epsilon(U) and ParametricTolerance.
265 //! - If U is less than the first parameter or greater than
266 //! the last parameter of this BSpline curve, nothing is done.
267 //! - If M is negative or null, nothing is done.
268 //! - The multiplicity of a knot is limited to the degree of
269 //! this BSpline curve.
270 Standard_EXPORT void InsertKnot (const Standard_Real U, const Standard_Integer M = 1, const Standard_Real ParametricTolerance = 0.0);
272 //! Inserts the values of the array Knots, with the
273 //! respective multiplicities given by the array Mults, into
274 //! the knots table of this BSpline curve.
275 //! If a value of the array Knots is an existing knot, its multiplicity is:
276 //! - increased by M, if Add is true, or
277 //! - increased to M, if Add is false (default value).
278 //! The tolerance criterion used for knot equality is the
279 //! larger of the values ParametricTolerance (defaulted
280 //! to 0.) and Standard_Real::Epsilon(U),
281 //! where U is the current knot value.
283 //! - For a value of the array Knots which is less than
284 //! the first parameter or greater than the last
285 //! parameter of this BSpline curve, nothing is done.
286 //! - For a value of the array Mults which is negative or
287 //! null, nothing is done.
288 //! - The multiplicity of a knot is limited to the degree of
289 //! this BSpline curve.
290 Standard_EXPORT void InsertKnots (const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Mults, const Standard_Real ParametricTolerance = 0.0, const Standard_Boolean Add = Standard_False);
292 //! Reduces the multiplicity of the knot of index Index
293 //! to M. If M is equal to 0, the knot is removed.
294 //! With a modification of this type, the array of poles is also modified.
295 //! Two different algorithms are systematically used to
296 //! compute the new poles of the curve. If, for each
297 //! pole, the distance between the pole calculated
298 //! using the first algorithm and the same pole
299 //! calculated using the second algorithm, is less than
300 //! Tolerance, this ensures that the curve is not
301 //! modified by more than Tolerance. Under these
302 //! conditions, true is returned; otherwise, false is returned.
303 //! A low tolerance is used to prevent modification of
304 //! the curve. A high tolerance is used to "smooth" the curve.
306 //! Standard_OutOfRange if Index is outside the
307 //! bounds of the knots table.
308 Standard_EXPORT Standard_Boolean RemoveKnot (const Standard_Integer Index, const Standard_Integer M, const Standard_Real Tolerance);
311 //! The new pole is inserted after the pole of range Index.
312 //! If the curve was non rational it can become rational.
314 //! Raised if the B-spline is NonUniform or PiecewiseBezier or if
316 //! Raised if Index is not in the range [1, Number of Poles]
317 Standard_EXPORT void InsertPoleAfter (const Standard_Integer Index, const gp_Pnt2d& P, const Standard_Real Weight = 1.0);
320 //! The new pole is inserted before the pole of range Index.
321 //! If the curve was non rational it can become rational.
323 //! Raised if the B-spline is NonUniform or PiecewiseBezier or if
325 //! Raised if Index is not in the range [1, Number of Poles]
326 Standard_EXPORT void InsertPoleBefore (const Standard_Integer Index, const gp_Pnt2d& P, const Standard_Real Weight = 1.0);
329 //! Removes the pole of range Index
330 //! If the curve was rational it can become non rational.
332 //! Raised if the B-spline is NonUniform or PiecewiseBezier.
333 //! Raised if the number of poles of the B-spline curve is lower or
334 //! equal to 2 before removing.
335 //! Raised if Index is not in the range [1, Number of Poles]
336 Standard_EXPORT void RemovePole (const Standard_Integer Index);
338 //! Reverses the orientation of this BSpline curve. As a result
339 //! - the knots and poles tables are modified;
340 //! - the start point of the initial curve becomes the end
341 //! point of the reversed curve;
342 //! - the end point of the initial curve becomes the start
343 //! point of the reversed curve.
344 Standard_EXPORT void Reverse() Standard_OVERRIDE;
346 //! Computes the parameter on the reversed curve for
347 //! the point of parameter U on this BSpline curve.
348 //! The returned value is: UFirst + ULast - U,
349 //! where UFirst and ULast are the values of the
350 //! first and last parameters of this BSpline curve.
351 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
353 //! Modifies this BSpline curve by segmenting it
354 //! between U1 and U2. Either of these values can be
355 //! outside the bounds of the curve, but U2 must be greater than U1.
356 //! All data structure tables of this BSpline curve are
357 //! modified, but the knots located between U1 and U2
358 //! are retained. The degree of the curve is not modified.
360 //! Even if <me> is not closed it can become closed after the
361 //! segmentation for example if U1 or U2 are out of the bounds
362 //! of the curve <me> or if the curve makes loop.
363 //! After the segmentation the length of a curve can be null.
364 //! - The segmentation of a periodic curve over an
365 //! interval corresponding to its period generates a
366 //! non-periodic curve with equivalent geometry.
368 //! Standard_DomainError if U2 is less than U1.
369 //! raises if U2 < U1.
370 //! Standard_DomainError if U2 - U1 exceeds the period for periodic curves.
371 //! i.e. ((U2 - U1) - Period) > Precision::PConfusion().
372 Standard_EXPORT void Segment (const Standard_Real U1, const Standard_Real U2);
374 //! Modifies this BSpline curve by assigning the value K
375 //! to the knot of index Index in the knots table. This is a
376 //! relatively local modification because K must be such that:
377 //! Knots(Index - 1) < K < Knots(Index + 1)
379 //! Standard_ConstructionError if:
380 //! - K is not such that:
381 //! Knots(Index - 1) < K < Knots(Index + 1)
382 //! - M is greater than the degree of this BSpline curve
383 //! or lower than the previous multiplicity of knot of
384 //! index Index in the knots table.
385 //! Standard_OutOfRange if Index is outside the bounds of the knots table.
386 Standard_EXPORT void SetKnot (const Standard_Integer Index, const Standard_Real K);
388 //! Modifies this BSpline curve by assigning the array
389 //! K to its knots table. The multiplicity of the knots is not modified.
391 //! Standard_ConstructionError if the values in the
392 //! array K are not in ascending order.
393 //! Standard_OutOfRange if the bounds of the array
394 //! K are not respectively 1 and the number of knots of this BSpline curve.
395 Standard_EXPORT void SetKnots (const TColStd_Array1OfReal& K);
397 //! Modifies this BSpline curve by assigning the value K
398 //! to the knot of index Index in the knots table. This is a
399 //! relatively local modification because K must be such that:
400 //! Knots(Index - 1) < K < Knots(Index + 1)
401 //! The second syntax allows you also to increase the
402 //! multiplicity of the knot to M (but it is not possible to
403 //! decrease the multiplicity of the knot with this function).
405 //! Standard_ConstructionError if:
406 //! - K is not such that:
407 //! Knots(Index - 1) < K < Knots(Index + 1)
408 //! - M is greater than the degree of this BSpline curve
409 //! or lower than the previous multiplicity of knot of
410 //! index Index in the knots table.
411 //! Standard_OutOfRange if Index is outside the bounds of the knots table.
412 Standard_EXPORT void SetKnot (const Standard_Integer Index, const Standard_Real K, const Standard_Integer M);
414 //! Computes the parameter normalized within the
415 //! "first" period of this BSpline curve, if it is periodic:
416 //! the returned value is in the range Param1 and
417 //! Param1 + Period, where:
418 //! - Param1 is the "first parameter", and
419 //! - Period the period of this BSpline curve.
420 //! Note: If this curve is not periodic, U is not modified.
421 Standard_EXPORT void PeriodicNormalization (Standard_Real& U) const;
423 //! Changes this BSpline curve into a periodic curve.
424 //! To become periodic, the curve must first be closed.
425 //! Next, the knot sequence must be periodic. For this,
426 //! FirstUKnotIndex and LastUKnotIndex are used to
427 //! compute I1 and I2, the indexes in the knots array
428 //! of the knots corresponding to the first and last
429 //! parameters of this BSpline curve.
430 //! The period is therefore Knot(I2) - Knot(I1).
431 //! Consequently, the knots and poles tables are modified.
433 //! Standard_ConstructionError if this BSpline curve is not closed.
434 Standard_EXPORT void SetPeriodic();
436 //! Assigns the knot of index Index in the knots table as
437 //! the origin of this periodic BSpline curve. As a
438 //! consequence, the knots and poles tables are modified.
440 //! Standard_NoSuchObject if this curve is not periodic.
441 //! Standard_DomainError if Index is outside the
442 //! bounds of the knots table.
443 Standard_EXPORT void SetOrigin (const Standard_Integer Index);
445 //! Changes this BSpline curve into a non-periodic
446 //! curve. If this curve is already non-periodic, it is not modified.
447 //! Note that the poles and knots tables are modified.
449 //! If this curve is periodic, as the multiplicity of the first
450 //! and last knots is not modified, and is not equal to
451 //! Degree + 1, where Degree is the degree of
452 //! this BSpline curve, the start and end points of the
453 //! curve are not its first and last poles.
454 Standard_EXPORT void SetNotPeriodic();
456 //! Modifies this BSpline curve by assigning P to the
457 //! pole of index Index in the poles table.
459 //! Standard_OutOfRange if Index is outside the
460 //! bounds of the poles table.
461 //! Standard_ConstructionError if Weight is negative or null.
462 Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt2d& P);
464 //! Modifies this BSpline curve by assigning P to the
465 //! pole of index Index in the poles table.
466 //! The second syntax also allows you to modify the
467 //! weight of the modified pole, which becomes Weight.
468 //! In this case, if this BSpline curve is non-rational, it
469 //! can become rational and vice versa.
471 //! Standard_OutOfRange if Index is outside the
472 //! bounds of the poles table.
473 //! Standard_ConstructionError if Weight is negative or null.
474 Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt2d& P, const Standard_Real Weight);
476 //! Assigns the weight Weight to the pole of index Index of the poles table.
477 //! If the curve was non rational it can become rational.
478 //! If the curve was rational it can become non rational.
480 //! Standard_OutOfRange if Index is outside the
481 //! bounds of the poles table.
482 //! Standard_ConstructionError if Weight is negative or null.
483 Standard_EXPORT void SetWeight (const Standard_Integer Index, const Standard_Real Weight);
485 //! Moves the point of parameter U of this BSpline
486 //! curve to P. Index1 and Index2 are the indexes in the
487 //! table of poles of this BSpline curve of the first and
488 //! last poles designated to be moved.
489 //! FirstModifiedPole and LastModifiedPole are the
490 //! indexes of the first and last poles, which are
491 //! effectively modified.
492 //! In the event of incompatibility between Index1,
493 //! Index2 and the value U:
494 //! - no change is made to this BSpline curve, and
495 //! - the FirstModifiedPole and LastModifiedPole are returned null.
497 //! Standard_OutOfRange if:
498 //! - Index1 is greater than or equal to Index2, or
499 //! - Index1 or Index2 is less than 1 or greater than the
500 //! number of poles of this BSpline curve.
501 Standard_EXPORT void MovePoint (const Standard_Real U, const gp_Pnt2d& P, const Standard_Integer Index1, const Standard_Integer Index2, Standard_Integer& FirstModifiedPole, Standard_Integer& LastModifiedPole);
503 //! Move a point with parameter U to P.
504 //! and makes it tangent at U be Tangent.
505 //! StartingCondition = -1 means first can move
506 //! EndingCondition = -1 means last point can move
507 //! StartingCondition = 0 means the first point cannot move
508 //! EndingCondition = 0 means the last point cannot move
509 //! StartingCondition = 1 means the first point and tangent cannot move
510 //! EndingCondition = 1 means the last point and tangent cannot move
512 //! ErrorStatus != 0 means that there are not enought degree of freedom
513 //! with the constrain to deform the curve accordingly
514 Standard_EXPORT void MovePointAndTangent (const Standard_Real U, const gp_Pnt2d& P, const gp_Vec2d& Tangent, const Standard_Real Tolerance, const Standard_Integer StartingCondition, const Standard_Integer EndingCondition, Standard_Integer& ErrorStatus);
516 //! Returns true if the degree of continuity of this
517 //! BSpline curve is at least N. A BSpline curve is at least GeomAbs_C0.
518 //! Exceptions Standard_RangeError if N is negative.
519 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE;
522 //! Check if curve has at least G1 continuity in interval [theTf, theTl]
523 //! Returns true if IsCN(1)
525 //! angle betweem "left" and "right" first derivatives at
526 //! knots with C0 continuity is less then theAngTol
527 //! only knots in interval [theTf, theTl] is checked
528 Standard_EXPORT Standard_Boolean IsG1 (const Standard_Real theTf, const Standard_Real theTl, const Standard_Real theAngTol) const;
531 //! Returns true if the distance between the first point and the
532 //! last point of the curve is lower or equal to Resolution
535 //! The first and the last point can be different from the first
536 //! pole and the last pole of the curve.
537 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
539 //! Returns True if the curve is periodic.
540 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
543 //! Returns True if the weights are not identical.
544 //! The tolerance criterion is Epsilon of the class Real.
545 Standard_EXPORT Standard_Boolean IsRational() const;
548 //! Returns the global continuity of the curve :
549 //! C0 : only geometric continuity,
550 //! C1 : continuity of the first derivative all along the Curve,
551 //! C2 : continuity of the second derivative all along the Curve,
552 //! C3 : continuity of the third derivative all along the Curve,
553 //! CN : the order of continuity is infinite.
554 //! For a B-spline curve of degree d if a knot Ui has a
555 //! multiplicity p the B-spline curve is only Cd-p continuous
556 //! at Ui. So the global continuity of the curve can't be greater
557 //! than Cd-p where p is the maximum multiplicity of the interior
558 //! Knots. In the interior of a knot span the curve is infinitely
559 //! continuously differentiable.
560 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
562 //! Returns the degree of this BSpline curve.
563 //! In this class the degree of the basis normalized B-spline
564 //! functions cannot be greater than "MaxDegree"
565 //! Computation of value and derivatives
566 Standard_EXPORT Standard_Integer Degree() const;
568 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
570 //! Raised if the continuity of the curve is not C1.
571 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE;
573 //! Raised if the continuity of the curve is not C2.
574 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
576 //! For this BSpline curve, computes
577 //! - the point P of parameter U, or
578 //! - the point P and one or more of the following values:
579 //! - V1, the first derivative vector,
580 //! - V2, the second derivative vector,
581 //! - V3, the third derivative vector.
583 //! On a point where the continuity of the curve is not the
584 //! one requested, these functions impact the part
585 //! defined by the parameter with a value greater than U,
586 //! i.e. the part of the curve to the "right" of the singularity.
587 //! Raises UndefinedDerivative if the continuity of the curve is not C3.
588 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
590 //! For the point of parameter U of this BSpline curve,
591 //! computes the vector corresponding to the Nth derivative.
593 //! On a point where the continuity of the curve is not the
594 //! one requested, this function impacts the part defined
595 //! by the parameter with a value greater than U, i.e. the
596 //! part of the curve to the "right" of the singularity.
597 //! Raises UndefinedDerivative if the continuity of the curve is not CN.
598 //! RangeError if N < 1.
599 //! The following functions computes the point of parameter U
600 //! and the derivatives at this point on the B-spline curve
601 //! arc defined between the knot FromK1 and the knot ToK2.
602 //! U can be out of bounds [Knot (FromK1), Knot (ToK2)] but
603 //! for the computation we only use the definition of the curve
604 //! between these two knots. This method is useful to compute
605 //! local derivative, if the order of continuity of the whole
606 //! curve is not greater enough. Inside the parametric
607 //! domain Knot (FromK1), Knot (ToK2) the evaluations are
608 //! the same as if we consider the whole definition of the
609 //! curve. Of course the evaluations are different outside
610 //! this parametric domain.
611 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
613 //! Raised if FromK1 = ToK2.
614 Standard_EXPORT gp_Pnt2d LocalValue (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2) const;
616 //! Raised if FromK1 = ToK2.
617 Standard_EXPORT void LocalD0 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt2d& P) const;
620 //! Raised if the local continuity of the curve is not C1
621 //! between the knot K1 and the knot K2.
622 //! Raised if FromK1 = ToK2.
623 Standard_EXPORT void LocalD1 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt2d& P, gp_Vec2d& V1) const;
626 //! Raised if the local continuity of the curve is not C2
627 //! between the knot K1 and the knot K2.
628 //! Raised if FromK1 = ToK2.
629 Standard_EXPORT void LocalD2 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const;
632 //! Raised if the local continuity of the curve is not C3
633 //! between the knot K1 and the knot K2.
634 //! Raised if FromK1 = ToK2.
635 Standard_EXPORT void LocalD3 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const;
638 //! Raised if the local continuity of the curve is not CN
639 //! between the knot K1 and the knot K2.
640 //! Raised if FromK1 = ToK2.
642 Standard_EXPORT gp_Vec2d LocalDN (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, const Standard_Integer N) const;
645 //! Returns the last point of the curve.
647 //! The last point of the curve is different from the last
648 //! pole of the curve if the multiplicity of the last knot
649 //! is lower than Degree.
650 Standard_EXPORT gp_Pnt2d EndPoint() const Standard_OVERRIDE;
653 //! For a B-spline curve the first parameter (which gives the start
654 //! point of the curve) is a knot value but if the multiplicity of
655 //! the first knot index is lower than Degree + 1 it is not the
656 //! first knot of the curve. This method computes the index of the
657 //! knot corresponding to the first parameter.
658 Standard_EXPORT Standard_Integer FirstUKnotIndex() const;
661 //! Computes the parametric value of the start point of the curve.
662 //! It is a knot value.
663 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
666 //! Returns the knot of range Index. When there is a knot
667 //! with a multiplicity greater than 1 the knot is not repeated.
668 //! The method Multiplicity can be used to get the multiplicity
670 //! Raised if Index < 1 or Index > NbKnots
671 Standard_EXPORT Standard_Real Knot (const Standard_Integer Index) const;
673 //! returns the knot values of the B-spline curve;
675 //! Raised K.Lower() is less than number of first knot or
676 //! K.Upper() is more than number of last knot.
677 Standard_EXPORT void Knots (TColStd_Array1OfReal& K) const;
679 //! returns the knot values of the B-spline curve;
680 Standard_EXPORT const TColStd_Array1OfReal& Knots() const;
682 //! Returns the knots sequence.
683 //! In this sequence the knots with a multiplicity greater than 1
686 //! K = {k1, k1, k1, k2, k3, k3, k4, k4, k4}
688 //! Raised if K.Lower() is less than number of first knot
689 //! in knot sequence with repetitions or K.Upper() is more
690 //! than number of last knot in knot sequence with repetitions.
691 Standard_EXPORT void KnotSequence (TColStd_Array1OfReal& K) const;
693 //! Returns the knots sequence.
694 //! In this sequence the knots with a multiplicity greater than 1
697 //! K = {k1, k1, k1, k2, k3, k3, k4, k4, k4}
698 Standard_EXPORT const TColStd_Array1OfReal& KnotSequence() const;
701 //! Returns NonUniform or Uniform or QuasiUniform or PiecewiseBezier.
702 //! If all the knots differ by a positive constant from the
703 //! preceding knot the BSpline Curve can be :
704 //! - Uniform if all the knots are of multiplicity 1,
705 //! - QuasiUniform if all the knots are of multiplicity 1 except for
706 //! the first and last knot which are of multiplicity Degree + 1,
707 //! - PiecewiseBezier if the first and last knots have multiplicity
708 //! Degree + 1 and if interior knots have multiplicity Degree
709 //! A piecewise Bezier with only two knots is a BezierCurve.
710 //! else the curve is non uniform.
711 //! The tolerance criterion is Epsilon from class Real.
712 Standard_EXPORT GeomAbs_BSplKnotDistribution KnotDistribution() const;
715 //! For a BSpline curve the last parameter (which gives the
716 //! end point of the curve) is a knot value but if the
717 //! multiplicity of the last knot index is lower than
718 //! Degree + 1 it is not the last knot of the curve. This
719 //! method computes the index of the knot corresponding to
720 //! the last parameter.
721 Standard_EXPORT Standard_Integer LastUKnotIndex() const;
724 //! Computes the parametric value of the end point of the curve.
725 //! It is a knot value.
726 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
729 //! Locates the parametric value U in the sequence of knots.
730 //! If "WithKnotRepetition" is True we consider the knot's
731 //! representation with repetition of multiple knot value,
732 //! otherwise we consider the knot's representation with
733 //! no repetition of multiple knot values.
734 //! Knots (I1) <= U <= Knots (I2)
735 //! . if I1 = I2 U is a knot value (the tolerance criterion
736 //! ParametricTolerance is used).
737 //! . if I1 < 1 => U < Knots (1) - Abs(ParametricTolerance)
738 //! . if I2 > NbKnots => U > Knots (NbKnots) + Abs(ParametricTolerance)
739 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;
742 //! Returns the multiplicity of the knots of range Index.
743 //! Raised if Index < 1 or Index > NbKnots
744 Standard_EXPORT Standard_Integer Multiplicity (const Standard_Integer Index) const;
747 //! Returns the multiplicity of the knots of the curve.
749 //! Raised if the length of M is not equal to NbKnots.
750 Standard_EXPORT void Multiplicities (TColStd_Array1OfInteger& M) const;
752 //! returns the multiplicity of the knots of the curve.
753 Standard_EXPORT const TColStd_Array1OfInteger& Multiplicities() const;
756 //! Returns the number of knots. This method returns the number of
757 //! knot without repetition of multiple knots.
758 Standard_EXPORT Standard_Integer NbKnots() const;
760 //! Returns the number of poles
761 Standard_EXPORT Standard_Integer NbPoles() const;
763 //! Returns the pole of range Index.
764 //! Raised if Index < 1 or Index > NbPoles.
765 Standard_EXPORT gp_Pnt2d Pole (const Standard_Integer Index) const;
767 //! Returns the poles of the B-spline curve;
769 //! Raised if the length of P is not equal to the number of poles.
770 Standard_EXPORT void Poles (TColgp_Array1OfPnt2d& P) const;
772 //! Returns the poles of the B-spline curve;
773 Standard_EXPORT const TColgp_Array1OfPnt2d& Poles() const;
776 //! Returns the start point of the curve.
778 //! This point is different from the first pole of the curve if the
779 //! multiplicity of the first knot is lower than Degree.
780 Standard_EXPORT gp_Pnt2d StartPoint() const Standard_OVERRIDE;
782 //! Returns the weight of the pole of range Index .
783 //! Raised if Index < 1 or Index > NbPoles.
784 Standard_EXPORT Standard_Real Weight (const Standard_Integer Index) const;
786 //! Returns the weights of the B-spline curve;
788 //! Raised if the length of W is not equal to NbPoles.
789 Standard_EXPORT void Weights (TColStd_Array1OfReal& W) const;
791 //! Returns the weights of the B-spline curve;
792 Standard_EXPORT const TColStd_Array1OfReal* Weights() const;
794 //! Applies the transformation T to this BSpline curve.
795 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE;
798 //! Returns the value of the maximum degree of the normalized
799 //! B-spline basis functions in this package.
800 Standard_EXPORT static Standard_Integer MaxDegree();
802 //! Computes for this BSpline curve the parametric
803 //! tolerance UTolerance for a given tolerance
804 //! Tolerance3D (relative to dimensions in the plane).
805 //! If f(t) is the equation of this BSpline curve,
806 //! UTolerance ensures that:
807 //! | t1 - t0| < Utolerance ===>
808 //! |f(t1) - f(t0)| < ToleranceUV
809 Standard_EXPORT void Resolution (const Standard_Real ToleranceUV, Standard_Real& UTolerance);
811 //! Creates a new object which is a copy of this BSpline curve.
812 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE;
817 DEFINE_STANDARD_RTTIEXT(Geom2d_BSplineCurve,Geom2d_BoundedCurve)
827 //! Recompute the flatknots, the knotsdistribution, the continuity.
828 Standard_EXPORT void UpdateKnots();
830 Standard_Boolean rational;
831 Standard_Boolean periodic;
832 GeomAbs_BSplKnotDistribution knotSet;
833 GeomAbs_Shape smooth;
834 Standard_Integer deg;
835 Handle(TColgp_HArray1OfPnt2d) poles;
836 Handle(TColStd_HArray1OfReal) weights;
837 Handle(TColStd_HArray1OfReal) flatknots;
838 Handle(TColStd_HArray1OfReal) knots;
839 Handle(TColStd_HArray1OfInteger) mults;
840 Standard_Real maxderivinv;
841 Standard_Boolean maxderivinvok;
852 #endif // _Geom2d_BSplineCurve_HeaderFile