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 #ifndef _Geom_BSplineCurve_HeaderFile
18 #define _Geom_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_HArray1OfPnt.hxx>
28 #include <TColStd_HArray1OfReal.hxx>
29 #include <TColStd_HArray1OfInteger.hxx>
30 #include <Standard_Real.hxx>
31 #include <Geom_BoundedCurve.hxx>
32 #include <TColgp_Array1OfPnt.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 Geom_UndefinedDerivative;
48 class Geom_BSplineCurve;
49 DEFINE_STANDARD_HANDLE(Geom_BSplineCurve, Geom_BoundedCurve)
51 //! Definition of the B_spline curve.
52 //! A B-spline curve can be
53 //! Uniform or non-uniform
54 //! Rational or non-rational
55 //! Periodic or non-periodic
57 //! a b-spline curve is defined by :
58 //! its degree; the degree for a
59 //! Geom_BSplineCurve is limited to a value (25)
60 //! which is defined and controlled by the system.
61 //! This value is returned by the function MaxDegree;
62 //! - its periodic or non-periodic nature;
63 //! - a table of poles (also called control points), with
64 //! their associated weights if the BSpline curve is
65 //! rational. The poles of the curve are "control
66 //! points" used to deform the curve. If the curve is
67 //! non-periodic, the first pole is the start point of
68 //! the curve, and the last pole is the end point of
69 //! the curve. The segment which joins the first pole
70 //! to the second pole is the tangent to the curve at
71 //! its start point, and the segment which joins the
72 //! last pole to the second-from-last pole is the
73 //! tangent to the curve at its end point. If the curve
74 //! is periodic, these geometric properties are not
75 //! verified. It is more difficult to give a geometric
76 //! signification to the weights but are useful for
77 //! providing exact representations of the arcs of a
78 //! circle or ellipse. Moreover, if the weights of all the
79 //! poles are equal, the curve has a polynomial
80 //! equation; it is therefore a non-rational curve.
81 //! - a table of knots with their multiplicities. For a
82 //! Geom_BSplineCurve, the table of knots is an
83 //! increasing sequence of reals without repetition;
84 //! the multiplicities define the repetition of the knots.
85 //! A BSpline curve is a piecewise polynomial or
86 //! rational curve. The knots are the parameters of
87 //! junction points between two pieces. The
88 //! multiplicity Mult(i) of the knot Knot(i) of
89 //! the BSpline curve is related to the degree of
90 //! continuity of the curve at the knot Knot(i),
91 //! which is equal to Degree - Mult(i)
92 //! where Degree is the degree of the BSpline curve.
93 //! If the knots are regularly spaced (i.e. the difference
94 //! between two consecutive knots is a constant), three
95 //! specific and frequently used cases of knot
96 //! distribution can be identified:
97 //! - "uniform" if all multiplicities are equal to 1,
98 //! - "quasi-uniform" if all multiplicities are equal to 1,
99 //! except the first and the last knot which have a
100 //! multiplicity of Degree + 1, where Degree is
101 //! the degree of the BSpline curve,
102 //! - "Piecewise Bezier" if all multiplicities are equal to
103 //! Degree except the first and last knot which
104 //! have a multiplicity of Degree + 1, where
105 //! Degree is the degree of the BSpline curve. A
106 //! curve of this type is a concatenation of arcs of Bezier curves.
107 //! If the BSpline curve is not periodic:
108 //! - the bounds of the Poles and Weights tables are 1
109 //! and NbPoles, where NbPoles is the number
110 //! of poles of the BSpline curve,
111 //! - the bounds of the Knots and Multiplicities tables
112 //! are 1 and NbKnots, where NbKnots is the
113 //! number of knots of the BSpline curve.
114 //! If the BSpline curve is periodic, and if there are k
115 //! periodic knots and p periodic poles, the period is:
116 //! period = Knot(k + 1) - Knot(1)
117 //! and the poles and knots tables can be considered
118 //! as infinite tables, verifying:
119 //! - Knot(i+k) = Knot(i) + period
120 //! - Pole(i+p) = Pole(i)
121 //! Note: data structures of a periodic BSpline curve
122 //! are more complex than those of a non-periodic one.
124 //! In this class, weight value is considered to be zero if
125 //! the weight is less than or equal to gp::Resolution().
128 //! . A survey of curve and surface methods in CADG Wolfgang BOHM
130 //! . On de Boor-like algorithms and blossoming Wolfgang BOEHM
132 //! . Blossoming and knot insertion algorithms for B-spline curves
133 //! Ronald N. GOLDMAN
134 //! . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA
135 //! . Curves and Surfaces for Computer Aided Geometric Design,
136 //! a practical guide Gerald Farin
137 class Geom_BSplineCurve : public Geom_BoundedCurve
143 //! Creates a non-rational B_spline curve on the
144 //! basis <Knots, Multiplicities> of degree <Degree>.
145 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 //! Creates a rational B_spline curve on the basis
148 //! <Knots, Multiplicities> of degree <Degree>.
149 //! Raises ConstructionError subject to the following conditions
150 //! 0 < Degree <= MaxDegree.
152 //! Weights.Length() == Poles.Length()
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
165 //! must be the same.
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
174 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 //! Increases the degree of this BSpline curve to
177 //! Degree. As a result, the poles, weights and
178 //! multiplicities tables are modified; the knots table is
179 //! not changed. Nothing is done if Degree is less than
180 //! or equal to the current degree.
182 //! Standard_ConstructionError if Degree is greater than
183 //! Geom_BSplineCurve::MaxDegree().
184 Standard_EXPORT void IncreaseDegree (const Standard_Integer Degree);
186 //! Increases the multiplicity of the knot <Index> to
189 //! If <M> is lower or equal to the current
190 //! multiplicity nothing is done. If <M> is higher than
191 //! the degree the degree is used.
192 //! If <Index> is not in [FirstUKnotIndex, LastUKnotIndex]
193 Standard_EXPORT void IncreaseMultiplicity (const Standard_Integer Index, const Standard_Integer M);
195 //! Increases the multiplicities of the knots in
198 //! For each knot if <M> is lower or equal to the
199 //! current multiplicity nothing is done. If <M> is
200 //! higher than the degree the degree is used.
201 //! If <I1,I2> are not in [FirstUKnotIndex, LastUKnotIndex]
202 Standard_EXPORT void IncreaseMultiplicity (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer M);
204 //! Increment the multiplicities of the knots in
207 //! If <M> is not positive nithing is done.
209 //! For each knot the resulting multiplicity is
210 //! limited to the Degree.
211 //! If <I1,I2> are not in [FirstUKnotIndex, LastUKnotIndex]
212 Standard_EXPORT void IncrementMultiplicity (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer M);
214 //! Inserts a knot value in the sequence of knots. If
215 //! <U> is an existing knot the multiplicity is
216 //! increased by <M>.
218 //! If U is not on the parameter range nothing is
221 //! If the multiplicity is negative or null nothing is
222 //! done. The new multiplicity is limited to the
225 //! The tolerance criterion for knots equality is
226 //! the max of Epsilon(U) and ParametricTolerance.
227 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 //! Inserts a set of knots values in the sequence of
232 //! For each U = Knots(i), M = Mults(i)
234 //! If <U> is an existing knot the multiplicity is
235 //! increased by <M> if <Add> is True, increased to
236 //! <M> if <Add> is False.
238 //! If U is not on the parameter range nothing is
241 //! If the multiplicity is negative or null nothing is
242 //! done. The new multiplicity is limited to the
245 //! The tolerance criterion for knots equality is
246 //! the max of Epsilon(U) and ParametricTolerance.
247 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 //! Reduces the multiplicity of the knot of index Index
250 //! to M. If M is equal to 0, the knot is removed.
251 //! With a modification of this type, the array of poles is also modified.
252 //! Two different algorithms are systematically used to
253 //! compute the new poles of the curve. If, for each
254 //! pole, the distance between the pole calculated
255 //! using the first algorithm and the same pole
256 //! calculated using the second algorithm, is less than
257 //! Tolerance, this ensures that the curve is not
258 //! modified by more than Tolerance. Under these
259 //! conditions, true is returned; otherwise, false is returned.
260 //! A low tolerance is used to prevent modification of
261 //! the curve. A high tolerance is used to "smooth" the curve.
263 //! Standard_OutOfRange if Index is outside the
264 //! bounds of the knots table.
265 //! pole insertion and pole removing
266 //! this operation is limited to the Uniform or QuasiUniform
267 //! BSplineCurve. The knot values are modified . If the BSpline is
268 //! NonUniform or Piecewise Bezier an exception Construction error
270 Standard_EXPORT Standard_Boolean RemoveKnot (const Standard_Integer Index, const Standard_Integer M, const Standard_Real Tolerance);
273 //! Changes the direction of parametrization of <me>. The Knot
274 //! sequence is modified, the FirstParameter and the
275 //! LastParameter are not modified. The StartPoint of the
276 //! initial curve becomes the EndPoint of the reversed curve
277 //! and the EndPoint of the initial curve becomes the StartPoint
278 //! of the reversed curve.
279 Standard_EXPORT void Reverse() Standard_OVERRIDE;
281 //! Returns the parameter on the reversed curve for
282 //! the point of parameter U on <me>.
284 //! returns UFirst + ULast - U
285 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE;
287 //! Modifies this BSpline curve by segmenting it between
288 //! U1 and U2. Either of these values can be outside the
289 //! bounds of the curve, but U2 must be greater than U1.
290 //! All data structure tables of this BSpline curve are
291 //! modified, but the knots located between U1 and U2
292 //! are retained. The degree of the curve is not modified.
294 //! Even if <me> is not closed it can become closed after the
295 //! segmentation for example if U1 or U2 are out of the bounds
296 //! of the curve <me> or if the curve makes loop.
297 //! After the segmentation the length of a curve can be null.
298 //! raises if U2 < U1.
299 //! Standard_DomainError if U2 - U1 exceeds the period for periodic curves.
300 //! i.e. ((U2 - U1) - Period) > Precision::PConfusion().
301 Standard_EXPORT void Segment (const Standard_Real U1, const Standard_Real U2);
303 //! Modifies this BSpline curve by assigning the value K
304 //! to the knot of index Index in the knots table. This is a
305 //! relatively local modification because K must be such that:
306 //! Knots(Index - 1) < K < Knots(Index + 1)
307 //! The second syntax allows you also to increase the
308 //! multiplicity of the knot to M (but it is not possible to
309 //! decrease the multiplicity of the knot with this function).
310 //! Standard_ConstructionError if:
311 //! - K is not such that:
312 //! Knots(Index - 1) < K < Knots(Index + 1)
313 //! - M is greater than the degree of this BSpline curve
314 //! or lower than the previous multiplicity of knot of
315 //! index Index in the knots table.
316 //! Standard_OutOfRange if Index is outside the bounds of the knots table.
317 Standard_EXPORT void SetKnot (const Standard_Integer Index, const Standard_Real K);
319 //! Modifies this BSpline curve by assigning the array
320 //! K to its knots table. The multiplicity of the knots is not modified.
322 //! Standard_ConstructionError if the values in the
323 //! array K are not in ascending order.
324 //! Standard_OutOfRange if the bounds of the array
325 //! K are not respectively 1 and the number of knots of this BSpline curve.
326 Standard_EXPORT void SetKnots (const TColStd_Array1OfReal& K);
329 //! Changes the knot of range Index with its multiplicity.
330 //! You can increase the multiplicity of a knot but it is
331 //! not allowed to decrease the multiplicity of an existing knot.
333 //! Raised if K >= Knots(Index+1) or K <= Knots(Index-1).
334 //! Raised if M is greater than Degree or lower than the previous
335 //! multiplicity of knot of range Index.
336 //! Raised if Index < 1 || Index > NbKnots
337 Standard_EXPORT void SetKnot (const Standard_Integer Index, const Standard_Real K, const Standard_Integer M);
339 //! returns the parameter normalized within
340 //! the period if the curve is periodic : otherwise
341 //! does not do anything
342 Standard_EXPORT void PeriodicNormalization (Standard_Real& U) const;
344 //! Changes this BSpline curve into a periodic curve.
345 //! To become periodic, the curve must first be closed.
346 //! Next, the knot sequence must be periodic. For this,
347 //! FirstUKnotIndex and LastUKnotIndex are used
348 //! to compute I1 and I2, the indexes in the knots
349 //! array of the knots corresponding to the first and
350 //! last parameters of this BSpline curve.
351 //! The period is therefore: Knots(I2) - Knots(I1).
352 //! Consequently, the knots and poles tables are modified.
354 //! Standard_ConstructionError if this BSpline curve is not closed.
355 Standard_EXPORT void SetPeriodic();
357 //! Assigns the knot of index Index in the knots table as
358 //! the origin of this periodic BSpline curve. As a
359 //! consequence, the knots and poles tables are modified.
361 //! Standard_NoSuchObject if this curve is not periodic.
362 //! Standard_DomainError if Index is outside the bounds of the knots table.
363 Standard_EXPORT void SetOrigin (const Standard_Integer Index);
365 //! Set the origin of a periodic curve at Knot U. If U
366 //! is not a knot of the BSpline a new knot is
367 //! inseted. KnotVector and poles are modified.
368 //! Raised if the curve is not periodic
369 Standard_EXPORT void SetOrigin (const Standard_Real U, const Standard_Real Tol);
371 //! Changes this BSpline curve into a non-periodic
372 //! curve. If this curve is already non-periodic, it is not modified.
373 //! Note: the poles and knots tables are modified.
375 //! If this curve is periodic, as the multiplicity of the first
376 //! and last knots is not modified, and is not equal to
377 //! Degree + 1, where Degree is the degree of
378 //! this BSpline curve, the start and end points of the
379 //! curve are not its first and last poles.
380 Standard_EXPORT void SetNotPeriodic();
382 //! Modifies this BSpline curve by assigning P to the pole
383 //! of index Index in the poles table.
385 //! Standard_OutOfRange if Index is outside the
386 //! bounds of the poles table.
387 //! Standard_ConstructionError if Weight is negative or null.
388 Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt& P);
390 //! Modifies this BSpline curve by assigning P to the pole
391 //! of index Index in the poles table.
392 //! This syntax also allows you to modify the
393 //! weight of the modified pole, which becomes Weight.
394 //! In this case, if this BSpline curve is non-rational, it
395 //! can become rational and vice versa.
397 //! Standard_OutOfRange if Index is outside the
398 //! bounds of the poles table.
399 //! Standard_ConstructionError if Weight is negative or null.
400 Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt& P, const Standard_Real Weight);
403 //! Changes the weight for the pole of range Index.
404 //! If the curve was non rational it can become rational.
405 //! If the curve was rational it can become non rational.
407 //! Raised if Index < 1 || Index > NbPoles
408 //! Raised if Weight <= 0.0
409 Standard_EXPORT void SetWeight (const Standard_Integer Index, const Standard_Real Weight);
411 //! Moves the point of parameter U of this BSpline curve
412 //! to P. Index1 and Index2 are the indexes in the table
413 //! of poles of this BSpline curve of the first and last
414 //! poles designated to be moved.
415 //! FirstModifiedPole and LastModifiedPole are the
416 //! indexes of the first and last poles which are effectively modified.
417 //! In the event of incompatibility between Index1, Index2 and the value U:
418 //! - no change is made to this BSpline curve, and
419 //! - the FirstModifiedPole and LastModifiedPole are returned null.
421 //! Standard_OutOfRange if:
422 //! - Index1 is greater than or equal to Index2, or
423 //! - Index1 or Index2 is less than 1 or greater than the
424 //! number of poles of this BSpline curve.
425 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);
428 //! Move a point with parameter U to P.
429 //! and makes it tangent at U be Tangent.
430 //! StartingCondition = -1 means first can move
431 //! EndingCondition = -1 means last point can move
432 //! StartingCondition = 0 means the first point cannot move
433 //! EndingCondition = 0 means the last point cannot move
434 //! StartingCondition = 1 means the first point and tangent cannot move
435 //! EndingCondition = 1 means the last point and tangent cannot move
437 //! ErrorStatus != 0 means that there are not enought degree of freedom
438 //! with the constrain to deform the curve accordingly
439 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);
442 //! Returns the continuity of the curve, the curve is at least C0.
444 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE;
447 //! Check if curve has at least G1 continuity in interval [theTf, theTl]
448 //! Returns true if IsCN(1)
450 //! angle betweem "left" and "right" first derivatives at
451 //! knots with C0 continuity is less then theAngTol
452 //! only knots in interval [theTf, theTl] is checked
453 Standard_EXPORT Standard_Boolean IsG1 (const Standard_Real theTf, const Standard_Real theTl, const Standard_Real theAngTol) const;
456 //! Returns true if the distance between the first point and the
457 //! last point of the curve is lower or equal to Resolution
460 //! The first and the last point can be different from the first
461 //! pole and the last pole of the curve.
462 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
464 //! Returns True if the curve is periodic.
465 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
468 //! Returns True if the weights are not identical.
469 //! The tolerance criterion is Epsilon of the class Real.
470 Standard_EXPORT Standard_Boolean IsRational() const;
473 //! Returns the global continuity of the curve :
474 //! C0 : only geometric continuity,
475 //! C1 : continuity of the first derivative all along the Curve,
476 //! C2 : continuity of the second derivative all along the Curve,
477 //! C3 : continuity of the third derivative all along the Curve,
478 //! CN : the order of continuity is infinite.
479 //! For a B-spline curve of degree d if a knot Ui has a
480 //! multiplicity p the B-spline curve is only Cd-p continuous
481 //! at Ui. So the global continuity of the curve can't be greater
482 //! than Cd-p where p is the maximum multiplicity of the interior
483 //! Knots. In the interior of a knot span the curve is infinitely
484 //! continuously differentiable.
485 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
487 //! Returns the degree of this BSpline curve.
488 //! The degree of a Geom_BSplineCurve curve cannot
489 //! be greater than Geom_BSplineCurve::MaxDegree().
490 //! Computation of value and derivatives
491 Standard_EXPORT Standard_Integer Degree() const;
493 //! Returns in P the point of parameter U.
494 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
496 //! Raised if the continuity of the curve is not C1.
497 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1) const Standard_OVERRIDE;
499 //! Raised if the continuity of the curve is not C2.
500 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE;
502 //! Raised if the continuity of the curve is not C3.
503 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE;
505 //! For the point of parameter U of this BSpline curve,
506 //! computes the vector corresponding to the Nth derivative.
508 //! On a point where the continuity of the curve is not the
509 //! one requested, this function impacts the part defined
510 //! by the parameter with a value greater than U, i.e. the
511 //! part of the curve to the "right" of the singularity.
513 //! Standard_RangeError if N is less than 1.
515 //! The following functions compute the point of parameter U
516 //! and the derivatives at this point on the B-spline curve
517 //! arc defined between the knot FromK1 and the knot ToK2.
518 //! U can be out of bounds [Knot (FromK1), Knot (ToK2)] but
519 //! for the computation we only use the definition of the curve
520 //! between these two knots. This method is useful to compute
521 //! local derivative, if the order of continuity of the whole
522 //! curve is not greater enough. Inside the parametric
523 //! domain Knot (FromK1), Knot (ToK2) the evaluations are
524 //! the same as if we consider the whole definition of the
525 //! curve. Of course the evaluations are different outside
526 //! this parametric domain.
527 Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
529 //! Raised if FromK1 = ToK2.
530 Standard_EXPORT gp_Pnt LocalValue (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2) const;
532 //! Raised if FromK1 = ToK2.
533 Standard_EXPORT void LocalD0 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt& P) const;
536 //! Raised if the local continuity of the curve is not C1
537 //! between the knot K1 and the knot K2.
538 //! Raised if FromK1 = ToK2.
539 Standard_EXPORT void LocalD1 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt& P, gp_Vec& V1) const;
542 //! Raised if the local continuity of the curve is not C2
543 //! between the knot K1 and the knot K2.
544 //! Raised if FromK1 = ToK2.
545 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;
548 //! Raised if the local continuity of the curve is not C3
549 //! between the knot K1 and the knot K2.
550 //! Raised if FromK1 = ToK2.
551 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;
554 //! Raised if the local continuity of the curve is not CN
555 //! between the knot K1 and the knot K2.
556 //! Raised if FromK1 = ToK2.
558 Standard_EXPORT gp_Vec LocalDN (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, const Standard_Integer N) const;
561 //! Returns the last point of the curve.
563 //! The last point of the curve is different from the last
564 //! pole of the curve if the multiplicity of the last knot
565 //! is lower than Degree.
566 Standard_EXPORT gp_Pnt EndPoint() const Standard_OVERRIDE;
568 //! Returns the index in the knot array of the knot
569 //! corresponding to the first or last parameter of this BSpline curve.
570 //! For a BSpline curve, the first (or last) parameter
571 //! (which gives the start (or end) point of the curve) is a
572 //! knot value. However, if the multiplicity of the first (or
573 //! last) knot is less than Degree + 1, where
574 //! Degree is the degree of the curve, it is not the first
575 //! (or last) knot of the curve.
576 Standard_EXPORT Standard_Integer FirstUKnotIndex() const;
578 //! Returns the value of the first parameter of this
579 //! BSpline curve. This is a knot value.
580 //! The first parameter is the one of the start point of the BSpline curve.
581 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
584 //! Returns the knot of range Index. When there is a knot
585 //! with a multiplicity greater than 1 the knot is not repeated.
586 //! The method Multiplicity can be used to get the multiplicity
588 //! Raised if Index < 1 or Index > NbKnots
589 Standard_EXPORT Standard_Real Knot (const Standard_Integer Index) const;
591 //! returns the knot values of the B-spline curve;
593 //! A knot with a multiplicity greater than 1 is not
594 //! repeated in the knot table. The Multiplicity function
595 //! can be used to obtain the multiplicity of each knot.
597 //! Raised K.Lower() is less than number of first knot or
598 //! K.Upper() is more than number of last knot.
599 Standard_EXPORT void Knots (TColStd_Array1OfReal& K) const;
601 //! returns the knot values of the B-spline curve;
603 //! A knot with a multiplicity greater than 1 is not
604 //! repeated in the knot table. The Multiplicity function
605 //! can be used to obtain the multiplicity of each knot.
606 Standard_EXPORT const TColStd_Array1OfReal& Knots() const;
608 //! Returns K, the knots sequence of this BSpline curve.
609 //! In this sequence, knots with a multiplicity greater than 1 are repeated.
610 //! In the case of a non-periodic curve the length of the
611 //! sequence must be equal to the sum of the NbKnots
612 //! multiplicities of the knots of the curve (where
613 //! NbKnots is the number of knots of this BSpline
614 //! curve). This sum is also equal to : NbPoles + Degree + 1
615 //! where NbPoles is the number of poles and
616 //! Degree the degree of this BSpline curve.
617 //! In the case of a periodic curve, if there are k periodic
618 //! knots, the period is Knot(k+1) - Knot(1).
619 //! The initial sequence is built by writing knots 1 to k+1,
620 //! which are repeated according to their corresponding multiplicities.
621 //! If Degree is the degree of the curve, the degree of
622 //! continuity of the curve at the knot of index 1 (or k+1)
623 //! is equal to c = Degree + 1 - Mult(1). c
624 //! knots are then inserted at the beginning and end of
625 //! the initial sequence:
626 //! - the c values of knots preceding the first item
627 //! Knot(k+1) in the initial sequence are inserted
628 //! at the beginning; the period is subtracted from these c values;
629 //! - the c values of knots following the last item
630 //! Knot(1) in the initial sequence are inserted at
631 //! the end; the period is added to these c values.
632 //! The length of the sequence must therefore be equal to:
633 //! NbPoles + 2*Degree - Mult(1) + 2.
635 //! For a non-periodic BSpline curve of degree 2 where:
636 //! - the array of knots is: { k1 k2 k3 k4 },
637 //! - with associated multiplicities: { 3 1 2 3 },
638 //! the knot sequence is:
639 //! K = { k1 k1 k1 k2 k3 k3 k4 k4 k4 }
640 //! For a periodic BSpline curve of degree 4 , which is
641 //! "C1" continuous at the first knot, and where :
642 //! - the periodic knots are: { k1 k2 k3 (k4) }
643 //! (3 periodic knots: the points of parameter k1 and k4
644 //! are identical, the period is p = k4 - k1),
645 //! - with associated multiplicities: { 3 1 2 (3) },
646 //! the degree of continuity at knots k1 and k4 is:
647 //! Degree + 1 - Mult(i) = 2.
648 //! 2 supplementary knots are added at the beginning
649 //! and end of the sequence:
650 //! - at the beginning: the 2 knots preceding k4 minus
651 //! the period; in this example, this is k3 - p both times;
652 //! - at the end: the 2 knots following k1 plus the period;
653 //! in this example, this is k2 + p and k3 + p.
654 //! The knot sequence is therefore:
655 //! K = { k3-p k3-p k1 k1 k1 k2 k3 k3
656 //! k4 k4 k4 k2+p k3+p }
658 //! Raised if K.Lower() is less than number of first knot
659 //! in knot sequence with repetitions or K.Upper() is more
660 //! than number of last knot in knot sequence with repetitions.
661 Standard_EXPORT void KnotSequence (TColStd_Array1OfReal& K) const;
663 //! returns the knots of the B-spline curve.
664 //! Knots with multiplicit greater than 1 are repeated
665 Standard_EXPORT const TColStd_Array1OfReal& KnotSequence() const;
668 //! Returns NonUniform or Uniform or QuasiUniform or PiecewiseBezier.
669 //! If all the knots differ by a positive constant from the
670 //! preceding knot the BSpline Curve can be :
671 //! - Uniform if all the knots are of multiplicity 1,
672 //! - QuasiUniform if all the knots are of multiplicity 1 except for
673 //! the first and last knot which are of multiplicity Degree + 1,
674 //! - PiecewiseBezier if the first and last knots have multiplicity
675 //! Degree + 1 and if interior knots have multiplicity Degree
676 //! A piecewise Bezier with only two knots is a BezierCurve.
677 //! else the curve is non uniform.
678 //! The tolerance criterion is Epsilon from class Real.
679 Standard_EXPORT GeomAbs_BSplKnotDistribution KnotDistribution() const;
682 //! For a BSpline curve the last parameter (which gives the
683 //! end point of the curve) is a knot value but if the
684 //! multiplicity of the last knot index is lower than
685 //! Degree + 1 it is not the last knot of the curve. This
686 //! method computes the index of the knot corresponding to
687 //! the last parameter.
688 Standard_EXPORT Standard_Integer LastUKnotIndex() const;
691 //! Computes the parametric value of the end point of the curve.
692 //! It is a knot value.
693 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
696 //! Locates the parametric value U in the sequence of knots.
697 //! If "WithKnotRepetition" is True we consider the knot's
698 //! representation with repetition of multiple knot value,
699 //! otherwise we consider the knot's representation with
700 //! no repetition of multiple knot values.
701 //! Knots (I1) <= U <= Knots (I2)
702 //! . if I1 = I2 U is a knot value (the tolerance criterion
703 //! ParametricTolerance is used).
704 //! . if I1 < 1 => U < Knots (1) - Abs(ParametricTolerance)
705 //! . if I2 > NbKnots => U > Knots (NbKnots) + Abs(ParametricTolerance)
706 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;
709 //! Returns the multiplicity of the knots of range Index.
710 //! Raised if Index < 1 or Index > NbKnots
711 Standard_EXPORT Standard_Integer Multiplicity (const Standard_Integer Index) const;
714 //! Returns the multiplicity of the knots of the curve.
716 //! Raised if the length of M is not equal to NbKnots.
717 Standard_EXPORT void Multiplicities (TColStd_Array1OfInteger& M) const;
719 //! returns the multiplicity of the knots of the curve.
720 Standard_EXPORT const TColStd_Array1OfInteger& Multiplicities() const;
723 //! Returns the number of knots. This method returns the number of
724 //! knot without repetition of multiple knots.
725 Standard_EXPORT Standard_Integer NbKnots() const;
727 //! Returns the number of poles
728 Standard_EXPORT Standard_Integer NbPoles() const;
730 //! Returns the pole of range Index.
731 //! Raised if Index < 1 or Index > NbPoles.
732 Standard_EXPORT const gp_Pnt& Pole(const Standard_Integer Index) const;
734 //! Returns the poles of the B-spline curve;
736 //! Raised if the length of P is not equal to the number of poles.
737 Standard_EXPORT void Poles (TColgp_Array1OfPnt& P) const;
739 //! Returns the poles of the B-spline curve;
740 Standard_EXPORT const TColgp_Array1OfPnt& Poles() const;
743 //! Returns the start point of the curve.
745 //! This point is different from the first pole of the curve if the
746 //! multiplicity of the first knot is lower than Degree.
747 Standard_EXPORT gp_Pnt StartPoint() const Standard_OVERRIDE;
749 //! Returns the weight of the pole of range Index .
750 //! Raised if Index < 1 or Index > NbPoles.
751 Standard_EXPORT Standard_Real Weight (const Standard_Integer Index) const;
753 //! Returns the weights of the B-spline curve;
755 //! Raised if the length of W is not equal to NbPoles.
756 Standard_EXPORT void Weights (TColStd_Array1OfReal& W) const;
758 //! Returns the weights of the B-spline curve;
759 Standard_EXPORT const TColStd_Array1OfReal* Weights() const;
761 //! Applies the transformation T to this BSpline curve.
762 Standard_EXPORT void Transform (const gp_Trsf& T) Standard_OVERRIDE;
765 //! Returns the value of the maximum degree of the normalized
766 //! B-spline basis functions in this package.
767 Standard_EXPORT static Standard_Integer MaxDegree();
769 //! Computes for this BSpline curve the parametric
770 //! tolerance UTolerance for a given 3D tolerance Tolerance3D.
771 //! If f(t) is the equation of this BSpline curve,
772 //! UTolerance ensures that:
773 //! | t1 - t0| < Utolerance ===>
774 //! |f(t1) - f(t0)| < Tolerance3D
775 Standard_EXPORT void Resolution (const Standard_Real Tolerance3D, Standard_Real& UTolerance);
777 //! Creates a new object which is a copy of this BSpline curve.
778 Standard_EXPORT Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
780 //! Comapare two Bspline curve on identity;
781 Standard_EXPORT Standard_Boolean IsEqual (const Handle(Geom_BSplineCurve)& theOther, const Standard_Real thePreci) const;
786 DEFINE_STANDARD_RTTIEXT(Geom_BSplineCurve,Geom_BoundedCurve)
796 //! Recompute the flatknots, the knotsdistribution, the continuity.
797 Standard_EXPORT void UpdateKnots();
799 Standard_Boolean rational;
800 Standard_Boolean periodic;
801 GeomAbs_BSplKnotDistribution knotSet;
802 GeomAbs_Shape smooth;
803 Standard_Integer deg;
804 Handle(TColgp_HArray1OfPnt) poles;
805 Handle(TColStd_HArray1OfReal) weights;
806 Handle(TColStd_HArray1OfReal) flatknots;
807 Handle(TColStd_HArray1OfReal) knots;
808 Handle(TColStd_HArray1OfInteger) mults;
809 Standard_Real maxderivinv;
810 Standard_Boolean maxderivinvok;
821 #endif // _Geom_BSplineCurve_HeaderFile