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