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