|
||||
File indexing completed on 2025-01-18 10:03:33
0001 // Created on: 1993-03-24 0002 // Created by: JCV 0003 // Copyright (c) 1993-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Geom2d_BSplineCurve_HeaderFile 0018 #define _Geom2d_BSplineCurve_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_Type.hxx> 0022 0023 #include <Precision.hxx> 0024 #include <GeomAbs_BSplKnotDistribution.hxx> 0025 #include <GeomAbs_Shape.hxx> 0026 #include <Standard_Integer.hxx> 0027 #include <TColgp_HArray1OfPnt2d.hxx> 0028 #include <TColStd_HArray1OfReal.hxx> 0029 #include <TColStd_HArray1OfInteger.hxx> 0030 #include <Geom2d_BoundedCurve.hxx> 0031 #include <TColgp_Array1OfPnt2d.hxx> 0032 #include <TColStd_Array1OfReal.hxx> 0033 #include <TColStd_Array1OfInteger.hxx> 0034 class gp_Pnt2d; 0035 class gp_Vec2d; 0036 class gp_Trsf2d; 0037 class Geom2d_Geometry; 0038 0039 0040 class Geom2d_BSplineCurve; 0041 DEFINE_STANDARD_HANDLE(Geom2d_BSplineCurve, Geom2d_BoundedCurve) 0042 0043 //! Describes a BSpline curve. 0044 //! A BSpline curve can be: 0045 //! - uniform or non-uniform, 0046 //! - rational or non-rational, 0047 //! - periodic or non-periodic. 0048 //! A BSpline curve is defined by: 0049 //! - its degree; the degree for a 0050 //! Geom2d_BSplineCurve is limited to a value (25) 0051 //! which is defined and controlled by the system. This 0052 //! value is returned by the function MaxDegree; 0053 //! - its periodic or non-periodic nature; 0054 //! - a table of poles (also called control points), with 0055 //! their associated weights if the BSpline curve is 0056 //! rational. The poles of the curve are "control points" 0057 //! used to deform the curve. If the curve is 0058 //! non-periodic, the first pole is the start point of the 0059 //! curve, and the last pole is the end point of the 0060 //! curve. The segment, which joins the first pole to the 0061 //! second pole, is the tangent to the curve at its start 0062 //! point, and the segment, which joins the last pole to 0063 //! the second-from-last pole, is the tangent to the 0064 //! curve at its end point. If the curve is periodic, these 0065 //! geometric properties are not verified. It is more 0066 //! difficult to give a geometric signification to the 0067 //! weights but they are useful for providing exact 0068 //! representations of the arcs of a circle or ellipse. 0069 //! Moreover, if the weights of all the poles are equal, 0070 //! the curve has a polynomial equation; it is 0071 //! therefore a non-rational curve. 0072 //! - a table of knots with their multiplicities. For a 0073 //! Geom2d_BSplineCurve, the table of knots is an 0074 //! increasing sequence of reals without repetition; the 0075 //! multiplicities define the repetition of the knots. A 0076 //! BSpline curve is a piecewise polynomial or rational 0077 //! curve. The knots are the parameters of junction 0078 //! points between two pieces. The multiplicity 0079 //! Mult(i) of the knot Knot(i) of the BSpline 0080 //! curve is related to the degree of continuity of the 0081 //! curve at the knot Knot(i), which is equal to 0082 //! Degree - Mult(i) where Degree is the 0083 //! degree of the BSpline curve. 0084 //! If the knots are regularly spaced (i.e. the difference 0085 //! between two consecutive knots is a constant), three 0086 //! specific and frequently used cases of knot distribution 0087 //! can be identified: 0088 //! - "uniform" if all multiplicities are equal to 1, 0089 //! - "quasi-uniform" if all multiplicities are equal to 1, 0090 //! except the first and the last knot which have a 0091 //! multiplicity of Degree + 1, where Degree is 0092 //! the degree of the BSpline curve, 0093 //! - "Piecewise Bezier" if all multiplicities are equal to 0094 //! Degree except the first and last knot which have 0095 //! a multiplicity of Degree + 1, where Degree is 0096 //! the degree of the BSpline curve. A curve of this 0097 //! type is a concatenation of arcs of Bezier curves. 0098 //! If the BSpline curve is not periodic: 0099 //! - the bounds of the Poles and Weights tables are 1 0100 //! and NbPoles, where NbPoles is the number of 0101 //! poles of the BSpline curve, 0102 //! - the bounds of the Knots and Multiplicities tables are 0103 //! 1 and NbKnots, where NbKnots is the number 0104 //! of knots of the BSpline curve. 0105 //! If the BSpline curve is periodic, and if there are k 0106 //! periodic knots and p periodic poles, the period is: 0107 //! period = Knot(k + 1) - Knot(1) 0108 //! and the poles and knots tables can be considered as 0109 //! infinite tables, such that: 0110 //! - Knot(i+k) = Knot(i) + period 0111 //! - Pole(i+p) = Pole(i) 0112 //! Note: data structures of a periodic BSpline curve are 0113 //! more complex than those of a non-periodic one. 0114 //! Warnings : 0115 //! In this class we consider that a weight value is zero if 0116 //! Weight <= Resolution from package gp. 0117 //! For two parametric values (or two knot values) U1, U2 we 0118 //! consider that U1 = U2 if Abs (U2 - U1) <= Epsilon (U1). 0119 //! For two weights values W1, W2 we consider that W1 = W2 if 0120 //! Abs (W2 - W1) <= Epsilon (W1). The method Epsilon is 0121 //! defined in the class Real from package Standard. 0122 //! 0123 //! References : 0124 //! . A survey of curve and surface methods in CADG Wolfgang BOHM 0125 //! CAGD 1 (1984) 0126 //! . On de Boor-like algorithms and blossoming Wolfgang BOEHM 0127 //! cagd 5 (1988) 0128 //! . Blossoming and knot insertion algorithms for B-spline curves 0129 //! Ronald N. GOLDMAN 0130 //! . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA 0131 //! . Curves and Surfaces for Computer Aided Geometric Design, 0132 //! a practical guide Gerald Farin 0133 class Geom2d_BSplineCurve : public Geom2d_BoundedCurve 0134 { 0135 0136 public: 0137 0138 0139 //! Creates a non-rational B_spline curve on the 0140 //! basis <Knots, Multiplicities> of degree <Degree>. 0141 //! The following conditions must be verified. 0142 //! 0 < Degree <= MaxDegree. 0143 //! 0144 //! Knots.Length() == Mults.Length() >= 2 0145 //! 0146 //! Knots(i) < Knots(i+1) (Knots are increasing) 0147 //! 0148 //! 1 <= Mults(i) <= Degree 0149 //! 0150 //! On a non periodic curve the first and last multiplicities 0151 //! may be Degree+1 (this is even recommended if you want the 0152 //! curve to start and finish on the first and last pole). 0153 //! 0154 //! On a periodic curve the first and the last multicities 0155 //! must be the same. 0156 //! 0157 //! on non-periodic curves 0158 //! 0159 //! Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2 0160 //! 0161 //! on periodic curves 0162 //! 0163 //! Poles.Length() == Sum(Mults(i)) except the first or last 0164 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); 0165 0166 //! Creates a rational B_spline curve on the basis 0167 //! <Knots, Multiplicities> of degree <Degree>. 0168 //! The following conditions must be verified. 0169 //! 0 < Degree <= MaxDegree. 0170 //! 0171 //! Knots.Length() == Mults.Length() >= 2 0172 //! 0173 //! Knots(i) < Knots(i+1) (Knots are increasing) 0174 //! 0175 //! 1 <= Mults(i) <= Degree 0176 //! 0177 //! On a non periodic curve the first and last multiplicities 0178 //! may be Degree+1 (this is even recommended if you want the 0179 //! curve to start and finish on the first and last pole). 0180 //! 0181 //! On a periodic curve the first and the last multicities 0182 //! must be the same. 0183 //! 0184 //! on non-periodic curves 0185 //! 0186 //! Poles.Length() == Sum(Mults(i)) - Degree - 1 >= 2 0187 //! 0188 //! on periodic curves 0189 //! 0190 //! Poles.Length() == Sum(Mults(i)) except the first or last 0191 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); 0192 0193 //! Increases the degree of this BSpline curve to 0194 //! Degree. As a result, the poles, weights and 0195 //! multiplicities tables are modified; the knots table is 0196 //! not changed. Nothing is done if Degree is less than 0197 //! or equal to the current degree. 0198 //! Exceptions 0199 //! Standard_ConstructionError if Degree is greater than 0200 //! Geom2d_BSplineCurve::MaxDegree(). 0201 Standard_EXPORT void IncreaseDegree (const Standard_Integer Degree); 0202 0203 //! Increases the multiplicity of the knot <Index> to 0204 //! <M>. 0205 //! 0206 //! If <M> is lower or equal to the current 0207 //! multiplicity nothing is done. If <M> is higher than 0208 //! the degree the degree is used. 0209 //! If <Index> is not in [FirstUKnotIndex, LastUKnotIndex] 0210 Standard_EXPORT void IncreaseMultiplicity (const Standard_Integer Index, const Standard_Integer M); 0211 0212 //! Increases the multiplicities of the knots in 0213 //! [I1,I2] to <M>. 0214 //! 0215 //! For each knot if <M> is lower or equal to the 0216 //! current multiplicity nothing is done. If <M> is 0217 //! higher than the degree the degree is used. 0218 //! As a result, the poles and weights tables of this curve are modified. 0219 //! Warning 0220 //! It is forbidden to modify the multiplicity of the first or 0221 //! last knot of a non-periodic curve. Be careful as 0222 //! Geom2d does not protect against this. 0223 //! Exceptions 0224 //! Standard_OutOfRange if either Index, I1 or I2 is 0225 //! outside the bounds of the knots table. 0226 Standard_EXPORT void IncreaseMultiplicity (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer M); 0227 0228 //! Increases by M the multiplicity of the knots of indexes 0229 //! I1 to I2 in the knots table of this BSpline curve. For 0230 //! each knot, the resulting multiplicity is limited to the 0231 //! degree of this curve. If M is negative, nothing is done. 0232 //! As a result, the poles and weights tables of this 0233 //! BSpline curve are modified. 0234 //! Warning 0235 //! It is forbidden to modify the multiplicity of the first or 0236 //! last knot of a non-periodic curve. Be careful as 0237 //! Geom2d does not protect against this. 0238 //! Exceptions 0239 //! Standard_OutOfRange if I1 or I2 is outside the 0240 //! bounds of the knots table. 0241 Standard_EXPORT void IncrementMultiplicity (const Standard_Integer I1, const Standard_Integer I2, const Standard_Integer M); 0242 0243 //! Inserts a knot value in the sequence of knots. If 0244 //! <U> is an existing knot the multiplicity is 0245 //! increased by <M>. 0246 //! 0247 //! If U is not on the parameter range nothing is 0248 //! done. 0249 //! 0250 //! If the multiplicity is negative or null nothing is 0251 //! done. The new multiplicity is limited to the 0252 //! degree. 0253 //! 0254 //! The tolerance criterion for knots equality is 0255 //! the max of Epsilon(U) and ParametricTolerance. 0256 //! Warning 0257 //! - If U is less than the first parameter or greater than 0258 //! the last parameter of this BSpline curve, nothing is done. 0259 //! - If M is negative or null, nothing is done. 0260 //! - The multiplicity of a knot is limited to the degree of 0261 //! this BSpline curve. 0262 Standard_EXPORT void InsertKnot (const Standard_Real U, const Standard_Integer M = 1, const Standard_Real ParametricTolerance = 0.0); 0263 0264 //! Inserts the values of the array Knots, with the 0265 //! respective multiplicities given by the array Mults, into 0266 //! the knots table of this BSpline curve. 0267 //! If a value of the array Knots is an existing knot, its multiplicity is: 0268 //! - increased by M, if Add is true, or 0269 //! - increased to M, if Add is false (default value). 0270 //! The tolerance criterion used for knot equality is the 0271 //! larger of the values ParametricTolerance (defaulted 0272 //! to 0.) and Standard_Real::Epsilon(U), 0273 //! where U is the current knot value. 0274 //! Warning 0275 //! - For a value of the array Knots which is less than 0276 //! the first parameter or greater than the last 0277 //! parameter of this BSpline curve, nothing is done. 0278 //! - For a value of the array Mults which is negative or 0279 //! null, nothing is done. 0280 //! - The multiplicity of a knot is limited to the degree of 0281 //! this BSpline curve. 0282 Standard_EXPORT void InsertKnots (const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Mults, const Standard_Real ParametricTolerance = 0.0, const Standard_Boolean Add = Standard_False); 0283 0284 //! Reduces the multiplicity of the knot of index Index 0285 //! to M. If M is equal to 0, the knot is removed. 0286 //! With a modification of this type, the array of poles is also modified. 0287 //! Two different algorithms are systematically used to 0288 //! compute the new poles of the curve. If, for each 0289 //! pole, the distance between the pole calculated 0290 //! using the first algorithm and the same pole 0291 //! calculated using the second algorithm, is less than 0292 //! Tolerance, this ensures that the curve is not 0293 //! modified by more than Tolerance. Under these 0294 //! conditions, true is returned; otherwise, false is returned. 0295 //! A low tolerance is used to prevent modification of 0296 //! the curve. A high tolerance is used to "smooth" the curve. 0297 //! Exceptions 0298 //! Standard_OutOfRange if Index is outside the 0299 //! bounds of the knots table. 0300 Standard_EXPORT Standard_Boolean RemoveKnot (const Standard_Integer Index, const Standard_Integer M, const Standard_Real Tolerance); 0301 0302 0303 //! The new pole is inserted after the pole of range Index. 0304 //! If the curve was non rational it can become rational. 0305 //! 0306 //! Raised if the B-spline is NonUniform or PiecewiseBezier or if 0307 //! Weight <= 0.0 0308 //! Raised if Index is not in the range [1, Number of Poles] 0309 Standard_EXPORT void InsertPoleAfter (const Standard_Integer Index, const gp_Pnt2d& P, const Standard_Real Weight = 1.0); 0310 0311 0312 //! The new pole is inserted before the pole of range Index. 0313 //! If the curve was non rational it can become rational. 0314 //! 0315 //! Raised if the B-spline is NonUniform or PiecewiseBezier or if 0316 //! Weight <= 0.0 0317 //! Raised if Index is not in the range [1, Number of Poles] 0318 Standard_EXPORT void InsertPoleBefore (const Standard_Integer Index, const gp_Pnt2d& P, const Standard_Real Weight = 1.0); 0319 0320 0321 //! Removes the pole of range Index 0322 //! If the curve was rational it can become non rational. 0323 //! 0324 //! Raised if the B-spline is NonUniform or PiecewiseBezier. 0325 //! Raised if the number of poles of the B-spline curve is lower or 0326 //! equal to 2 before removing. 0327 //! Raised if Index is not in the range [1, Number of Poles] 0328 Standard_EXPORT void RemovePole (const Standard_Integer Index); 0329 0330 //! Reverses the orientation of this BSpline curve. As a result 0331 //! - the knots and poles tables are modified; 0332 //! - the start point of the initial curve becomes the end 0333 //! point of the reversed curve; 0334 //! - the end point of the initial curve becomes the start 0335 //! point of the reversed curve. 0336 Standard_EXPORT void Reverse() Standard_OVERRIDE; 0337 0338 //! Computes the parameter on the reversed curve for 0339 //! the point of parameter U on this BSpline curve. 0340 //! The returned value is: UFirst + ULast - U, 0341 //! where UFirst and ULast are the values of the 0342 //! first and last parameters of this BSpline curve. 0343 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE; 0344 0345 //! Modifies this BSpline curve by segmenting it 0346 //! between U1 and U2. Either of these values can be 0347 //! outside the bounds of the curve, but U2 must be greater than U1. 0348 //! All data structure tables of this BSpline curve are 0349 //! modified, but the knots located between U1 and U2 0350 //! are retained. The degree of the curve is not modified. 0351 //! 0352 //! Parameter theTolerance defines the possible proximity of the segment 0353 //! boundaries and B-spline knots to treat them as equal. 0354 //! 0355 //! Warnings : 0356 //! Even if <me> is not closed it can become closed after the 0357 //! segmentation for example if U1 or U2 are out of the bounds 0358 //! of the curve <me> or if the curve makes loop. 0359 //! After the segmentation the length of a curve can be null. 0360 //! - The segmentation of a periodic curve over an 0361 //! interval corresponding to its period generates a 0362 //! non-periodic curve with equivalent geometry. 0363 //! Exceptions 0364 //! Standard_DomainError if U2 is less than U1. 0365 //! raises if U2 < U1. 0366 //! Standard_DomainError if U2 - U1 exceeds the period for periodic curves. 0367 //! i.e. ((U2 - U1) - Period) > Precision::PConfusion(). 0368 Standard_EXPORT void Segment (const Standard_Real U1, const Standard_Real U2, 0369 const Standard_Real theTolerance = Precision::PConfusion()); 0370 0371 //! Modifies this BSpline curve by assigning the value K 0372 //! to the knot of index Index in the knots table. This is a 0373 //! relatively local modification because K must be such that: 0374 //! Knots(Index - 1) < K < Knots(Index + 1) 0375 //! Exceptions 0376 //! Standard_ConstructionError if: 0377 //! - K is not such that: 0378 //! Knots(Index - 1) < K < Knots(Index + 1) 0379 //! - M is greater than the degree of this BSpline curve 0380 //! or lower than the previous multiplicity of knot of 0381 //! index Index in the knots table. 0382 //! Standard_OutOfRange if Index is outside the bounds of the knots table. 0383 Standard_EXPORT void SetKnot (const Standard_Integer Index, const Standard_Real K); 0384 0385 //! Modifies this BSpline curve by assigning the array 0386 //! K to its knots table. The multiplicity of the knots is not modified. 0387 //! Exceptions 0388 //! Standard_ConstructionError if the values in the 0389 //! array K are not in ascending order. 0390 //! Standard_OutOfRange if the bounds of the array 0391 //! K are not respectively 1 and the number of knots of this BSpline curve. 0392 Standard_EXPORT void SetKnots (const TColStd_Array1OfReal& K); 0393 0394 //! Modifies this BSpline curve by assigning the value K 0395 //! to the knot of index Index in the knots table. This is a 0396 //! relatively local modification because K must be such that: 0397 //! Knots(Index - 1) < K < Knots(Index + 1) 0398 //! The second syntax allows you also to increase the 0399 //! multiplicity of the knot to M (but it is not possible to 0400 //! decrease the multiplicity of the knot with this function). 0401 //! Exceptions 0402 //! Standard_ConstructionError if: 0403 //! - K is not such that: 0404 //! Knots(Index - 1) < K < Knots(Index + 1) 0405 //! - M is greater than the degree of this BSpline curve 0406 //! or lower than the previous multiplicity of knot of 0407 //! index Index in the knots table. 0408 //! Standard_OutOfRange if Index is outside the bounds of the knots table. 0409 Standard_EXPORT void SetKnot (const Standard_Integer Index, const Standard_Real K, const Standard_Integer M); 0410 0411 //! Computes the parameter normalized within the 0412 //! "first" period of this BSpline curve, if it is periodic: 0413 //! the returned value is in the range Param1 and 0414 //! Param1 + Period, where: 0415 //! - Param1 is the "first parameter", and 0416 //! - Period the period of this BSpline curve. 0417 //! Note: If this curve is not periodic, U is not modified. 0418 Standard_EXPORT void PeriodicNormalization (Standard_Real& U) const; 0419 0420 //! Changes this BSpline curve into a periodic curve. 0421 //! To become periodic, the curve must first be closed. 0422 //! Next, the knot sequence must be periodic. For this, 0423 //! FirstUKnotIndex and LastUKnotIndex are used to 0424 //! compute I1 and I2, the indexes in the knots array 0425 //! of the knots corresponding to the first and last 0426 //! parameters of this BSpline curve. 0427 //! The period is therefore Knot(I2) - Knot(I1). 0428 //! Consequently, the knots and poles tables are modified. 0429 //! Exceptions 0430 //! Standard_ConstructionError if this BSpline curve is not closed. 0431 Standard_EXPORT void SetPeriodic(); 0432 0433 //! Assigns the knot of index Index in the knots table as 0434 //! the origin of this periodic BSpline curve. As a 0435 //! consequence, the knots and poles tables are modified. 0436 //! Exceptions 0437 //! Standard_NoSuchObject if this curve is not periodic. 0438 //! Standard_DomainError if Index is outside the 0439 //! bounds of the knots table. 0440 Standard_EXPORT void SetOrigin (const Standard_Integer Index); 0441 0442 //! Changes this BSpline curve into a non-periodic 0443 //! curve. If this curve is already non-periodic, it is not modified. 0444 //! Note that the poles and knots tables are modified. 0445 //! Warning 0446 //! If this curve is periodic, as the multiplicity of the first 0447 //! and last knots is not modified, and is not equal to 0448 //! Degree + 1, where Degree is the degree of 0449 //! this BSpline curve, the start and end points of the 0450 //! curve are not its first and last poles. 0451 Standard_EXPORT void SetNotPeriodic(); 0452 0453 //! Modifies this BSpline curve by assigning P to the 0454 //! pole of index Index in the poles table. 0455 //! Exceptions 0456 //! Standard_OutOfRange if Index is outside the 0457 //! bounds of the poles table. 0458 //! Standard_ConstructionError if Weight is negative or null. 0459 Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt2d& P); 0460 0461 //! Modifies this BSpline curve by assigning P to the 0462 //! pole of index Index in the poles table. 0463 //! The second syntax also allows you to modify the 0464 //! weight of the modified pole, which becomes Weight. 0465 //! In this case, if this BSpline curve is non-rational, it 0466 //! can become rational and vice versa. 0467 //! Exceptions 0468 //! Standard_OutOfRange if Index is outside the 0469 //! bounds of the poles table. 0470 //! Standard_ConstructionError if Weight is negative or null. 0471 Standard_EXPORT void SetPole (const Standard_Integer Index, const gp_Pnt2d& P, const Standard_Real Weight); 0472 0473 //! Assigns the weight Weight to the pole of index Index of the poles table. 0474 //! If the curve was non rational it can become rational. 0475 //! If the curve was rational it can become non rational. 0476 //! Exceptions 0477 //! Standard_OutOfRange if Index is outside the 0478 //! bounds of the poles table. 0479 //! Standard_ConstructionError if Weight is negative or null. 0480 Standard_EXPORT void SetWeight (const Standard_Integer Index, const Standard_Real Weight); 0481 0482 //! Moves the point of parameter U of this BSpline 0483 //! curve to P. Index1 and Index2 are the indexes in the 0484 //! table of poles of this BSpline curve of the first and 0485 //! last poles designated to be moved. 0486 //! FirstModifiedPole and LastModifiedPole are the 0487 //! indexes of the first and last poles, which are 0488 //! effectively modified. 0489 //! In the event of incompatibility between Index1, 0490 //! Index2 and the value U: 0491 //! - no change is made to this BSpline curve, and 0492 //! - the FirstModifiedPole and LastModifiedPole are returned null. 0493 //! Exceptions 0494 //! Standard_OutOfRange if: 0495 //! - Index1 is greater than or equal to Index2, or 0496 //! - Index1 or Index2 is less than 1 or greater than the 0497 //! number of poles of this BSpline curve. 0498 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); 0499 0500 //! Move a point with parameter U to P. 0501 //! and makes it tangent at U be Tangent. 0502 //! StartingCondition = -1 means first can move 0503 //! EndingCondition = -1 means last point can move 0504 //! StartingCondition = 0 means the first point cannot move 0505 //! EndingCondition = 0 means the last point cannot move 0506 //! StartingCondition = 1 means the first point and tangent cannot move 0507 //! EndingCondition = 1 means the last point and tangent cannot move 0508 //! and so forth 0509 //! ErrorStatus != 0 means that there are not enough degree of freedom 0510 //! with the constrain to deform the curve accordingly 0511 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); 0512 0513 //! Returns true if the degree of continuity of this 0514 //! BSpline curve is at least N. A BSpline curve is at least GeomAbs_C0. 0515 //! Exceptions Standard_RangeError if N is negative. 0516 Standard_EXPORT Standard_Boolean IsCN (const Standard_Integer N) const Standard_OVERRIDE; 0517 0518 0519 //! Check if curve has at least G1 continuity in interval [theTf, theTl] 0520 //! Returns true if IsCN(1) 0521 //! or 0522 //! angle between "left" and "right" first derivatives at 0523 //! knots with C0 continuity is less then theAngTol 0524 //! only knots in interval [theTf, theTl] is checked 0525 Standard_EXPORT Standard_Boolean IsG1 (const Standard_Real theTf, const Standard_Real theTl, const Standard_Real theAngTol) const; 0526 0527 0528 //! Returns true if the distance between the first point and the 0529 //! last point of the curve is lower or equal to Resolution 0530 //! from package gp. 0531 //! Warnings : 0532 //! The first and the last point can be different from the first 0533 //! pole and the last pole of the curve. 0534 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; 0535 0536 //! Returns True if the curve is periodic. 0537 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; 0538 0539 0540 //! Returns True if the weights are not identical. 0541 //! The tolerance criterion is Epsilon of the class Real. 0542 Standard_EXPORT Standard_Boolean IsRational() const; 0543 0544 0545 //! Returns the global continuity of the curve : 0546 //! C0 : only geometric continuity, 0547 //! C1 : continuity of the first derivative all along the Curve, 0548 //! C2 : continuity of the second derivative all along the Curve, 0549 //! C3 : continuity of the third derivative all along the Curve, 0550 //! CN : the order of continuity is infinite. 0551 //! For a B-spline curve of degree d if a knot Ui has a 0552 //! multiplicity p the B-spline curve is only Cd-p continuous 0553 //! at Ui. So the global continuity of the curve can't be greater 0554 //! than Cd-p where p is the maximum multiplicity of the interior 0555 //! Knots. In the interior of a knot span the curve is infinitely 0556 //! continuously differentiable. 0557 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; 0558 0559 //! Returns the degree of this BSpline curve. 0560 //! In this class the degree of the basis normalized B-spline 0561 //! functions cannot be greater than "MaxDegree" 0562 //! Computation of value and derivatives 0563 Standard_EXPORT Standard_Integer Degree() const; 0564 0565 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE; 0566 0567 //! Raised if the continuity of the curve is not C1. 0568 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE; 0569 0570 //! Raised if the continuity of the curve is not C2. 0571 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE; 0572 0573 //! For this BSpline curve, computes 0574 //! - the point P of parameter U, or 0575 //! - the point P and one or more of the following values: 0576 //! - V1, the first derivative vector, 0577 //! - V2, the second derivative vector, 0578 //! - V3, the third derivative vector. 0579 //! Warning 0580 //! On a point where the continuity of the curve is not the 0581 //! one requested, these functions impact the part 0582 //! defined by the parameter with a value greater than U, 0583 //! i.e. the part of the curve to the "right" of the singularity. 0584 //! Raises UndefinedDerivative if the continuity of the curve is not C3. 0585 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE; 0586 0587 //! For the point of parameter U of this BSpline curve, 0588 //! computes the vector corresponding to the Nth derivative. 0589 //! Warning 0590 //! On a point where the continuity of the curve is not the 0591 //! one requested, this function impacts the part defined 0592 //! by the parameter with a value greater than U, i.e. the 0593 //! part of the curve to the "right" of the singularity. 0594 //! Raises UndefinedDerivative if the continuity of the curve is not CN. 0595 //! RangeError if N < 1. 0596 //! The following functions computes the point of parameter U 0597 //! and the derivatives at this point on the B-spline curve 0598 //! arc defined between the knot FromK1 and the knot ToK2. 0599 //! U can be out of bounds [Knot (FromK1), Knot (ToK2)] but 0600 //! for the computation we only use the definition of the curve 0601 //! between these two knots. This method is useful to compute 0602 //! local derivative, if the order of continuity of the whole 0603 //! curve is not greater enough. Inside the parametric 0604 //! domain Knot (FromK1), Knot (ToK2) the evaluations are 0605 //! the same as if we consider the whole definition of the 0606 //! curve. Of course the evaluations are different outside 0607 //! this parametric domain. 0608 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; 0609 0610 //! Raised if FromK1 = ToK2. 0611 Standard_EXPORT gp_Pnt2d LocalValue (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2) const; 0612 0613 //! Raised if FromK1 = ToK2. 0614 Standard_EXPORT void LocalD0 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt2d& P) const; 0615 0616 0617 //! Raised if the local continuity of the curve is not C1 0618 //! between the knot K1 and the knot K2. 0619 //! Raised if FromK1 = ToK2. 0620 Standard_EXPORT void LocalD1 (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, gp_Pnt2d& P, gp_Vec2d& V1) const; 0621 0622 0623 //! Raised if the local continuity of the curve is not C2 0624 //! between the knot K1 and the knot K2. 0625 //! Raised if FromK1 = ToK2. 0626 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; 0627 0628 0629 //! Raised if the local continuity of the curve is not C3 0630 //! between the knot K1 and the knot K2. 0631 //! Raised if FromK1 = ToK2. 0632 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; 0633 0634 0635 //! Raised if the local continuity of the curve is not CN 0636 //! between the knot K1 and the knot K2. 0637 //! Raised if FromK1 = ToK2. 0638 //! Raised if N < 1. 0639 Standard_EXPORT gp_Vec2d LocalDN (const Standard_Real U, const Standard_Integer FromK1, const Standard_Integer ToK2, const Standard_Integer N) const; 0640 0641 0642 //! Returns the last point of the curve. 0643 //! Warnings : 0644 //! The last point of the curve is different from the last 0645 //! pole of the curve if the multiplicity of the last knot 0646 //! is lower than Degree. 0647 Standard_EXPORT gp_Pnt2d EndPoint() const Standard_OVERRIDE; 0648 0649 0650 //! For a B-spline curve the first parameter (which gives the start 0651 //! point of the curve) is a knot value but if the multiplicity of 0652 //! the first knot index is lower than Degree + 1 it is not the 0653 //! first knot of the curve. This method computes the index of the 0654 //! knot corresponding to the first parameter. 0655 Standard_EXPORT Standard_Integer FirstUKnotIndex() const; 0656 0657 0658 //! Computes the parametric value of the start point of the curve. 0659 //! It is a knot value. 0660 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; 0661 0662 0663 //! Returns the knot of range Index. When there is a knot 0664 //! with a multiplicity greater than 1 the knot is not repeated. 0665 //! The method Multiplicity can be used to get the multiplicity 0666 //! of the Knot. 0667 //! Raised if Index < 1 or Index > NbKnots 0668 Standard_EXPORT Standard_Real Knot (const Standard_Integer Index) const; 0669 0670 //! returns the knot values of the B-spline curve; 0671 //! 0672 //! Raised K.Lower() is less than number of first knot or 0673 //! K.Upper() is more than number of last knot. 0674 Standard_EXPORT void Knots (TColStd_Array1OfReal& K) const; 0675 0676 //! returns the knot values of the B-spline curve; 0677 Standard_EXPORT const TColStd_Array1OfReal& Knots() const; 0678 0679 //! Returns the knots sequence. 0680 //! In this sequence the knots with a multiplicity greater than 1 0681 //! are repeated. 0682 //! Example : 0683 //! K = {k1, k1, k1, k2, k3, k3, k4, k4, k4} 0684 //! 0685 //! Raised if K.Lower() is less than number of first knot 0686 //! in knot sequence with repetitions or K.Upper() is more 0687 //! than number of last knot in knot sequence with repetitions. 0688 Standard_EXPORT void KnotSequence (TColStd_Array1OfReal& K) const; 0689 0690 //! Returns the knots sequence. 0691 //! In this sequence the knots with a multiplicity greater than 1 0692 //! are repeated. 0693 //! Example : 0694 //! K = {k1, k1, k1, k2, k3, k3, k4, k4, k4} 0695 Standard_EXPORT const TColStd_Array1OfReal& KnotSequence() const; 0696 0697 0698 //! Returns NonUniform or Uniform or QuasiUniform or PiecewiseBezier. 0699 //! If all the knots differ by a positive constant from the 0700 //! preceding knot the BSpline Curve can be : 0701 //! - Uniform if all the knots are of multiplicity 1, 0702 //! - QuasiUniform if all the knots are of multiplicity 1 except for 0703 //! the first and last knot which are of multiplicity Degree + 1, 0704 //! - PiecewiseBezier if the first and last knots have multiplicity 0705 //! Degree + 1 and if interior knots have multiplicity Degree 0706 //! A piecewise Bezier with only two knots is a BezierCurve. 0707 //! else the curve is non uniform. 0708 //! The tolerance criterion is Epsilon from class Real. 0709 Standard_EXPORT GeomAbs_BSplKnotDistribution KnotDistribution() const; 0710 0711 0712 //! For a BSpline curve the last parameter (which gives the 0713 //! end point of the curve) is a knot value but if the 0714 //! multiplicity of the last knot index is lower than 0715 //! Degree + 1 it is not the last knot of the curve. This 0716 //! method computes the index of the knot corresponding to 0717 //! the last parameter. 0718 Standard_EXPORT Standard_Integer LastUKnotIndex() const; 0719 0720 0721 //! Computes the parametric value of the end point of the curve. 0722 //! It is a knot value. 0723 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; 0724 0725 0726 //! Locates the parametric value U in the sequence of knots. 0727 //! If "WithKnotRepetition" is True we consider the knot's 0728 //! representation with repetition of multiple knot value, 0729 //! otherwise we consider the knot's representation with 0730 //! no repetition of multiple knot values. 0731 //! Knots (I1) <= U <= Knots (I2) 0732 //! . if I1 = I2 U is a knot value (the tolerance criterion 0733 //! ParametricTolerance is used). 0734 //! . if I1 < 1 => U < Knots (1) - Abs(ParametricTolerance) 0735 //! . if I2 > NbKnots => U > Knots (NbKnots) + Abs(ParametricTolerance) 0736 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; 0737 0738 0739 //! Returns the multiplicity of the knots of range Index. 0740 //! Raised if Index < 1 or Index > NbKnots 0741 Standard_EXPORT Standard_Integer Multiplicity (const Standard_Integer Index) const; 0742 0743 0744 //! Returns the multiplicity of the knots of the curve. 0745 //! 0746 //! Raised if the length of M is not equal to NbKnots. 0747 Standard_EXPORT void Multiplicities (TColStd_Array1OfInteger& M) const; 0748 0749 //! returns the multiplicity of the knots of the curve. 0750 Standard_EXPORT const TColStd_Array1OfInteger& Multiplicities() const; 0751 0752 0753 //! Returns the number of knots. This method returns the number of 0754 //! knot without repetition of multiple knots. 0755 Standard_EXPORT Standard_Integer NbKnots() const; 0756 0757 //! Returns the number of poles 0758 Standard_EXPORT Standard_Integer NbPoles() const; 0759 0760 //! Returns the pole of range Index. 0761 //! Raised if Index < 1 or Index > NbPoles. 0762 Standard_EXPORT const gp_Pnt2d& Pole (const Standard_Integer Index) const; 0763 0764 //! Returns the poles of the B-spline curve; 0765 //! 0766 //! Raised if the length of P is not equal to the number of poles. 0767 Standard_EXPORT void Poles (TColgp_Array1OfPnt2d& P) const; 0768 0769 //! Returns the poles of the B-spline curve; 0770 Standard_EXPORT const TColgp_Array1OfPnt2d& Poles() const; 0771 0772 0773 //! Returns the start point of the curve. 0774 //! Warnings : 0775 //! This point is different from the first pole of the curve if the 0776 //! multiplicity of the first knot is lower than Degree. 0777 Standard_EXPORT gp_Pnt2d StartPoint() const Standard_OVERRIDE; 0778 0779 //! Returns the weight of the pole of range Index . 0780 //! Raised if Index < 1 or Index > NbPoles. 0781 Standard_EXPORT Standard_Real Weight (const Standard_Integer Index) const; 0782 0783 //! Returns the weights of the B-spline curve; 0784 //! 0785 //! Raised if the length of W is not equal to NbPoles. 0786 Standard_EXPORT void Weights (TColStd_Array1OfReal& W) const; 0787 0788 //! Returns the weights of the B-spline curve; 0789 Standard_EXPORT const TColStd_Array1OfReal* Weights() const; 0790 0791 //! Applies the transformation T to this BSpline curve. 0792 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE; 0793 0794 0795 //! Returns the value of the maximum degree of the normalized 0796 //! B-spline basis functions in this package. 0797 Standard_EXPORT static Standard_Integer MaxDegree(); 0798 0799 //! Computes for this BSpline curve the parametric 0800 //! tolerance UTolerance for a given tolerance 0801 //! Tolerance3D (relative to dimensions in the plane). 0802 //! If f(t) is the equation of this BSpline curve, 0803 //! UTolerance ensures that: 0804 //! | t1 - t0| < Utolerance ===> 0805 //! |f(t1) - f(t0)| < ToleranceUV 0806 Standard_EXPORT void Resolution (const Standard_Real ToleranceUV, Standard_Real& UTolerance); 0807 0808 //! Creates a new object which is a copy of this BSpline curve. 0809 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE; 0810 0811 //! Dumps the content of me into the stream 0812 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; 0813 0814 0815 0816 0817 DEFINE_STANDARD_RTTIEXT(Geom2d_BSplineCurve,Geom2d_BoundedCurve) 0818 0819 protected: 0820 0821 0822 0823 0824 private: 0825 0826 0827 //! Recompute the flatknots, the knotsdistribution, the continuity. 0828 Standard_EXPORT void UpdateKnots(); 0829 0830 Standard_Boolean rational; 0831 Standard_Boolean periodic; 0832 GeomAbs_BSplKnotDistribution knotSet; 0833 GeomAbs_Shape smooth; 0834 Standard_Integer deg; 0835 Handle(TColgp_HArray1OfPnt2d) poles; 0836 Handle(TColStd_HArray1OfReal) weights; 0837 Handle(TColStd_HArray1OfReal) flatknots; 0838 Handle(TColStd_HArray1OfReal) knots; 0839 Handle(TColStd_HArray1OfInteger) mults; 0840 Standard_Real maxderivinv; 0841 Standard_Boolean maxderivinvok; 0842 0843 0844 }; 0845 0846 0847 0848 0849 0850 0851 0852 #endif // _Geom2d_BSplineCurve_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |