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