1 -- Created on: 1993-03-09
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 -- xab : modified 15-Mar-95 : added cache mecanism to speed up evaluation
18 -- mei : modified 08-Jun-95 : added method MovePoint
21 class BSplineCurve from Geom inherits BoundedCurve from Geom
23 ---Purpose : Definition of the B_spline curve.
24 -- A B-spline curve can be
25 -- Uniform or non-uniform
26 -- Rational or non-rational
27 -- Periodic or non-periodic
29 -- a b-spline curve is defined by :
30 -- its degree; the degree for a
31 -- Geom_BSplineCurve is limited to a value (25)
32 -- which is defined and controlled by the system.
33 -- This value is returned by the function MaxDegree;
34 -- - its periodic or non-periodic nature;
35 -- - a table of poles (also called control points), with
36 -- their associated weights if the BSpline curve is
37 -- rational. The poles of the curve are "control
38 -- points" used to deform the curve. If the curve is
39 -- non-periodic, the first pole is the start point of
40 -- the curve, and the last pole is the end point of
41 -- the curve. The segment which joins the first pole
42 -- to the second pole is the tangent to the curve at
43 -- its start point, and the segment which joins the
44 -- last pole to the second-from-last pole is the
45 -- tangent to the curve at its end point. If the curve
46 -- is periodic, these geometric properties are not
47 -- verified. It is more difficult to give a geometric
48 -- signification to the weights but are useful for
49 -- providing exact representations of the arcs of a
50 -- circle or ellipse. Moreover, if the weights of all the
51 -- poles are equal, the curve has a polynomial
52 -- equation; it is therefore a non-rational curve.
53 -- - a table of knots with their multiplicities. For a
54 -- Geom_BSplineCurve, the table of knots is an
55 -- increasing sequence of reals without repetition;
56 -- the multiplicities define the repetition of the knots.
57 -- A BSpline curve is a piecewise polynomial or
58 -- rational curve. The knots are the parameters of
59 -- junction points between two pieces. The
60 -- multiplicity Mult(i) of the knot Knot(i) of
61 -- the BSpline curve is related to the degree of
62 -- continuity of the curve at the knot Knot(i),
63 -- which is equal to Degree - Mult(i)
64 -- where Degree is the degree of the BSpline curve.
65 -- If the knots are regularly spaced (i.e. the difference
66 -- between two consecutive knots is a constant), three
67 -- specific and frequently used cases of knot
68 -- distribution can be identified:
69 -- - "uniform" if all multiplicities are equal to 1,
70 -- - "quasi-uniform" if all multiplicities are equal to 1,
71 -- except the first and the last knot which have a
72 -- multiplicity of Degree + 1, where Degree is
73 -- the degree of the BSpline curve,
74 -- - "Piecewise Bezier" if all multiplicities are equal to
75 -- Degree except the first and last knot which
76 -- have a multiplicity of Degree + 1, where
77 -- Degree is the degree of the BSpline curve. A
78 -- curve of this type is a concatenation of arcs of Bezier curves.
79 -- If the BSpline curve is not periodic:
80 -- - the bounds of the Poles and Weights tables are 1
81 -- and NbPoles, where NbPoles is the number
82 -- of poles of the BSpline curve,
83 -- - the bounds of the Knots and Multiplicities tables
84 -- are 1 and NbKnots, where NbKnots is the
85 -- number of knots of the BSpline curve.
86 -- If the BSpline curve is periodic, and if there are k
87 -- periodic knots and p periodic poles, the period is:
88 -- period = Knot(k + 1) - Knot(1)
89 -- and the poles and knots tables can be considered
90 -- as infinite tables, verifying:
91 -- - Knot(i+k) = Knot(i) + period
92 -- - Pole(i+p) = Pole(i)
93 -- Note: data structures of a periodic BSpline curve
94 -- are more complex than those of a non-periodic one.
96 -- In this class, weight value is considered to be zero if
97 -- the weight is less than or equal to gp::Resolution().
100 -- . A survey of curve and surface methods in CADG Wolfgang BOHM
102 -- . On de Boor-like algorithms and blossoming Wolfgang BOEHM
104 -- . Blossoming and knot insertion algorithms for B-spline curves
106 -- . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA
107 -- . Curves and Surfaces for Computer Aided Geometric Design,
108 -- a practical guide Gerald Farin
110 uses Array1OfInteger from TColStd,
111 Array1OfReal from TColStd,
112 HArray1OfInteger from TColStd,
113 HArray1OfReal from TColStd,
114 Array1OfPnt from TColgp,
118 HArray1OfPnt from TColgp,
121 BSplKnotDistribution from GeomAbs,
127 raises ConstructionError from Standard,
128 DimensionError from Standard,
129 DomainError from Standard,
130 OutOfRange from Standard,
131 RangeError from Standard,
132 NoSuchObject from Standard,
133 UndefinedDerivative from Geom
137 Create (Poles : Array1OfPnt from TColgp;
138 Knots : Array1OfReal from TColStd;
139 Multiplicities : Array1OfInteger from TColStd;
141 Periodic : Boolean = Standard_False)
143 returns BSplineCurve from Geom
145 ---Purpose : Creates a non-rational B_spline curve on the
146 -- basis <Knots, Multiplicities> of degree <Degree>.
148 raises ConstructionError;
150 -- The following conditions must be verified.
152 -- 0 < Degree <= MaxDegree.
154 -- Knots.Length() == Mults.Length() >= 2
156 -- Knots(i) < Knots(i+1) (Knots are increasing)
158 -- 1 <= Mults(i) <= Degree
160 -- On a non periodic curve the first and last multiplicities
161 -- may be Degree+1 (this is even recommanded if you want the
162 -- curve to start and finish on the first and last pole).
164 -- On a periodic curve the first and the last multicities
167 -- on non-periodic curves
169 -- Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2
171 -- on periodic curves
173 -- Poles.Length() == Sum(Mults(i)) except the first or last
176 Create (Poles : Array1OfPnt from TColgp;
177 Weights : Array1OfReal from TColStd;
178 Knots : Array1OfReal from TColStd;
179 Multiplicities : Array1OfInteger from TColStd;
181 Periodic : Boolean = Standard_False;
182 CheckRational : Boolean = Standard_True)
184 returns BSplineCurve from Geom
186 ---Purpose : Creates a rational B_spline curve on the basis
187 -- <Knots, Multiplicities> of degree <Degree>.
188 -- Raises ConstructionError subject to the following conditions
189 -- 0 < Degree <= MaxDegree.
191 -- Weights.Length() == Poles.Length()
193 -- Knots.Length() == Mults.Length() >= 2
195 -- Knots(i) < Knots(i+1) (Knots are increasing)
197 -- 1 <= Mults(i) <= Degree
199 -- On a non periodic curve the first and last multiplicities
200 -- may be Degree+1 (this is even recommanded if you want the
201 -- curve to start and finish on the first and last pole).
203 -- On a periodic curve the first and the last multicities
206 -- on non-periodic curves
208 -- Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2
210 -- on periodic curves
212 -- Poles.Length() == Sum(Mults(i)) except the first or last
214 raises ConstructionError;
219 IncreaseDegree (me : mutable; Degree : Integer)
221 ---Purpose: Increases the degree of this BSpline curve to
222 -- Degree. As a result, the poles, weights and
223 -- multiplicities tables are modified; the knots table is
224 -- not changed. Nothing is done if Degree is less than
225 -- or equal to the current degree.
227 -- Standard_ConstructionError if Degree is greater than
228 -- Geom_BSplineCurve::MaxDegree().
229 raises ConstructionError;
231 IncreaseMultiplicity (me : mutable; Index : Integer; M : Integer)
233 ---Purpose :Increases the multiplicity of the knot <Index> to
236 -- If <M> is lower or equal to the current
237 -- multiplicity nothing is done. If <M> is higher than
238 -- the degree the degree is used.
242 ---Purpose: If <Index> is not in [FirstUKnotIndex, LastUKnotIndex]
245 IncreaseMultiplicity (me : mutable; I1, I2 : Integer; M : Integer)
247 ---Purpose :Increases the multiplicities of the knots in
250 -- For each knot if <M> is lower or equal to the
251 -- current multiplicity nothing is done. If <M> is
252 -- higher than the degree the degree is used.
256 ---Purpose: If <I1,I2> are not in [FirstUKnotIndex, LastUKnotIndex]
258 IncrementMultiplicity (me : mutable; I1, I2 : Integer; M : Integer)
260 ---Purpose :Increment the multiplicities of the knots in
263 -- If <M> is not positive nithing is done.
265 -- For each knot the resulting multiplicity is
266 -- limited to the Degree.
270 ---Purpose: If <I1,I2> are not in [FirstUKnotIndex, LastUKnotIndex]
275 InsertKnot (me : mutable;
278 ParametricTolerance : Real = 0.0;
279 Add : Boolean = Standard_True);
281 ---Purpose: Inserts a knot value in the sequence of knots. If
282 -- <U> is an existing knot the multiplicity is
285 -- If U is not on the parameter range nothing is
288 -- If the multiplicity is negative or null nothing is
289 -- done. The new multiplicity is limited to the
292 -- The tolerance criterion for knots equality is
293 -- the max of Epsilon(U) and ParametricTolerance.
296 InsertKnots (me : mutable; Knots : Array1OfReal from TColStd;
297 Mults : Array1OfInteger from TColStd;
298 ParametricTolerance : Real = 0.0;
299 Add : Boolean = Standard_False);
301 ---Purpose: Inserts a set of knots values in the sequence of
304 -- For each U = Knots(i), M = Mults(i)
306 -- If <U> is an existing knot the multiplicity is
307 -- increased by <M> if <Add> is True, increased to
308 -- <M> if <Add> is False.
310 -- If U is not on the parameter range nothing is
313 -- If the multiplicity is negative or null nothing is
314 -- done. The new multiplicity is limited to the
317 -- The tolerance criterion for knots equality is
318 -- the max of Epsilon(U) and ParametricTolerance.
324 RemoveKnot(me : mutable; Index : Integer;
326 Tolerance : Real) returns Boolean
328 ---Purpose : Reduces the multiplicity of the knot of index Index
329 -- to M. If M is equal to 0, the knot is removed.
330 -- With a modification of this type, the array of poles is also modified.
331 -- Two different algorithms are systematically used to
332 -- compute the new poles of the curve. If, for each
333 -- pole, the distance between the pole calculated
334 -- using the first algorithm and the same pole
335 -- calculated using the second algorithm, is less than
336 -- Tolerance, this ensures that the curve is not
337 -- modified by more than Tolerance. Under these
338 -- conditions, true is returned; otherwise, false is returned.
339 -- A low tolerance is used to prevent modification of
340 -- the curve. A high tolerance is used to "smooth" the curve.
342 -- Standard_OutOfRange if Index is outside the
343 -- bounds of the knots table.
347 ---Purpose : pole insertion and pole removing
348 -- this operation is limited to the Uniform or QuasiUniform
349 -- BSplineCurve. The knot values are modified . If the BSpline is
350 -- NonUniform or Piecewise Bezier an exception Construction error
354 Reverse (me : mutable);
356 -- Changes the direction of parametrization of <me>. The Knot
357 -- sequence is modified, the FirstParameter and the
358 -- LastParameter are not modified. The StartPoint of the
359 -- initial curve becomes the EndPoint of the reversed curve
360 -- and the EndPoint of the initial curve becomes the StartPoint
361 -- of the reversed curve.
364 ReversedParameter(me; U : Real) returns Real;
365 ---Purpose: Returns the parameter on the reversed curve for
366 -- the point of parameter U on <me>.
368 -- returns UFirst + ULast - U
370 Segment (me : mutable; U1, U2 : Real)
371 ---Purpose : Modifies this BSpline curve by segmenting it between
372 -- U1 and U2. Either of these values can be outside the
373 -- bounds of the curve, but U2 must be greater than U1.
374 -- All data structure tables of this BSpline curve are
375 -- modified, but the knots located between U1 and U2
376 -- are retained. The degree of the curve is not modified.
378 -- Even if <me> is not closed it can become closed after the
379 -- segmentation for example if U1 or U2 are out of the bounds
380 -- of the curve <me> or if the curve makes loop.
381 -- After the segmentation the length of a curve can be null.
382 raises DomainError from Standard;
383 ---Purpose: raises if U2 < U1.
386 SetKnot (me : mutable; Index : Integer; K : Real)
387 ---Purpose : Modifies this BSpline curve by assigning the value K
388 -- to the knot of index Index in the knots table. This is a
389 -- relatively local modification because K must be such that:
390 -- Knots(Index - 1) < K < Knots(Index + 1)
391 -- The second syntax allows you also to increase the
392 -- multiplicity of the knot to M (but it is not possible to
393 -- decrease the multiplicity of the knot with this function).
394 -- Standard_ConstructionError if:
395 -- - K is not such that:
396 -- Knots(Index - 1) < K < Knots(Index + 1)
397 -- - M is greater than the degree of this BSpline curve
398 -- or lower than the previous multiplicity of knot of
399 -- index Index in the knots table.
400 -- Standard_OutOfRange if Index is outside the bounds of the knots table.
401 raises ConstructionError,
405 SetKnots (me : mutable; K : Array1OfReal from TColStd)
406 ---Purpose : Modifies this BSpline curve by assigning the array
407 -- K to its knots table. The multiplicity of the knots is not modified.
409 -- Standard_ConstructionError if the values in the
410 -- array K are not in ascending order.
411 -- Standard_OutOfRange if the bounds of the array
412 -- K are not respectively 1 and the number of knots of this BSpline curve.
413 raises ConstructionError,
416 SetKnot (me : mutable; Index : Integer; K : Real; M : Integer)
418 -- Changes the knot of range Index with its multiplicity.
419 -- You can increase the multiplicity of a knot but it is
420 -- not allowed to decrease the multiplicity of an existing knot.
421 raises ConstructionError,
423 -- Raised if K >= Knots(Index+1) or K <= Knots(Index-1).
424 -- Raised if M is greater than Degree or lower than the previous
425 -- multiplicity of knot of range Index.
427 ---Purpose : Raised if Index < 1 || Index > NbKnots
429 PeriodicNormalization(me ; U : in out Real) ;
431 ---Purpose : returns the parameter normalized within
432 -- the period if the curve is periodic : otherwise
433 -- does not do anything
435 SetPeriodic (me : mutable)
436 ---Purpose : Changes this BSpline curve into a periodic curve.
437 -- To become periodic, the curve must first be closed.
438 -- Next, the knot sequence must be periodic. For this,
439 -- FirstUKnotIndex and LastUKnotIndex are used
440 -- to compute I1 and I2, the indexes in the knots
441 -- array of the knots corresponding to the first and
442 -- last parameters of this BSpline curve.
443 -- The period is therefore: Knots(I2) - Knots(I1).
444 -- Consequently, the knots and poles tables are modified.
446 -- Standard_ConstructionError if this BSpline curve is not closed.
447 raises ConstructionError;
450 SetOrigin (me : mutable; Index : Integer)
451 ---Purpose: Assigns the knot of index Index in the knots table as
452 -- the origin of this periodic BSpline curve. As a
453 -- consequence, the knots and poles tables are modified.
455 -- Standard_NoSuchObject if this curve is not periodic.
456 -- Standard_DomainError if Index is outside the bounds of the knots table.
460 SetOrigin (me : mutable;
461 U : Real from Standard;
462 Tol : Real from Standard)
463 ---Purpose: Set the origin of a periodic curve at Knot U. If U
464 -- is not a knot of the BSpline a new knot is
465 -- inseted. KnotVector and poles are modified.
467 ---Purpose: Raised if the curve is not periodic
470 SetNotPeriodic (me : mutable);
471 ---Purpose : Changes this BSpline curve into a non-periodic
472 -- curve. If this curve is already non-periodic, it is not modified.
473 -- Note: the poles and knots tables are modified.
475 -- If this curve is periodic, as the multiplicity of the first
476 -- and last knots is not modified, and is not equal to
477 -- Degree + 1, where Degree is the degree of
478 -- this BSpline curve, the start and end points of the
479 -- curve are not its first and last poles.
483 SetPole (me : mutable; Index : Integer; P : Pnt)
484 ---Purpose : Modifies this BSpline curve by assigning P to the pole
485 -- of index Index in the poles table.
487 -- Standard_OutOfRange if Index is outside the
488 -- bounds of the poles table.
489 -- Standard_ConstructionError if Weight is negative or null.
492 SetPole (me : mutable; Index : Integer; P : Pnt; Weight : Real)
493 ---Purpose: Modifies this BSpline curve by assigning P to the pole
494 -- of index Index in the poles table.
495 -- This syntax also allows you to modify the
496 -- weight of the modified pole, which becomes Weight.
497 -- In this case, if this BSpline curve is non-rational, it
498 -- can become rational and vice versa.
500 -- Standard_OutOfRange if Index is outside the
501 -- bounds of the poles table.
502 -- Standard_ConstructionError if Weight is negative or null.
507 SetWeight (me : mutable; Index : Integer; Weight : Real)
509 -- Changes the weight for the pole of range Index.
510 -- If the curve was non rational it can become rational.
511 -- If the curve was rational it can become non rational.
514 -- Raised if Index < 1 || Index > NbPoles
516 ---Purpose : Raised if Weight <= 0.0
518 MovePoint (me : mutable; U: Real; P: Pnt; Index1, Index2: Integer;
519 FirstModifiedPole, LastModifiedPole: out Integer)
520 ---Purpose : Moves the point of parameter U of this BSpline curve
521 -- to P. Index1 and Index2 are the indexes in the table
522 -- of poles of this BSpline curve of the first and last
523 -- poles designated to be moved.
524 -- FirstModifiedPole and LastModifiedPole are the
525 -- indexes of the first and last poles which are effectively modified.
526 -- In the event of incompatibility between Index1, Index2 and the value U:
527 -- - no change is made to this BSpline curve, and
528 -- - the FirstModifiedPole and LastModifiedPole are returned null.
530 -- Standard_OutOfRange if:
531 -- - Index1 is greater than or equal to Index2, or
532 -- - Index1 or Index2 is less than 1 or greater than the
533 -- number of poles of this BSpline curve.
536 MovePointAndTangent (me : mutable;
542 EndingCondition : Integer;
543 ErrorStatus : out Integer)
546 -- Move a point with parameter U to P.
547 -- and makes it tangent at U be Tangent.
548 -- StartingCondition = -1 means first can move
549 -- EndingCondition = -1 means last point can move
550 -- StartingCondition = 0 means the first point cannot move
551 -- EndingCondition = 0 means the last point cannot move
552 -- StartingCondition = 1 means the first point and tangent cannot move
553 -- EndingCondition = 1 means the last point and tangent cannot move
555 -- ErrorStatus != 0 means that there are not enought degree of freedom
556 -- with the constrain to deform the curve accordingly
560 IsCN (me; N : Integer) returns Boolean
562 -- Returns the continuity of the curve, the curve is at least C0.
564 ---Purpose : Raised if N < 0.
567 IsClosed (me) returns Boolean;
569 -- Returns true if the distance between the first point and the
570 -- last point of the curve is lower or equal to Resolution
573 -- The first and the last point can be different from the first
574 -- pole and the last pole of the curve.
577 IsPeriodic (me) returns Boolean;
578 ---Purpose : Returns True if the curve is periodic.
581 IsRational (me) returns Boolean;
583 -- Returns True if the weights are not identical.
584 -- The tolerance criterion is Epsilon of the class Real.
586 IsCacheValid(me; Parameter : Real) returns Boolean
589 -- Tells whether the Cache is valid for the
591 -- Warnings : the parameter must be normalized within
592 -- the period if the curve is periodic. Otherwise
593 -- the answer will be false
597 Continuity (me) returns Shape from GeomAbs;
599 -- Returns the global continuity of the curve :
600 -- C0 : only geometric continuity,
601 -- C1 : continuity of the first derivative all along the Curve,
602 -- C2 : continuity of the second derivative all along the Curve,
603 -- C3 : continuity of the third derivative all along the Curve,
604 -- CN : the order of continuity is infinite.
605 -- For a B-spline curve of degree d if a knot Ui has a
606 -- multiplicity p the B-spline curve is only Cd-p continuous
607 -- at Ui. So the global continuity of the curve can't be greater
608 -- than Cd-p where p is the maximum multiplicity of the interior
609 -- Knots. In the interior of a knot span the curve is infinitely
610 -- continuously differentiable.
613 Degree (me) returns Integer;
614 ---Purpose: Returns the degree of this BSpline curve.
615 -- The degree of a Geom_BSplineCurve curve cannot
616 -- be greater than Geom_BSplineCurve::MaxDegree().
618 ---Purpose : Computation of value and derivatives
620 D0 (me ; U : Real; P : out Pnt);
621 ---Purpose: Returns in P the point of parameter U.
623 D1 (me; U : Real; P : out Pnt; V1 : out Vec)
624 raises UndefinedDerivative;
625 ---Purpose : Raised if the continuity of the curve is not C1.
628 D2 (me; U : Real; P : out Pnt; V1, V2 : out Vec)
629 raises UndefinedDerivative;
630 ---Purpose : Raised if the continuity of the curve is not C2.
633 D3 (me; U : Real; P : out Pnt; V1, V2, V3 : out Vec)
634 raises UndefinedDerivative;
635 ---Purpose : Raised if the continuity of the curve is not C3.
638 DN (me; U : Real; N : Integer) returns Vec
639 ---Purpose : For the point of parameter U of this BSpline curve,
640 -- computes the vector corresponding to the Nth derivative.
642 -- On a point where the continuity of the curve is not the
643 -- one requested, this function impacts the part defined
644 -- by the parameter with a value greater than U, i.e. the
645 -- part of the curve to the "right" of the singularity.
647 -- Standard_RangeError if N is less than 1.
648 raises UndefinedDerivative,
652 -- The following functions compute the point of parameter U
653 -- and the derivatives at this point on the B-spline curve
654 -- arc defined between the knot FromK1 and the knot ToK2.
655 -- U can be out of bounds [Knot (FromK1), Knot (ToK2)] but
656 -- for the computation we only use the definition of the curve
657 -- between these two knots. This method is useful to compute
658 -- local derivative, if the order of continuity of the whole
659 -- curve is not greater enough. Inside the parametric
660 -- domain Knot (FromK1), Knot (ToK2) the evaluations are
661 -- the same as if we consider the whole definition of the
662 -- curve. Of course the evaluations are different outside
663 -- this parametric domain.
666 LocalValue (me; U : Real; FromK1, ToK2 : Integer) returns Pnt
668 ---Purpose : Raised if FromK1 = ToK2.
671 -- Raised if FromK1 and ToK2 are not in the range
672 -- [FirstUKnotIndex, LastUKnotIndex].
674 LocalD0 (me; U : Real; FromK1, ToK2 : Integer; P : out Pnt)
676 ---Purpose : Raised if FromK1 = ToK2.
679 -- Raised if FromK1 and ToK2 are not in the range
680 -- [FirstUKnotIndex, LastUKnotIndex].
682 LocalD1 (me; U : Real; FromK1, ToK2 : Integer; P : out Pnt; V1 : out Vec)
683 raises UndefinedDerivative,
685 -- Raised if the local continuity of the curve is not C1
686 -- between the knot K1 and the knot K2.
688 ---Purpose : Raised if FromK1 = ToK2.
691 -- Raised if FromK1 and ToK2 are not in the range
692 -- [FirstUKnotIndex, LastUKnotIndex].
695 LocalD2 (me; U : Real; FromK1, ToK2 : Integer; P : out Pnt; V1, V2 : out Vec)
696 raises UndefinedDerivative,
698 -- Raised if the local continuity of the curve is not C2
699 -- between the knot K1 and the knot K2.
701 ---Purpose : Raised if FromK1 = ToK2.
704 -- Raised if FromK1 and ToK2 are not in the range
705 -- [FirstUKnotIndex, LastUKnotIndex].
709 LocalD3 (me; U : Real; FromK1, ToK2 : Integer;
710 P : out Pnt; V1, V2, V3 : out Vec)
711 raises UndefinedDerivative,
713 -- Raised if the local continuity of the curve is not C3
714 -- between the knot K1 and the knot K2.
716 ---Purpose : Raised if FromK1 = ToK2.
719 -- Raised if FromK1 and ToK2 are not in the range
720 -- [FirstUKnotIndex, LastUKnotIndex].
723 LocalDN (me; U : Real; FromK1, ToK2 : Integer; N : Integer) returns Vec
724 raises UndefinedDerivative,
726 -- Raised if the local continuity of the curve is not CN
727 -- between the knot K1 and the knot K2.
729 ---Purpose : Raised if FromK1 = ToK2.
731 ---Purpose : Raised if N < 1.
734 -- Raises if FromK1 and ToK2 are not in the range
735 -- [FirstUKnotIndex, LastUKnotIndex].
738 EndPoint (me) returns Pnt;
740 -- Returns the last point of the curve.
742 -- The last point of the curve is different from the last
743 -- pole of the curve if the multiplicity of the last knot
744 -- is lower than Degree.
747 FirstUKnotIndex (me) returns Integer;
748 ---Purpose : Returns the index in the knot array of the knot
749 -- corresponding to the first or last parameter of this BSpline curve.
750 -- For a BSpline curve, the first (or last) parameter
751 -- (which gives the start (or end) point of the curve) is a
752 -- knot value. However, if the multiplicity of the first (or
753 -- last) knot is less than Degree + 1, where
754 -- Degree is the degree of the curve, it is not the first
755 -- (or last) knot of the curve.
758 FirstParameter (me) returns Real;
759 ---Purpose : Returns the value of the first parameter of this
760 -- BSpline curve. This is a knot value.
761 -- The first parameter is the one of the start point of the BSpline curve.
765 Knot (me; Index : Integer) returns Real
767 -- Returns the knot of range Index. When there is a knot
768 -- with a multiplicity greater than 1 the knot is not repeated.
769 -- The method Multiplicity can be used to get the multiplicity
772 ---Purpose : Raised if Index < 1 or Index > NbKnots
775 Knots (me; K : out Array1OfReal from TColStd)
776 ---Purpose : returns the knot values of the B-spline curve;
778 -- A knot with a multiplicity greater than 1 is not
779 -- repeated in the knot table. The Multiplicity function
780 -- can be used to obtain the multiplicity of each knot.
781 raises DimensionError;
783 -- Raised if the length of K is not equal to the number of knots.
786 KnotSequence (me; K : out Array1OfReal from TColStd)
787 ---Purpose : Returns K, the knots sequence of this BSpline curve.
788 -- In this sequence, knots with a multiplicity greater than 1 are repeated.
789 -- In the case of a non-periodic curve the length of the
790 -- sequence must be equal to the sum of the NbKnots
791 -- multiplicities of the knots of the curve (where
792 -- NbKnots is the number of knots of this BSpline
793 -- curve). This sum is also equal to : NbPoles + Degree + 1
794 -- where NbPoles is the number of poles and
795 -- Degree the degree of this BSpline curve.
796 -- In the case of a periodic curve, if there are k periodic
797 -- knots, the period is Knot(k+1) - Knot(1).
798 -- The initial sequence is built by writing knots 1 to k+1,
799 -- which are repeated according to their corresponding multiplicities.
800 -- If Degree is the degree of the curve, the degree of
801 -- continuity of the curve at the knot of index 1 (or k+1)
802 -- is equal to c = Degree + 1 - Mult(1). c
803 -- knots are then inserted at the beginning and end of
804 -- the initial sequence:
805 -- - the c values of knots preceding the first item
806 -- Knot(k+1) in the initial sequence are inserted
807 -- at the beginning; the period is subtracted from these c values;
808 -- - the c values of knots following the last item
809 -- Knot(1) in the initial sequence are inserted at
810 -- the end; the period is added to these c values.
811 -- The length of the sequence must therefore be equal to:
812 -- NbPoles + 2*Degree - Mult(1) + 2.
814 -- For a non-periodic BSpline curve of degree 2 where:
815 -- - the array of knots is: { k1 k2 k3 k4 },
816 -- - with associated multiplicities: { 3 1 2 3 },
817 -- the knot sequence is:
818 -- K = { k1 k1 k1 k2 k3 k3 k4 k4 k4 }
819 -- For a periodic BSpline curve of degree 4 , which is
820 -- "C1" continuous at the first knot, and where :
821 -- - the periodic knots are: { k1 k2 k3 (k4) }
822 -- (3 periodic knots: the points of parameter k1 and k4
823 -- are identical, the period is p = k4 - k1),
824 -- - with associated multiplicities: { 3 1 2 (3) },
825 -- the degree of continuity at knots k1 and k4 is:
826 -- Degree + 1 - Mult(i) = 2.
827 -- 2 supplementary knots are added at the beginning
828 -- and end of the sequence:
829 -- - at the beginning: the 2 knots preceding k4 minus
830 -- the period; in this example, this is k3 - p both times;
831 -- - at the end: the 2 knots following k1 plus the period;
832 -- in this example, this is k2 + p and k3 + p.
833 -- The knot sequence is therefore:
834 -- K = { k3-p k3-p k1 k1 k1 k2 k3 k3
835 -- k4 k4 k4 k2+p k3+p }
837 -- Standard_DimensionError if the array K is not of
838 -- the appropriate length.Returns the knots sequence.
839 raises DimensionError;
843 KnotDistribution (me) returns BSplKnotDistribution from GeomAbs;
845 -- Returns NonUniform or Uniform or QuasiUniform or PiecewiseBezier.
846 -- If all the knots differ by a positive constant from the
847 -- preceding knot the BSpline Curve can be :
848 -- - Uniform if all the knots are of multiplicity 1,
849 -- - QuasiUniform if all the knots are of multiplicity 1 except for
850 -- the first and last knot which are of multiplicity Degree + 1,
851 -- - PiecewiseBezier if the first and last knots have multiplicity
852 -- Degree + 1 and if interior knots have multiplicity Degree
853 -- A piecewise Bezier with only two knots is a BezierCurve.
854 -- else the curve is non uniform.
855 -- The tolerance criterion is Epsilon from class Real.
858 LastUKnotIndex (me) returns Integer;
860 -- For a BSpline curve the last parameter (which gives the
861 -- end point of the curve) is a knot value but if the
862 -- multiplicity of the last knot index is lower than
863 -- Degree + 1 it is not the last knot of the curve. This
864 -- method computes the index of the knot corresponding to
865 -- the last parameter.
868 LastParameter (me) returns Real;
870 -- Computes the parametric value of the end point of the curve.
871 -- It is a knot value.
876 ParametricTolerance : Real;
877 I1, I2 : in out Integer;
878 WithKnotRepetition : Boolean = Standard_False);
880 -- Locates the parametric value U in the sequence of knots.
881 -- If "WithKnotRepetition" is True we consider the knot's
882 -- representation with repetition of multiple knot value,
883 -- otherwise we consider the knot's representation with
884 -- no repetition of multiple knot values.
885 -- Knots (I1) <= U <= Knots (I2)
886 -- . if I1 = I2 U is a knot value (the tolerance criterion
887 -- ParametricTolerance is used).
888 -- . if I1 < 1 => U < Knots (1) - Abs(ParametricTolerance)
889 -- . if I2 > NbKnots => U > Knots (NbKnots) + Abs(ParametricTolerance)
892 Multiplicity (me; Index : Integer) returns Integer
894 -- Returns the multiplicity of the knots of range Index.
896 ---Purpose : Raised if Index < 1 or Index > NbKnots
899 Multiplicities (me; M : out Array1OfInteger from TColStd)
901 -- Returns the multiplicity of the knots of the curve.
902 raises DimensionError;
904 -- Raised if the length of M is not equal to NbKnots.
907 NbKnots (me) returns Integer;
909 -- Returns the number of knots. This method returns the number of
910 -- knot without repetition of multiple knots.
913 NbPoles (me) returns Integer;
914 ---Purpose : Returns the number of poles
917 Pole (me; Index : Integer) returns Pnt
918 ---Purpose : Returns the pole of range Index.
920 ---Purpose : Raised if Index < 1 or Index > NbPoles.
923 Poles (me; P : out Array1OfPnt from TColgp)
924 ---Purpose : Returns the poles of the B-spline curve;
925 raises DimensionError;
927 -- Raised if the length of P is not equal to the number of poles.
930 StartPoint (me) returns Pnt;
932 -- Returns the start point of the curve.
934 -- This point is different from the first pole of the curve if the
935 -- multiplicity of the first knot is lower than Degree.
938 Weight (me; Index : Integer) returns Real
939 ---Purpose : Returns the weight of the pole of range Index .
941 ---Purpose : Raised if Index < 1 or Index > NbPoles.
944 Weights (me; W : out Array1OfReal from TColStd)
945 ---Purpose : Returns the weights of the B-spline curve;
946 raises DimensionError;
948 -- Raised if the length of W is not equal to NbPoles.
956 Transform (me : mutable; T : Trsf);
957 ---Purpose: Applies the transformation T to this BSpline curve.
958 MaxDegree (myclass) returns Integer;
960 -- Returns the value of the maximum degree of the normalized
961 -- B-spline basis functions in this package.
963 Resolution(me : mutable;
965 UTolerance : out Real)
966 ---Purpose: Computes for this BSpline curve the parametric
967 -- tolerance UTolerance for a given 3D tolerance Tolerance3D.
968 -- If f(t) is the equation of this BSpline curve,
969 -- UTolerance ensures that:
970 -- | t1 - t0| < Utolerance ===>
971 -- |f(t1) - f(t0)| < Tolerance3D
974 Copy (me) returns like me;
975 ---Purpose: Creates a new object which is a copy of this BSpline curve.
977 InvalidateCache(me : mutable)
978 ---Purpose : Invalidates the cache. This has to be private
979 -- this has to be private
982 UpdateKnots(me : mutable)
983 ---Purpose : Recompute the flatknots, the knotsdistribution, the continuity.
986 ValidateCache(me : mutable ; Parameter : Real)
989 ---Purpose : updates the cache and validates it
991 IsEqual(me; theOther : BSplineCurve from Geom;
992 thePreci : Real from Standard ) returns Boolean;
993 ---Purpose : Comapare two Bspline curve on identity;
1002 knotSet : BSplKnotDistribution from GeomAbs;
1003 smooth : Shape from GeomAbs;
1005 poles : HArray1OfPnt from TColgp;
1006 weights : HArray1OfReal from TColStd;
1007 flatknots : HArray1OfReal from TColStd;
1008 knots : HArray1OfReal from TColStd;
1009 mults : HArray1OfInteger from TColStd;
1010 cachepoles : HArray1OfPnt from TColgp;
1011 -- Taylor expansion of the poles function, in homogeneous
1012 -- form if the curve is rational. The taylor expansion
1013 -- is normalized so that the span corresponds to
1015 cacheweights : HArray1OfReal from TColStd;
1016 -- Taylor expansion of the poles function, in homogeneous
1017 -- form if the curve is rational. The taylor expansion
1018 -- is normalized so that the span corresponds to
1020 validcache : Integer;
1021 -- = 1 the cache is valid
1022 -- = 0 the cache is invalid
1023 parametercache : Real;
1024 -- Parameter at which the Taylor expension is stored in
1026 spanlenghtcache : Real;
1027 -- Since the Taylor expansion is normalized in the
1028 -- cache to evaluate the cache one has to use
1029 -- (Parameter - parametercache) / nspanlenghtcache
1030 spanindexcache : Integer;
1031 -- the span for which the cache is valid if
1034 -- usefull to evaluate the parametric resolution
1035 maxderivinv : Real from Standard;
1036 maxderivinvok : Boolean from Standard;
1038 myMutex : Mutex from Standard;
1039 -- protected bspline-cache