Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-22 09:23:37

0001 // Created on: 1991-08-09
0002 // Created by: Jean Claude VAUTHIER
0003 // Copyright (c) 1991-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 _BSplCLib_HeaderFile
0018 #define _BSplCLib_HeaderFile
0019 
0020 #include <BSplCLib_EvaluatorFunction.hxx>
0021 #include <BSplCLib_KnotDistribution.hxx>
0022 #include <BSplCLib_MultDistribution.hxx>
0023 #include <GeomAbs_BSplKnotDistribution.hxx>
0024 #include <Standard.hxx>
0025 #include <Standard_DefineAlloc.hxx>
0026 #include <Standard_Handle.hxx>
0027 #include <Standard_Integer.hxx>
0028 #include <Standard_Real.hxx>
0029 #include <TColgp_Array1OfPnt.hxx>
0030 #include <TColgp_Array1OfPnt2d.hxx>
0031 #include <TColStd_Array1OfReal.hxx>
0032 #include <TColStd_Array2OfReal.hxx>
0033 #include <TColStd_HArray1OfInteger.hxx>
0034 #include <TColStd_HArray1OfReal.hxx>
0035 
0036 class gp_Pnt;
0037 class gp_Pnt2d;
0038 class gp_Vec;
0039 class gp_Vec2d;
0040 class math_Matrix;
0041 
0042 //! BSplCLib   B-spline curve Library.
0043 //!
0044 //! The BSplCLib package is  a basic library  for BSplines. It
0045 //! provides three categories of functions.
0046 //!
0047 //! * Management methods to  process knots and multiplicities.
0048 //!
0049 //! * Multi-Dimensions  spline methods.  BSpline methods where
0050 //! poles have an arbitrary number of dimensions. They divides
0051 //! in two groups :
0052 //!
0053 //! - Global methods modifying the  whole set of  poles. The
0054 //! poles are    described   by an array   of   Reals and  a
0055 //! Dimension. Example : Inserting knots.
0056 //!
0057 //! - Local methods  computing  points and derivatives.  The
0058 //! poles  are described by a pointer  on  a local array  of
0059 //! Reals and a Dimension. The local array is modified.
0060 //!
0061 //! *  2D  and 3D spline   curves  methods.
0062 //!
0063 //! Methods  for 2d and 3d BSplines  curves  rational or not
0064 //! rational.
0065 //!
0066 //! Those methods have the following structure :
0067 //!
0068 //! - They extract the pole information in a working array.
0069 //!
0070 //! -  They      process the  working   array    with   the
0071 //! multi-dimension  methods. (for example  a  3d  rational
0072 //! curve is processed as a 4 dimension curve).
0073 //!
0074 //! - They get back the result in the original dimension.
0075 //!
0076 //! Note that the  bspline   surface methods found   in the
0077 //! package BSplSLib  uses  the same  structure and rely on
0078 //! BSplCLib.
0079 //!
0080 //! In the following list  of methods the  2d and 3d  curve
0081 //! methods   will be  described   with  the  corresponding
0082 //! multi-dimension method.
0083 //!
0084 //! The 3d or 2d B-spline curve is defined with :
0085 //!
0086 //! . its control points : TColgp_Array1OfPnt(2d)        Poles
0087 //! . its weights        : TColStd_Array1OfReal          Weights
0088 //! . its knots          : TColStd_Array1OfReal          Knots
0089 //! . its multiplicities : TColStd_Array1OfInteger       Mults
0090 //! . its degree         : Standard_Integer              Degree
0091 //! . its periodicity    : Standard_Boolean              Periodic
0092 //!
0093 //! Warnings :
0094 //! The bounds of Poles and Weights should be the same.
0095 //! The bounds of Knots and Mults   should be the same.
0096 //!
0097 //! Note: weight and multiplicity arrays can be passed by pointer for
0098 //! some functions so that NULL pointer is valid.
0099 //! That means no weights/no multiplicities passed.
0100 //!
0101 //! No weights (BSplCLib::NoWeights()) means the curve is non rational.
0102 //! No mults (BSplCLib::NoMults()) means the knots are "flat" knots.
0103 //!
0104 //! KeyWords :
0105 //! B-spline curve, Functions, Library
0106 //!
0107 //! References :
0108 //! . A survey of curves and surfaces methods in CADG Wolfgang
0109 //! BOHM CAGD 1 (1984)
0110 //! . On de Boor-like algorithms and blossoming Wolfgang BOEHM
0111 //! cagd 5 (1988)
0112 //! . Blossoming and knot insertion algorithms for B-spline curves
0113 //! Ronald N. GOLDMAN
0114 //! . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA
0115 //! . Curves and Surfaces for Computer Aided Geometric Design,
0116 //! a practical guide Gerald Farin
0117 class BSplCLib
0118 {
0119 public:
0120   DEFINE_STANDARD_ALLOC
0121 
0122   //! This routine searches the position of the real value theX
0123   //! in the monotonically increasing set of real values theArray using bisection algorithm.
0124   //!
0125   //! If the given value is out of range or array values, algorithm returns either
0126   //! theArray.Lower()-1 or theArray.Upper()+1 depending on theX position in the ordered set.
0127   //!
0128   //! This routine is used to locate a knot value in a set of knots.
0129   Standard_EXPORT static void Hunt(const TColStd_Array1OfReal& theArray,
0130                                    const Standard_Real         theX,
0131                                    Standard_Integer&           theXPos);
0132 
0133   //! Computes the index of the knots value which gives
0134   //! the start point of the curve.
0135   Standard_EXPORT static Standard_Integer FirstUKnotIndex(const Standard_Integer         Degree,
0136                                                           const TColStd_Array1OfInteger& Mults);
0137 
0138   //! Computes the index of the knots value which gives
0139   //! the end point of the curve.
0140   Standard_EXPORT static Standard_Integer LastUKnotIndex(const Standard_Integer         Degree,
0141                                                          const TColStd_Array1OfInteger& Mults);
0142 
0143   //! Computes the index  of  the  flats knots  sequence
0144   //! corresponding  to  <Index> in  the  knots sequence
0145   //! which multiplicities are <Mults>.
0146   Standard_EXPORT static Standard_Integer FlatIndex(const Standard_Integer         Degree,
0147                                                     const Standard_Integer         Index,
0148                                                     const TColStd_Array1OfInteger& Mults,
0149                                                     const Standard_Boolean         Periodic);
0150 
0151   //! Locates  the parametric value    U  in the knots
0152   //! sequence  between  the  knot K1   and the knot  K2.
0153   //! The value return in Index verifies.
0154   //!
0155   //! Knots(Index) <= U < Knots(Index + 1)
0156   //! if U <= Knots (K1) then Index = K1
0157   //! if U >= Knots (K2) then Index = K2 - 1
0158   //!
0159   //! If Periodic is True U  may be  modified  to fit in
0160   //! the range  Knots(K1), Knots(K2).  In any case  the
0161   //! correct value is returned in NewU.
0162   //!
0163   //! Warnings :Index is used  as input   data to initialize  the
0164   //! searching  function.
0165   //! Warning: Knots have to be "with repetitions"
0166   Standard_EXPORT static void LocateParameter(const Standard_Integer         Degree,
0167                                               const TColStd_Array1OfReal&    Knots,
0168                                               const TColStd_Array1OfInteger& Mults,
0169                                               const Standard_Real            U,
0170                                               const Standard_Boolean         IsPeriodic,
0171                                               const Standard_Integer         FromK1,
0172                                               const Standard_Integer         ToK2,
0173                                               Standard_Integer&              KnotIndex,
0174                                               Standard_Real&                 NewU);
0175 
0176   //! Locates  the parametric value    U  in the knots
0177   //! sequence  between  the  knot K1   and the knot  K2.
0178   //! The value return in Index verifies.
0179   //!
0180   //! Knots(Index) <= U < Knots(Index + 1)
0181   //! if U <= Knots (K1) then Index = K1
0182   //! if U >= Knots (K2) then Index = K2 - 1
0183   //!
0184   //! If Periodic is True U  may be  modified  to fit in
0185   //! the range  Knots(K1), Knots(K2).  In any case  the
0186   //! correct value is returned in NewU.
0187   //!
0188   //! Warnings :Index is used  as input   data to initialize  the
0189   //! searching  function.
0190   //! Warning: Knots have to be "flat"
0191   Standard_EXPORT static void LocateParameter(const Standard_Integer      Degree,
0192                                               const TColStd_Array1OfReal& Knots,
0193                                               const Standard_Real         U,
0194                                               const Standard_Boolean      IsPeriodic,
0195                                               const Standard_Integer      FromK1,
0196                                               const Standard_Integer      ToK2,
0197                                               Standard_Integer&           KnotIndex,
0198                                               Standard_Real&              NewU);
0199 
0200   Standard_EXPORT static void LocateParameter(const Standard_Integer         Degree,
0201                                               const TColStd_Array1OfReal&    Knots,
0202                                               const TColStd_Array1OfInteger* Mults,
0203                                               const Standard_Real            U,
0204                                               const Standard_Boolean         Periodic,
0205                                               Standard_Integer&              Index,
0206                                               Standard_Real&                 NewU);
0207 
0208   //! Finds the greatest multiplicity in a set of knots
0209   //! between  K1  and K2.   Mults  is  the  multiplicity
0210   //! associated with each knot value.
0211   Standard_EXPORT static Standard_Integer MaxKnotMult(const TColStd_Array1OfInteger& Mults,
0212                                                       const Standard_Integer         K1,
0213                                                       const Standard_Integer         K2);
0214 
0215   //! Finds the lowest multiplicity in  a  set of knots
0216   //! between   K1  and K2.   Mults is  the  multiplicity
0217   //! associated with each knot value.
0218   Standard_EXPORT static Standard_Integer MinKnotMult(const TColStd_Array1OfInteger& Mults,
0219                                                       const Standard_Integer         K1,
0220                                                       const Standard_Integer         K2);
0221 
0222   //! Returns the number of poles of the curve. Returns 0 if
0223   //! one of the multiplicities is incorrect.
0224   //!
0225   //! * Non positive.
0226   //!
0227   //! * Greater than Degree,  or  Degree+1  at the first and
0228   //! last knot of a non periodic curve.
0229   //!
0230   //! *  The  last periodicity  on  a periodic  curve is not
0231   //! equal to the first.
0232   Standard_EXPORT static Standard_Integer NbPoles(const Standard_Integer         Degree,
0233                                                   const Standard_Boolean         Periodic,
0234                                                   const TColStd_Array1OfInteger& Mults);
0235 
0236   //! Returns the length  of the sequence  of knots with
0237   //! repetition.
0238   //!
0239   //! Periodic :
0240   //!
0241   //! Sum(Mults(i), i = Mults.Lower(); i <= Mults.Upper());
0242   //!
0243   //! Non Periodic :
0244   //!
0245   //! Sum(Mults(i); i = Mults.Lower(); i < Mults.Upper())
0246   //! + 2 * Degree
0247   Standard_EXPORT static Standard_Integer KnotSequenceLength(const TColStd_Array1OfInteger& Mults,
0248                                                              const Standard_Integer         Degree,
0249                                                              const Standard_Boolean Periodic);
0250 
0251   Standard_EXPORT static void KnotSequence(const TColStd_Array1OfReal&    Knots,
0252                                            const TColStd_Array1OfInteger& Mults,
0253                                            TColStd_Array1OfReal&          KnotSeq,
0254                                            const Standard_Boolean Periodic = Standard_False);
0255 
0256   //! Computes  the  sequence   of knots KnotSeq  with
0257   //! repetition  of the  knots  of multiplicity  greater
0258   //! than 1.
0259   //!
0260   //! Length of KnotSeq must be KnotSequenceLength(Mults,Degree,Periodic)
0261   Standard_EXPORT static void KnotSequence(const TColStd_Array1OfReal&    Knots,
0262                                            const TColStd_Array1OfInteger& Mults,
0263                                            const Standard_Integer         Degree,
0264                                            const Standard_Boolean         Periodic,
0265                                            TColStd_Array1OfReal&          KnotSeq);
0266 
0267   //! Returns the  length  of the   sequence of  knots  (and
0268   //! Mults)  without repetition.
0269   Standard_EXPORT static Standard_Integer KnotsLength(
0270     const TColStd_Array1OfReal& KnotSeq,
0271     const Standard_Boolean      Periodic = Standard_False);
0272 
0273   //! Computes  the  sequence   of knots Knots  without
0274   //! repetition  of the  knots  of multiplicity  greater
0275   //! than 1.
0276   //!
0277   //! Length  of <Knots> and  <Mults> must be
0278   //! KnotsLength(KnotSequence,Periodic)
0279   Standard_EXPORT static void Knots(const TColStd_Array1OfReal& KnotSeq,
0280                                     TColStd_Array1OfReal&       Knots,
0281                                     TColStd_Array1OfInteger&    Mults,
0282                                     const Standard_Boolean      Periodic = Standard_False);
0283 
0284   //! Analyses if the  knots distribution is "Uniform"
0285   //! or  "NonUniform" between  the  knot  FromK1 and the
0286   //! knot ToK2.  There is  no repetition of  knot in the
0287   //! knots'sequence <Knots>.
0288   Standard_EXPORT static BSplCLib_KnotDistribution KnotForm(const TColStd_Array1OfReal& Knots,
0289                                                             const Standard_Integer      FromK1,
0290                                                             const Standard_Integer      ToK2);
0291 
0292   //! Analyses the distribution of multiplicities between
0293   //! the knot FromK1 and the Knot ToK2.
0294   Standard_EXPORT static BSplCLib_MultDistribution MultForm(const TColStd_Array1OfInteger& Mults,
0295                                                             const Standard_Integer         FromK1,
0296                                                             const Standard_Integer         ToK2);
0297 
0298   //! Analyzes the array of knots.
0299   //! Returns the form and the maximum knot multiplicity.
0300   Standard_EXPORT static void KnotAnalysis(const Standard_Integer         Degree,
0301                                            const Standard_Boolean         Periodic,
0302                                            const TColStd_Array1OfReal&    CKnots,
0303                                            const TColStd_Array1OfInteger& CMults,
0304                                            GeomAbs_BSplKnotDistribution&  KnotForm,
0305                                            Standard_Integer&              MaxKnotMult);
0306 
0307   //! Reparametrizes a B-spline curve to [U1, U2].
0308   //! The knot values are recomputed such that Knots (Lower) = U1
0309   //! and Knots (Upper) = U2   but the knot form is not modified.
0310   //! Warnings :
0311   //! In the array Knots the values must be in ascending order.
0312   //! U1 must not be equal to U2 to avoid division by zero.
0313   Standard_EXPORT static void Reparametrize(const Standard_Real   U1,
0314                                             const Standard_Real   U2,
0315                                             TColStd_Array1OfReal& Knots);
0316 
0317   //! Reverses  the  array   knots  to  become  the knots
0318   //! sequence of the reversed curve.
0319   Standard_EXPORT static void Reverse(TColStd_Array1OfReal& Knots);
0320 
0321   //! Reverses  the  array of multiplicities.
0322   Standard_EXPORT static void Reverse(TColStd_Array1OfInteger& Mults);
0323 
0324   //! Reverses the array of poles. Last is the  index of
0325   //! the new first pole. On  a  non periodic curve last
0326   //! is Poles.Upper(). On a periodic curve last is
0327   //!
0328   //! (number of flat knots - degree - 1)
0329   //!
0330   //! or
0331   //!
0332   //! (sum of multiplicities(but  for the last) + degree
0333   //! - 1)
0334   Standard_EXPORT static void Reverse(TColgp_Array1OfPnt& Poles, const Standard_Integer Last);
0335 
0336   //! Reverses the array of poles.
0337   Standard_EXPORT static void Reverse(TColgp_Array1OfPnt2d& Poles, const Standard_Integer Last);
0338 
0339   //! Reverses the array of poles.
0340   Standard_EXPORT static void Reverse(TColStd_Array1OfReal& Weights, const Standard_Integer Last);
0341 
0342   //! Returns False if all the weights  of the  array <Weights>
0343   //! between   I1 an I2   are  identic.   Epsilon  is used for
0344   //! comparing  weights. If Epsilon  is 0. the  Epsilon of the
0345   //! first weight is used.
0346   Standard_EXPORT static Standard_Boolean IsRational(const TColStd_Array1OfReal& Weights,
0347                                                      const Standard_Integer      I1,
0348                                                      const Standard_Integer      I2,
0349                                                      const Standard_Real         Epsilon = 0.0);
0350 
0351   //! returns the degree maxima for a BSplineCurve.
0352   static Standard_Integer MaxDegree();
0353 
0354   //! Perform the Boor  algorithm  to  evaluate a point at
0355   //! parameter <U>, with <Degree> and <Dimension>.
0356   //!
0357   //! Poles is  an array of  Reals of size
0358   //!
0359   //! <Dimension> *  <Degree>+1
0360   //!
0361   //! Containing  the poles.  At  the end <Poles> contains
0362   //! the current point.
0363   Standard_EXPORT static void Eval(const Standard_Real    U,
0364                                    const Standard_Integer Degree,
0365                                    Standard_Real&         Knots,
0366                                    const Standard_Integer Dimension,
0367                                    Standard_Real&         Poles);
0368 
0369   //! Performs the  Boor Algorithm  at  parameter <U> with
0370   //! the given <Degree> and the  array of <Knots> on  the
0371   //! poles <Poles> of dimension  <Dimension>.  The schema
0372   //! is  computed  until  level  <Depth>  on a   basis of
0373   //! <Length+1> poles.
0374   //!
0375   //! * Knots is an array of reals of length :
0376   //!
0377   //! <Length> + <Degree>
0378   //!
0379   //! * Poles is an array of reals of length :
0380   //!
0381   //! (2 * <Length> + 1) * <Dimension>
0382   //!
0383   //! The poles values  must be  set  in the array at the
0384   //! positions.
0385   //!
0386   //! 0..Dimension,
0387   //!
0388   //! 2 * Dimension ..
0389   //! 3 * Dimension
0390   //!
0391   //! 4  * Dimension ..
0392   //! 5  * Dimension
0393   //!
0394   //! ...
0395   //!
0396   //! The results are found in the array poles depending
0397   //! on the Depth. (See the method GetPole).
0398   Standard_EXPORT static void BoorScheme(const Standard_Real    U,
0399                                          const Standard_Integer Degree,
0400                                          Standard_Real&         Knots,
0401                                          const Standard_Integer Dimension,
0402                                          Standard_Real&         Poles,
0403                                          const Standard_Integer Depth,
0404                                          const Standard_Integer Length);
0405 
0406   //! Compute  the content of  Pole before the BoorScheme.
0407   //! This method is used to remove poles.
0408   //!
0409   //! U is the poles to  remove, Knots should contains the
0410   //! knots of the curve after knot removal.
0411   //!
0412   //! The first  and last poles  do not  change, the other
0413   //! poles are computed by averaging two possible values.
0414   //! The distance between  the  two   possible  poles  is
0415   //! computed, if it  is higher than <Tolerance> False is
0416   //! returned.
0417   Standard_EXPORT static Standard_Boolean AntiBoorScheme(const Standard_Real    U,
0418                                                          const Standard_Integer Degree,
0419                                                          Standard_Real&         Knots,
0420                                                          const Standard_Integer Dimension,
0421                                                          Standard_Real&         Poles,
0422                                                          const Standard_Integer Depth,
0423                                                          const Standard_Integer Length,
0424                                                          const Standard_Real    Tolerance);
0425 
0426   //! Computes   the   poles of  the    BSpline  giving the
0427   //! derivatives of order <Order>.
0428   //!
0429   //! The formula for the first order is
0430   //!
0431   //! Pole(i) = Degree * (Pole(i+1) - Pole(i)) /
0432   //! (Knots(i+Degree+1) - Knots(i+1))
0433   //!
0434   //! This formula  is repeated  (Degree  is decremented at
0435   //! each step).
0436   Standard_EXPORT static void Derivative(const Standard_Integer Degree,
0437                                          Standard_Real&         Knots,
0438                                          const Standard_Integer Dimension,
0439                                          const Standard_Integer Length,
0440                                          const Standard_Integer Order,
0441                                          Standard_Real&         Poles);
0442 
0443   //! Performs the Bohm  Algorithm at  parameter <U>. This
0444   //! algorithm computes the value and all the derivatives
0445   //! up to order N (N <= Degree).
0446   //!
0447   //! <Poles> is the original array of poles.
0448   //!
0449   //! The   result in  <Poles>  is    the value and    the
0450   //! derivatives.  Poles[0] is  the value,  Poles[Degree]
0451   //! is the last  derivative.
0452   Standard_EXPORT static void Bohm(const Standard_Real    U,
0453                                    const Standard_Integer Degree,
0454                                    const Standard_Integer N,
0455                                    Standard_Real&         Knots,
0456                                    const Standard_Integer Dimension,
0457                                    Standard_Real&         Poles);
0458 
0459   //! Used as argument for a non rational curve.
0460   static TColStd_Array1OfReal* NoWeights();
0461 
0462   //! Used as argument for a flatknots evaluation.
0463   static TColStd_Array1OfInteger* NoMults();
0464 
0465   //! Stores in LK the useful knots for the BoorSchem
0466   //! on the span Knots(Index) - Knots(Index+1)
0467   Standard_EXPORT static void BuildKnots(const Standard_Integer         Degree,
0468                                          const Standard_Integer         Index,
0469                                          const Standard_Boolean         Periodic,
0470                                          const TColStd_Array1OfReal&    Knots,
0471                                          const TColStd_Array1OfInteger* Mults,
0472                                          Standard_Real&                 LK);
0473 
0474   //! Return the index of the  first Pole to  use on the
0475   //! span  Mults(Index)  - Mults(Index+1).  This  index
0476   //! must be added to Poles.Lower().
0477   Standard_EXPORT static Standard_Integer PoleIndex(const Standard_Integer         Degree,
0478                                                     const Standard_Integer         Index,
0479                                                     const Standard_Boolean         Periodic,
0480                                                     const TColStd_Array1OfInteger& Mults);
0481 
0482   Standard_EXPORT static void BuildEval(const Standard_Integer      Degree,
0483                                         const Standard_Integer      Index,
0484                                         const TColStd_Array1OfReal& Poles,
0485                                         const TColStd_Array1OfReal* Weights,
0486                                         Standard_Real&              LP);
0487 
0488   Standard_EXPORT static void BuildEval(const Standard_Integer      Degree,
0489                                         const Standard_Integer      Index,
0490                                         const TColgp_Array1OfPnt&   Poles,
0491                                         const TColStd_Array1OfReal* Weights,
0492                                         Standard_Real&              LP);
0493 
0494   //! Copy in <LP>  the poles and  weights for  the Eval
0495   //! scheme. starting from  Poles(Poles.Lower()+Index)
0496   Standard_EXPORT static void BuildEval(const Standard_Integer      Degree,
0497                                         const Standard_Integer      Index,
0498                                         const TColgp_Array1OfPnt2d& Poles,
0499                                         const TColStd_Array1OfReal* Weights,
0500                                         Standard_Real&              LP);
0501 
0502   //! Copy in <LP>  poles for <Dimension>  Boor  scheme.
0503   //! Starting  from    <Index>     *  <Dimension>, copy
0504   //! <Length+1> poles.
0505   Standard_EXPORT static void BuildBoor(const Standard_Integer      Index,
0506                                         const Standard_Integer      Length,
0507                                         const Standard_Integer      Dimension,
0508                                         const TColStd_Array1OfReal& Poles,
0509                                         Standard_Real&              LP);
0510 
0511   //! Returns the index in  the Boor result array of the
0512   //! poles <Index>. If  the Boor  algorithm was perform
0513   //! with <Length> and <Depth>.
0514   Standard_EXPORT static Standard_Integer BoorIndex(const Standard_Integer Index,
0515                                                     const Standard_Integer Length,
0516                                                     const Standard_Integer Depth);
0517 
0518   //! Copy  the  pole at  position  <Index>  in  the Boor
0519   //! scheme of   dimension <Dimension> to  <Position> in
0520   //! the array <Pole>. <Position> is updated.
0521   Standard_EXPORT static void GetPole(const Standard_Integer Index,
0522                                       const Standard_Integer Length,
0523                                       const Standard_Integer Depth,
0524                                       const Standard_Integer Dimension,
0525                                       Standard_Real&         LocPoles,
0526                                       Standard_Integer&      Position,
0527                                       TColStd_Array1OfReal&  Pole);
0528 
0529   //! Returns in <NbPoles, NbKnots> the  new number of poles
0530   //! and  knots    if  the  sequence   of  knots <AddKnots,
0531   //! AddMults> is inserted in the sequence <Knots, Mults>.
0532   //!
0533   //! Epsilon is used to compare knots for equality.
0534   //!
0535   //! If Add is True  the multiplicities on  equal knots are
0536   //! added.
0537   //!
0538   //! If Add is False the max value of the multiplicities is
0539   //! kept.
0540   //!
0541   //! Return False if :
0542   //! The knew knots are knot increasing.
0543   //! The new knots are not in the range.
0544   Standard_EXPORT static Standard_Boolean PrepareInsertKnots(
0545     const Standard_Integer         Degree,
0546     const Standard_Boolean         Periodic,
0547     const TColStd_Array1OfReal&    Knots,
0548     const TColStd_Array1OfInteger& Mults,
0549     const TColStd_Array1OfReal&    AddKnots,
0550     const TColStd_Array1OfInteger* AddMults,
0551     Standard_Integer&              NbPoles,
0552     Standard_Integer&              NbKnots,
0553     const Standard_Real            Epsilon,
0554     const Standard_Boolean         Add = Standard_True);
0555 
0556   Standard_EXPORT static void InsertKnots(const Standard_Integer         Degree,
0557                                           const Standard_Boolean         Periodic,
0558                                           const Standard_Integer         Dimension,
0559                                           const TColStd_Array1OfReal&    Poles,
0560                                           const TColStd_Array1OfReal&    Knots,
0561                                           const TColStd_Array1OfInteger& Mults,
0562                                           const TColStd_Array1OfReal&    AddKnots,
0563                                           const TColStd_Array1OfInteger* AddMults,
0564                                           TColStd_Array1OfReal&          NewPoles,
0565                                           TColStd_Array1OfReal&          NewKnots,
0566                                           TColStd_Array1OfInteger&       NewMults,
0567                                           const Standard_Real            Epsilon,
0568                                           const Standard_Boolean         Add = Standard_True);
0569 
0570   Standard_EXPORT static void InsertKnots(const Standard_Integer         Degree,
0571                                           const Standard_Boolean         Periodic,
0572                                           const TColgp_Array1OfPnt&      Poles,
0573                                           const TColStd_Array1OfReal*    Weights,
0574                                           const TColStd_Array1OfReal&    Knots,
0575                                           const TColStd_Array1OfInteger& Mults,
0576                                           const TColStd_Array1OfReal&    AddKnots,
0577                                           const TColStd_Array1OfInteger* AddMults,
0578                                           TColgp_Array1OfPnt&            NewPoles,
0579                                           TColStd_Array1OfReal*          NewWeights,
0580                                           TColStd_Array1OfReal&          NewKnots,
0581                                           TColStd_Array1OfInteger&       NewMults,
0582                                           const Standard_Real            Epsilon,
0583                                           const Standard_Boolean         Add = Standard_True);
0584 
0585   //! Insert   a  sequence  of  knots <AddKnots> with
0586   //! multiplicities   <AddMults>. <AddKnots>   must  be a   non
0587   //! decreasing sequence and verifies :
0588   //!
0589   //! Knots(Knots.Lower()) <= AddKnots(AddKnots.Lower())
0590   //! Knots(Knots.Upper()) >= AddKnots(AddKnots.Upper())
0591   //!
0592   //! The NewPoles and NewWeights arrays must have a length :
0593   //! Poles.Length() + Sum(AddMults())
0594   //!
0595   //! When a knot  to insert is identic  to an existing knot the
0596   //! multiplicities   are added.
0597   //!
0598   //! Epsilon is used to test knots for equality.
0599   //!
0600   //! When AddMult is negative or null the knot is not inserted.
0601   //! No multiplicity will becomes higher than the degree.
0602   //!
0603   //! The new Knots and Multiplicities  are copied in <NewKnots>
0604   //! and  <NewMults>.
0605   //!
0606   //! All the New arrays should be correctly dimensioned.
0607   //!
0608   //! When all  the new knots  are existing knots, i.e. only the
0609   //! multiplicities  will  change it is   safe to  use the same
0610   //! arrays as input and output.
0611   Standard_EXPORT static void InsertKnots(const Standard_Integer         Degree,
0612                                           const Standard_Boolean         Periodic,
0613                                           const TColgp_Array1OfPnt2d&    Poles,
0614                                           const TColStd_Array1OfReal*    Weights,
0615                                           const TColStd_Array1OfReal&    Knots,
0616                                           const TColStd_Array1OfInteger& Mults,
0617                                           const TColStd_Array1OfReal&    AddKnots,
0618                                           const TColStd_Array1OfInteger* AddMults,
0619                                           TColgp_Array1OfPnt2d&          NewPoles,
0620                                           TColStd_Array1OfReal*          NewWeights,
0621                                           TColStd_Array1OfReal&          NewKnots,
0622                                           TColStd_Array1OfInteger&       NewMults,
0623                                           const Standard_Real            Epsilon,
0624                                           const Standard_Boolean         Add = Standard_True);
0625 
0626   Standard_EXPORT static void InsertKnot(const Standard_Integer         UIndex,
0627                                          const Standard_Real            U,
0628                                          const Standard_Integer         UMult,
0629                                          const Standard_Integer         Degree,
0630                                          const Standard_Boolean         Periodic,
0631                                          const TColgp_Array1OfPnt&      Poles,
0632                                          const TColStd_Array1OfReal*    Weights,
0633                                          const TColStd_Array1OfReal&    Knots,
0634                                          const TColStd_Array1OfInteger& Mults,
0635                                          TColgp_Array1OfPnt&            NewPoles,
0636                                          TColStd_Array1OfReal*          NewWeights);
0637 
0638   //! Insert a new knot U of multiplicity UMult in the
0639   //! knot sequence.
0640   //!
0641   //! The  location of the new Knot  should be given as an input
0642   //! data.  UIndex locates the new knot U  in the knot sequence
0643   //! and Knots (UIndex) < U < Knots (UIndex + 1).
0644   //!
0645   //! The new control points corresponding to this insertion are
0646   //! returned. Knots and Mults are not updated.
0647   Standard_EXPORT static void InsertKnot(const Standard_Integer         UIndex,
0648                                          const Standard_Real            U,
0649                                          const Standard_Integer         UMult,
0650                                          const Standard_Integer         Degree,
0651                                          const Standard_Boolean         Periodic,
0652                                          const TColgp_Array1OfPnt2d&    Poles,
0653                                          const TColStd_Array1OfReal*    Weights,
0654                                          const TColStd_Array1OfReal&    Knots,
0655                                          const TColStd_Array1OfInteger& Mults,
0656                                          TColgp_Array1OfPnt2d&          NewPoles,
0657                                          TColStd_Array1OfReal*          NewWeights);
0658 
0659   Standard_EXPORT static void RaiseMultiplicity(const Standard_Integer         KnotIndex,
0660                                                 const Standard_Integer         Mult,
0661                                                 const Standard_Integer         Degree,
0662                                                 const Standard_Boolean         Periodic,
0663                                                 const TColgp_Array1OfPnt&      Poles,
0664                                                 const TColStd_Array1OfReal*    Weights,
0665                                                 const TColStd_Array1OfReal&    Knots,
0666                                                 const TColStd_Array1OfInteger& Mults,
0667                                                 TColgp_Array1OfPnt&            NewPoles,
0668                                                 TColStd_Array1OfReal*          NewWeights);
0669 
0670   //! Raise the multiplicity of knot to <UMult>.
0671   //!
0672   //! The new control points  are  returned. Knots and Mults are
0673   //! not updated.
0674   Standard_EXPORT static void RaiseMultiplicity(const Standard_Integer         KnotIndex,
0675                                                 const Standard_Integer         Mult,
0676                                                 const Standard_Integer         Degree,
0677                                                 const Standard_Boolean         Periodic,
0678                                                 const TColgp_Array1OfPnt2d&    Poles,
0679                                                 const TColStd_Array1OfReal*    Weights,
0680                                                 const TColStd_Array1OfReal&    Knots,
0681                                                 const TColStd_Array1OfInteger& Mults,
0682                                                 TColgp_Array1OfPnt2d&          NewPoles,
0683                                                 TColStd_Array1OfReal*          NewWeights);
0684 
0685   Standard_EXPORT static Standard_Boolean RemoveKnot(const Standard_Integer         Index,
0686                                                      const Standard_Integer         Mult,
0687                                                      const Standard_Integer         Degree,
0688                                                      const Standard_Boolean         Periodic,
0689                                                      const Standard_Integer         Dimension,
0690                                                      const TColStd_Array1OfReal&    Poles,
0691                                                      const TColStd_Array1OfReal&    Knots,
0692                                                      const TColStd_Array1OfInteger& Mults,
0693                                                      TColStd_Array1OfReal&          NewPoles,
0694                                                      TColStd_Array1OfReal&          NewKnots,
0695                                                      TColStd_Array1OfInteger&       NewMults,
0696                                                      const Standard_Real            Tolerance);
0697 
0698   Standard_EXPORT static Standard_Boolean RemoveKnot(const Standard_Integer         Index,
0699                                                      const Standard_Integer         Mult,
0700                                                      const Standard_Integer         Degree,
0701                                                      const Standard_Boolean         Periodic,
0702                                                      const TColgp_Array1OfPnt&      Poles,
0703                                                      const TColStd_Array1OfReal*    Weights,
0704                                                      const TColStd_Array1OfReal&    Knots,
0705                                                      const TColStd_Array1OfInteger& Mults,
0706                                                      TColgp_Array1OfPnt&            NewPoles,
0707                                                      TColStd_Array1OfReal*          NewWeights,
0708                                                      TColStd_Array1OfReal&          NewKnots,
0709                                                      TColStd_Array1OfInteger&       NewMults,
0710                                                      const Standard_Real            Tolerance);
0711 
0712   //! Decrement the  multiplicity  of <Knots(Index)>
0713   //! to <Mult>. If <Mult>   is  null the   knot  is
0714   //! removed.
0715   //!
0716   //! As there are two ways to compute the new poles
0717   //! the midlle   will  be used  as  long    as the
0718   //! distance is lower than Tolerance.
0719   //!
0720   //! If a  distance is  bigger  than  tolerance the
0721   //! methods returns False  and  the new arrays are
0722   //! not modified.
0723   //!
0724   //! A low  tolerance can be  used  to test  if the
0725   //! knot  can be  removed  without  modifying  the
0726   //! curve.
0727   //!
0728   //! A high tolerance  can be used  to "smooth" the
0729   //! curve.
0730   Standard_EXPORT static Standard_Boolean RemoveKnot(const Standard_Integer         Index,
0731                                                      const Standard_Integer         Mult,
0732                                                      const Standard_Integer         Degree,
0733                                                      const Standard_Boolean         Periodic,
0734                                                      const TColgp_Array1OfPnt2d&    Poles,
0735                                                      const TColStd_Array1OfReal*    Weights,
0736                                                      const TColStd_Array1OfReal&    Knots,
0737                                                      const TColStd_Array1OfInteger& Mults,
0738                                                      TColgp_Array1OfPnt2d&          NewPoles,
0739                                                      TColStd_Array1OfReal*          NewWeights,
0740                                                      TColStd_Array1OfReal&          NewKnots,
0741                                                      TColStd_Array1OfInteger&       NewMults,
0742                                                      const Standard_Real            Tolerance);
0743 
0744   //! Returns the   number   of  knots   of  a  curve   with
0745   //! multiplicities <Mults> after elevating the degree from
0746   //! <Degree> to <NewDegree>. See the IncreaseDegree method
0747   //! for more comments.
0748   Standard_EXPORT static Standard_Integer IncreaseDegreeCountKnots(
0749     const Standard_Integer         Degree,
0750     const Standard_Integer         NewDegree,
0751     const Standard_Boolean         Periodic,
0752     const TColStd_Array1OfInteger& Mults);
0753 
0754   Standard_EXPORT static void IncreaseDegree(const Standard_Integer         Degree,
0755                                              const Standard_Integer         NewDegree,
0756                                              const Standard_Boolean         Periodic,
0757                                              const Standard_Integer         Dimension,
0758                                              const TColStd_Array1OfReal&    Poles,
0759                                              const TColStd_Array1OfReal&    Knots,
0760                                              const TColStd_Array1OfInteger& Mults,
0761                                              TColStd_Array1OfReal&          NewPoles,
0762                                              TColStd_Array1OfReal&          NewKnots,
0763                                              TColStd_Array1OfInteger&       NewMults);
0764 
0765   Standard_EXPORT static void IncreaseDegree(const Standard_Integer         Degree,
0766                                              const Standard_Integer         NewDegree,
0767                                              const Standard_Boolean         Periodic,
0768                                              const TColgp_Array1OfPnt&      Poles,
0769                                              const TColStd_Array1OfReal*    Weights,
0770                                              const TColStd_Array1OfReal&    Knots,
0771                                              const TColStd_Array1OfInteger& Mults,
0772                                              TColgp_Array1OfPnt&            NewPoles,
0773                                              TColStd_Array1OfReal*          NewWeights,
0774                                              TColStd_Array1OfReal&          NewKnots,
0775                                              TColStd_Array1OfInteger&       NewMults);
0776 
0777   Standard_EXPORT static void IncreaseDegree(const Standard_Integer         Degree,
0778                                              const Standard_Integer         NewDegree,
0779                                              const Standard_Boolean         Periodic,
0780                                              const TColgp_Array1OfPnt2d&    Poles,
0781                                              const TColStd_Array1OfReal*    Weights,
0782                                              const TColStd_Array1OfReal&    Knots,
0783                                              const TColStd_Array1OfInteger& Mults,
0784                                              TColgp_Array1OfPnt2d&          NewPoles,
0785                                              TColStd_Array1OfReal*          NewWeights,
0786                                              TColStd_Array1OfReal&          NewKnots,
0787                                              TColStd_Array1OfInteger&       NewMults);
0788 
0789   Standard_EXPORT static void IncreaseDegree(const Standard_Integer      NewDegree,
0790                                              const TColgp_Array1OfPnt&   Poles,
0791                                              const TColStd_Array1OfReal* Weights,
0792                                              TColgp_Array1OfPnt&         NewPoles,
0793                                              TColStd_Array1OfReal*       NewWeights);
0794 
0795   //! Increase the degree of a bspline (or bezier) curve
0796   //! of dimension theDimension form theDegree to theNewDegree.
0797   //!
0798   //! The number of poles in the new curve is:
0799   //! @code
0800   //!   Poles.Length() + (NewDegree - Degree) * Number of spans
0801   //! @endcode
0802   //! Where the number of spans is:
0803   //! @code
0804   //!   LastUKnotIndex(Mults) - FirstUKnotIndex(Mults) + 1
0805   //! @endcode
0806   //! for a non-periodic curve, and
0807   //! @code
0808   //!   Knots.Length() - 1
0809   //! @endcode
0810   //! for a periodic curve.
0811   //!
0812   //! The multiplicities of all knots are increased by the degree elevation.
0813   //!
0814   //! The new knots are usually the same knots with the
0815   //! exception of a non-periodic curve with the first
0816   //! and last multiplicity not  equal to Degree+1 where
0817   //! knots are removed form the start and the bottom
0818   //! until the sum of the multiplicities is equal to
0819   //! NewDegree+1  at the knots corresponding to the
0820   //! first and last parameters of the curve.
0821   //!
0822   //! Example: Suppose a curve of degree 3 starting
0823   //! with following knots and multiplicities:
0824   //! @code
0825   //!   knot : 0.  1.  2.
0826   //!   mult : 1   2   1
0827   //! @endcode
0828   //!
0829   //! The FirstUKnot is 2.0 because the sum of multiplicities is
0830   //! @code
0831   //!   Degree+1 : 1 + 2 + 1 = 4 = 3 + 1
0832   //! @endcode
0833   //! i.e. the first parameter of the curve is 2.0 and
0834   //! will still be 2.0 after degree elevation.
0835   //! Let raise this curve to degree 4.
0836   //! The multiplicities are increased by 2.
0837   //!
0838   //! They  become 2 3 2.
0839   //! But we need a sum of multiplicities of 5 at knot 2.
0840   //! So the first knot is removed and the new knots are:
0841   //! @code
0842   //!   knot : 1.  2.
0843   //!   mult : 3   2
0844   //! @endcode
0845   //! The multiplicity of the first knot may also be reduced if the sum is still too big.
0846   //!
0847   //! In the most common situations (periodic curve or curve with first
0848   //! and last multiplicities equals to Degree+1) the knots are knot changes.
0849   //!
0850   //! The method IncreaseDegreeCountKnots can be used to compute the new number of knots.
0851   Standard_EXPORT static void IncreaseDegree(const Standard_Integer      theNewDegree,
0852                                              const TColgp_Array1OfPnt2d& thePoles,
0853                                              const TColStd_Array1OfReal* theWeights,
0854                                              TColgp_Array1OfPnt2d&       theNewPoles,
0855                                              TColStd_Array1OfReal*       theNewWeights);
0856 
0857   //! Set in <NbKnots> and <NbPolesToAdd> the number of Knots and
0858   //! Poles   of  the NotPeriodic  Curve   identical  at the
0859   //! periodic     curve with    a  degree    <Degree>  ,  a
0860   //! knots-distribution with Multiplicities <Mults>.
0861   Standard_EXPORT static void PrepareUnperiodize(const Standard_Integer         Degree,
0862                                                  const TColStd_Array1OfInteger& Mults,
0863                                                  Standard_Integer&              NbKnots,
0864                                                  Standard_Integer&              NbPoles);
0865 
0866   Standard_EXPORT static void Unperiodize(const Standard_Integer         Degree,
0867                                           const Standard_Integer         Dimension,
0868                                           const TColStd_Array1OfInteger& Mults,
0869                                           const TColStd_Array1OfReal&    Knots,
0870                                           const TColStd_Array1OfReal&    Poles,
0871                                           TColStd_Array1OfInteger&       NewMults,
0872                                           TColStd_Array1OfReal&          NewKnots,
0873                                           TColStd_Array1OfReal&          NewPoles);
0874 
0875   Standard_EXPORT static void Unperiodize(const Standard_Integer         Degree,
0876                                           const TColStd_Array1OfInteger& Mults,
0877                                           const TColStd_Array1OfReal&    Knots,
0878                                           const TColgp_Array1OfPnt&      Poles,
0879                                           const TColStd_Array1OfReal*    Weights,
0880                                           TColStd_Array1OfInteger&       NewMults,
0881                                           TColStd_Array1OfReal&          NewKnots,
0882                                           TColgp_Array1OfPnt&            NewPoles,
0883                                           TColStd_Array1OfReal*          NewWeights);
0884 
0885   Standard_EXPORT static void Unperiodize(const Standard_Integer         Degree,
0886                                           const TColStd_Array1OfInteger& Mults,
0887                                           const TColStd_Array1OfReal&    Knots,
0888                                           const TColgp_Array1OfPnt2d&    Poles,
0889                                           const TColStd_Array1OfReal*    Weights,
0890                                           TColStd_Array1OfInteger&       NewMults,
0891                                           TColStd_Array1OfReal&          NewKnots,
0892                                           TColgp_Array1OfPnt2d&          NewPoles,
0893                                           TColStd_Array1OfReal*          NewWeights);
0894 
0895   //! Set in <NbKnots> and <NbPoles> the number of Knots and
0896   //! Poles of the curve resulting from  the trimming of the
0897   //! BSplinecurve defined with <degree>, <knots>, <mults>
0898   Standard_EXPORT static void PrepareTrimming(const Standard_Integer         Degree,
0899                                               const Standard_Boolean         Periodic,
0900                                               const TColStd_Array1OfReal&    Knots,
0901                                               const TColStd_Array1OfInteger& Mults,
0902                                               const Standard_Real            U1,
0903                                               const Standard_Real            U2,
0904                                               Standard_Integer&              NbKnots,
0905                                               Standard_Integer&              NbPoles);
0906 
0907   Standard_EXPORT static void Trimming(const Standard_Integer         Degree,
0908                                        const Standard_Boolean         Periodic,
0909                                        const Standard_Integer         Dimension,
0910                                        const TColStd_Array1OfReal&    Knots,
0911                                        const TColStd_Array1OfInteger& Mults,
0912                                        const TColStd_Array1OfReal&    Poles,
0913                                        const Standard_Real            U1,
0914                                        const Standard_Real            U2,
0915                                        TColStd_Array1OfReal&          NewKnots,
0916                                        TColStd_Array1OfInteger&       NewMults,
0917                                        TColStd_Array1OfReal&          NewPoles);
0918 
0919   Standard_EXPORT static void Trimming(const Standard_Integer         Degree,
0920                                        const Standard_Boolean         Periodic,
0921                                        const TColStd_Array1OfReal&    Knots,
0922                                        const TColStd_Array1OfInteger& Mults,
0923                                        const TColgp_Array1OfPnt&      Poles,
0924                                        const TColStd_Array1OfReal*    Weights,
0925                                        const Standard_Real            U1,
0926                                        const Standard_Real            U2,
0927                                        TColStd_Array1OfReal&          NewKnots,
0928                                        TColStd_Array1OfInteger&       NewMults,
0929                                        TColgp_Array1OfPnt&            NewPoles,
0930                                        TColStd_Array1OfReal*          NewWeights);
0931 
0932   Standard_EXPORT static void Trimming(const Standard_Integer         Degree,
0933                                        const Standard_Boolean         Periodic,
0934                                        const TColStd_Array1OfReal&    Knots,
0935                                        const TColStd_Array1OfInteger& Mults,
0936                                        const TColgp_Array1OfPnt2d&    Poles,
0937                                        const TColStd_Array1OfReal*    Weights,
0938                                        const Standard_Real            U1,
0939                                        const Standard_Real            U2,
0940                                        TColStd_Array1OfReal&          NewKnots,
0941                                        TColStd_Array1OfInteger&       NewMults,
0942                                        TColgp_Array1OfPnt2d&          NewPoles,
0943                                        TColStd_Array1OfReal*          NewWeights);
0944 
0945   Standard_EXPORT static void D0(const Standard_Real            U,
0946                                  const Standard_Integer         Index,
0947                                  const Standard_Integer         Degree,
0948                                  const Standard_Boolean         Periodic,
0949                                  const TColStd_Array1OfReal&    Poles,
0950                                  const TColStd_Array1OfReal*    Weights,
0951                                  const TColStd_Array1OfReal&    Knots,
0952                                  const TColStd_Array1OfInteger* Mults,
0953                                  Standard_Real&                 P);
0954 
0955   Standard_EXPORT static void D0(const Standard_Real            U,
0956                                  const Standard_Integer         Index,
0957                                  const Standard_Integer         Degree,
0958                                  const Standard_Boolean         Periodic,
0959                                  const TColgp_Array1OfPnt&      Poles,
0960                                  const TColStd_Array1OfReal*    Weights,
0961                                  const TColStd_Array1OfReal&    Knots,
0962                                  const TColStd_Array1OfInteger* Mults,
0963                                  gp_Pnt&                        P);
0964 
0965   Standard_EXPORT static void D0(const Standard_Real            U,
0966                                  const Standard_Integer         UIndex,
0967                                  const Standard_Integer         Degree,
0968                                  const Standard_Boolean         Periodic,
0969                                  const TColgp_Array1OfPnt2d&    Poles,
0970                                  const TColStd_Array1OfReal*    Weights,
0971                                  const TColStd_Array1OfReal&    Knots,
0972                                  const TColStd_Array1OfInteger* Mults,
0973                                  gp_Pnt2d&                      P);
0974 
0975   Standard_EXPORT static void D0(const Standard_Real         U,
0976                                  const TColgp_Array1OfPnt&   Poles,
0977                                  const TColStd_Array1OfReal* Weights,
0978                                  gp_Pnt&                     P);
0979 
0980   Standard_EXPORT static void D0(const Standard_Real         U,
0981                                  const TColgp_Array1OfPnt2d& Poles,
0982                                  const TColStd_Array1OfReal* Weights,
0983                                  gp_Pnt2d&                   P);
0984 
0985   Standard_EXPORT static void D1(const Standard_Real            U,
0986                                  const Standard_Integer         Index,
0987                                  const Standard_Integer         Degree,
0988                                  const Standard_Boolean         Periodic,
0989                                  const TColStd_Array1OfReal&    Poles,
0990                                  const TColStd_Array1OfReal*    Weights,
0991                                  const TColStd_Array1OfReal&    Knots,
0992                                  const TColStd_Array1OfInteger* Mults,
0993                                  Standard_Real&                 P,
0994                                  Standard_Real&                 V);
0995 
0996   Standard_EXPORT static void D1(const Standard_Real            U,
0997                                  const Standard_Integer         Index,
0998                                  const Standard_Integer         Degree,
0999                                  const Standard_Boolean         Periodic,
1000                                  const TColgp_Array1OfPnt&      Poles,
1001                                  const TColStd_Array1OfReal*    Weights,
1002                                  const TColStd_Array1OfReal&    Knots,
1003                                  const TColStd_Array1OfInteger* Mults,
1004                                  gp_Pnt&                        P,
1005                                  gp_Vec&                        V);
1006 
1007   Standard_EXPORT static void D1(const Standard_Real            U,
1008                                  const Standard_Integer         UIndex,
1009                                  const Standard_Integer         Degree,
1010                                  const Standard_Boolean         Periodic,
1011                                  const TColgp_Array1OfPnt2d&    Poles,
1012                                  const TColStd_Array1OfReal*    Weights,
1013                                  const TColStd_Array1OfReal&    Knots,
1014                                  const TColStd_Array1OfInteger* Mults,
1015                                  gp_Pnt2d&                      P,
1016                                  gp_Vec2d&                      V);
1017 
1018   Standard_EXPORT static void D1(const Standard_Real         U,
1019                                  const TColgp_Array1OfPnt&   Poles,
1020                                  const TColStd_Array1OfReal* Weights,
1021                                  gp_Pnt&                     P,
1022                                  gp_Vec&                     V);
1023 
1024   Standard_EXPORT static void D1(const Standard_Real         U,
1025                                  const TColgp_Array1OfPnt2d& Poles,
1026                                  const TColStd_Array1OfReal* Weights,
1027                                  gp_Pnt2d&                   P,
1028                                  gp_Vec2d&                   V);
1029 
1030   Standard_EXPORT static void D2(const Standard_Real            U,
1031                                  const Standard_Integer         Index,
1032                                  const Standard_Integer         Degree,
1033                                  const Standard_Boolean         Periodic,
1034                                  const TColStd_Array1OfReal&    Poles,
1035                                  const TColStd_Array1OfReal*    Weights,
1036                                  const TColStd_Array1OfReal&    Knots,
1037                                  const TColStd_Array1OfInteger* Mults,
1038                                  Standard_Real&                 P,
1039                                  Standard_Real&                 V1,
1040                                  Standard_Real&                 V2);
1041 
1042   Standard_EXPORT static void D2(const Standard_Real            U,
1043                                  const Standard_Integer         Index,
1044                                  const Standard_Integer         Degree,
1045                                  const Standard_Boolean         Periodic,
1046                                  const TColgp_Array1OfPnt&      Poles,
1047                                  const TColStd_Array1OfReal*    Weights,
1048                                  const TColStd_Array1OfReal&    Knots,
1049                                  const TColStd_Array1OfInteger* Mults,
1050                                  gp_Pnt&                        P,
1051                                  gp_Vec&                        V1,
1052                                  gp_Vec&                        V2);
1053 
1054   Standard_EXPORT static void D2(const Standard_Real            U,
1055                                  const Standard_Integer         UIndex,
1056                                  const Standard_Integer         Degree,
1057                                  const Standard_Boolean         Periodic,
1058                                  const TColgp_Array1OfPnt2d&    Poles,
1059                                  const TColStd_Array1OfReal*    Weights,
1060                                  const TColStd_Array1OfReal&    Knots,
1061                                  const TColStd_Array1OfInteger* Mults,
1062                                  gp_Pnt2d&                      P,
1063                                  gp_Vec2d&                      V1,
1064                                  gp_Vec2d&                      V2);
1065 
1066   Standard_EXPORT static void D2(const Standard_Real         U,
1067                                  const TColgp_Array1OfPnt&   Poles,
1068                                  const TColStd_Array1OfReal* Weights,
1069                                  gp_Pnt&                     P,
1070                                  gp_Vec&                     V1,
1071                                  gp_Vec&                     V2);
1072 
1073   Standard_EXPORT static void D2(const Standard_Real         U,
1074                                  const TColgp_Array1OfPnt2d& Poles,
1075                                  const TColStd_Array1OfReal* Weights,
1076                                  gp_Pnt2d&                   P,
1077                                  gp_Vec2d&                   V1,
1078                                  gp_Vec2d&                   V2);
1079 
1080   Standard_EXPORT static void D3(const Standard_Real            U,
1081                                  const Standard_Integer         Index,
1082                                  const Standard_Integer         Degree,
1083                                  const Standard_Boolean         Periodic,
1084                                  const TColStd_Array1OfReal&    Poles,
1085                                  const TColStd_Array1OfReal*    Weights,
1086                                  const TColStd_Array1OfReal&    Knots,
1087                                  const TColStd_Array1OfInteger* Mults,
1088                                  Standard_Real&                 P,
1089                                  Standard_Real&                 V1,
1090                                  Standard_Real&                 V2,
1091                                  Standard_Real&                 V3);
1092 
1093   Standard_EXPORT static void D3(const Standard_Real            U,
1094                                  const Standard_Integer         Index,
1095                                  const Standard_Integer         Degree,
1096                                  const Standard_Boolean         Periodic,
1097                                  const TColgp_Array1OfPnt&      Poles,
1098                                  const TColStd_Array1OfReal*    Weights,
1099                                  const TColStd_Array1OfReal&    Knots,
1100                                  const TColStd_Array1OfInteger* Mults,
1101                                  gp_Pnt&                        P,
1102                                  gp_Vec&                        V1,
1103                                  gp_Vec&                        V2,
1104                                  gp_Vec&                        V3);
1105 
1106   Standard_EXPORT static void D3(const Standard_Real            U,
1107                                  const Standard_Integer         UIndex,
1108                                  const Standard_Integer         Degree,
1109                                  const Standard_Boolean         Periodic,
1110                                  const TColgp_Array1OfPnt2d&    Poles,
1111                                  const TColStd_Array1OfReal*    Weights,
1112                                  const TColStd_Array1OfReal&    Knots,
1113                                  const TColStd_Array1OfInteger* Mults,
1114                                  gp_Pnt2d&                      P,
1115                                  gp_Vec2d&                      V1,
1116                                  gp_Vec2d&                      V2,
1117                                  gp_Vec2d&                      V3);
1118 
1119   Standard_EXPORT static void D3(const Standard_Real         U,
1120                                  const TColgp_Array1OfPnt&   Poles,
1121                                  const TColStd_Array1OfReal* Weights,
1122                                  gp_Pnt&                     P,
1123                                  gp_Vec&                     V1,
1124                                  gp_Vec&                     V2,
1125                                  gp_Vec&                     V3);
1126 
1127   Standard_EXPORT static void D3(const Standard_Real         U,
1128                                  const TColgp_Array1OfPnt2d& Poles,
1129                                  const TColStd_Array1OfReal* Weights,
1130                                  gp_Pnt2d&                   P,
1131                                  gp_Vec2d&                   V1,
1132                                  gp_Vec2d&                   V2,
1133                                  gp_Vec2d&                   V3);
1134 
1135   Standard_EXPORT static void DN(const Standard_Real            U,
1136                                  const Standard_Integer         N,
1137                                  const Standard_Integer         Index,
1138                                  const Standard_Integer         Degree,
1139                                  const Standard_Boolean         Periodic,
1140                                  const TColStd_Array1OfReal&    Poles,
1141                                  const TColStd_Array1OfReal*    Weights,
1142                                  const TColStd_Array1OfReal&    Knots,
1143                                  const TColStd_Array1OfInteger* Mults,
1144                                  Standard_Real&                 VN);
1145 
1146   Standard_EXPORT static void DN(const Standard_Real            U,
1147                                  const Standard_Integer         N,
1148                                  const Standard_Integer         Index,
1149                                  const Standard_Integer         Degree,
1150                                  const Standard_Boolean         Periodic,
1151                                  const TColgp_Array1OfPnt&      Poles,
1152                                  const TColStd_Array1OfReal*    Weights,
1153                                  const TColStd_Array1OfReal&    Knots,
1154                                  const TColStd_Array1OfInteger* Mults,
1155                                  gp_Vec&                        VN);
1156 
1157   Standard_EXPORT static void DN(const Standard_Real            U,
1158                                  const Standard_Integer         N,
1159                                  const Standard_Integer         UIndex,
1160                                  const Standard_Integer         Degree,
1161                                  const Standard_Boolean         Periodic,
1162                                  const TColgp_Array1OfPnt2d&    Poles,
1163                                  const TColStd_Array1OfReal*    Weights,
1164                                  const TColStd_Array1OfReal&    Knots,
1165                                  const TColStd_Array1OfInteger* Mults,
1166                                  gp_Vec2d&                      V);
1167 
1168   Standard_EXPORT static void DN(const Standard_Real         U,
1169                                  const Standard_Integer      N,
1170                                  const TColgp_Array1OfPnt&   Poles,
1171                                  const TColStd_Array1OfReal& Weights,
1172                                  gp_Pnt&                     P,
1173                                  gp_Vec&                     VN);
1174 
1175   //! The  above  functions  compute   values and
1176   //! derivatives in the following situations :
1177   //!
1178   //! * 3D, 2D and 1D
1179   //!
1180   //! * Rational or not Rational.
1181   //!
1182   //! * Knots  and multiplicities or "flat knots" without
1183   //! multiplicities.
1184   //!
1185   //! * The  <Index>  is   the localization  of  the
1186   //! parameter in the knot sequence.  If <Index> is  out
1187   //! of range the correct value will be searched.
1188   //!
1189   //! VERY IMPORTANT!!!
1190   //! USE  BSplCLib::NoWeights()  as Weights argument for non
1191   //! rational curves computations.
1192   Standard_EXPORT static void DN(const Standard_Real         U,
1193                                  const Standard_Integer      N,
1194                                  const TColgp_Array1OfPnt2d& Poles,
1195                                  const TColStd_Array1OfReal& Weights,
1196                                  gp_Pnt2d&                   P,
1197                                  gp_Vec2d&                   VN);
1198 
1199   //! This  evaluates  the Bspline  Basis  at  a
1200   //! given  parameter  Parameter   up   to  the
1201   //! requested   DerivativeOrder  and store the
1202   //! result  in the  array BsplineBasis  in the
1203   //! following   fashion
1204   //! BSplineBasis(1,1)   =
1205   //! value of first non vanishing
1206   //! Bspline function which has Index FirstNonZeroBsplineIndex
1207   //! BsplineBasis(1,2)   =
1208   //! value of second non vanishing
1209   //! Bspline   function which  has   Index
1210   //! FirstNonZeroBsplineIndex + 1
1211   //! BsplineBasis(1,n)   =
1212   //! value of second non vanishing non vanishing
1213   //! Bspline   function which  has   Index
1214   //! FirstNonZeroBsplineIndex + n (n <= Order)
1215   //! BSplineBasis(2,1)   =
1216   //! value of derivative of first non vanishing
1217   //! Bspline function which has Index FirstNonZeroBsplineIndex
1218   //! BSplineBasis(N,1)   =
1219   //! value of Nth derivative of first non vanishing
1220   //! Bspline function which has Index FirstNonZeroBsplineIndex
1221   //! if N <= DerivativeOrder + 1
1222   Standard_EXPORT static Standard_Integer EvalBsplineBasis(
1223     const Standard_Integer      DerivativeOrder,
1224     const Standard_Integer      Order,
1225     const TColStd_Array1OfReal& FlatKnots,
1226     const Standard_Real         Parameter,
1227     Standard_Integer&           FirstNonZeroBsplineIndex,
1228     math_Matrix&                BsplineBasis,
1229     const Standard_Boolean      isPeriodic = Standard_False);
1230 
1231   //! This Builds   a fully  blown   Matrix of
1232   //! (ni)
1233   //! Bi    (tj)
1234   //!
1235   //! with i  and j within 1..Order + NumPoles
1236   //! The  integer ni is   the ith slot of the
1237   //! array OrderArray, tj is the jth slot of
1238   //! the array Parameters
1239   Standard_EXPORT static Standard_Integer BuildBSpMatrix(const TColStd_Array1OfReal&    Parameters,
1240                                                          const TColStd_Array1OfInteger& OrderArray,
1241                                                          const TColStd_Array1OfReal&    FlatKnots,
1242                                                          const Standard_Integer         Degree,
1243                                                          math_Matrix&                   Matrix,
1244                                                          Standard_Integer& UpperBandWidth,
1245                                                          Standard_Integer& LowerBandWidth);
1246 
1247   //! this  factors  the Banded Matrix in
1248   //! the LU form with a Banded storage of
1249   //! components of the L matrix
1250   //! WARNING : do not use if the Matrix is
1251   //! totally positive (It is the case for
1252   //! Bspline matrices build as above with
1253   //! parameters being the Schoenberg points
1254   Standard_EXPORT static Standard_Integer FactorBandedMatrix(math_Matrix&           Matrix,
1255                                                              const Standard_Integer UpperBandWidth,
1256                                                              const Standard_Integer LowerBandWidth,
1257                                                              Standard_Integer& PivotIndexProblem);
1258 
1259   //! This solves  the system Matrix.X =  B
1260   //! with when Matrix is factored in LU form
1261   //! The  Array   is    an   seen   as    an
1262   //! Array[1..N][1..ArrayDimension] with N =
1263   //! the  rank  of the  matrix  Matrix.  The
1264   //! result is stored   in Array  when  each
1265   //! coordinate is  solved that is  B is the
1266   //! array whose values are
1267   //! B[i] = Array[i][p] for each p in 1..ArrayDimension
1268   Standard_EXPORT static Standard_Integer SolveBandedSystem(const math_Matrix&     Matrix,
1269                                                             const Standard_Integer UpperBandWidth,
1270                                                             const Standard_Integer LowerBandWidth,
1271                                                             const Standard_Integer ArrayDimension,
1272                                                             Standard_Real&         Array);
1273 
1274   //! This solves  the system Matrix.X =  B
1275   //! with when Matrix is factored in LU form
1276   //! The  Array   has the length of
1277   //! the  rank  of the  matrix  Matrix.  The
1278   //! result is stored   in Array  when  each
1279   //! coordinate is  solved that is  B is the
1280   //! array whose values are
1281   //! B[i] = Array[i][p] for each p in 1..ArrayDimension
1282   Standard_EXPORT static Standard_Integer SolveBandedSystem(const math_Matrix&     Matrix,
1283                                                             const Standard_Integer UpperBandWidth,
1284                                                             const Standard_Integer LowerBandWidth,
1285                                                             TColgp_Array1OfPnt2d&  Array);
1286 
1287   //! This solves  the system Matrix.X =  B
1288   //! with when Matrix is factored in LU form
1289   //! The  Array   has the length of
1290   //! the  rank  of the  matrix  Matrix.  The
1291   //! result is stored   in Array  when  each
1292   //! coordinate is  solved that is  B is the
1293   //! array whose values are
1294   //! B[i] = Array[i][p] for each p in 1..ArrayDimension
1295   Standard_EXPORT static Standard_Integer SolveBandedSystem(const math_Matrix&     Matrix,
1296                                                             const Standard_Integer UpperBandWidth,
1297                                                             const Standard_Integer LowerBandWidth,
1298                                                             TColgp_Array1OfPnt&    Array);
1299 
1300   Standard_EXPORT static Standard_Integer SolveBandedSystem(const math_Matrix&     Matrix,
1301                                                             const Standard_Integer UpperBandWidth,
1302                                                             const Standard_Integer LowerBandWidth,
1303                                                             const Standard_Boolean HomogenousFlag,
1304                                                             const Standard_Integer ArrayDimension,
1305                                                             Standard_Real&         Array,
1306                                                             Standard_Real&         Weights);
1307 
1308   //! This solves the  system Matrix.X =  B
1309   //! with when Matrix is factored in LU form
1310   //! The    Array   is    an   seen  as   an
1311   //! Array[1..N][1..ArrayDimension] with N =
1312   //! the  rank  of  the  matrix Matrix.  The
1313   //! result is  stored   in Array when  each
1314   //! coordinate is  solved that is B  is the
1315   //! array  whose   values     are   B[i]  =
1316   //! Array[i][p]       for     each  p    in
1317   //! 1..ArrayDimension. If  HomogeneousFlag ==
1318   //! 0  the  Poles  are  multiplied by   the
1319   //! Weights   upon   Entry   and      once
1320   //! interpolation   is    carried  over the
1321   //! result of the  poles are divided by the
1322   //! result of   the   interpolation of  the
1323   //! weights. Otherwise if HomogenousFlag == 1
1324   //! the Poles and Weights are treated homogeneously
1325   //! that is that those are interpolated as they
1326   //! are and result is returned without division
1327   //! by the interpolated weights.
1328   Standard_EXPORT static Standard_Integer SolveBandedSystem(const math_Matrix&     Matrix,
1329                                                             const Standard_Integer UpperBandWidth,
1330                                                             const Standard_Integer LowerBandWidth,
1331                                                             const Standard_Boolean HomogenousFlag,
1332                                                             TColgp_Array1OfPnt2d&  Array,
1333                                                             TColStd_Array1OfReal&  Weights);
1334 
1335   //! This solves  the system Matrix.X =  B
1336   //! with when Matrix is factored in LU form
1337   //! The  Array   is    an   seen   as    an
1338   //! Array[1..N][1..ArrayDimension] with N =
1339   //! the  rank  of the  matrix  Matrix.  The
1340   //! result is stored   in Array  when  each
1341   //! coordinate is  solved that is  B is the
1342   //! array whose values are
1343   //! B[i] = Array[i][p] for each p in 1..ArrayDimension
1344   //! If  HomogeneousFlag ==
1345   //! 0  the  Poles  are  multiplied by   the
1346   //! Weights   upon   Entry   and      once
1347   //! interpolation   is    carried  over the
1348   //! result of the  poles are divided by the
1349   //! result of   the   interpolation of  the
1350   //! weights. Otherwise if HomogenousFlag == 1
1351   //! the Poles and Weights are treated homogeneously
1352   //! that is that those are interpolated as they
1353   //! are and result is returned without division
1354   //! by the interpolated weights.
1355   Standard_EXPORT static Standard_Integer SolveBandedSystem(const math_Matrix&     Matrix,
1356                                                             const Standard_Integer UpperBandWidth,
1357                                                             const Standard_Integer LowerBandWidth,
1358                                                             const Standard_Boolean HomogeneousFlag,
1359                                                             TColgp_Array1OfPnt&    Array,
1360                                                             TColStd_Array1OfReal&  Weights);
1361 
1362   //! Merges  two knot vector by   setting the starting and
1363   //! ending values to StartValue and EndValue
1364   Standard_EXPORT static void MergeBSplineKnots(const Standard_Real               Tolerance,
1365                                                 const Standard_Real               StartValue,
1366                                                 const Standard_Real               EndValue,
1367                                                 const Standard_Integer            Degree1,
1368                                                 const TColStd_Array1OfReal&       Knots1,
1369                                                 const TColStd_Array1OfInteger&    Mults1,
1370                                                 const Standard_Integer            Degree2,
1371                                                 const TColStd_Array1OfReal&       Knots2,
1372                                                 const TColStd_Array1OfInteger&    Mults2,
1373                                                 Standard_Integer&                 NumPoles,
1374                                                 Handle(TColStd_HArray1OfReal)&    NewKnots,
1375                                                 Handle(TColStd_HArray1OfInteger)& NewMults);
1376 
1377   //! This function will compose  a given Vectorial BSpline F(t)
1378   //! defined  by its  BSplineDegree and BSplineFlatKnotsl,
1379   //! its Poles  array which are coded as  an array of Real
1380   //! of  the  form  [1..NumPoles][1..PolesDimension] with  a
1381   //! function     a(t) which is   assumed to   satisfy the
1382   //! following:
1383   //!
1384   //! 1. F(a(t))  is a polynomial BSpline
1385   //! that can be expressed  exactly as a BSpline of degree
1386   //! NewDegree on the knots FlatKnots
1387   //!
1388   //! 2. a(t) defines a differentiable
1389   //! isomorphism between the range of FlatKnots to the range
1390   //! of BSplineFlatKnots which is the
1391   //! same as the  range of F(t)
1392   //!
1393   //! Warning: it is
1394   //! the caller's responsibility to insure that conditions
1395   //! 1. and  2. above are  satisfied : no check whatsoever
1396   //! is made in this method
1397   //!
1398   //! theStatus will return 0 if OK else it will return the pivot index
1399   //! of the matrix that was inverted to compute the multiplied
1400   //! BSpline : the method used is interpolation at Schoenenberg
1401   //! points of F(a(t))
1402   Standard_EXPORT static void FunctionReparameterise(const BSplCLib_EvaluatorFunction& Function,
1403                                                      const Standard_Integer      BSplineDegree,
1404                                                      const TColStd_Array1OfReal& BSplineFlatKnots,
1405                                                      const Standard_Integer      PolesDimension,
1406                                                      Standard_Real&              Poles,
1407                                                      const TColStd_Array1OfReal& FlatKnots,
1408                                                      const Standard_Integer      NewDegree,
1409                                                      Standard_Real&              NewPoles,
1410                                                      Standard_Integer&           theStatus);
1411 
1412   //! This function will compose  a given Vectorial BSpline F(t)
1413   //! defined  by its  BSplineDegree and BSplineFlatKnotsl,
1414   //! its Poles  array which are coded as  an array of Real
1415   //! of  the  form  [1..NumPoles][1..PolesDimension] with  a
1416   //! function     a(t) which is   assumed to   satisfy the
1417   //! following:
1418   //!
1419   //! 1. F(a(t))  is a polynomial BSpline
1420   //! that can be expressed  exactly as a BSpline of degree
1421   //! NewDegree on the knots FlatKnots
1422   //!
1423   //! 2. a(t) defines a differentiable
1424   //! isomorphism between the range of FlatKnots to the range
1425   //! of BSplineFlatKnots which is the
1426   //! same as the  range of F(t)
1427   //!
1428   //! Warning: it is
1429   //! the caller's responsibility to insure that conditions
1430   //! 1. and  2. above are  satisfied : no check whatsoever
1431   //! is made in this method
1432   //!
1433   //! theStatus will return 0 if OK else it will return the pivot index
1434   //! of the matrix that was inverted to compute the multiplied
1435   //! BSpline : the method used is interpolation at Schoenenberg
1436   //! points of F(a(t))
1437   Standard_EXPORT static void FunctionReparameterise(const BSplCLib_EvaluatorFunction& Function,
1438                                                      const Standard_Integer      BSplineDegree,
1439                                                      const TColStd_Array1OfReal& BSplineFlatKnots,
1440                                                      const TColStd_Array1OfReal& Poles,
1441                                                      const TColStd_Array1OfReal& FlatKnots,
1442                                                      const Standard_Integer      NewDegree,
1443                                                      TColStd_Array1OfReal&       NewPoles,
1444                                                      Standard_Integer&           theStatus);
1445 
1446   //! this will compose  a given Vectorial BSpline F(t)
1447   //! defined  by its  BSplineDegree and BSplineFlatKnotsl,
1448   //! its Poles  array which are coded as  an array of Real
1449   //! of  the  form  [1..NumPoles][1..PolesDimension] with  a
1450   //! function     a(t) which is   assumed to   satisfy the
1451   //! following  : 1. F(a(t))  is a polynomial BSpline
1452   //! that can be expressed  exactly as a BSpline of degree
1453   //! NewDegree on the knots FlatKnots
1454   //! 2. a(t) defines a differentiable
1455   //! isomorphism between the range of FlatKnots to the range
1456   //! of BSplineFlatKnots which is the
1457   //! same as the  range of F(t)
1458   //! Warning: it is
1459   //! the caller's responsibility to insure that conditions
1460   //! 1. and  2. above are  satisfied : no check whatsoever
1461   //! is made in this method
1462   //! theStatus will return 0 if OK else it will return the pivot index
1463   //! of the matrix that was inverted to compute the multiplied
1464   //! BSpline : the method used is interpolation at Schoenenberg
1465   //! points of F(a(t))
1466   Standard_EXPORT static void FunctionReparameterise(const BSplCLib_EvaluatorFunction& Function,
1467                                                      const Standard_Integer      BSplineDegree,
1468                                                      const TColStd_Array1OfReal& BSplineFlatKnots,
1469                                                      const TColgp_Array1OfPnt&   Poles,
1470                                                      const TColStd_Array1OfReal& FlatKnots,
1471                                                      const Standard_Integer      NewDegree,
1472                                                      TColgp_Array1OfPnt&         NewPoles,
1473                                                      Standard_Integer&           theStatus);
1474 
1475   //! this will compose  a given Vectorial BSpline F(t)
1476   //! defined  by its  BSplineDegree and BSplineFlatKnotsl,
1477   //! its Poles  array which are coded as  an array of Real
1478   //! of  the  form  [1..NumPoles][1..PolesDimension] with  a
1479   //! function     a(t) which is   assumed to   satisfy the
1480   //! following  : 1. F(a(t))  is a polynomial BSpline
1481   //! that can be expressed  exactly as a BSpline of degree
1482   //! NewDegree on the knots FlatKnots
1483   //! 2. a(t) defines a differentiable
1484   //! isomorphism between the range of FlatKnots to the range
1485   //! of BSplineFlatKnots which is the
1486   //! same as the  range of F(t)
1487   //! Warning: it is
1488   //! the caller's responsibility to insure that conditions
1489   //! 1. and  2. above are  satisfied : no check whatsoever
1490   //! is made in this method
1491   //! theStatus will return 0 if OK else it will return the pivot index
1492   //! of the matrix that was inverted to compute the multiplied
1493   //! BSpline : the method used is interpolation at Schoenenberg
1494   //! points of F(a(t))
1495   Standard_EXPORT static void FunctionReparameterise(const BSplCLib_EvaluatorFunction& Function,
1496                                                      const Standard_Integer      BSplineDegree,
1497                                                      const TColStd_Array1OfReal& BSplineFlatKnots,
1498                                                      const TColgp_Array1OfPnt2d& Poles,
1499                                                      const TColStd_Array1OfReal& FlatKnots,
1500                                                      const Standard_Integer      NewDegree,
1501                                                      TColgp_Array1OfPnt2d&       NewPoles,
1502                                                      Standard_Integer&           theStatus);
1503 
1504   //! this will  multiply a given Vectorial BSpline F(t)
1505   //! defined  by its  BSplineDegree and BSplineFlatKnotsl,
1506   //! its Poles  array which are coded as  an array of Real
1507   //! of  the  form  [1..NumPoles][1..PolesDimension] by  a
1508   //! function     a(t) which is   assumed to   satisfy the
1509   //! following  : 1. a(t)  * F(t)  is a polynomial BSpline
1510   //! that can be expressed  exactly as a BSpline of degree
1511   //! NewDegree on the knots FlatKnots 2. the range of a(t)
1512   //! is the same as the  range of F(t)
1513   //! Warning: it is
1514   //! the caller's responsibility to insure that conditions
1515   //! 1. and  2. above are  satisfied : no check whatsoever
1516   //! is made in this method
1517   //! theStatus will return 0 if OK else it will return the pivot index
1518   //! of the matrix that was inverted to compute the multiplied
1519   //! BSpline : the method used is interpolation at Schoenenberg
1520   //! points of a(t)*F(t)
1521   Standard_EXPORT static void FunctionMultiply(const BSplCLib_EvaluatorFunction& Function,
1522                                                const Standard_Integer            BSplineDegree,
1523                                                const TColStd_Array1OfReal&       BSplineFlatKnots,
1524                                                const Standard_Integer            PolesDimension,
1525                                                Standard_Real&                    Poles,
1526                                                const TColStd_Array1OfReal&       FlatKnots,
1527                                                const Standard_Integer            NewDegree,
1528                                                Standard_Real&                    NewPoles,
1529                                                Standard_Integer&                 theStatus);
1530 
1531   //! this will  multiply a given Vectorial BSpline F(t)
1532   //! defined  by its  BSplineDegree and BSplineFlatKnotsl,
1533   //! its Poles  array which are coded as  an array of Real
1534   //! of  the  form  [1..NumPoles][1..PolesDimension] by  a
1535   //! function     a(t) which is   assumed to   satisfy the
1536   //! following  : 1. a(t)  * F(t)  is a polynomial BSpline
1537   //! that can be expressed  exactly as a BSpline of degree
1538   //! NewDegree on the knots FlatKnots 2. the range of a(t)
1539   //! is the same as the  range of F(t)
1540   //! Warning: it is
1541   //! the caller's responsibility to insure that conditions
1542   //! 1. and  2. above are  satisfied : no check whatsoever
1543   //! is made in this method
1544   //! theStatus will return 0 if OK else it will return the pivot index
1545   //! of the matrix that was inverted to compute the multiplied
1546   //! BSpline : the method used is interpolation at Schoenenberg
1547   //! points of a(t)*F(t)
1548   Standard_EXPORT static void FunctionMultiply(const BSplCLib_EvaluatorFunction& Function,
1549                                                const Standard_Integer            BSplineDegree,
1550                                                const TColStd_Array1OfReal&       BSplineFlatKnots,
1551                                                const TColStd_Array1OfReal&       Poles,
1552                                                const TColStd_Array1OfReal&       FlatKnots,
1553                                                const Standard_Integer            NewDegree,
1554                                                TColStd_Array1OfReal&             NewPoles,
1555                                                Standard_Integer&                 theStatus);
1556 
1557   //! this will  multiply a given Vectorial BSpline F(t)
1558   //! defined  by its  BSplineDegree and BSplineFlatKnotsl,
1559   //! its Poles  array which are coded as  an array of Real
1560   //! of  the  form  [1..NumPoles][1..PolesDimension] by  a
1561   //! function     a(t) which is   assumed to   satisfy the
1562   //! following  : 1. a(t)  * F(t)  is a polynomial BSpline
1563   //! that can be expressed  exactly as a BSpline of degree
1564   //! NewDegree on the knots FlatKnots 2. the range of a(t)
1565   //! is the same as the  range of F(t)
1566   //! Warning: it is
1567   //! the caller's responsibility to insure that conditions
1568   //! 1. and  2. above are  satisfied : no check whatsoever
1569   //! is made in this method
1570   //! theStatus will return 0 if OK else it will return the pivot index
1571   //! of the matrix that was inverted to compute the multiplied
1572   //! BSpline : the method used is interpolation at Schoenenberg
1573   //! points of a(t)*F(t)
1574   Standard_EXPORT static void FunctionMultiply(const BSplCLib_EvaluatorFunction& Function,
1575                                                const Standard_Integer            BSplineDegree,
1576                                                const TColStd_Array1OfReal&       BSplineFlatKnots,
1577                                                const TColgp_Array1OfPnt2d&       Poles,
1578                                                const TColStd_Array1OfReal&       FlatKnots,
1579                                                const Standard_Integer            NewDegree,
1580                                                TColgp_Array1OfPnt2d&             NewPoles,
1581                                                Standard_Integer&                 theStatus);
1582 
1583   //! this will  multiply a given Vectorial BSpline F(t)
1584   //! defined  by its  BSplineDegree and BSplineFlatKnotsl,
1585   //! its Poles  array which are coded as  an array of Real
1586   //! of  the  form  [1..NumPoles][1..PolesDimension] by  a
1587   //! function     a(t) which is   assumed to   satisfy the
1588   //! following  : 1. a(t)  * F(t)  is a polynomial BSpline
1589   //! that can be expressed  exactly as a BSpline of degree
1590   //! NewDegree on the knots FlatKnots 2. the range of a(t)
1591   //! is the same as the  range of F(t)
1592   //! Warning: it is
1593   //! the caller's responsibility to insure that conditions
1594   //! 1. and  2. above are  satisfied : no check whatsoever
1595   //! is made in this method
1596   //! theStatus will return 0 if OK else it will return the pivot index
1597   //! of the matrix that was inverted to compute the multiplied
1598   //! BSpline : the method used is interpolation at Schoenenberg
1599   //! points of a(t)*F(t)
1600   Standard_EXPORT static void FunctionMultiply(const BSplCLib_EvaluatorFunction& Function,
1601                                                const Standard_Integer            BSplineDegree,
1602                                                const TColStd_Array1OfReal&       BSplineFlatKnots,
1603                                                const TColgp_Array1OfPnt&         Poles,
1604                                                const TColStd_Array1OfReal&       FlatKnots,
1605                                                const Standard_Integer            NewDegree,
1606                                                TColgp_Array1OfPnt&               NewPoles,
1607                                                Standard_Integer&                 theStatus);
1608 
1609   //! Perform the De Boor   algorithm  to  evaluate a point at
1610   //! parameter <U>, with <Degree> and <Dimension>.
1611   //!
1612   //! Poles is  an array of  Reals of size
1613   //!
1614   //! <Dimension> *  <Degree>+1
1615   //!
1616   //! Containing the  poles.  At  the end <Poles> contains
1617   //! the current point.   Poles Contain all  the poles of
1618   //! the BsplineCurve, Knots  also Contains all the knots
1619   //! of the BsplineCurve.  ExtrapMode has two slots [0] =
1620   //! Degree used to extrapolate before the first knot [1]
1621   //! = Degre used to  extrapolate after the last knot has
1622   //! to be between 1 and  Degree
1623   Standard_EXPORT static void Eval(const Standard_Real         U,
1624                                    const Standard_Boolean      PeriodicFlag,
1625                                    const Standard_Integer      DerivativeRequest,
1626                                    Standard_Integer&           ExtrapMode,
1627                                    const Standard_Integer      Degree,
1628                                    const TColStd_Array1OfReal& FlatKnots,
1629                                    const Standard_Integer      ArrayDimension,
1630                                    Standard_Real&              Poles,
1631                                    Standard_Real&              Result);
1632 
1633   //! Perform the  De Boor algorithm  to evaluate a point at
1634   //! parameter   <U>,  with   <Degree>    and  <Dimension>.
1635   //! Evaluates by multiplying the  Poles by the Weights and
1636   //! gives  the homogeneous  result  in PolesResult that is
1637   //! the results of the evaluation of the numerator once it
1638   //! has     been  multiplied   by  the     weights and  in
1639   //! WeightsResult one has  the result of the evaluation of
1640   //! the denominator
1641   //!
1642   //! Warning:   <PolesResult> and <WeightsResult>  must be   dimensioned
1643   //! properly.
1644   Standard_EXPORT static void Eval(const Standard_Real         U,
1645                                    const Standard_Boolean      PeriodicFlag,
1646                                    const Standard_Integer      DerivativeRequest,
1647                                    Standard_Integer&           ExtrapMode,
1648                                    const Standard_Integer      Degree,
1649                                    const TColStd_Array1OfReal& FlatKnots,
1650                                    const Standard_Integer      ArrayDimension,
1651                                    Standard_Real&              Poles,
1652                                    Standard_Real&              Weights,
1653                                    Standard_Real&              PolesResult,
1654                                    Standard_Real&              WeightsResult);
1655 
1656   //! Perform the evaluation of the Bspline Basis
1657   //! and then multiplies by the weights
1658   //! this just evaluates the current point
1659   Standard_EXPORT static void Eval(const Standard_Real         U,
1660                                    const Standard_Boolean      PeriodicFlag,
1661                                    const Standard_Boolean      HomogeneousFlag,
1662                                    Standard_Integer&           ExtrapMode,
1663                                    const Standard_Integer      Degree,
1664                                    const TColStd_Array1OfReal& FlatKnots,
1665                                    const TColgp_Array1OfPnt&   Poles,
1666                                    const TColStd_Array1OfReal& Weights,
1667                                    gp_Pnt&                     Point,
1668                                    Standard_Real&              Weight);
1669 
1670   //! Perform the evaluation of the Bspline Basis
1671   //! and then multiplies by the weights
1672   //! this just evaluates the current point
1673   Standard_EXPORT static void Eval(const Standard_Real         U,
1674                                    const Standard_Boolean      PeriodicFlag,
1675                                    const Standard_Boolean      HomogeneousFlag,
1676                                    Standard_Integer&           ExtrapMode,
1677                                    const Standard_Integer      Degree,
1678                                    const TColStd_Array1OfReal& FlatKnots,
1679                                    const TColgp_Array1OfPnt2d& Poles,
1680                                    const TColStd_Array1OfReal& Weights,
1681                                    gp_Pnt2d&                   Point,
1682                                    Standard_Real&              Weight);
1683 
1684   //! Extend a BSpline nD using the tangency map
1685   //! <C1Coefficient> is the coefficient of reparametrisation
1686   //! <Continuity> must be equal to 1, 2 or 3.
1687   //! <Degree> must be greater or equal than <Continuity> + 1.
1688   //!
1689   //! Warning:   <KnotsResult> and <PolesResult>  must be   dimensioned
1690   //! properly.
1691   Standard_EXPORT static void TangExtendToConstraint(const TColStd_Array1OfReal& FlatKnots,
1692                                                      const Standard_Real         C1Coefficient,
1693                                                      const Standard_Integer      NumPoles,
1694                                                      Standard_Real&              Poles,
1695                                                      const Standard_Integer      Dimension,
1696                                                      const Standard_Integer      Degree,
1697                                                      const TColStd_Array1OfReal& ConstraintPoint,
1698                                                      const Standard_Integer      Continuity,
1699                                                      const Standard_Boolean      After,
1700                                                      Standard_Integer&           NbPolesResult,
1701                                                      Standard_Integer&           NbKnotsRsult,
1702                                                      Standard_Real&              KnotsResult,
1703                                                      Standard_Real&              PolesResult);
1704 
1705   //! Perform the evaluation of the of the cache
1706   //! the parameter must be normalized between
1707   //! the 0 and 1 for the span.
1708   //! The Cache must be valid when calling this
1709   //! routine. Geom Package will insure that.
1710   //! and then multiplies by the weights
1711   //! this just evaluates the current point
1712   //! the CacheParameter is where the Cache was
1713   //! constructed the SpanLength is to normalize
1714   //! the polynomial in the cache to avoid bad conditioning
1715   //! effects
1716   Standard_EXPORT static void CacheD0(const Standard_Real         U,
1717                                       const Standard_Integer      Degree,
1718                                       const Standard_Real         CacheParameter,
1719                                       const Standard_Real         SpanLenght,
1720                                       const TColgp_Array1OfPnt&   Poles,
1721                                       const TColStd_Array1OfReal* Weights,
1722                                       gp_Pnt&                     Point);
1723 
1724   //! Perform the evaluation of the Bspline Basis
1725   //! and then multiplies by the weights
1726   //! this just evaluates the current point
1727   //! the parameter must be normalized between
1728   //! the 0 and 1 for the span.
1729   //! The Cache must be valid when calling this
1730   //! routine. Geom Package will insure that.
1731   //! and then multiplies by the weights
1732   //! ththe CacheParameter is where the Cache was
1733   //! constructed the SpanLength is to normalize
1734   //! the polynomial in the cache to avoid bad conditioning
1735   //! effectsis just evaluates the current point
1736   Standard_EXPORT static void CacheD0(const Standard_Real         U,
1737                                       const Standard_Integer      Degree,
1738                                       const Standard_Real         CacheParameter,
1739                                       const Standard_Real         SpanLenght,
1740                                       const TColgp_Array1OfPnt2d& Poles,
1741                                       const TColStd_Array1OfReal* Weights,
1742                                       gp_Pnt2d&                   Point);
1743 
1744   //! Calls CacheD0 for Bezier  Curves Arrays computed with
1745   //! the method PolesCoefficients.
1746   //! Warning: To be used for Beziercurves ONLY!!!
1747   static void CoefsD0(const Standard_Real         U,
1748                       const TColgp_Array1OfPnt&   Poles,
1749                       const TColStd_Array1OfReal* Weights,
1750                       gp_Pnt&                     Point);
1751 
1752   //! Calls CacheD0 for Bezier  Curves Arrays computed with
1753   //! the method PolesCoefficients.
1754   //! Warning: To be used for Beziercurves ONLY!!!
1755   static void CoefsD0(const Standard_Real         U,
1756                       const TColgp_Array1OfPnt2d& Poles,
1757                       const TColStd_Array1OfReal* Weights,
1758                       gp_Pnt2d&                   Point);
1759 
1760   //! Perform the evaluation of the of the cache
1761   //! the parameter must be normalized between
1762   //! the 0 and 1 for the span.
1763   //! The Cache must be valid when calling this
1764   //! routine. Geom Package will insure that.
1765   //! and then multiplies by the weights
1766   //! this just evaluates the current point
1767   //! the CacheParameter is where the Cache was
1768   //! constructed the SpanLength is to normalize
1769   //! the polynomial in the cache to avoid bad conditioning
1770   //! effects
1771   Standard_EXPORT static void CacheD1(const Standard_Real         U,
1772                                       const Standard_Integer      Degree,
1773                                       const Standard_Real         CacheParameter,
1774                                       const Standard_Real         SpanLenght,
1775                                       const TColgp_Array1OfPnt&   Poles,
1776                                       const TColStd_Array1OfReal* Weights,
1777                                       gp_Pnt&                     Point,
1778                                       gp_Vec&                     Vec);
1779 
1780   //! Perform the evaluation of the Bspline Basis
1781   //! and then multiplies by the weights
1782   //! this just evaluates the current point
1783   //! the parameter must be normalized between
1784   //! the 0 and 1 for the span.
1785   //! The Cache must be valid when calling this
1786   //! routine. Geom Package will insure that.
1787   //! and then multiplies by the weights
1788   //! ththe CacheParameter is where the Cache was
1789   //! constructed the SpanLength is to normalize
1790   //! the polynomial in the cache to avoid bad conditioning
1791   //! effectsis just evaluates the current point
1792   Standard_EXPORT static void CacheD1(const Standard_Real         U,
1793                                       const Standard_Integer      Degree,
1794                                       const Standard_Real         CacheParameter,
1795                                       const Standard_Real         SpanLenght,
1796                                       const TColgp_Array1OfPnt2d& Poles,
1797                                       const TColStd_Array1OfReal* Weights,
1798                                       gp_Pnt2d&                   Point,
1799                                       gp_Vec2d&                   Vec);
1800 
1801   //! Calls CacheD1 for Bezier  Curves Arrays computed with
1802   //! the method PolesCoefficients.
1803   //! Warning: To be used for Beziercurves ONLY!!!
1804   static void CoefsD1(const Standard_Real         U,
1805                       const TColgp_Array1OfPnt&   Poles,
1806                       const TColStd_Array1OfReal* Weights,
1807                       gp_Pnt&                     Point,
1808                       gp_Vec&                     Vec);
1809 
1810   //! Calls CacheD1 for Bezier  Curves Arrays computed with
1811   //! the method PolesCoefficients.
1812   //! Warning: To be used for Beziercurves ONLY!!!
1813   static void CoefsD1(const Standard_Real         U,
1814                       const TColgp_Array1OfPnt2d& Poles,
1815                       const TColStd_Array1OfReal* Weights,
1816                       gp_Pnt2d&                   Point,
1817                       gp_Vec2d&                   Vec);
1818 
1819   //! Perform the evaluation of the of the cache
1820   //! the parameter must be normalized between
1821   //! the 0 and 1 for the span.
1822   //! The Cache must be valid when calling this
1823   //! routine. Geom Package will insure that.
1824   //! and then multiplies by the weights
1825   //! this just evaluates the current point
1826   //! the CacheParameter is where the Cache was
1827   //! constructed the SpanLength is to normalize
1828   //! the polynomial in the cache to avoid bad conditioning
1829   //! effects
1830   Standard_EXPORT static void CacheD2(const Standard_Real         U,
1831                                       const Standard_Integer      Degree,
1832                                       const Standard_Real         CacheParameter,
1833                                       const Standard_Real         SpanLenght,
1834                                       const TColgp_Array1OfPnt&   Poles,
1835                                       const TColStd_Array1OfReal* Weights,
1836                                       gp_Pnt&                     Point,
1837                                       gp_Vec&                     Vec1,
1838                                       gp_Vec&                     Vec2);
1839 
1840   //! Perform the evaluation of the Bspline Basis
1841   //! and then multiplies by the weights
1842   //! this just evaluates the current point
1843   //! the parameter must be normalized between
1844   //! the 0 and 1 for the span.
1845   //! The Cache must be valid when calling this
1846   //! routine. Geom Package will insure that.
1847   //! and then multiplies by the weights
1848   //! ththe CacheParameter is where the Cache was
1849   //! constructed the SpanLength is to normalize
1850   //! the polynomial in the cache to avoid bad conditioning
1851   //! effectsis just evaluates the current point
1852   Standard_EXPORT static void CacheD2(const Standard_Real         U,
1853                                       const Standard_Integer      Degree,
1854                                       const Standard_Real         CacheParameter,
1855                                       const Standard_Real         SpanLenght,
1856                                       const TColgp_Array1OfPnt2d& Poles,
1857                                       const TColStd_Array1OfReal* Weights,
1858                                       gp_Pnt2d&                   Point,
1859                                       gp_Vec2d&                   Vec1,
1860                                       gp_Vec2d&                   Vec2);
1861 
1862   //! Calls CacheD1 for Bezier  Curves Arrays computed with
1863   //! the method PolesCoefficients.
1864   //! Warning: To be used for Beziercurves ONLY!!!
1865   static void CoefsD2(const Standard_Real         U,
1866                       const TColgp_Array1OfPnt&   Poles,
1867                       const TColStd_Array1OfReal* Weights,
1868                       gp_Pnt&                     Point,
1869                       gp_Vec&                     Vec1,
1870                       gp_Vec&                     Vec2);
1871 
1872   //! Calls CacheD1 for Bezier  Curves Arrays computed with
1873   //! the method PolesCoefficients.
1874   //! Warning: To be used for Beziercurves ONLY!!!
1875   static void CoefsD2(const Standard_Real         U,
1876                       const TColgp_Array1OfPnt2d& Poles,
1877                       const TColStd_Array1OfReal* Weights,
1878                       gp_Pnt2d&                   Point,
1879                       gp_Vec2d&                   Vec1,
1880                       gp_Vec2d&                   Vec2);
1881 
1882   //! Perform the evaluation of the of the cache
1883   //! the parameter must be normalized between
1884   //! the 0 and 1 for the span.
1885   //! The Cache must be valid when calling this
1886   //! routine. Geom Package will insure that.
1887   //! and then multiplies by the weights
1888   //! this just evaluates the current point
1889   //! the CacheParameter is where the Cache was
1890   //! constructed the SpanLength is to normalize
1891   //! the polynomial in the cache to avoid bad conditioning
1892   //! effects
1893   Standard_EXPORT static void CacheD3(const Standard_Real         U,
1894                                       const Standard_Integer      Degree,
1895                                       const Standard_Real         CacheParameter,
1896                                       const Standard_Real         SpanLenght,
1897                                       const TColgp_Array1OfPnt&   Poles,
1898                                       const TColStd_Array1OfReal* Weights,
1899                                       gp_Pnt&                     Point,
1900                                       gp_Vec&                     Vec1,
1901                                       gp_Vec&                     Vec2,
1902                                       gp_Vec&                     Vec3);
1903 
1904   //! Perform the evaluation of the Bspline Basis
1905   //! and then multiplies by the weights
1906   //! this just evaluates the current point
1907   //! the parameter must be normalized between
1908   //! the 0 and 1 for the span.
1909   //! The Cache must be valid when calling this
1910   //! routine. Geom Package will insure that.
1911   //! and then multiplies by the weights
1912   //! ththe CacheParameter is where the Cache was
1913   //! constructed the SpanLength is to normalize
1914   //! the polynomial in the cache to avoid bad conditioning
1915   //! effectsis just evaluates the current point
1916   Standard_EXPORT static void CacheD3(const Standard_Real         U,
1917                                       const Standard_Integer      Degree,
1918                                       const Standard_Real         CacheParameter,
1919                                       const Standard_Real         SpanLenght,
1920                                       const TColgp_Array1OfPnt2d& Poles,
1921                                       const TColStd_Array1OfReal* Weights,
1922                                       gp_Pnt2d&                   Point,
1923                                       gp_Vec2d&                   Vec1,
1924                                       gp_Vec2d&                   Vec2,
1925                                       gp_Vec2d&                   Vec3);
1926 
1927   //! Calls CacheD1 for Bezier  Curves Arrays computed with
1928   //! the method PolesCoefficients.
1929   //! Warning: To be used for Beziercurves ONLY!!!
1930   static void CoefsD3(const Standard_Real         U,
1931                       const TColgp_Array1OfPnt&   Poles,
1932                       const TColStd_Array1OfReal* Weights,
1933                       gp_Pnt&                     Point,
1934                       gp_Vec&                     Vec1,
1935                       gp_Vec&                     Vec2,
1936                       gp_Vec&                     Vec3);
1937 
1938   //! Calls CacheD1 for Bezier  Curves Arrays computed with
1939   //! the method PolesCoefficients.
1940   //! Warning: To be used for Beziercurves ONLY!!!
1941   static void CoefsD3(const Standard_Real         U,
1942                       const TColgp_Array1OfPnt2d& Poles,
1943                       const TColStd_Array1OfReal* Weights,
1944                       gp_Pnt2d&                   Point,
1945                       gp_Vec2d&                   Vec1,
1946                       gp_Vec2d&                   Vec2,
1947                       gp_Vec2d&                   Vec3);
1948 
1949   //! Perform the evaluation of the Taylor expansion
1950   //! of the Bspline normalized between 0 and 1.
1951   //! If rational computes the homogeneous Taylor expansion
1952   //! for the numerator and stores it in CachePoles
1953   Standard_EXPORT static void BuildCache(const Standard_Real         U,
1954                                          const Standard_Real         InverseOfSpanDomain,
1955                                          const Standard_Boolean      PeriodicFlag,
1956                                          const Standard_Integer      Degree,
1957                                          const TColStd_Array1OfReal& FlatKnots,
1958                                          const TColgp_Array1OfPnt&   Poles,
1959                                          const TColStd_Array1OfReal* Weights,
1960                                          TColgp_Array1OfPnt&         CachePoles,
1961                                          TColStd_Array1OfReal*       CacheWeights);
1962 
1963   //! Perform the evaluation of the Taylor expansion
1964   //! of the Bspline normalized between 0 and 1.
1965   //! If rational computes the homogeneous Taylor expansion
1966   //! for the numerator and stores it in CachePoles
1967   Standard_EXPORT static void BuildCache(const Standard_Real         U,
1968                                          const Standard_Real         InverseOfSpanDomain,
1969                                          const Standard_Boolean      PeriodicFlag,
1970                                          const Standard_Integer      Degree,
1971                                          const TColStd_Array1OfReal& FlatKnots,
1972                                          const TColgp_Array1OfPnt2d& Poles,
1973                                          const TColStd_Array1OfReal* Weights,
1974                                          TColgp_Array1OfPnt2d&       CachePoles,
1975                                          TColStd_Array1OfReal*       CacheWeights);
1976 
1977   //! Perform the evaluation of the Taylor expansion
1978   //! of the Bspline normalized between 0 and 1.
1979   //! Structure of result optimized for BSplCLib_Cache.
1980   Standard_EXPORT static void BuildCache(const Standard_Real         theParameter,
1981                                          const Standard_Real         theSpanDomain,
1982                                          const Standard_Boolean      thePeriodicFlag,
1983                                          const Standard_Integer      theDegree,
1984                                          const Standard_Integer      theSpanIndex,
1985                                          const TColStd_Array1OfReal& theFlatKnots,
1986                                          const TColgp_Array1OfPnt&   thePoles,
1987                                          const TColStd_Array1OfReal* theWeights,
1988                                          TColStd_Array2OfReal&       theCacheArray);
1989 
1990   //! Perform the evaluation of the Taylor expansion
1991   //! of the Bspline normalized between 0 and 1.
1992   //! Structure of result optimized for BSplCLib_Cache.
1993   Standard_EXPORT static void BuildCache(const Standard_Real         theParameter,
1994                                          const Standard_Real         theSpanDomain,
1995                                          const Standard_Boolean      thePeriodicFlag,
1996                                          const Standard_Integer      theDegree,
1997                                          const Standard_Integer      theSpanIndex,
1998                                          const TColStd_Array1OfReal& theFlatKnots,
1999                                          const TColgp_Array1OfPnt2d& thePoles,
2000                                          const TColStd_Array1OfReal* theWeights,
2001                                          TColStd_Array2OfReal&       theCacheArray);
2002 
2003   static void PolesCoefficients(const TColgp_Array1OfPnt2d& Poles,
2004                                 TColgp_Array1OfPnt2d&       CachePoles);
2005 
2006   Standard_EXPORT static void PolesCoefficients(const TColgp_Array1OfPnt2d& Poles,
2007                                                 const TColStd_Array1OfReal* Weights,
2008                                                 TColgp_Array1OfPnt2d&       CachePoles,
2009                                                 TColStd_Array1OfReal*       CacheWeights);
2010 
2011   static void PolesCoefficients(const TColgp_Array1OfPnt& Poles, TColgp_Array1OfPnt& CachePoles);
2012 
2013   //! Encapsulation   of  BuildCache    to   perform   the
2014   //! evaluation  of the Taylor expansion for beziercurves
2015   //! at parameter 0.
2016   //! Warning: To be used for Beziercurves ONLY!!!
2017   Standard_EXPORT static void PolesCoefficients(const TColgp_Array1OfPnt&   Poles,
2018                                                 const TColStd_Array1OfReal* Weights,
2019                                                 TColgp_Array1OfPnt&         CachePoles,
2020                                                 TColStd_Array1OfReal*       CacheWeights);
2021 
2022   //! Returns pointer to statically allocated array representing
2023   //! flat knots for bezier curve of the specified degree.
2024   //! Raises OutOfRange if Degree > MaxDegree()
2025   Standard_EXPORT static const Standard_Real& FlatBezierKnots(const Standard_Integer Degree);
2026 
2027   //! builds the Schoenberg points from the flat knot
2028   //! used to interpolate a BSpline since the
2029   //! BSpline matrix is invertible.
2030   Standard_EXPORT static void BuildSchoenbergPoints(const Standard_Integer      Degree,
2031                                                     const TColStd_Array1OfReal& FlatKnots,
2032                                                     TColStd_Array1OfReal&       Parameters);
2033 
2034   //! Performs the interpolation of  the data given in
2035   //! the Poles  array  according  to the  requests in
2036   //! ContactOrderArray    that is      :           if
2037   //! ContactOrderArray(i) has value  d it means  that
2038   //! Poles(i)   contains the dth  derivative of  the
2039   //! function to be interpolated. The length L of the
2040   //! following arrays must be the same :
2041   //! Parameters, ContactOrderArray, Poles,
2042   //! The length of FlatKnots is Degree + L + 1
2043   //! Warning:
2044   //! the method used to do that interpolation is
2045   //! gauss elimination WITHOUT pivoting. Thus if the
2046   //! diagonal is not dominant there is no guarantee
2047   //! that the algorithm will work. Nevertheless for
2048   //! Cubic interpolation or interpolation at Scheonberg
2049   //! points the method will work
2050   //! The InversionProblem will report 0 if there was no
2051   //! problem else it will give the index of the faulty
2052   //! pivot
2053   Standard_EXPORT static void Interpolate(const Standard_Integer         Degree,
2054                                           const TColStd_Array1OfReal&    FlatKnots,
2055                                           const TColStd_Array1OfReal&    Parameters,
2056                                           const TColStd_Array1OfInteger& ContactOrderArray,
2057                                           TColgp_Array1OfPnt&            Poles,
2058                                           Standard_Integer&              InversionProblem);
2059 
2060   //! Performs the interpolation of  the data given in
2061   //! the Poles  array  according  to the  requests in
2062   //! ContactOrderArray    that is      :           if
2063   //! ContactOrderArray(i) has value  d it means  that
2064   //! Poles(i)   contains the dth  derivative of  the
2065   //! function to be interpolated. The length L of the
2066   //! following arrays must be the same :
2067   //! Parameters, ContactOrderArray, Poles,
2068   //! The length of FlatKnots is Degree + L + 1
2069   //! Warning:
2070   //! the method used to do that interpolation is
2071   //! gauss elimination WITHOUT pivoting. Thus if the
2072   //! diagonal is not dominant there is no guarantee
2073   //! that the algorithm will work. Nevertheless for
2074   //! Cubic interpolation at knots or interpolation at Scheonberg
2075   //! points the method will work.
2076   //! The InversionProblem w
2077   //! ll report 0 if there was no
2078   //! problem else it will give the index of the faulty
2079   //! pivot
2080   Standard_EXPORT static void Interpolate(const Standard_Integer         Degree,
2081                                           const TColStd_Array1OfReal&    FlatKnots,
2082                                           const TColStd_Array1OfReal&    Parameters,
2083                                           const TColStd_Array1OfInteger& ContactOrderArray,
2084                                           TColgp_Array1OfPnt2d&          Poles,
2085                                           Standard_Integer&              InversionProblem);
2086 
2087   //! Performs the interpolation of  the data given in
2088   //! the Poles  array  according  to the  requests in
2089   //! ContactOrderArray    that is      :           if
2090   //! ContactOrderArray(i) has value  d it means  that
2091   //! Poles(i)   contains the dth  derivative of  the
2092   //! function to be interpolated. The length L of the
2093   //! following arrays must be the same :
2094   //! Parameters, ContactOrderArray, Poles,
2095   //! The length of FlatKnots is Degree + L + 1
2096   //! Warning:
2097   //! the method used to do that interpolation is
2098   //! gauss elimination WITHOUT pivoting. Thus if the
2099   //! diagonal is not dominant there is no guarantee
2100   //! that the algorithm will work. Nevertheless for
2101   //! Cubic interpolation at knots or interpolation at Scheonberg
2102   //! points the method will work.
2103   //! The InversionProblem will report 0 if there was no
2104   //! problem else it will give the index of the faulty
2105   //! pivot
2106   Standard_EXPORT static void Interpolate(const Standard_Integer         Degree,
2107                                           const TColStd_Array1OfReal&    FlatKnots,
2108                                           const TColStd_Array1OfReal&    Parameters,
2109                                           const TColStd_Array1OfInteger& ContactOrderArray,
2110                                           TColgp_Array1OfPnt&            Poles,
2111                                           TColStd_Array1OfReal&          Weights,
2112                                           Standard_Integer&              InversionProblem);
2113 
2114   //! Performs the interpolation of  the data given in
2115   //! the Poles  array  according  to the  requests in
2116   //! ContactOrderArray    that is      :           if
2117   //! ContactOrderArray(i) has value  d it means  that
2118   //! Poles(i)   contains the dth  derivative of  the
2119   //! function to be interpolated. The length L of the
2120   //! following arrays must be the same :
2121   //! Parameters, ContactOrderArray, Poles,
2122   //! The length of FlatKnots is Degree + L + 1
2123   //! Warning:
2124   //! the method used to do that interpolation is
2125   //! gauss elimination WITHOUT pivoting. Thus if the
2126   //! diagonal is not dominant there is no guarantee
2127   //! that the algorithm will work. Nevertheless for
2128   //! Cubic interpolation at knots or interpolation at Scheonberg
2129   //! points the method will work.
2130   //! The InversionProblem w
2131   //! ll report 0 if there was no
2132   //! problem else it will give the i
2133   Standard_EXPORT static void Interpolate(const Standard_Integer         Degree,
2134                                           const TColStd_Array1OfReal&    FlatKnots,
2135                                           const TColStd_Array1OfReal&    Parameters,
2136                                           const TColStd_Array1OfInteger& ContactOrderArray,
2137                                           TColgp_Array1OfPnt2d&          Poles,
2138                                           TColStd_Array1OfReal&          Weights,
2139                                           Standard_Integer&              InversionProblem);
2140 
2141   //! Performs the interpolation of  the data given in
2142   //! the Poles  array  according  to the  requests in
2143   //! ContactOrderArray    that is      :           if
2144   //! ContactOrderArray(i) has value  d it means  that
2145   //! Poles(i)   contains the dth  derivative of  the
2146   //! function to be interpolated. The length L of the
2147   //! following arrays must be the same :
2148   //! Parameters, ContactOrderArray
2149   //! The length of FlatKnots is Degree + L + 1
2150   //! The  PolesArray   is    an   seen   as    an
2151   //! Array[1..N][1..ArrayDimension] with N = tge length
2152   //! of the parameters array
2153   //! Warning:
2154   //! the method used to do that interpolation is
2155   //! gauss elimination WITHOUT pivoting. Thus if the
2156   //! diagonal is not dominant there is no guarantee
2157   //! that the algorithm will work. Nevertheless for
2158   //! Cubic interpolation or interpolation at Scheonberg
2159   //! points the method will work
2160   //! The InversionProblem will report 0 if there was no
2161   //! problem else it will give the index of the faulty
2162   //! pivot
2163   Standard_EXPORT static void Interpolate(const Standard_Integer         Degree,
2164                                           const TColStd_Array1OfReal&    FlatKnots,
2165                                           const TColStd_Array1OfReal&    Parameters,
2166                                           const TColStd_Array1OfInteger& ContactOrderArray,
2167                                           const Standard_Integer         ArrayDimension,
2168                                           Standard_Real&                 Poles,
2169                                           Standard_Integer&              InversionProblem);
2170 
2171   Standard_EXPORT static void Interpolate(const Standard_Integer         Degree,
2172                                           const TColStd_Array1OfReal&    FlatKnots,
2173                                           const TColStd_Array1OfReal&    Parameters,
2174                                           const TColStd_Array1OfInteger& ContactOrderArray,
2175                                           const Standard_Integer         ArrayDimension,
2176                                           Standard_Real&                 Poles,
2177                                           Standard_Real&                 Weights,
2178                                           Standard_Integer&              InversionProblem);
2179 
2180   //! Find the new poles which allows  an old point (with a
2181   //! given  u as parameter) to reach a new position
2182   //! Index1 and Index2 indicate the range of poles we can move
2183   //! (1, NbPoles-1) or (2, NbPoles) -> no constraint for one side
2184   //! don't enter (1,NbPoles) -> error: rigid move
2185   //! (2, NbPoles-1) -> the ends are enforced
2186   //! (3, NbPoles-2) -> the ends and the tangency are enforced
2187   //! if Problem in BSplineBasis calculation, no change for the curve
2188   //! and FirstIndex, LastIndex = 0
2189   Standard_EXPORT static void MovePoint(const Standard_Real         U,
2190                                         const gp_Vec2d&             Displ,
2191                                         const Standard_Integer      Index1,
2192                                         const Standard_Integer      Index2,
2193                                         const Standard_Integer      Degree,
2194                                         const TColgp_Array1OfPnt2d& Poles,
2195                                         const TColStd_Array1OfReal* Weights,
2196                                         const TColStd_Array1OfReal& FlatKnots,
2197                                         Standard_Integer&           FirstIndex,
2198                                         Standard_Integer&           LastIndex,
2199                                         TColgp_Array1OfPnt2d&       NewPoles);
2200 
2201   //! Find the new poles which allows  an old point (with a
2202   //! given  u as parameter) to reach a new position
2203   //! Index1 and Index2 indicate the range of poles we can move
2204   //! (1, NbPoles-1) or (2, NbPoles) -> no constraint for one side
2205   //! don't enter (1,NbPoles) -> error: rigid move
2206   //! (2, NbPoles-1) -> the ends are enforced
2207   //! (3, NbPoles-2) -> the ends and the tangency are enforced
2208   //! if Problem in BSplineBasis calculation, no change for the curve
2209   //! and FirstIndex, LastIndex = 0
2210   Standard_EXPORT static void MovePoint(const Standard_Real         U,
2211                                         const gp_Vec&               Displ,
2212                                         const Standard_Integer      Index1,
2213                                         const Standard_Integer      Index2,
2214                                         const Standard_Integer      Degree,
2215                                         const TColgp_Array1OfPnt&   Poles,
2216                                         const TColStd_Array1OfReal* Weights,
2217                                         const TColStd_Array1OfReal& FlatKnots,
2218                                         Standard_Integer&           FirstIndex,
2219                                         Standard_Integer&           LastIndex,
2220                                         TColgp_Array1OfPnt&         NewPoles);
2221 
2222   //! This is the dimension free version of the utility
2223   //! U is the parameter  must be within the  first FlatKnots and the
2224   //! last FlatKnots  Delta is the amount the  curve has  to be moved
2225   //! DeltaDerivative is the  amount the derivative  has to be moved.
2226   //! Delta  and   DeltaDerivative   must be    array   of  dimension
2227   //! ArrayDimension  Degree  is the degree  of   the BSpline and the
2228   //! FlatKnots are the knots of the BSpline  Starting Condition if =
2229   //! -1 means the starting point of the curve can move
2230   //! = 0 means the
2231   //! starting  point  of the curve  cannot  move but  tangent  starting
2232   //! point of the curve cannot move
2233   //! = 1 means the starting point and tangents cannot move
2234   //! = 2 means the starting point tangent and curvature cannot move
2235   //! = ...
2236   //! Same holds for EndingCondition
2237   //! Poles are the poles of the curve
2238   //! Weights are the weights of the curve if not NULL
2239   //! NewPoles are the poles of the deformed curve
2240   //! ErrorStatus will be 0 if no error happened
2241   //! 1 if there are not enough knots/poles
2242   //! the imposed conditions
2243   //! The way to solve this problem is to add knots to the BSpline
2244   //! If StartCondition = 1 and EndCondition = 1 then you need at least
2245   //! 4 + 2 = 6 poles so for example to have a C1 cubic you will need
2246   //! have at least 2 internal knots.
2247   Standard_EXPORT static void MovePointAndTangent(const Standard_Real         U,
2248                                                   const Standard_Integer      ArrayDimension,
2249                                                   Standard_Real&              Delta,
2250                                                   Standard_Real&              DeltaDerivative,
2251                                                   const Standard_Real         Tolerance,
2252                                                   const Standard_Integer      Degree,
2253                                                   const Standard_Integer      StartingCondition,
2254                                                   const Standard_Integer      EndingCondition,
2255                                                   Standard_Real&              Poles,
2256                                                   const TColStd_Array1OfReal* Weights,
2257                                                   const TColStd_Array1OfReal& FlatKnots,
2258                                                   Standard_Real&              NewPoles,
2259                                                   Standard_Integer&           ErrorStatus);
2260 
2261   //! This is the dimension free version of the utility
2262   //! U is the parameter  must be within the  first FlatKnots and the
2263   //! last FlatKnots  Delta is the amount the  curve has  to be moved
2264   //! DeltaDerivative is the  amount the derivative  has to be moved.
2265   //! Delta  and   DeltaDerivative   must be    array   of  dimension
2266   //! ArrayDimension  Degree  is the degree  of   the BSpline and the
2267   //! FlatKnots are the knots of the BSpline  Starting Condition if =
2268   //! -1 means the starting point of the curve can move
2269   //! = 0 means the
2270   //! starting  point  of the curve  cannot  move but  tangent  starting
2271   //! point of the curve cannot move
2272   //! = 1 means the starting point and tangents cannot move
2273   //! = 2 means the starting point tangent and curvature cannot move
2274   //! = ...
2275   //! Same holds for EndingCondition
2276   //! Poles are the poles of the curve
2277   //! Weights are the weights of the curve if not NULL
2278   //! NewPoles are the poles of the deformed curve
2279   //! ErrorStatus will be 0 if no error happened
2280   //! 1 if there are not enough knots/poles
2281   //! the imposed conditions
2282   //! The way to solve this problem is to add knots to the BSpline
2283   //! If StartCondition = 1 and EndCondition = 1 then you need at least
2284   //! 4 + 2 = 6 poles so for example to have a C1 cubic you will need
2285   //! have at least 2 internal knots.
2286   Standard_EXPORT static void MovePointAndTangent(const Standard_Real         U,
2287                                                   const gp_Vec&               Delta,
2288                                                   const gp_Vec&               DeltaDerivative,
2289                                                   const Standard_Real         Tolerance,
2290                                                   const Standard_Integer      Degree,
2291                                                   const Standard_Integer      StartingCondition,
2292                                                   const Standard_Integer      EndingCondition,
2293                                                   const TColgp_Array1OfPnt&   Poles,
2294                                                   const TColStd_Array1OfReal* Weights,
2295                                                   const TColStd_Array1OfReal& FlatKnots,
2296                                                   TColgp_Array1OfPnt&         NewPoles,
2297                                                   Standard_Integer&           ErrorStatus);
2298 
2299   //! This is the dimension free version of the utility
2300   //! U is the parameter  must be within the  first FlatKnots and the
2301   //! last FlatKnots  Delta is the amount the  curve has  to be moved
2302   //! DeltaDerivative is the  amount the derivative  has to be moved.
2303   //! Delta  and   DeltaDerivative   must be    array   of  dimension
2304   //! ArrayDimension  Degree  is the degree  of   the BSpline and the
2305   //! FlatKnots are the knots of the BSpline  Starting Condition if =
2306   //! -1 means the starting point of the curve can move
2307   //! = 0 means the
2308   //! starting  point  of the curve  cannot  move but  tangent  starting
2309   //! point of the curve cannot move
2310   //! = 1 means the starting point and tangents cannot move
2311   //! = 2 means the starting point tangent and curvature cannot move
2312   //! = ...
2313   //! Same holds for EndingCondition
2314   //! Poles are the poles of the curve
2315   //! Weights are the weights of the curve if not NULL
2316   //! NewPoles are the poles of the deformed curve
2317   //! ErrorStatus will be 0 if no error happened
2318   //! 1 if there are not enough knots/poles
2319   //! the imposed conditions
2320   //! The way to solve this problem is to add knots to the BSpline
2321   //! If StartCondition = 1 and EndCondition = 1 then you need at least
2322   //! 4 + 2 = 6 poles so for example to have a C1 cubic you will need
2323   //! have at least 2 internal knots.
2324   Standard_EXPORT static void MovePointAndTangent(const Standard_Real         U,
2325                                                   const gp_Vec2d&             Delta,
2326                                                   const gp_Vec2d&             DeltaDerivative,
2327                                                   const Standard_Real         Tolerance,
2328                                                   const Standard_Integer      Degree,
2329                                                   const Standard_Integer      StartingCondition,
2330                                                   const Standard_Integer      EndingCondition,
2331                                                   const TColgp_Array1OfPnt2d& Poles,
2332                                                   const TColStd_Array1OfReal* Weights,
2333                                                   const TColStd_Array1OfReal& FlatKnots,
2334                                                   TColgp_Array1OfPnt2d&       NewPoles,
2335                                                   Standard_Integer&           ErrorStatus);
2336 
2337   //! given a tolerance in 3D space returns a
2338   //! tolerance    in U parameter space such that
2339   //! all u1 and u0 in the domain of the curve f(u)
2340   //! | u1 - u0 | < UTolerance and
2341   //! we have |f (u1) - f (u0)| < Tolerance3D
2342   Standard_EXPORT static void Resolution(Standard_Real&              PolesArray,
2343                                          const Standard_Integer      ArrayDimension,
2344                                          const Standard_Integer      NumPoles,
2345                                          const TColStd_Array1OfReal* Weights,
2346                                          const TColStd_Array1OfReal& FlatKnots,
2347                                          const Standard_Integer      Degree,
2348                                          const Standard_Real         Tolerance3D,
2349                                          Standard_Real&              UTolerance);
2350 
2351   //! given a tolerance in 3D space returns a
2352   //! tolerance    in U parameter space such that
2353   //! all u1 and u0 in the domain of the curve f(u)
2354   //! | u1 - u0 | < UTolerance and
2355   //! we have |f (u1) - f (u0)| < Tolerance3D
2356   Standard_EXPORT static void Resolution(const TColgp_Array1OfPnt&   Poles,
2357                                          const TColStd_Array1OfReal* Weights,
2358                                          const Standard_Integer      NumPoles,
2359                                          const TColStd_Array1OfReal& FlatKnots,
2360                                          const Standard_Integer      Degree,
2361                                          const Standard_Real         Tolerance3D,
2362                                          Standard_Real&              UTolerance);
2363 
2364   //! given a tolerance in 3D space returns a
2365   //! tolerance    in U parameter space such that
2366   //! all u1 and u0 in the domain of the curve f(u)
2367   //! | u1 - u0 | < UTolerance and
2368   //! we have |f (u1) - f (u0)| < Tolerance3D
2369   Standard_EXPORT static void Resolution(const TColgp_Array1OfPnt2d& Poles,
2370                                          const TColStd_Array1OfReal* Weights,
2371                                          const Standard_Integer      NumPoles,
2372                                          const TColStd_Array1OfReal& FlatKnots,
2373                                          const Standard_Integer      Degree,
2374                                          const Standard_Real         Tolerance3D,
2375                                          Standard_Real&              UTolerance);
2376 
2377   //! Splits the given range to BSpline intervals of given continuity
2378   //! @param[in] theKnots the knots of BSpline
2379   //! @param[in] theMults the knots' multiplicities
2380   //! @param[in] theDegree the degree of BSpline
2381   //! @param[in] isPeriodic the periodicity of BSpline
2382   //! @param[in] theContinuity the target interval's continuity
2383   //! @param[in] theFirst the begin of the target range
2384   //! @param[in] theLast the end of the target range
2385   //! @param[in] theTolerance the tolerance
2386   //! @param[in,out] theIntervals the array to store intervals if isn't nullptr
2387   //! @return the number of intervals
2388   Standard_EXPORT static Standard_Integer Intervals(const TColStd_Array1OfReal&    theKnots,
2389                                                     const TColStd_Array1OfInteger& theMults,
2390                                                     Standard_Integer               theDegree,
2391                                                     Standard_Boolean               isPeriodic,
2392                                                     Standard_Integer               theContinuity,
2393                                                     Standard_Real                  theFirst,
2394                                                     Standard_Real                  theLast,
2395                                                     Standard_Real                  theTolerance,
2396                                                     TColStd_Array1OfReal*          theIntervals);
2397 
2398 protected:
2399 private:
2400   Standard_EXPORT static void LocateParameter(const TColStd_Array1OfReal& Knots,
2401                                               const Standard_Real         U,
2402                                               const Standard_Boolean      Periodic,
2403                                               const Standard_Integer      K1,
2404                                               const Standard_Integer      K2,
2405                                               Standard_Integer&           Index,
2406                                               Standard_Real&              NewU,
2407                                               const Standard_Real         Uf,
2408                                               const Standard_Real         Ue);
2409 };
2410 
2411 #include <BSplCLib.lxx>
2412 
2413 #endif // _BSplCLib_HeaderFile