Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Geom_BSplineCurve.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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