Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 09:15:08

0001 // Created on: 1991-08-26
0002 // Created by: JCV
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 _BSplSLib_HeaderFile
0018 #define _BSplSLib_HeaderFile
0019 
0020 #include <BSplSLib_EvaluatorFunction.hxx>
0021 #include <Standard.hxx>
0022 #include <Standard_DefineAlloc.hxx>
0023 #include <TColgp_Array1OfPnt.hxx>
0024 #include <TColgp_Array2OfPnt.hxx>
0025 #include <TColStd_Array1OfInteger.hxx>
0026 #include <TColStd_Array1OfReal.hxx>
0027 #include <TColStd_Array2OfReal.hxx>
0028 
0029 class gp_Pnt;
0030 class gp_Vec;
0031 
0032 //! BSplSLib   B-spline surface Library
0033 //! This  package provides   an  implementation  of  geometric
0034 //! functions for rational and non rational, periodic  and non
0035 //! periodic B-spline surface computation.
0036 //!
0037 //! this package uses   the  multi-dimensions splines  methods
0038 //! provided in the package BSplCLib.
0039 //!
0040 //! In this package the B-spline surface is defined with :
0041 //! . its control points :  Array2OfPnt     Poles
0042 //! . its weights        :  Array2OfReal    Weights
0043 //! . its knots and their multiplicity in the two parametric
0044 //! direction U and V  :  Array1OfReal    UKnots, VKnots and
0045 //! Array1OfInteger UMults, VMults.
0046 //! . the degree of the normalized Spline functions :
0047 //! UDegree, VDegree
0048 //!
0049 //! . the Booleans URational, VRational to know if the weights
0050 //! are constant in the U or V direction.
0051 //!
0052 //! . the Booleans UPeriodic,   VRational  to know if the  the
0053 //! surface is periodic in the U or V direction.
0054 //!
0055 //! Warnings : The  bounds of UKnots  and UMults should be the
0056 //! same, the bounds of VKnots and VMults should be  the same,
0057 //! the bounds of Poles and Weights should be the same.
0058 //!
0059 //! The Control points representation is :
0060 //! Poles(Uorigin,Vorigin) ...................Poles(Uorigin,Vend)
0061 //! .                                     .
0062 //! .                                     .
0063 //! Poles(Uend, Vorigin) .....................Poles(Uend, Vend)
0064 //!
0065 //! For  the double array  the row indice   corresponds to the
0066 //! parametric U direction  and the columns indice corresponds
0067 //! to the parametric V direction.
0068 //!
0069 //! Note: weight and multiplicity arrays can be passed by pointer for
0070 //! some functions so that NULL pointer is valid.
0071 //! That means no weights/no multiplicities passed.
0072 //!
0073 //! KeyWords :
0074 //! B-spline surface, Functions, Library
0075 //!
0076 //! References :
0077 //! . A survey of curve and surface methods in CADG Wolfgang BOHM
0078 //! CAGD 1 (1984)
0079 //! . On de Boor-like algorithms and blossoming Wolfgang BOEHM
0080 //! cagd 5 (1988)
0081 //! . Blossoming and knot insertion algorithms for B-spline curves
0082 //! Ronald N. GOLDMAN
0083 //! . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA
0084 //! . Curves and Surfaces for Computer Aided Geometric Design,
0085 //! a practical guide Gerald Farin
0086 class BSplSLib
0087 {
0088 public:
0089   DEFINE_STANDARD_ALLOC
0090 
0091   //! this is a one dimensional function
0092   //! typedef  void (*EvaluatorFunction)  (
0093   //! Standard_Integer     // Derivative Request
0094   //! Standard_Real    *   // StartEnd[2][2]
0095   //! //  [0] = U
0096   //! //  [1] = V
0097   //! //        [0] = start
0098   //! //        [1] = end
0099   //! Standard_Real        // UParameter
0100   //! Standard_Real        // VParamerer
0101   //! Standard_Real    &   // Result
0102   //! Standard_Integer &) ;// Error Code
0103   //! serves to multiply a given vectorial BSpline by a function
0104   //! Computes  the     derivatives   of  a    ratio  of
0105   //! two-variables functions  x(u,v) / w(u,v) at orders
0106   //! <N,M>,    x(u,v)    is   a  vector in    dimension
0107   //! <3>.
0108   //!
0109   //! <Ders> is  an array  containing the values  of the
0110   //! input derivatives from 0  to Min(<N>,<UDeg>), 0 to
0111   //! Min(<M>,<VDeg>).    For orders    higher      than
0112   //! <UDeg,VDeg>  the  input derivatives are assumed to
0113   //! be 0.
0114   //!
0115   //! The <Ders> is a 2d array and the  dimension of the
0116   //! lines is always (<VDeg>+1) * (<3>+1), even
0117   //! if   <N> is smaller  than  <Udeg> (the derivatives
0118   //! higher than <N> are not used).
0119   //!
0120   //! Content of <Ders> :
0121   //!
0122   //! x(i,j)[k] means :  the composant  k of x derivated
0123   //! (i) times in u and (j) times in v.
0124   //!
0125   //! ... First line ...
0126   //!
0127   //! x[1],x[2],...,x[3],w
0128   //! x(0,1)[1],...,x(0,1)[3],w(1,0)
0129   //! ...
0130   //! x(0,VDeg)[1],...,x(0,VDeg)[3],w(0,VDeg)
0131   //!
0132   //! ... Then second line ...
0133   //!
0134   //! x(1,0)[1],...,x(1,0)[3],w(1,0)
0135   //! x(1,1)[1],...,x(1,1)[3],w(1,1)
0136   //! ...
0137   //! x(1,VDeg)[1],...,x(1,VDeg)[3],w(1,VDeg)
0138   //!
0139   //! ...
0140   //!
0141   //! ... Last line ...
0142   //!
0143   //! x(UDeg,0)[1],...,x(UDeg,0)[3],w(UDeg,0)
0144   //! x(UDeg,1)[1],...,x(UDeg,1)[3],w(UDeg,1)
0145   //! ...
0146   //! x(Udeg,VDeg)[1],...,x(UDeg,VDeg)[3],w(Udeg,VDeg)
0147   //!
0148   //! If <All>  is false, only  the derivative  at order
0149   //! <N,M> is computed.  <RDers> is an  array of length
0150   //! 3 which will contain the result :
0151   //!
0152   //! x(1)/w , x(2)/w ,  ... derivated <N> <M> times
0153   //!
0154   //! If   <All>    is  true  multiples  derivatives are
0155   //! computed. All the  derivatives (i,j) with 0 <= i+j
0156   //! <= Max(N,M) are  computed.  <RDers> is an array of
0157   //! length 3 *  (<N>+1)  * (<M>+1) which  will
0158   //! contains :
0159   //!
0160   //! x(1)/w , x(2)/w ,  ...
0161   //! x(1)/w , x(2)/w ,  ... derivated <0,1> times
0162   //! x(1)/w , x(2)/w ,  ... derivated <0,2> times
0163   //! ...
0164   //! x(1)/w , x(2)/w ,  ... derivated <0,N> times
0165   //!
0166   //! x(1)/w , x(2)/w ,  ... derivated <1,0> times
0167   //! x(1)/w , x(2)/w ,  ... derivated <1,1> times
0168   //! ...
0169   //! x(1)/w , x(2)/w ,  ... derivated <1,N> times
0170   //!
0171   //! x(1)/w , x(2)/w ,  ... derivated <N,0> times
0172   //! ....
0173   //! Warning: <RDers> must be dimensioned properly.
0174   Standard_EXPORT static void RationalDerivative(const Standard_Integer UDeg,
0175                                                  const Standard_Integer VDeg,
0176                                                  const Standard_Integer N,
0177                                                  const Standard_Integer M,
0178                                                  Standard_Real&         Ders,
0179                                                  Standard_Real&         RDers,
0180                                                  const Standard_Boolean All = Standard_True);
0181 
0182   Standard_EXPORT static void D0(const Standard_Real            U,
0183                                  const Standard_Real            V,
0184                                  const Standard_Integer         UIndex,
0185                                  const Standard_Integer         VIndex,
0186                                  const TColgp_Array2OfPnt&      Poles,
0187                                  const TColStd_Array2OfReal*    Weights,
0188                                  const TColStd_Array1OfReal&    UKnots,
0189                                  const TColStd_Array1OfReal&    VKnots,
0190                                  const TColStd_Array1OfInteger* UMults,
0191                                  const TColStd_Array1OfInteger* VMults,
0192                                  const Standard_Integer         UDegree,
0193                                  const Standard_Integer         VDegree,
0194                                  const Standard_Boolean         URat,
0195                                  const Standard_Boolean         VRat,
0196                                  const Standard_Boolean         UPer,
0197                                  const Standard_Boolean         VPer,
0198                                  gp_Pnt&                        P);
0199 
0200   Standard_EXPORT static void D1(const Standard_Real            U,
0201                                  const Standard_Real            V,
0202                                  const Standard_Integer         UIndex,
0203                                  const Standard_Integer         VIndex,
0204                                  const TColgp_Array2OfPnt&      Poles,
0205                                  const TColStd_Array2OfReal*    Weights,
0206                                  const TColStd_Array1OfReal&    UKnots,
0207                                  const TColStd_Array1OfReal&    VKnots,
0208                                  const TColStd_Array1OfInteger* UMults,
0209                                  const TColStd_Array1OfInteger* VMults,
0210                                  const Standard_Integer         Degree,
0211                                  const Standard_Integer         VDegree,
0212                                  const Standard_Boolean         URat,
0213                                  const Standard_Boolean         VRat,
0214                                  const Standard_Boolean         UPer,
0215                                  const Standard_Boolean         VPer,
0216                                  gp_Pnt&                        P,
0217                                  gp_Vec&                        Vu,
0218                                  gp_Vec&                        Vv);
0219 
0220   Standard_EXPORT static void D2(const Standard_Real            U,
0221                                  const Standard_Real            V,
0222                                  const Standard_Integer         UIndex,
0223                                  const Standard_Integer         VIndex,
0224                                  const TColgp_Array2OfPnt&      Poles,
0225                                  const TColStd_Array2OfReal*    Weights,
0226                                  const TColStd_Array1OfReal&    UKnots,
0227                                  const TColStd_Array1OfReal&    VKnots,
0228                                  const TColStd_Array1OfInteger* UMults,
0229                                  const TColStd_Array1OfInteger* VMults,
0230                                  const Standard_Integer         UDegree,
0231                                  const Standard_Integer         VDegree,
0232                                  const Standard_Boolean         URat,
0233                                  const Standard_Boolean         VRat,
0234                                  const Standard_Boolean         UPer,
0235                                  const Standard_Boolean         VPer,
0236                                  gp_Pnt&                        P,
0237                                  gp_Vec&                        Vu,
0238                                  gp_Vec&                        Vv,
0239                                  gp_Vec&                        Vuu,
0240                                  gp_Vec&                        Vvv,
0241                                  gp_Vec&                        Vuv);
0242 
0243   Standard_EXPORT static void D3(const Standard_Real            U,
0244                                  const Standard_Real            V,
0245                                  const Standard_Integer         UIndex,
0246                                  const Standard_Integer         VIndex,
0247                                  const TColgp_Array2OfPnt&      Poles,
0248                                  const TColStd_Array2OfReal*    Weights,
0249                                  const TColStd_Array1OfReal&    UKnots,
0250                                  const TColStd_Array1OfReal&    VKnots,
0251                                  const TColStd_Array1OfInteger* UMults,
0252                                  const TColStd_Array1OfInteger* VMults,
0253                                  const Standard_Integer         UDegree,
0254                                  const Standard_Integer         VDegree,
0255                                  const Standard_Boolean         URat,
0256                                  const Standard_Boolean         VRat,
0257                                  const Standard_Boolean         UPer,
0258                                  const Standard_Boolean         VPer,
0259                                  gp_Pnt&                        P,
0260                                  gp_Vec&                        Vu,
0261                                  gp_Vec&                        Vv,
0262                                  gp_Vec&                        Vuu,
0263                                  gp_Vec&                        Vvv,
0264                                  gp_Vec&                        Vuv,
0265                                  gp_Vec&                        Vuuu,
0266                                  gp_Vec&                        Vvvv,
0267                                  gp_Vec&                        Vuuv,
0268                                  gp_Vec&                        Vuvv);
0269 
0270   Standard_EXPORT static void DN(const Standard_Real            U,
0271                                  const Standard_Real            V,
0272                                  const Standard_Integer         Nu,
0273                                  const Standard_Integer         Nv,
0274                                  const Standard_Integer         UIndex,
0275                                  const Standard_Integer         VIndex,
0276                                  const TColgp_Array2OfPnt&      Poles,
0277                                  const TColStd_Array2OfReal*    Weights,
0278                                  const TColStd_Array1OfReal&    UKnots,
0279                                  const TColStd_Array1OfReal&    VKnots,
0280                                  const TColStd_Array1OfInteger* UMults,
0281                                  const TColStd_Array1OfInteger* VMults,
0282                                  const Standard_Integer         UDegree,
0283                                  const Standard_Integer         VDegree,
0284                                  const Standard_Boolean         URat,
0285                                  const Standard_Boolean         VRat,
0286                                  const Standard_Boolean         UPer,
0287                                  const Standard_Boolean         VPer,
0288                                  gp_Vec&                        Vn);
0289 
0290   //! Computes the  poles and weights of an isoparametric
0291   //! curve at parameter  <Param> (UIso if <IsU> is True,
0292   //! VIso  else).
0293   Standard_EXPORT static void Iso(const Standard_Real            Param,
0294                                   const Standard_Boolean         IsU,
0295                                   const TColgp_Array2OfPnt&      Poles,
0296                                   const TColStd_Array2OfReal*    Weights,
0297                                   const TColStd_Array1OfReal&    Knots,
0298                                   const TColStd_Array1OfInteger* Mults,
0299                                   const Standard_Integer         Degree,
0300                                   const Standard_Boolean         Periodic,
0301                                   TColgp_Array1OfPnt&            CPoles,
0302                                   TColStd_Array1OfReal*          CWeights);
0303 
0304   //! Reverses the array of poles. Last is the Index of
0305   //! the new first Row( Col) of Poles.
0306   //! On  a  non periodic surface Last is
0307   //! Poles.Upper().
0308   //! On a periodic curve last is
0309   //! (number of flat knots - degree - 1)
0310   //! or
0311   //! (sum of multiplicities(but  for the last) + degree
0312   //! - 1)
0313   Standard_EXPORT static void Reverse(TColgp_Array2OfPnt&    Poles,
0314                                       const Standard_Integer Last,
0315                                       const Standard_Boolean UDirection);
0316 
0317   //! Makes an homogeneous  evaluation of Poles and Weights
0318   //! any and returns in P the Numerator value and
0319   //! in W the Denominator value if Weights are present
0320   //! otherwise returns 1.0e0
0321   Standard_EXPORT static void HomogeneousD0(const Standard_Real            U,
0322                                             const Standard_Real            V,
0323                                             const Standard_Integer         UIndex,
0324                                             const Standard_Integer         VIndex,
0325                                             const TColgp_Array2OfPnt&      Poles,
0326                                             const TColStd_Array2OfReal*    Weights,
0327                                             const TColStd_Array1OfReal&    UKnots,
0328                                             const TColStd_Array1OfReal&    VKnots,
0329                                             const TColStd_Array1OfInteger* UMults,
0330                                             const TColStd_Array1OfInteger* VMults,
0331                                             const Standard_Integer         UDegree,
0332                                             const Standard_Integer         VDegree,
0333                                             const Standard_Boolean         URat,
0334                                             const Standard_Boolean         VRat,
0335                                             const Standard_Boolean         UPer,
0336                                             const Standard_Boolean         VPer,
0337                                             Standard_Real&                 W,
0338                                             gp_Pnt&                        P);
0339 
0340   //! Makes an homogeneous  evaluation of Poles and Weights
0341   //! any and returns in P the Numerator value and
0342   //! in W the Denominator value if Weights are present
0343   //! otherwise returns 1.0e0
0344   Standard_EXPORT static void HomogeneousD1(const Standard_Real            U,
0345                                             const Standard_Real            V,
0346                                             const Standard_Integer         UIndex,
0347                                             const Standard_Integer         VIndex,
0348                                             const TColgp_Array2OfPnt&      Poles,
0349                                             const TColStd_Array2OfReal*    Weights,
0350                                             const TColStd_Array1OfReal&    UKnots,
0351                                             const TColStd_Array1OfReal&    VKnots,
0352                                             const TColStd_Array1OfInteger* UMults,
0353                                             const TColStd_Array1OfInteger* VMults,
0354                                             const Standard_Integer         UDegree,
0355                                             const Standard_Integer         VDegree,
0356                                             const Standard_Boolean         URat,
0357                                             const Standard_Boolean         VRat,
0358                                             const Standard_Boolean         UPer,
0359                                             const Standard_Boolean         VPer,
0360                                             gp_Pnt&                        N,
0361                                             gp_Vec&                        Nu,
0362                                             gp_Vec&                        Nv,
0363                                             Standard_Real&                 D,
0364                                             Standard_Real&                 Du,
0365                                             Standard_Real&                 Dv);
0366 
0367   //! Reverses the array of weights.
0368   Standard_EXPORT static void Reverse(TColStd_Array2OfReal&  Weights,
0369                                       const Standard_Integer Last,
0370                                       const Standard_Boolean UDirection);
0371 
0372   //! Returns False if all the weights  of the  array <Weights>
0373   //! in the area [I1,I2] * [J1,J2] are  identic.
0374   //! Epsilon  is used for comparing  weights.
0375   //! If Epsilon  is 0. the  Epsilon of the first weight is used.
0376   Standard_EXPORT static Standard_Boolean IsRational(const TColStd_Array2OfReal& Weights,
0377                                                      const Standard_Integer      I1,
0378                                                      const Standard_Integer      I2,
0379                                                      const Standard_Integer      J1,
0380                                                      const Standard_Integer      J2,
0381                                                      const Standard_Real         Epsilon = 0.0);
0382 
0383   //! Copy in FP the coordinates of the poles.
0384   Standard_EXPORT static void SetPoles(const TColgp_Array2OfPnt& Poles,
0385                                        TColStd_Array1OfReal&     FP,
0386                                        const Standard_Boolean    UDirection);
0387 
0388   //! Copy in FP the coordinates of the poles.
0389   Standard_EXPORT static void SetPoles(const TColgp_Array2OfPnt&   Poles,
0390                                        const TColStd_Array2OfReal& Weights,
0391                                        TColStd_Array1OfReal&       FP,
0392                                        const Standard_Boolean      UDirection);
0393 
0394   //! Get from FP the coordinates of the poles.
0395   Standard_EXPORT static void GetPoles(const TColStd_Array1OfReal& FP,
0396                                        TColgp_Array2OfPnt&         Poles,
0397                                        const Standard_Boolean      UDirection);
0398 
0399   //! Get from FP the coordinates of the poles.
0400   Standard_EXPORT static void GetPoles(const TColStd_Array1OfReal& FP,
0401                                        TColgp_Array2OfPnt&         Poles,
0402                                        TColStd_Array2OfReal&       Weights,
0403                                        const Standard_Boolean      UDirection);
0404 
0405   //! Find the new poles which allows an old point (with a
0406   //! given u,v  as parameters)  to  reach a  new position
0407   //! UIndex1,UIndex2 indicate the  range of poles we can
0408   //! move for U
0409   //! (1, UNbPoles-1) or (2, UNbPoles) -> no constraint
0410   //! for one side in U
0411   //! (2, UNbPoles-1)   -> the ends are enforced for U
0412   //! don't enter (1,NbPoles) and (1,VNbPoles)
0413   //! -> error: rigid move
0414   //! if problem in BSplineBasis calculation, no change
0415   //! for the curve  and
0416   //! UFirstIndex, VLastIndex = 0
0417   //! VFirstIndex, VLastIndex = 0
0418   Standard_EXPORT static void MovePoint(const Standard_Real         U,
0419                                         const Standard_Real         V,
0420                                         const gp_Vec&               Displ,
0421                                         const Standard_Integer      UIndex1,
0422                                         const Standard_Integer      UIndex2,
0423                                         const Standard_Integer      VIndex1,
0424                                         const Standard_Integer      VIndex2,
0425                                         const Standard_Integer      UDegree,
0426                                         const Standard_Integer      VDegree,
0427                                         const Standard_Boolean      Rational,
0428                                         const TColgp_Array2OfPnt&   Poles,
0429                                         const TColStd_Array2OfReal& Weights,
0430                                         const TColStd_Array1OfReal& UFlatKnots,
0431                                         const TColStd_Array1OfReal& VFlatKnots,
0432                                         Standard_Integer&           UFirstIndex,
0433                                         Standard_Integer&           ULastIndex,
0434                                         Standard_Integer&           VFirstIndex,
0435                                         Standard_Integer&           VLastIndex,
0436                                         TColgp_Array2OfPnt&         NewPoles);
0437 
0438   Standard_EXPORT static void InsertKnots(const Standard_Boolean         UDirection,
0439                                           const Standard_Integer         Degree,
0440                                           const Standard_Boolean         Periodic,
0441                                           const TColgp_Array2OfPnt&      Poles,
0442                                           const TColStd_Array2OfReal*    Weights,
0443                                           const TColStd_Array1OfReal&    Knots,
0444                                           const TColStd_Array1OfInteger& Mults,
0445                                           const TColStd_Array1OfReal&    AddKnots,
0446                                           const TColStd_Array1OfInteger* AddMults,
0447                                           TColgp_Array2OfPnt&            NewPoles,
0448                                           TColStd_Array2OfReal*          NewWeights,
0449                                           TColStd_Array1OfReal&          NewKnots,
0450                                           TColStd_Array1OfInteger&       NewMults,
0451                                           const Standard_Real            Epsilon,
0452                                           const Standard_Boolean         Add = Standard_True);
0453 
0454   Standard_EXPORT static Standard_Boolean RemoveKnot(const Standard_Boolean         UDirection,
0455                                                      const Standard_Integer         Index,
0456                                                      const Standard_Integer         Mult,
0457                                                      const Standard_Integer         Degree,
0458                                                      const Standard_Boolean         Periodic,
0459                                                      const TColgp_Array2OfPnt&      Poles,
0460                                                      const TColStd_Array2OfReal*    Weights,
0461                                                      const TColStd_Array1OfReal&    Knots,
0462                                                      const TColStd_Array1OfInteger& Mults,
0463                                                      TColgp_Array2OfPnt&            NewPoles,
0464                                                      TColStd_Array2OfReal*          NewWeights,
0465                                                      TColStd_Array1OfReal&          NewKnots,
0466                                                      TColStd_Array1OfInteger&       NewMults,
0467                                                      const Standard_Real            Tolerance);
0468 
0469   Standard_EXPORT static void IncreaseDegree(const Standard_Boolean         UDirection,
0470                                              const Standard_Integer         Degree,
0471                                              const Standard_Integer         NewDegree,
0472                                              const Standard_Boolean         Periodic,
0473                                              const TColgp_Array2OfPnt&      Poles,
0474                                              const TColStd_Array2OfReal*    Weights,
0475                                              const TColStd_Array1OfReal&    Knots,
0476                                              const TColStd_Array1OfInteger& Mults,
0477                                              TColgp_Array2OfPnt&            NewPoles,
0478                                              TColStd_Array2OfReal*          NewWeights,
0479                                              TColStd_Array1OfReal&          NewKnots,
0480                                              TColStd_Array1OfInteger&       NewMults);
0481 
0482   Standard_EXPORT static void Unperiodize(const Standard_Boolean         UDirection,
0483                                           const Standard_Integer         Degree,
0484                                           const TColStd_Array1OfInteger& Mults,
0485                                           const TColStd_Array1OfReal&    Knots,
0486                                           const TColgp_Array2OfPnt&      Poles,
0487                                           const TColStd_Array2OfReal*    Weights,
0488                                           TColStd_Array1OfInteger&       NewMults,
0489                                           TColStd_Array1OfReal&          NewKnots,
0490                                           TColgp_Array2OfPnt&            NewPoles,
0491                                           TColStd_Array2OfReal*          NewWeights);
0492 
0493   //! Used as argument for a non rational curve.
0494   static TColStd_Array2OfReal* NoWeights();
0495 
0496   //! Perform the evaluation of the Taylor expansion
0497   //! of the Bspline normalized between 0 and 1.
0498   //! If rational computes the homogeneous Taylor expansion
0499   //! for the numerator and stores it in CachePoles
0500   Standard_EXPORT static void BuildCache(const Standard_Real         U,
0501                                          const Standard_Real         V,
0502                                          const Standard_Real         USpanDomain,
0503                                          const Standard_Real         VSpanDomain,
0504                                          const Standard_Boolean      UPeriodicFlag,
0505                                          const Standard_Boolean      VPeriodicFlag,
0506                                          const Standard_Integer      UDegree,
0507                                          const Standard_Integer      VDegree,
0508                                          const Standard_Integer      UIndex,
0509                                          const Standard_Integer      VIndex,
0510                                          const TColStd_Array1OfReal& UFlatKnots,
0511                                          const TColStd_Array1OfReal& VFlatKnots,
0512                                          const TColgp_Array2OfPnt&   Poles,
0513                                          const TColStd_Array2OfReal* Weights,
0514                                          TColgp_Array2OfPnt&         CachePoles,
0515                                          TColStd_Array2OfReal*       CacheWeights);
0516 
0517   //! Perform the evaluation of the Taylor expansion
0518   //! of the Bspline normalized between 0 and 1.
0519   //! Structure of result optimized for BSplSLib_Cache.
0520   Standard_EXPORT static void BuildCache(const Standard_Real         theU,
0521                                          const Standard_Real         theV,
0522                                          const Standard_Real         theUSpanDomain,
0523                                          const Standard_Real         theVSpanDomain,
0524                                          const Standard_Boolean      theUPeriodic,
0525                                          const Standard_Boolean      theVPeriodic,
0526                                          const Standard_Integer      theUDegree,
0527                                          const Standard_Integer      theVDegree,
0528                                          const Standard_Integer      theUIndex,
0529                                          const Standard_Integer      theVIndex,
0530                                          const TColStd_Array1OfReal& theUFlatKnots,
0531                                          const TColStd_Array1OfReal& theVFlatKnots,
0532                                          const TColgp_Array2OfPnt&   thePoles,
0533                                          const TColStd_Array2OfReal* theWeights,
0534                                          TColStd_Array2OfReal&       theCacheArray);
0535 
0536   //! Perform the evaluation of the of the cache
0537   //! the parameter must be normalized between
0538   //! the 0 and 1 for the span.
0539   //! The Cache must be valid when calling this
0540   //! routine. Geom Package will insure that.
0541   //! and then multiplies by the weights
0542   //! this just evaluates the current point
0543   //! the CacheParameter is where the Cache was
0544   //! constructed the SpanLength is to normalize
0545   //! the polynomial in the cache to avoid bad conditioning
0546   //! effects
0547   Standard_EXPORT static void CacheD0(const Standard_Real         U,
0548                                       const Standard_Real         V,
0549                                       const Standard_Integer      UDegree,
0550                                       const Standard_Integer      VDegree,
0551                                       const Standard_Real         UCacheParameter,
0552                                       const Standard_Real         VCacheParameter,
0553                                       const Standard_Real         USpanLenght,
0554                                       const Standard_Real         VSpanLength,
0555                                       const TColgp_Array2OfPnt&   Poles,
0556                                       const TColStd_Array2OfReal* Weights,
0557                                       gp_Pnt&                     Point);
0558 
0559   //! Calls CacheD0 for Bezier Surfaces Arrays computed with
0560   //! the method PolesCoefficients.
0561   //! Warning: To be used for BezierSurfaces ONLY!!!
0562   static void CoefsD0(const Standard_Real         U,
0563                       const Standard_Real         V,
0564                       const TColgp_Array2OfPnt&   Poles,
0565                       const TColStd_Array2OfReal* Weights,
0566                       gp_Pnt&                     Point);
0567 
0568   //! Perform the evaluation of the of the cache
0569   //! the parameter must be normalized between
0570   //! the 0 and 1 for the span.
0571   //! The Cache must be valid when calling this
0572   //! routine. Geom Package will insure that.
0573   //! and then multiplies by the weights
0574   //! this just evaluates the current point
0575   //! the CacheParameter is where the Cache was
0576   //! constructed the SpanLength is to normalize
0577   //! the polynomial in the cache to avoid bad conditioning
0578   //! effects
0579   Standard_EXPORT static void CacheD1(const Standard_Real         U,
0580                                       const Standard_Real         V,
0581                                       const Standard_Integer      UDegree,
0582                                       const Standard_Integer      VDegree,
0583                                       const Standard_Real         UCacheParameter,
0584                                       const Standard_Real         VCacheParameter,
0585                                       const Standard_Real         USpanLenght,
0586                                       const Standard_Real         VSpanLength,
0587                                       const TColgp_Array2OfPnt&   Poles,
0588                                       const TColStd_Array2OfReal* Weights,
0589                                       gp_Pnt&                     Point,
0590                                       gp_Vec&                     VecU,
0591                                       gp_Vec&                     VecV);
0592 
0593   //! Calls CacheD0 for Bezier Surfaces Arrays computed with
0594   //! the method PolesCoefficients.
0595   //! Warning: To be used for BezierSurfaces ONLY!!!
0596   static void CoefsD1(const Standard_Real         U,
0597                       const Standard_Real         V,
0598                       const TColgp_Array2OfPnt&   Poles,
0599                       const TColStd_Array2OfReal* Weights,
0600                       gp_Pnt&                     Point,
0601                       gp_Vec&                     VecU,
0602                       gp_Vec&                     VecV);
0603 
0604   //! Perform the evaluation of the of the cache
0605   //! the parameter must be normalized between
0606   //! the 0 and 1 for the span.
0607   //! The Cache must be valid when calling this
0608   //! routine. Geom Package will insure that.
0609   //! and then multiplies by the weights
0610   //! this just evaluates the current point
0611   //! the CacheParameter is where the Cache was
0612   //! constructed the SpanLength is to normalize
0613   //! the polynomial in the cache to avoid bad conditioning
0614   //! effects
0615   Standard_EXPORT static void CacheD2(const Standard_Real         U,
0616                                       const Standard_Real         V,
0617                                       const Standard_Integer      UDegree,
0618                                       const Standard_Integer      VDegree,
0619                                       const Standard_Real         UCacheParameter,
0620                                       const Standard_Real         VCacheParameter,
0621                                       const Standard_Real         USpanLenght,
0622                                       const Standard_Real         VSpanLength,
0623                                       const TColgp_Array2OfPnt&   Poles,
0624                                       const TColStd_Array2OfReal* Weights,
0625                                       gp_Pnt&                     Point,
0626                                       gp_Vec&                     VecU,
0627                                       gp_Vec&                     VecV,
0628                                       gp_Vec&                     VecUU,
0629                                       gp_Vec&                     VecUV,
0630                                       gp_Vec&                     VecVV);
0631 
0632   //! Calls CacheD0 for Bezier Surfaces Arrays computed with
0633   //! the method PolesCoefficients.
0634   //! Warning: To be used for BezierSurfaces ONLY!!!
0635   static void CoefsD2(const Standard_Real         U,
0636                       const Standard_Real         V,
0637                       const TColgp_Array2OfPnt&   Poles,
0638                       const TColStd_Array2OfReal* Weights,
0639                       gp_Pnt&                     Point,
0640                       gp_Vec&                     VecU,
0641                       gp_Vec&                     VecV,
0642                       gp_Vec&                     VecUU,
0643                       gp_Vec&                     VecUV,
0644                       gp_Vec&                     VecVV);
0645 
0646   //! Warning! To be used for BezierSurfaces ONLY!!!
0647   static void PolesCoefficients(const TColgp_Array2OfPnt& Poles, TColgp_Array2OfPnt& CachePoles);
0648 
0649   //! Encapsulation   of  BuildCache    to   perform   the
0650   //! evaluation  of the Taylor expansion for beziersurfaces
0651   //! at parameters 0.,0.;
0652   //! Warning: To be used for BezierSurfaces ONLY!!!
0653   Standard_EXPORT static void PolesCoefficients(const TColgp_Array2OfPnt&   Poles,
0654                                                 const TColStd_Array2OfReal* Weights,
0655                                                 TColgp_Array2OfPnt&         CachePoles,
0656                                                 TColStd_Array2OfReal*       CacheWeights);
0657 
0658   //! Given a tolerance in 3D space returns two
0659   //! tolerances, one in U one in V such that for
0660   //! all (u1,v1) and (u0,v0) in the domain of
0661   //! the surface f(u,v)  we have :
0662   //! | u1 - u0 | < UTolerance and
0663   //! | v1 - v0 | < VTolerance
0664   //! we have |f (u1,v1) - f (u0,v0)| < Tolerance3D
0665   Standard_EXPORT static void Resolution(const TColgp_Array2OfPnt&      Poles,
0666                                          const TColStd_Array2OfReal*    Weights,
0667                                          const TColStd_Array1OfReal&    UKnots,
0668                                          const TColStd_Array1OfReal&    VKnots,
0669                                          const TColStd_Array1OfInteger& UMults,
0670                                          const TColStd_Array1OfInteger& VMults,
0671                                          const Standard_Integer         UDegree,
0672                                          const Standard_Integer         VDegree,
0673                                          const Standard_Boolean         URat,
0674                                          const Standard_Boolean         VRat,
0675                                          const Standard_Boolean         UPer,
0676                                          const Standard_Boolean         VPer,
0677                                          const Standard_Real            Tolerance3D,
0678                                          Standard_Real&                 UTolerance,
0679                                          Standard_Real&                 VTolerance);
0680 
0681   //! Performs the interpolation of the data points given in
0682   //! the   Poles       array      in   the      form
0683   //! [1,...,RL][1,...,RC][1...PolesDimension]    .    The
0684   //! ColLength CL and the Length of UParameters must be the
0685   //! same. The length of VFlatKnots is VDegree + CL + 1.
0686   //!
0687   //! The  RowLength RL and the Length of VParameters must be
0688   //! the  same. The length of VFlatKnots is Degree + RL + 1.
0689   //!
0690   //! Warning: the method used  to do that  interpolation
0691   //! is gauss  elimination  WITHOUT pivoting.  Thus if  the
0692   //! diagonal is not  dominant  there is no guarantee  that
0693   //! the   algorithm will    work.  Nevertheless  for Cubic
0694   //! interpolation  at knots or interpolation at Scheonberg
0695   //! points  the method   will work.  The  InversionProblem
0696   //! will  report 0 if there   was no problem  else it will
0697   //! give the index of the faulty pivot
0698   Standard_EXPORT static void Interpolate(const Standard_Integer      UDegree,
0699                                           const Standard_Integer      VDegree,
0700                                           const TColStd_Array1OfReal& UFlatKnots,
0701                                           const TColStd_Array1OfReal& VFlatKnots,
0702                                           const TColStd_Array1OfReal& UParameters,
0703                                           const TColStd_Array1OfReal& VParameters,
0704                                           TColgp_Array2OfPnt&         Poles,
0705                                           TColStd_Array2OfReal&       Weights,
0706                                           Standard_Integer&           InversionProblem);
0707 
0708   //! Performs the interpolation of the data points given in
0709   //! the  Poles array.
0710   //! The  ColLength CL and the Length of UParameters must be
0711   //! the  same. The length of VFlatKnots is VDegree + CL + 1.
0712   //!
0713   //! The  RowLength RL and the Length of VParameters must be
0714   //! the  same. The length of VFlatKnots is Degree + RL + 1.
0715   //!
0716   //! Warning: the method used  to do that  interpolation
0717   //! is gauss  elimination  WITHOUT pivoting.  Thus if  the
0718   //! diagonal is not  dominant  there is no guarantee  that
0719   //! the   algorithm will    work.  Nevertheless  for Cubic
0720   //! interpolation  at knots or interpolation at Scheonberg
0721   //! points  the method   will work.  The  InversionProblem
0722   //! will  report 0 if there   was no problem  else it will
0723   //! give the index of the faulty pivot
0724   Standard_EXPORT static void Interpolate(const Standard_Integer      UDegree,
0725                                           const Standard_Integer      VDegree,
0726                                           const TColStd_Array1OfReal& UFlatKnots,
0727                                           const TColStd_Array1OfReal& VFlatKnots,
0728                                           const TColStd_Array1OfReal& UParameters,
0729                                           const TColStd_Array1OfReal& VParameters,
0730                                           TColgp_Array2OfPnt&         Poles,
0731                                           Standard_Integer&           InversionProblem);
0732 
0733   //! this will multiply  a given BSpline numerator  N(u,v)
0734   //! and    denominator    D(u,v)  defined     by   its
0735   //! U/VBSplineDegree   and    U/VBSplineKnots,     and
0736   //! U/VMults. Its Poles  and Weights are arrays which are
0737   //! coded   as      array2      of      the    form
0738   //! [1..UNumPoles][1..VNumPoles]  by  a function a(u,v)
0739   //! which  is assumed  to satisfy    the following :  1.
0740   //! a(u,v)  * N(u,v) and a(u,v) *  D(u,v)  is a polynomial
0741   //! BSpline that can be expressed exactly as a BSpline of
0742   //! degree U/VNewDegree  on  the knots U/VFlatKnots 2. the range
0743   //! of a(u,v) is   the   same as  the range   of  N(u,v)
0744   //! or D(u,v)
0745   //! ---Warning:  it is   the caller's  responsibility  to
0746   //! insure that conditions 1. and  2. above are satisfied
0747   //! : no  check  whatsoever is made   in  this method  --
0748   //! theStatus will  return 0 if  OK else it will return  the
0749   //! pivot index -- of the   matrix that was inverted to
0750   //! compute the multiplied -- BSpline  : the method used
0751   //! is  interpolation   at Schoenenberg   --  points  of
0752   //! a(u,v)* N(u,v) and a(u,v) * D(u,v)
0753   //! theStatus will return 0 if OK else it will return the pivot index
0754   //! of the matrix that was inverted to compute the multiplied
0755   //! BSpline : the method used is interpolation at Schoenenberg
0756   //! points of a(u,v)*F(u,v)
0757   //! --
0758   Standard_EXPORT static void FunctionMultiply(const BSplSLib_EvaluatorFunction& Function,
0759                                                const Standard_Integer            UBSplineDegree,
0760                                                const Standard_Integer            VBSplineDegree,
0761                                                const TColStd_Array1OfReal&       UBSplineKnots,
0762                                                const TColStd_Array1OfReal&       VBSplineKnots,
0763                                                const TColStd_Array1OfInteger*    UMults,
0764                                                const TColStd_Array1OfInteger*    VMults,
0765                                                const TColgp_Array2OfPnt&         Poles,
0766                                                const TColStd_Array2OfReal*       Weights,
0767                                                const TColStd_Array1OfReal&       UFlatKnots,
0768                                                const TColStd_Array1OfReal&       VFlatKnots,
0769                                                const Standard_Integer            UNewDegree,
0770                                                const Standard_Integer            VNewDegree,
0771                                                TColgp_Array2OfPnt&               NewNumerator,
0772                                                TColStd_Array2OfReal&             NewDenominator,
0773                                                Standard_Integer&                 theStatus);
0774 
0775 protected:
0776 private:
0777 };
0778 
0779 #include <BSplSLib.lxx>
0780 
0781 #endif // _BSplSLib_HeaderFile