b311480e |
1 | -- Created on: 1993-03-24 |
2 | -- Created by: JCV |
3 | -- Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | -- |
973c2be1 |
6 | -- This file is part of Open CASCADE Technology software library. |
b311480e |
7 | -- |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | -- |
973c2be1 |
14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. |
7fd59977 |
16 | |
7fd59977 |
17 | -- xab : modified 15-Mar-95 : added cache mecanism to speed up |
18 | -- evaluation |
19 | |
20 | |
21 | class BSplineCurve from Geom2d inherits BoundedCurve from Geom2d |
22 | |
23 | --- Purpose : Describes a BSpline curve. |
24 | -- A BSpline curve can be: |
25 | -- - uniform or non-uniform, |
26 | -- - rational or non-rational, |
27 | -- - periodic or non-periodic. |
28 | -- A BSpline curve is defined by: |
29 | -- - its degree; the degree for a |
30 | -- Geom2d_BSplineCurve is limited to a value (25) |
31 | -- which is defined and controlled by the system. This |
32 | -- value is returned by the function MaxDegree; |
33 | -- - its periodic or non-periodic nature; |
34 | -- - a table of poles (also called control points), with |
35 | -- their associated weights if the BSpline curve is |
36 | -- rational. The poles of the curve are "control points" |
37 | -- used to deform the curve. If the curve is |
38 | -- non-periodic, the first pole is the start point of the |
39 | -- curve, and the last pole is the end point of the |
40 | -- curve. The segment, which joins the first pole to the |
41 | -- second pole, is the tangent to the curve at its start |
42 | -- point, and the segment, which joins the last pole to |
43 | -- the second-from-last pole, is the tangent to the |
44 | -- curve at its end point. If the curve is periodic, these |
45 | -- geometric properties are not verified. It is more |
46 | -- difficult to give a geometric signification to the |
47 | -- weights but they are useful for providing exact |
48 | -- representations of the arcs of a circle or ellipse. |
49 | -- Moreover, if the weights of all the poles are equal, |
50 | -- the curve has a polynomial equation; it is |
51 | -- therefore a non-rational curve. |
52 | -- - a table of knots with their multiplicities. For a |
53 | -- Geom2d_BSplineCurve, the table of knots is an |
54 | -- increasing sequence of reals without repetition; the |
55 | -- multiplicities define the repetition of the knots. A |
56 | -- BSpline curve is a piecewise polynomial or rational |
57 | -- curve. The knots are the parameters of junction |
58 | -- points between two pieces. The multiplicity |
59 | -- Mult(i) of the knot Knot(i) of the BSpline |
60 | -- curve is related to the degree of continuity of the |
61 | -- curve at the knot Knot(i), which is equal to |
62 | -- Degree - Mult(i) where Degree is the |
63 | -- degree of the BSpline curve. |
64 | -- If the knots are regularly spaced (i.e. the difference |
65 | -- between two consecutive knots is a constant), three |
66 | -- specific and frequently used cases of knot distribution |
67 | -- can be identified: |
68 | -- - "uniform" if all multiplicities are equal to 1, |
69 | -- - "quasi-uniform" if all multiplicities are equal to 1, |
70 | -- except the first and the last knot which have a |
71 | -- multiplicity of Degree + 1, where Degree is |
72 | -- the degree of the BSpline curve, |
73 | -- - "Piecewise Bezier" if all multiplicities are equal to |
74 | -- Degree except the first and last knot which have |
75 | -- a multiplicity of Degree + 1, where Degree is |
76 | -- the degree of the BSpline curve. A curve of this |
77 | -- type is a concatenation of arcs of Bezier curves. |
78 | -- If the BSpline curve is not periodic: |
79 | -- - the bounds of the Poles and Weights tables are 1 |
80 | -- and NbPoles, where NbPoles is the number of |
81 | -- poles of the BSpline curve, |
82 | -- - the bounds of the Knots and Multiplicities tables are |
83 | -- 1 and NbKnots, where NbKnots is the number |
84 | -- of knots of the BSpline curve. |
85 | -- If the BSpline curve is periodic, and if there are k |
86 | -- periodic knots and p periodic poles, the period is: |
87 | -- period = Knot(k + 1) - Knot(1) |
88 | -- and the poles and knots tables can be considered as |
89 | -- infinite tables, such that: |
90 | -- - Knot(i+k) = Knot(i) + period |
91 | -- - Pole(i+p) = Pole(i) |
92 | -- Note: data structures of a periodic BSpline curve are |
93 | -- more complex than those of a non-periodic one. |
94 | -- Warnings : |
95 | -- In this class we consider that a weight value is zero if |
96 | -- Weight <= Resolution from package gp. |
97 | -- For two parametric values (or two knot values) U1, U2 we |
98 | -- consider that U1 = U2 if Abs (U2 - U1) <= Epsilon (U1). |
99 | -- For two weights values W1, W2 we consider that W1 = W2 if |
100 | -- Abs (W2 - W1) <= Epsilon (W1). The method Epsilon is |
101 | -- defined in the class Real from package Standard. |
102 | -- |
103 | -- References : |
104 | -- . A survey of curve and surface methods in CADG Wolfgang BOHM |
105 | -- CAGD 1 (1984) |
106 | -- . On de Boor-like algorithms and blossoming Wolfgang BOEHM |
107 | -- cagd 5 (1988) |
108 | -- . Blossoming and knot insertion algorithms for B-spline curves |
109 | -- Ronald N. GOLDMAN |
110 | -- . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA |
111 | -- . Curves and Surfaces for Computer Aided Geometric Design, |
112 | -- a practical guide Gerald Farin |
113 | |
114 | |
115 | uses Array1OfInteger from TColStd, |
116 | Array1OfReal from TColStd, |
117 | HArray1OfInteger from TColStd, |
118 | HArray1OfReal from TColStd, |
119 | Array1OfPnt2d from TColgp, |
120 | Ax2d from gp, |
121 | Pnt2d from gp, |
122 | HArray1OfPnt2d from TColgp, |
123 | Trsf2d from gp, |
124 | Vec2d from gp, |
125 | BSplKnotDistribution from GeomAbs, |
126 | Geometry from Geom2d, |
94f71cad |
127 | Shape from GeomAbs |
7fd59977 |
128 | |
129 | raises ConstructionError from Standard, |
130 | DimensionError from Standard, |
131 | DomainError from Standard, |
132 | OutOfRange from Standard, |
133 | RangeError from Standard, |
134 | NoSuchObject from Standard, |
135 | UndefinedDerivative from Geom2d |
136 | |
137 | is |
138 | |
139 | |
140 | |
141 | Create (Poles : Array1OfPnt2d from TColgp; |
142 | Knots : Array1OfReal from TColStd; |
143 | Multiplicities : Array1OfInteger from TColStd; |
144 | Degree : Integer; |
145 | Periodic : Boolean = Standard_False) |
146 | |
6e33d3ce |
147 | returns BSplineCurve from Geom2d |
7fd59977 |
148 | |
149 | ---Purpose : Creates a non-rational B_spline curve on the |
150 | -- basis <Knots, Multiplicities> of degree <Degree>. |
151 | -- The following conditions must be verified. |
152 | -- 0 < Degree <= MaxDegree. |
153 | -- |
154 | -- Knots.Length() == Mults.Length() >= 2 |
155 | -- |
156 | -- Knots(i) < Knots(i+1) (Knots are increasing) |
157 | -- |
158 | -- 1 <= Mults(i) <= Degree |
159 | -- |
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). |
163 | -- |
164 | -- On a periodic curve the first and the last multicities |
165 | -- must be the same. |
166 | -- |
167 | -- on non-periodic curves |
168 | -- |
169 | -- Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2 |
170 | -- |
171 | -- on periodic curves |
172 | -- |
173 | -- Poles.Length() == Sum(Mults(i)) except the first or last |
174 | |
175 | raises ConstructionError; |
176 | |
177 | |
178 | |
179 | Create (Poles : Array1OfPnt2d from TColgp; |
180 | Weights : Array1OfReal from TColStd; |
181 | Knots : Array1OfReal from TColStd; |
182 | Multiplicities : Array1OfInteger from TColStd; |
183 | Degree : Integer; |
184 | Periodic : Boolean = Standard_False) |
185 | |
6e33d3ce |
186 | returns BSplineCurve from Geom2d |
7fd59977 |
187 | |
188 | ---Purpose : Creates a rational B_spline curve on the basis |
189 | -- <Knots, Multiplicities> of degree <Degree>. |
190 | -- The following conditions must be verified. |
191 | -- 0 < Degree <= MaxDegree. |
192 | -- |
193 | -- Knots.Length() == Mults.Length() >= 2 |
194 | -- |
195 | -- Knots(i) < Knots(i+1) (Knots are increasing) |
196 | -- |
197 | -- 1 <= Mults(i) <= Degree |
198 | -- |
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). |
202 | -- |
203 | -- On a periodic curve the first and the last multicities |
204 | -- must be the same. |
205 | -- |
206 | -- on non-periodic curves |
207 | -- |
208 | -- Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2 |
209 | -- |
210 | -- on periodic curves |
211 | -- |
212 | -- Poles.Length() == Sum(Mults(i)) except the first or last |
213 | |
214 | raises ConstructionError; |
215 | |
216 | |
217 | IncreaseDegree (me : mutable; Degree : Integer) |
218 | |
219 | ---Purpose: Increases the degree of this BSpline curve to |
220 | -- Degree. As a result, the poles, weights and |
221 | -- multiplicities tables are modified; the knots table is |
222 | -- not changed. Nothing is done if Degree is less than |
223 | -- or equal to the current degree. |
224 | -- Exceptions |
225 | -- Standard_ConstructionError if Degree is greater than |
226 | -- Geom2d_BSplineCurve::MaxDegree(). |
227 | raises ConstructionError; |
228 | |
229 | |
230 | IncreaseMultiplicity (me : mutable; Index : Integer; M : Integer) |
231 | |
232 | ---Purpose :Increases the multiplicity of the knot <Index> to |
233 | -- <M>. |
234 | -- |
235 | -- If <M> is lower or equal to the current |
236 | -- multiplicity nothing is done. If <M> is higher than |
237 | -- the degree the degree is used. |
238 | |
239 | raises OutOfRange; |
240 | |
241 | ---Purpose: If <Index> is not in [FirstUKnotIndex, LastUKnotIndex] |
242 | |
243 | |
244 | IncreaseMultiplicity (me : mutable; I1, I2 : Integer; M : Integer) |
245 | |
246 | ---Purpose :Increases the multiplicities of the knots in |
247 | -- [I1,I2] to <M>. |
248 | -- |
249 | -- For each knot if <M> is lower or equal to the |
250 | -- current multiplicity nothing is done. If <M> is |
251 | -- higher than the degree the degree is used. |
252 | -- As a result, the poles and weights tables of this curve are modified. |
253 | -- Warning |
254 | -- It is forbidden to modify the multiplicity of the first or |
255 | -- last knot of a non-periodic curve. Be careful as |
256 | -- Geom2d does not protect against this. |
257 | -- Exceptions |
258 | -- Standard_OutOfRange if either Index, I1 or I2 is |
259 | -- outside the bounds of the knots table. |
260 | raises OutOfRange; |
261 | |
262 | |
263 | IncrementMultiplicity (me : mutable; I1, I2 : Integer; M : Integer) |
264 | |
265 | ---Purpose : Increases by M the multiplicity of the knots of indexes |
266 | -- I1 to I2 in the knots table of this BSpline curve. For |
267 | -- each knot, the resulting multiplicity is limited to the |
268 | -- degree of this curve. If M is negative, nothing is done. |
269 | -- As a result, the poles and weights tables of this |
270 | -- BSpline curve are modified. |
271 | -- Warning |
272 | -- It is forbidden to modify the multiplicity of the first or |
273 | -- last knot of a non-periodic curve. Be careful as |
274 | -- Geom2d does not protect against this. |
275 | -- Exceptions |
276 | -- Standard_OutOfRange if I1 or I2 is outside the |
277 | -- bounds of the knots table. |
278 | |
279 | raises OutOfRange; |
280 | |
281 | |
282 | InsertKnot (me : mutable; |
283 | U : Real; |
284 | M : Integer = 1; |
285 | ParametricTolerance : Real = 0.0); |
286 | |
287 | ---Purpose: Inserts a knot value in the sequence of knots. If |
288 | -- <U> is an existing knot the multiplicity is |
289 | -- increased by <M>. |
290 | -- |
291 | -- If U is not on the parameter range nothing is |
292 | -- done. |
293 | -- |
294 | -- If the multiplicity is negative or null nothing is |
295 | -- done. The new multiplicity is limited to the |
296 | -- degree. |
297 | -- |
298 | -- The tolerance criterion for knots equality is |
299 | -- the max of Epsilon(U) and ParametricTolerance. |
300 | -- Warning |
301 | -- - If U is less than the first parameter or greater than |
302 | -- the last parameter of this BSpline curve, nothing is done. |
303 | -- - If M is negative or null, nothing is done. |
304 | -- - The multiplicity of a knot is limited to the degree of |
305 | -- this BSpline curve. |
306 | |
307 | |
308 | InsertKnots (me : mutable; Knots : Array1OfReal from TColStd; |
309 | Mults : Array1OfInteger from TColStd; |
310 | ParametricTolerance : Real = 0.0; |
311 | Add : Boolean = Standard_False); |
312 | |
313 | ---Purpose: Inserts the values of the array Knots, with the |
314 | -- respective multiplicities given by the array Mults, into |
315 | -- the knots table of this BSpline curve. |
316 | -- If a value of the array Knots is an existing knot, its multiplicity is: |
317 | -- - increased by M, if Add is true, or |
318 | -- - increased to M, if Add is false (default value). |
319 | -- The tolerance criterion used for knot equality is the |
320 | -- larger of the values ParametricTolerance (defaulted |
321 | -- to 0.) and Standard_Real::Epsilon(U), |
322 | -- where U is the current knot value. |
323 | -- Warning |
324 | -- - For a value of the array Knots which is less than |
325 | -- the first parameter or greater than the last |
326 | -- parameter of this BSpline curve, nothing is done. |
327 | -- - For a value of the array Mults which is negative or |
328 | -- null, nothing is done. |
329 | -- - The multiplicity of a knot is limited to the degree of |
330 | -- this BSpline curve. |
331 | |
332 | |
333 | |
334 | RemoveKnot(me : mutable; Index : Integer; |
335 | M : Integer; |
336 | Tolerance : Real) returns Boolean |
337 | |
338 | ---Purpose : Reduces the multiplicity of the knot of index Index |
339 | -- to M. If M is equal to 0, the knot is removed. |
340 | -- With a modification of this type, the array of poles is also modified. |
341 | -- Two different algorithms are systematically used to |
342 | -- compute the new poles of the curve. If, for each |
343 | -- pole, the distance between the pole calculated |
344 | -- using the first algorithm and the same pole |
345 | -- calculated using the second algorithm, is less than |
346 | -- Tolerance, this ensures that the curve is not |
347 | -- modified by more than Tolerance. Under these |
348 | -- conditions, true is returned; otherwise, false is returned. |
349 | -- A low tolerance is used to prevent modification of |
350 | -- the curve. A high tolerance is used to "smooth" the curve. |
351 | -- Exceptions |
352 | -- Standard_OutOfRange if Index is outside the |
353 | -- bounds of the knots table. |
354 | raises OutOfRange; |
355 | |
356 | |
357 | InsertPoleAfter (me : mutable; Index : Integer; P : Pnt2d; |
358 | Weight : Real = 1.0) |
359 | --- Purpose : |
360 | -- The new pole is inserted after the pole of range Index. |
361 | -- If the curve was non rational it can become rational. |
362 | raises ConstructionError, |
363 | --- Purpose : |
364 | -- Raised if the B-spline is NonUniform or PiecewiseBezier or if |
365 | -- Weight <= 0.0 |
366 | OutOfRange; |
367 | --- Purpose : Raised if Index is not in the range [1, Number of Poles] |
368 | |
369 | |
370 | InsertPoleBefore (me : mutable; Index : Integer; P : Pnt2d; |
371 | Weight : Real = 1.0) |
372 | --- Purpose : |
373 | -- The new pole is inserted before the pole of range Index. |
374 | -- If the curve was non rational it can become rational. |
375 | raises ConstructionError, |
376 | --- Purpose : |
377 | -- Raised if the B-spline is NonUniform or PiecewiseBezier or if |
378 | -- Weight <= 0.0 |
379 | OutOfRange; |
380 | --- Purpose : Raised if Index is not in the range [1, Number of Poles] |
381 | |
382 | |
383 | RemovePole (me : mutable; Index : Integer) |
384 | --- Purpose : |
385 | -- Removes the pole of range Index |
386 | -- If the curve was rational it can become non rational. |
387 | raises ConstructionError, |
388 | --- Purpose : |
389 | -- Raised if the B-spline is NonUniform or PiecewiseBezier. |
390 | -- Raised if the number of poles of the B-spline curve is lower or |
391 | -- equal to 2 before removing. |
392 | OutOfRange; |
393 | --- Purpose : Raised if Index is not in the range [1, Number of Poles] |
394 | |
395 | Reverse (me : mutable); |
396 | --- Purpose : Reverses the orientation of this BSpline curve. As a result |
397 | -- - the knots and poles tables are modified; |
398 | -- - the start point of the initial curve becomes the end |
399 | -- point of the reversed curve; |
400 | -- - the end point of the initial curve becomes the start |
401 | -- point of the reversed curve. |
402 | |
403 | |
404 | ReversedParameter(me; U : Real) returns Real; |
405 | ---Purpose: Computes the parameter on the reversed curve for |
406 | -- the point of parameter U on this BSpline curve. |
407 | -- The returned value is: UFirst + ULast - U, |
408 | -- where UFirst and ULast are the values of the |
409 | -- first and last parameters of this BSpline curve. |
410 | |
411 | |
412 | Segment (me : mutable; U1, U2 : Real) |
413 | ---Purpose : Modifies this BSpline curve by segmenting it |
414 | -- between U1 and U2. Either of these values can be |
415 | -- outside the bounds of the curve, but U2 must be greater than U1. |
416 | -- All data structure tables of this BSpline curve are |
417 | -- modified, but the knots located between U1 and U2 |
418 | -- are retained. The degree of the curve is not modified. |
419 | -- Warnings : |
420 | -- Even if <me> is not closed it can become closed after the |
421 | -- segmentation for example if U1 or U2 are out of the bounds |
422 | -- of the curve <me> or if the curve makes loop. |
423 | -- After the segmentation the length of a curve can be null. |
424 | -- - The segmentation of a periodic curve over an |
425 | --- interval corresponding to its period generates a |
426 | -- non-periodic curve with equivalent geometry. |
427 | -- Exceptions |
428 | -- Standard_DomainError if U2 is less than U1. |
429 | raises DomainError from Standard; |
430 | ---Purpose: raises if U2 < U1. |
431 | |
432 | |
433 | SetKnot (me : mutable; Index : Integer; K : Real) |
434 | --- Purpose : Modifies this BSpline curve by assigning the value K |
435 | -- to the knot of index Index in the knots table. This is a |
436 | -- relatively local modification because K must be such that: |
437 | -- Knots(Index - 1) < K < Knots(Index + 1) |
438 | -- Exceptions |
439 | -- Standard_ConstructionError if: |
440 | -- - K is not such that: |
441 | -- Knots(Index - 1) < K < Knots(Index + 1) |
442 | -- - M is greater than the degree of this BSpline curve |
443 | -- or lower than the previous multiplicity of knot of |
444 | -- index Index in the knots table. |
445 | -- Standard_OutOfRange if Index is outside the bounds of the knots table. |
446 | raises ConstructionError, |
447 | OutOfRange; |
448 | |
449 | |
450 | SetKnots (me : mutable; K : Array1OfReal from TColStd) |
451 | --- Purpose : Modifies this BSpline curve by assigning the array |
452 | -- K to its knots table. The multiplicity of the knots is not modified. |
453 | -- Exceptions |
454 | -- Standard_ConstructionError if the values in the |
455 | -- array K are not in ascending order. |
456 | -- Standard_OutOfRange if the bounds of the array |
457 | -- K are not respectively 1 and the number of knots of this BSpline curve. |
458 | raises ConstructionError, |
459 | OutOfRange; |
460 | |
461 | |
462 | SetKnot (me : mutable; Index : Integer; K : Real; M : Integer) |
463 | --- Purpose : Modifies this BSpline curve by assigning the value K |
464 | -- to the knot of index Index in the knots table. This is a |
465 | -- relatively local modification because K must be such that: |
466 | -- Knots(Index - 1) < K < Knots(Index + 1) |
467 | -- The second syntax allows you also to increase the |
468 | -- multiplicity of the knot to M (but it is not possible to |
469 | -- decrease the multiplicity of the knot with this function). |
470 | -- Exceptions |
471 | -- Standard_ConstructionError if: |
472 | -- - K is not such that: |
473 | -- Knots(Index - 1) < K < Knots(Index + 1) |
474 | -- - M is greater than the degree of this BSpline curve |
475 | -- or lower than the previous multiplicity of knot of |
476 | -- index Index in the knots table. |
477 | -- Standard_OutOfRange if Index is outside the bounds of the knots table. |
478 | raises ConstructionError, |
479 | OutOfRange; |
480 | |
481 | PeriodicNormalization(me ; U : in out Real) ; |
482 | |
483 | ---Purpose : Computes the parameter normalized within the |
484 | -- "first" period of this BSpline curve, if it is periodic: |
485 | -- the returned value is in the range Param1 and |
486 | -- Param1 + Period, where: |
487 | -- - Param1 is the "first parameter", and |
488 | -- - Period the period of this BSpline curve. |
489 | -- Note: If this curve is not periodic, U is not modified. |
490 | |
491 | SetPeriodic (me : mutable) |
492 | --- Purpose :Changes this BSpline curve into a periodic curve. |
493 | -- To become periodic, the curve must first be closed. |
494 | -- Next, the knot sequence must be periodic. For this, |
495 | -- FirstUKnotIndex and LastUKnotIndex are used to |
496 | -- compute I1 and I2, the indexes in the knots array |
497 | -- of the knots corresponding to the first and last |
498 | -- parameters of this BSpline curve. |
499 | -- The period is therefore Knot(I2) - Knot(I1). |
500 | -- Consequently, the knots and poles tables are modified. |
501 | -- Exceptions |
502 | -- Standard_ConstructionError if this BSpline curve is not closed. |
503 | raises ConstructionError; |
504 | |
505 | |
506 | SetOrigin (me : mutable; Index : Integer) |
507 | ---Purpose: Assigns the knot of index Index in the knots table as |
508 | -- the origin of this periodic BSpline curve. As a |
509 | -- consequence, the knots and poles tables are modified. |
510 | -- Exceptions |
511 | -- Standard_NoSuchObject if this curve is not periodic. |
512 | -- Standard_DomainError if Index is outside the |
513 | -- bounds of the knots table. |
514 | raises NoSuchObject, |
515 | DomainError; |
516 | |
517 | |
518 | SetNotPeriodic (me : mutable); |
519 | --- Purpose : Changes this BSpline curve into a non-periodic |
520 | -- curve. If this curve is already non-periodic, it is not modified. |
521 | -- Note that the poles and knots tables are modified. |
522 | -- Warning |
523 | -- If this curve is periodic, as the multiplicity of the first |
524 | -- and last knots is not modified, and is not equal to |
525 | -- Degree + 1, where Degree is the degree of |
526 | -- this BSpline curve, the start and end points of the |
527 | -- curve are not its first and last poles. |
528 | |
529 | |
530 | SetPole (me : mutable; Index : Integer; P : Pnt2d) |
531 | --- Purpose : Modifies this BSpline curve by assigning P to the |
532 | -- pole of index Index in the poles table. |
533 | -- Exceptions |
534 | -- Standard_OutOfRange if Index is outside the |
535 | -- bounds of the poles table. |
536 | -- Standard_ConstructionError if Weight is negative or null. |
537 | raises OutOfRange; |
538 | |
539 | |
540 | SetPole (me : mutable; Index : Integer; P : Pnt2d; Weight : Real) |
541 | --- Purpose : Modifies this BSpline curve by assigning P to the |
542 | -- pole of index Index in the poles table. |
543 | -- The second syntax also allows you to modify the |
544 | -- weight of the modified pole, which becomes Weight. |
545 | -- In this case, if this BSpline curve is non-rational, it |
546 | -- can become rational and vice versa. |
547 | -- Exceptions |
548 | -- Standard_OutOfRange if Index is outside the |
549 | -- bounds of the poles table. |
550 | -- Standard_ConstructionError if Weight is negative or null. |
551 | raises OutOfRange, |
552 | ConstructionError; |
553 | |
554 | SetWeight (me : mutable; Index : Integer; Weight : Real) |
555 | --- Purpose : Assigns the weight Weight to the pole of index Index of the poles table. |
556 | -- If the curve was non rational it can become rational. |
557 | -- If the curve was rational it can become non rational. |
558 | -- Exceptions |
559 | -- Standard_OutOfRange if Index is outside the |
560 | -- bounds of the poles table. |
561 | -- Standard_ConstructionError if Weight is negative or null. |
562 | raises OutOfRange, |
563 | ConstructionError; |
564 | |
565 | MovePoint (me : mutable; U: Real; P: Pnt2d; Index1, Index2: Integer; |
566 | FirstModifiedPole, LastModifiedPole: out Integer) |
567 | ---Purpose : Moves the point of parameter U of this BSpline |
568 | -- curve to P. Index1 and Index2 are the indexes in the |
569 | -- table of poles of this BSpline curve of the first and |
570 | -- last poles designated to be moved. |
571 | -- FirstModifiedPole and LastModifiedPole are the |
572 | -- indexes of the first and last poles, which are |
573 | -- effectively modified. |
574 | -- In the event of incompatibility between Index1, |
575 | -- Index2 and the value U: |
576 | -- - no change is made to this BSpline curve, and |
577 | -- - the FirstModifiedPole and LastModifiedPole are returned null. |
578 | -- Exceptions |
579 | -- Standard_OutOfRange if: |
580 | -- - Index1 is greater than or equal to Index2, or |
581 | -- - Index1 or Index2 is less than 1 or greater than the |
582 | -- number of poles of this BSpline curve. |
583 | raises OutOfRange; |
584 | |
585 | |
586 | MovePointAndTangent (me : mutable; |
587 | U : Real; |
588 | P : Pnt2d; |
589 | Tangent : Vec2d ; |
590 | Tolerance : Real ; |
591 | StartingCondition, |
592 | EndingCondition : Integer; |
593 | ErrorStatus : out Integer) |
594 | |
595 | ---Purpose : Move a point with parameter U to P. |
596 | -- and makes it tangent at U be Tangent. |
597 | -- StartingCondition = -1 means first can move |
598 | -- EndingCondition = -1 means last point can move |
599 | -- StartingCondition = 0 means the first point cannot move |
600 | -- EndingCondition = 0 means the last point cannot move |
601 | -- StartingCondition = 1 means the first point and tangent cannot move |
602 | -- EndingCondition = 1 means the last point and tangent cannot move |
603 | -- and so forth |
604 | -- ErrorStatus != 0 means that there are not enought degree of freedom |
605 | -- with the constrain to deform the curve accordingly |
606 | |
607 | raises OutOfRange; |
608 | |
609 | |
610 | IsCN (me; N : Integer) returns Boolean |
611 | --- Purpose : Returns true if the degree of continuity of this |
612 | -- BSpline curve is at least N. A BSpline curve is at least GeomAbs_C0. |
613 | -- Exceptions Standard_RangeError if N is negative. |
614 | raises RangeError; |
615 | |
3d58dc49 |
616 | IsG1 (me; theTf, theTl, theAngTol : Real) returns Boolean; |
617 | ---Purpose : |
618 | -- Check if curve has at least G1 continuity in interval [theTf, theTl] |
619 | -- Returns true if IsCN(1) |
620 | -- or |
621 | -- angle betweem "left" and "right" first derivatives at |
622 | -- knots with C0 continuity is less then theAngTol |
623 | -- only knots in interval [theTf, theTl] is checked |
7fd59977 |
624 | |
625 | IsClosed (me) returns Boolean; |
626 | --- Purpose : |
627 | -- Returns true if the distance between the first point and the |
628 | -- last point of the curve is lower or equal to Resolution |
629 | -- from package gp. |
630 | -- Warnings : |
631 | -- The first and the last point can be different from the first |
632 | -- pole and the last pole of the curve. |
633 | |
634 | |
635 | IsPeriodic (me) returns Boolean; |
636 | --- Purpose : Returns True if the curve is periodic. |
637 | |
638 | |
639 | IsRational (me) returns Boolean; |
640 | --- Purpose : |
641 | -- Returns True if the weights are not identical. |
642 | -- The tolerance criterion is Epsilon of the class Real. |
643 | |
7fd59977 |
644 | Continuity (me) returns Shape from GeomAbs; |
645 | --- Purpose : |
646 | -- Returns the global continuity of the curve : |
647 | -- C0 : only geometric continuity, |
648 | -- C1 : continuity of the first derivative all along the Curve, |
649 | -- C2 : continuity of the second derivative all along the Curve, |
650 | -- C3 : continuity of the third derivative all along the Curve, |
651 | -- CN : the order of continuity is infinite. |
652 | -- For a B-spline curve of degree d if a knot Ui has a |
653 | -- multiplicity p the B-spline curve is only Cd-p continuous |
654 | -- at Ui. So the global continuity of the curve can't be greater |
655 | -- than Cd-p where p is the maximum multiplicity of the interior |
656 | -- Knots. In the interior of a knot span the curve is infinitely |
657 | -- continuously differentiable. |
658 | |
659 | |
660 | Degree (me) returns Integer; |
661 | --- Purpose : Returns the degree of this BSpline curve. |
662 | -- In this class the degree of the basis normalized B-spline |
663 | -- functions cannot be greater than "MaxDegree" |
664 | |
665 | |
666 | --- Purpose : Computation of value and derivatives |
667 | |
668 | D0 (me; U : Real; P : out Pnt2d); |
669 | |
670 | |
671 | D1 (me; U : Real; P : out Pnt2d; V1 : out Vec2d) |
672 | raises UndefinedDerivative; |
673 | --- Purpose : Raised if the continuity of the curve is not C1. |
674 | |
675 | |
676 | D2 (me; U : Real; P : out Pnt2d; V1, V2 : out Vec2d) |
677 | raises UndefinedDerivative; |
678 | --- Purpose : Raised if the continuity of the curve is not C2. |
679 | |
680 | |
681 | D3 (me; U : Real; P : out Pnt2d; V1, V2, V3 : out Vec2d) |
682 | raises UndefinedDerivative; |
683 | --- Purpose: For this BSpline curve, computes |
684 | -- - the point P of parameter U, or |
685 | -- - the point P and one or more of the following values: |
686 | -- - V1, the first derivative vector, |
687 | -- - V2, the second derivative vector, |
688 | -- - V3, the third derivative vector. |
689 | -- Warning |
690 | -- On a point where the continuity of the curve is not the |
691 | -- one requested, these functions impact the part |
692 | -- defined by the parameter with a value greater than U, |
693 | -- i.e. the part of the curve to the "right" of the singularity. |
694 | -- Raises UndefinedDerivative if the continuity of the curve is not C3. |
695 | |
696 | DN (me; U : Real; N : Integer) returns Vec2d |
697 | --- Purpose: For the point of parameter U of this BSpline curve, |
698 | -- computes the vector corresponding to the Nth derivative. |
699 | -- Warning |
700 | -- On a point where the continuity of the curve is not the |
701 | -- one requested, this function impacts the part defined |
702 | -- by the parameter with a value greater than U, i.e. the |
703 | -- part of the curve to the "right" of the singularity. |
704 | -- Raises UndefinedDerivative if the continuity of the curve is not CN. |
705 | -- RangeError if N < 1. |
706 | raises UndefinedDerivative, |
707 | RangeError; |
708 | |
709 | --- Purpose: The following functions computes the point of parameter U |
710 | -- and the derivatives at this point on the B-spline curve |
711 | -- arc defined between the knot FromK1 and the knot ToK2. |
712 | -- U can be out of bounds [Knot (FromK1), Knot (ToK2)] but |
713 | -- for the computation we only use the definition of the curve |
714 | -- between these two knots. This method is useful to compute |
715 | -- local derivative, if the order of continuity of the whole |
716 | -- curve is not greater enough. Inside the parametric |
717 | -- domain Knot (FromK1), Knot (ToK2) the evaluations are |
718 | -- the same as if we consider the whole definition of the |
719 | -- curve. Of course the evaluations are different outside |
720 | -- this parametric domain. |
721 | |
722 | |
723 | LocalValue (me; U : Real; FromK1, ToK2 : Integer) returns Pnt2d |
724 | raises DomainError, |
725 | --- Purpose : Raised if FromK1 = ToK2. |
726 | OutOfRange; |
727 | --- Purpose : |
728 | -- Raised if FromK1 and ToK2 are not in the range |
729 | -- [FirstUKnotIndex, LastUKnotIndex]. |
730 | |
731 | |
732 | LocalD0 (me; U : Real; FromK1, ToK2 : Integer; |
733 | P : out Pnt2d) |
734 | raises UndefinedDerivative, OutOfRange; |
735 | |
736 | |
737 | LocalD1 (me; U : Real; FromK1, ToK2 : Integer; |
738 | P : out Pnt2d; V1 : out Vec2d) |
739 | raises UndefinedDerivative, |
740 | --- Purpose : |
741 | -- Raised if the local continuity of the curve is not C1 |
742 | -- between the knot K1 and the knot K2. |
743 | DomainError, |
744 | --- Purpose : Raised if FromK1 = ToK2. |
745 | OutOfRange; |
746 | --- Purpose : |
747 | -- Raised if FromK1 and ToK2 are not in the range |
748 | -- [FirstUKnotIndex, LastUKnotIndex]. |
749 | |
750 | |
751 | LocalD2 (me; U : Real; FromK1, ToK2 : Integer; |
752 | P : out Pnt2d; V1, V2 : out Vec2d) |
753 | raises UndefinedDerivative, |
754 | --- Purpose : |
755 | -- Raised if the local continuity of the curve is not C2 |
756 | -- between the knot K1 and the knot K2. |
757 | DomainError, |
758 | --- Purpose : Raised if FromK1 = ToK2. |
759 | OutOfRange; |
760 | --- Purpose : |
761 | -- Raised if FromK1 and ToK2 are not in the range |
762 | -- [FirstUKnotIndex, LastUKnotIndex]. |
763 | |
764 | |
765 | |
766 | LocalD3 (me; U : Real; FromK1, ToK2 : Integer; |
767 | P : out Pnt2d; V1, V2, V3 : out Vec2d) |
768 | raises UndefinedDerivative, |
769 | --- Purpose : |
770 | -- Raised if the local continuity of the curve is not C3 |
771 | -- between the knot K1 and the knot K2. |
772 | DomainError, |
773 | --- Purpose : Raised if FromK1 = ToK2. |
774 | OutOfRange; |
775 | --- Purpose : |
776 | -- Raised if FromK1 and ToK2 are not in the range |
777 | -- [FirstUKnotIndex, LastUKnotIndex]. |
778 | |
779 | |
780 | LocalDN (me; U : Real; FromK1, ToK2 : Integer; N : Integer) returns Vec2d |
781 | raises UndefinedDerivative, |
782 | --- Purpose : |
783 | -- Raised if the local continuity of the curve is not CN |
784 | -- between the knot K1 and the knot K2. |
785 | DomainError, |
786 | --- Purpose : Raised if FromK1 = ToK2. |
787 | RangeError, |
788 | --- Purpose : Raised if N < 1. |
789 | OutOfRange; |
790 | --- Purpose : |
791 | -- Raises if FromK1 and ToK2 are not in the range |
792 | -- [FirstUKnotIndex, LastUKnotIndex]. |
793 | |
794 | |
795 | EndPoint (me) returns Pnt2d; |
796 | --- Purpose : |
797 | -- Returns the last point of the curve. |
798 | -- Warnings : |
799 | -- The last point of the curve is different from the last |
800 | -- pole of the curve if the multiplicity of the last knot |
801 | -- is lower than Degree. |
802 | |
803 | |
804 | FirstUKnotIndex (me) returns Integer; |
805 | --- Purpose : |
806 | -- For a B-spline curve the first parameter (which gives the start |
807 | -- point of the curve) is a knot value but if the multiplicity of |
808 | -- the first knot index is lower than Degree + 1 it is not the |
809 | -- first knot of the curve. This method computes the index of the |
810 | -- knot corresponding to the first parameter. |
811 | |
812 | |
813 | FirstParameter (me) returns Real; |
814 | --- Purpose : |
815 | -- Computes the parametric value of the start point of the curve. |
816 | -- It is a knot value. |
817 | |
818 | |
819 | Knot (me; Index : Integer) returns Real |
820 | --- Purpose : |
821 | -- Returns the knot of range Index. When there is a knot |
822 | -- with a multiplicity greater than 1 the knot is not repeated. |
823 | -- The method Multiplicity can be used to get the multiplicity |
824 | -- of the Knot. |
825 | raises OutOfRange; |
826 | --- Purpose : Raised if Index < 1 or Index > NbKnots |
827 | |
828 | |
829 | Knots (me; K : out Array1OfReal from TColStd) |
830 | --- Purpose : returns the knot values of the B-spline curve; |
831 | raises DimensionError; |
832 | --- Purpose : |
833 | -- Raised if the length of K is not equal to the number of knots. |
94f71cad |
834 | Knots (me) |
835 | returns Array1OfReal from TColStd |
836 | ---Purpose : returns the knot values of the B-spline curve; |
837 | ---C++ : return const & |
838 | is static; |
7fd59977 |
839 | |
840 | |
841 | KnotSequence (me; K : out Array1OfReal from TColStd) |
842 | --- Purpose : Returns the knots sequence. |
843 | -- In this sequence the knots with a multiplicity greater than 1 |
844 | -- are repeated. |
845 | -- Example : |
846 | -- K = {k1, k1, k1, k2, k3, k3, k4, k4, k4} |
847 | raises DimensionError; |
848 | --- Purpose : |
849 | -- Raised if the length of K is not equal to NbPoles + Degree + 1 |
94f71cad |
850 | KnotSequence (me) |
851 | returns Array1OfReal from TColStd |
852 | ---Purpose : Returns the knots sequence. |
853 | -- In this sequence the knots with a multiplicity greater than 1 |
854 | -- are repeated. |
855 | -- Example : |
856 | -- K = {k1, k1, k1, k2, k3, k3, k4, k4, k4} |
857 | ---C++ : return const & |
858 | is static; |
7fd59977 |
859 | |
860 | |
861 | |
862 | KnotDistribution (me) returns BSplKnotDistribution from GeomAbs; |
863 | --- Purpose : |
864 | -- Returns NonUniform or Uniform or QuasiUniform or PiecewiseBezier. |
865 | -- If all the knots differ by a positive constant from the |
866 | -- preceding knot the BSpline Curve can be : |
867 | -- - Uniform if all the knots are of multiplicity 1, |
868 | -- - QuasiUniform if all the knots are of multiplicity 1 except for |
869 | -- the first and last knot which are of multiplicity Degree + 1, |
870 | -- - PiecewiseBezier if the first and last knots have multiplicity |
871 | -- Degree + 1 and if interior knots have multiplicity Degree |
872 | -- A piecewise Bezier with only two knots is a BezierCurve. |
873 | -- else the curve is non uniform. |
874 | -- The tolerance criterion is Epsilon from class Real. |
875 | |
876 | |
877 | LastUKnotIndex (me) returns Integer; |
878 | --- Purpose : |
879 | -- For a BSpline curve the last parameter (which gives the |
880 | -- end point of the curve) is a knot value but if the |
881 | -- multiplicity of the last knot index is lower than |
882 | -- Degree + 1 it is not the last knot of the curve. This |
883 | -- method computes the index of the knot corresponding to |
884 | -- the last parameter. |
885 | |
886 | |
887 | LastParameter (me) returns Real; |
888 | --- Purpose : |
889 | -- Computes the parametric value of the end point of the curve. |
890 | -- It is a knot value. |
891 | |
892 | |
893 | LocateU (me; |
894 | U : Real; |
895 | ParametricTolerance : Real; |
896 | I1, I2 : in out Integer; |
897 | WithKnotRepetition : Boolean = Standard_False); |
898 | --- Purpose : |
899 | -- Locates the parametric value U in the sequence of knots. |
900 | -- If "WithKnotRepetition" is True we consider the knot's |
901 | -- representation with repetition of multiple knot value, |
902 | -- otherwise we consider the knot's representation with |
903 | -- no repetition of multiple knot values. |
904 | -- Knots (I1) <= U <= Knots (I2) |
905 | -- . if I1 = I2 U is a knot value (the tolerance criterion |
906 | -- ParametricTolerance is used). |
907 | -- . if I1 < 1 => U < Knots (1) - Abs(ParametricTolerance) |
908 | -- . if I2 > NbKnots => U > Knots (NbKnots) + Abs(ParametricTolerance) |
909 | |
910 | |
911 | Multiplicity (me; Index : Integer) returns Integer |
912 | --- Purpose : |
913 | -- Returns the multiplicity of the knots of range Index. |
914 | raises OutOfRange; |
915 | --- Purpose : Raised if Index < 1 or Index > NbKnots |
916 | |
917 | |
918 | Multiplicities (me; M : out Array1OfInteger from TColStd) |
919 | --- Purpose : |
920 | -- Returns the multiplicity of the knots of the curve. |
921 | raises DimensionError; |
922 | --- Purpose : |
923 | -- Raised if the length of M is not equal to NbKnots. |
94f71cad |
924 | Multiplicities (me) |
925 | returns Array1OfInteger from TColStd |
926 | ---Purpose : returns the multiplicity of the knots of the curve. |
927 | ---C++ : return const & |
928 | is static; |
7fd59977 |
929 | |
930 | |
931 | NbKnots (me) returns Integer; |
932 | --- Purpose : |
933 | -- Returns the number of knots. This method returns the number of |
934 | -- knot without repetition of multiple knots. |
935 | |
936 | |
937 | NbPoles (me) returns Integer; |
938 | --- Purpose : Returns the number of poles |
939 | |
940 | |
941 | Pole (me; Index : Integer) returns Pnt2d |
942 | --- Purpose : Returns the pole of range Index. |
943 | raises OutOfRange; |
944 | --- Purpose : Raised if Index < 1 or Index > NbPoles. |
945 | |
946 | |
947 | Poles (me; P : out Array1OfPnt2d) |
948 | --- Purpose : Returns the poles of the B-spline curve; |
949 | raises DimensionError; |
950 | --- Purpose : |
951 | -- Raised if the length of P is not equal to the number of poles. |
94f71cad |
952 | Poles (me) |
953 | returns Array1OfPnt2d from TColgp |
954 | ---Purpose : Returns the poles of the B-spline curve; |
955 | ---C++ : return const & |
956 | is static; |
7fd59977 |
957 | |
958 | |
959 | StartPoint (me) returns Pnt2d; |
960 | --- Purpose : |
961 | -- Returns the start point of the curve. |
962 | -- Warnings : |
963 | -- This point is different from the first pole of the curve if the |
964 | -- multiplicity of the first knot is lower than Degree. |
965 | |
966 | |
967 | Weight (me; Index : Integer) returns Real |
968 | --- Purpose : Returns the weight of the pole of range Index . |
969 | raises OutOfRange; |
970 | --- Purpose : Raised if Index < 1 or Index > NbPoles. |
971 | |
972 | |
973 | Weights (me; W : out Array1OfReal from TColStd) |
974 | --- Purpose : Returns the weights of the B-spline curve; |
975 | raises DimensionError; |
976 | --- Purpose : |
977 | -- Raised if the length of W is not equal to NbPoles. |
94f71cad |
978 | Weights (me) |
979 | returns Array1OfReal from TColStd |
980 | ---Purpose : Returns the weights of the B-spline curve; |
981 | ---C++ : return const & |
982 | is static; |
7fd59977 |
983 | |
984 | |
985 | |
986 | |
987 | |
988 | |
989 | Transform (me : mutable; T : Trsf2d); |
990 | ---Purpose: Applies the transformation T to this BSpline curve. |
991 | |
992 | MaxDegree (myclass) returns Integer; |
993 | --- Purpose : |
994 | -- Returns the value of the maximum degree of the normalized |
995 | -- B-spline basis functions in this package. |
996 | |
997 | |
998 | Resolution(me : mutable; |
999 | ToleranceUV : Real; |
1000 | UTolerance : out Real); |
1001 | ---Purpose: Computes for this BSpline curve the parametric |
1002 | -- tolerance UTolerance for a given tolerance |
1003 | -- Tolerance3D (relative to dimensions in the plane). |
1004 | -- If f(t) is the equation of this BSpline curve, |
1005 | -- UTolerance ensures that: |
1006 | -- | t1 - t0| < Utolerance ===> |
1007 | -- |f(t1) - f(t0)| < ToleranceUV |
1008 | |
1009 | |
6e33d3ce |
1010 | Copy (me) returns like me; |
7fd59977 |
1011 | ---Purpose: Creates a new object which is a copy of this BSpline curve. |
1012 | |
1013 | UpdateKnots(me : mutable) |
1014 | ---Purpose: Recompute the flatknots, the knotsdistribution, the continuity. |
1015 | is static private; |
7fd59977 |
1016 | |
1017 | |
7fd59977 |
1018 | fields |
1019 | |
1020 | rational : Boolean; |
1021 | periodic : Boolean; |
1022 | knotSet : BSplKnotDistribution from GeomAbs; |
1023 | smooth : Shape from GeomAbs; |
1024 | deg : Integer; |
1025 | poles : HArray1OfPnt2d from TColgp; |
1026 | weights : HArray1OfReal from TColStd; |
1027 | flatknots : HArray1OfReal from TColStd; |
1028 | knots : HArray1OfReal from TColStd; |
1029 | mults : HArray1OfInteger from TColStd; |
7fd59977 |
1030 | maxderivinv : Real from Standard; |
1031 | maxderivinvok : Boolean from Standard; |
1032 | |
1033 | end; |