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