Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1993-03-09
0002 // Created by: JCV
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Geom_BSplineSurface_HeaderFile
0018 #define _Geom_BSplineSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Precision.hxx>
0024 #include <GeomAbs_BSplKnotDistribution.hxx>
0025 #include <GeomAbs_Shape.hxx>
0026 #include <gp_Pnt.hxx>
0027 #include <NCollection_Array2.hxx>
0028 #include <NCollection_Array1.hxx>
0029 #include <Geom_BoundedSurface.hxx>
0030 class Geom_Curve;
0031 class gp_Trsf;
0032 class Geom_Geometry;
0033 
0034 namespace GeomEval_RepSurfaceDesc
0035 {
0036 class Base;
0037 }
0038 
0039 //! Describes a BSpline surface.
0040 //! In each parametric direction, a BSpline surface can be:
0041 //! - uniform or non-uniform,
0042 //! - rational or non-rational,
0043 //! - periodic or non-periodic.
0044 //! A BSpline surface is defined by:
0045 //! - its degrees, in the u and v parametric directions,
0046 //! - its periodic characteristic, in the u and v parametric directions,
0047 //! - a table of poles, also called control points (together
0048 //! with the associated weights if the surface is rational), and
0049 //! - a table of knots, together with the associated multiplicities.
0050 //! The degree of a Geom_BSplineSurface is limited to
0051 //! a value (25) which is defined and controlled by the
0052 //! system. This value is returned by the function MaxDegree.
0053 //! Poles and Weights
0054 //! Poles and Weights are manipulated using two associative double arrays:
0055 //! - the poles table, which is a double array of gp_Pnt points, and
0056 //! - the weights table, which is a double array of reals.
0057 //! The bounds of the poles and weights arrays are:
0058 //! - 1 and NbUPoles for the row bounds (provided
0059 //! that the BSpline surface is not periodic in the u
0060 //! parametric direction), where NbUPoles is the
0061 //! number of poles of the surface in the u parametric direction, and
0062 //! - 1 and NbVPoles for the column bounds (provided
0063 //! that the BSpline surface is not periodic in the v
0064 //! parametric direction), where NbVPoles is the
0065 //! number of poles of the surface in the v parametric direction.
0066 //! The poles of the surface are the points used to shape
0067 //! and reshape the surface. They comprise a rectangular network.
0068 //! If the surface is not periodic:
0069 //! - The points (1, 1), (NbUPoles, 1), (1,
0070 //! NbVPoles), and (NbUPoles, NbVPoles)
0071 //! are the four parametric "corners" of the surface.
0072 //! - The first column of poles and the last column of
0073 //! poles define two BSpline curves which delimit the
0074 //! surface in the v parametric direction. These are the
0075 //! v isoparametric curves corresponding to the two
0076 //! bounds of the v parameter.
0077 //! - The first row of poles and the last row of poles
0078 //! define two BSpline curves which delimit the surface
0079 //! in the u parametric direction. These are the u
0080 //! isoparametric curves corresponding to the two bounds of the u parameter.
0081 //! If the surface is periodic, these geometric properties are not verified.
0082 //! It is more difficult to define a geometrical significance
0083 //! for the weights. However they are useful for
0084 //! representing a quadric surface precisely. Moreover, if
0085 //! the weights of all the poles are equal, the surface has
0086 //! a polynomial equation, and hence is a "non-rational surface".
0087 //! The non-rational surface is a special, but frequently
0088 //! used, case, where all poles have identical weights.
0089 //! The weights are defined and used only in the case of
0090 //! a rational surface. The rational characteristic is
0091 //! defined in each parametric direction. A surface can be
0092 //! rational in the u parametric direction, and
0093 //! non-rational in the v parametric direction.
0094 //! Knots and Multiplicities
0095 //! For a Geom_BSplineSurface the table of knots is
0096 //! made up of two increasing sequences of reals, without
0097 //! repetition, one for each parametric direction. The
0098 //! multiplicities define the repetition of the knots.
0099 //! A BSpline surface comprises multiple contiguous
0100 //! patches, which are themselves polynomial or rational
0101 //! surfaces. The knots are the parameters of the
0102 //! isoparametric curves which limit these contiguous
0103 //! patches. The multiplicity of a knot on a BSpline
0104 //! surface (in a given parametric direction) is related to
0105 //! the degree of continuity of the surface at that knot in
0106 //! that parametric direction:
0107 //! Degree of continuity at knot(i) = Degree - Multi(i) where:
0108 //! - Degree is the degree of the BSpline surface in
0109 //! the given parametric direction, and
0110 //! - Multi(i) is the multiplicity of knot number i in
0111 //! the given parametric direction.
0112 //! There are some special cases, where the knots are
0113 //! regularly spaced in one parametric direction (i.e. the
0114 //! difference between two consecutive knots is a constant).
0115 //! - "Uniform": all the multiplicities are equal to 1.
0116 //! - "Quasi-uniform": all the multiplicities are equal to 1,
0117 //! except for the first and last knots in this parametric
0118 //! direction, and these are equal to Degree + 1.
0119 //! - "Piecewise Bezier": all the multiplicities are equal to
0120 //! Degree except for the first and last knots, which
0121 //! are equal to Degree + 1. This surface is a
0122 //! concatenation of Bezier patches in the given
0123 //! parametric direction.
0124 //! If the BSpline surface is not periodic in a given
0125 //! parametric direction, the bounds of the knots and
0126 //! multiplicities tables are 1 and NbKnots, where
0127 //! NbKnots is the number of knots of the BSpline
0128 //! surface in that parametric direction.
0129 //! If the BSpline surface is periodic in a given parametric
0130 //! direction, and there are k periodic knots and p
0131 //! periodic poles in that parametric direction:
0132 //! - the period is such that:
0133 //! period = Knot(k+1) - Knot(1), and
0134 //! - the poles and knots tables in that parametric
0135 //! direction can be considered as infinite tables, such that:
0136 //! Knot(i+k) = Knot(i) + period, and
0137 //! Pole(i+p) = Pole(i)
0138 //! Note: The data structure tables for a periodic BSpline
0139 //! surface are more complex than those of a non-periodic one.
0140 //! References :
0141 //! . A survey of curve and surface methods in CADG Wolfgang BOHM
0142 //! CAGD 1 (1984)
0143 //! . On de Boor-like algorithms and blossoming Wolfgang BOEHM
0144 //! cagd 5 (1988)
0145 //! . Blossoming and knot insertion algorithms for B-spline curves
0146 //! Ronald N. GOLDMAN
0147 //! . Modelisation des surfaces en CAO, Henri GIAUME Peugeot SA
0148 //! . Curves and Surfaces for Computer Aided Geometric Design,
0149 //! a practical guide Gerald Farin
0150 class Geom_BSplineSurface : public Geom_BoundedSurface
0151 {
0152 
0153 public:
0154   //! Creates a non-rational b-spline surface (weights
0155   //! default value is 1.).
0156   //! The following conditions must be verified.
0157   //! 0 < UDegree <= MaxDegree.
0158   //! UKnots.Length() == UMults.Length() >= 2
0159   //! UKnots(i) < UKnots(i+1) (Knots are increasing)
0160   //! 1 <= UMults(i) <= UDegree
0161   //! On a non uperiodic surface the first and last
0162   //! umultiplicities may be UDegree+1 (this is even
0163   //! recommended if you want the curve to start and finish on
0164   //! the first and last pole).
0165   //! On a uperiodic surface the first and the last
0166   //! umultiplicities must be the same.
0167   //! on non-uperiodic surfaces
0168   //! Poles.ColLength() == Sum(UMults(i)) - UDegree - 1 >= 2
0169   //! on uperiodic surfaces
0170   //! Poles.ColLength() == Sum(UMults(i)) except the first or last
0171   //! The previous conditions for U holds also for V, with the
0172   //! RowLength of the poles.
0173   Standard_EXPORT Geom_BSplineSurface(const NCollection_Array2<gp_Pnt>& Poles,
0174                                       const NCollection_Array1<double>& UKnots,
0175                                       const NCollection_Array1<double>& VKnots,
0176                                       const NCollection_Array1<int>&    UMults,
0177                                       const NCollection_Array1<int>&    VMults,
0178                                       const int                         UDegree,
0179                                       const int                         VDegree,
0180                                       const bool                        UPeriodic = false,
0181                                       const bool                        VPeriodic = false);
0182 
0183   //! Creates a non-rational b-spline surface (weights
0184   //! default value is 1.).
0185   //!
0186   //! The following conditions must be verified.
0187   //! 0 < UDegree <= MaxDegree.
0188   //!
0189   //! UKnots.Length() == UMults.Length() >= 2
0190   //!
0191   //! UKnots(i) < UKnots(i+1) (Knots are increasing)
0192   //! 1 <= UMults(i) <= UDegree
0193   //!
0194   //! On a non uperiodic surface the first and last
0195   //! umultiplicities may be UDegree+1 (this is even recommended
0196   //! if you want the curve to start and finish on the first
0197   //! and last pole).
0198   //!
0199   //! On a uperiodic surface the first and the last
0200   //! umultiplicities must be the same.
0201   //!
0202   //! on non-uperiodic surfaces
0203   //!
0204   //! Poles.ColLength() == Sum(UMults(i)) - UDegree - 1 >= 2
0205   //!
0206   //! on uperiodic surfaces
0207   //!
0208   //! Poles.ColLength() == Sum(UMults(i)) except the first or
0209   //! last
0210   //!
0211   //! The previous conditions for U holds also for V, with the
0212   //! RowLength of the poles.
0213   Standard_EXPORT Geom_BSplineSurface(const NCollection_Array2<gp_Pnt>& Poles,
0214                                       const NCollection_Array2<double>& Weights,
0215                                       const NCollection_Array1<double>& UKnots,
0216                                       const NCollection_Array1<double>& VKnots,
0217                                       const NCollection_Array1<int>&    UMults,
0218                                       const NCollection_Array1<int>&    VMults,
0219                                       const int                         UDegree,
0220                                       const int                         VDegree,
0221                                       const bool                        UPeriodic = false,
0222                                       const bool                        VPeriodic = false);
0223 
0224   //! Copy constructor for optimized copying without validation.
0225   //! @param[in] theOther the BSpline surface to copy from
0226   Standard_EXPORT Geom_BSplineSurface(const Geom_BSplineSurface& theOther);
0227 
0228   //! Returns true if an evaluation representation is attached.
0229   bool HasEvalRepresentation() const { return !myEvalRep.IsNull(); }
0230 
0231   //! Returns the current evaluation representation descriptor (may be null).
0232   const occ::handle<GeomEval_RepSurfaceDesc::Base>& EvalRepresentation() const { return myEvalRep; }
0233 
0234   //! Sets a new evaluation representation.
0235   //! Validates descriptor data and ensures no circular references.
0236   Standard_EXPORT void SetEvalRepresentation(
0237     const occ::handle<GeomEval_RepSurfaceDesc::Base>& theDesc);
0238 
0239   //! Removes the evaluation representation.
0240   void ClearEvalRepresentation() { myEvalRep.Nullify(); }
0241 
0242   //! Exchanges the u and v parametric directions on
0243   //! this BSpline surface.
0244   //! As a consequence:
0245   //! - the poles and weights tables are transposed,
0246   //! - the knots and multiplicities tables are exchanged,
0247   //! - degrees of continuity, and rational, periodic and
0248   //! uniform characteristics are exchanged, and
0249   //! - the orientation of the surface is inverted.
0250   Standard_EXPORT void ExchangeUV();
0251 
0252   //! Sets the surface U periodic.
0253   //! Modifies this surface to be periodic in the U
0254   //! parametric direction.
0255   //! To become periodic in a given parametric direction a
0256   //! surface must be closed in that parametric direction,
0257   //! and the knot sequence relative to that direction must be periodic.
0258   //! To generate this periodic sequence of knots, the
0259   //! functions FirstUKnotIndex and LastUKnotIndex are used to
0260   //! compute I1 and I2. These are the indexes, in the
0261   //! knot array associated with the given parametric
0262   //! direction, of the knots that correspond to the first and
0263   //! last parameters of this BSpline surface in the given
0264   //! parametric direction. Hence the period is:
0265   //! Knots(I1) - Knots(I2)
0266   //! As a result, the knots and poles tables are modified.
0267   //! Exceptions
0268   //! Standard_ConstructionError if the surface is not
0269   //! closed in the given parametric direction.
0270   Standard_EXPORT void SetUPeriodic();
0271 
0272   //! Sets the surface V periodic.
0273   //! Modifies this surface to be periodic in the V
0274   //! parametric direction.
0275   //! To become periodic in a given parametric direction a
0276   //! surface must be closed in that parametric direction,
0277   //! and the knot sequence relative to that direction must be periodic.
0278   //! To generate this periodic sequence of knots, the
0279   //! functions FirstVKnotIndex and LastVKnotIndex are used to
0280   //! compute I1 and I2. These are the indexes, in the
0281   //! knot array associated with the given parametric
0282   //! direction, of the knots that correspond to the first and
0283   //! last parameters of this BSpline surface in the given
0284   //! parametric direction. Hence the period is:
0285   //! Knots(I1) - Knots(I2)
0286   //! As a result, the knots and poles tables are modified.
0287   //! Exceptions
0288   //! Standard_ConstructionError if the surface is not
0289   //! closed in the given parametric direction.
0290   Standard_EXPORT void SetVPeriodic();
0291 
0292   //! returns the parameter normalized within
0293   //! the period if the surface is periodic : otherwise
0294   //! does not do anything
0295   Standard_EXPORT void PeriodicNormalization(double& U, double& V) const;
0296 
0297   //! Assigns the knot of index Index in the knots table in
0298   //! the corresponding parametric direction to be the
0299   //! origin of this periodic BSpline surface. As a
0300   //! consequence, the knots and poles tables are modified.
0301   //! Exceptions
0302   //! Standard_NoSuchObject if this BSpline surface is
0303   //! not periodic in the given parametric direction.
0304   //! Standard_DomainError if Index is outside the
0305   //! bounds of the knots table in the given parametric direction.
0306   Standard_EXPORT void SetUOrigin(const int Index);
0307 
0308   //! Assigns the knot of index Index in the knots table in
0309   //! the corresponding parametric direction to be the
0310   //! origin of this periodic BSpline surface. As a
0311   //! consequence, the knots and poles tables are modified.
0312   //! Exceptions
0313   //! Standard_NoSuchObject if this BSpline surface is
0314   //! not periodic in the given parametric direction.
0315   //! Standard_DomainError if Index is outside the
0316   //! bounds of the knots table in the given parametric direction.
0317   Standard_EXPORT void SetVOrigin(const int Index);
0318 
0319   //! Sets the surface U not periodic.
0320   //! Changes this BSpline surface into a non-periodic
0321   //! surface along U direction.
0322   //! If this surface is already non-periodic, it is not modified.
0323   //! Note: the poles and knots tables are modified.
0324   Standard_EXPORT void SetUNotPeriodic();
0325 
0326   //! Sets the surface V not periodic.
0327   //! Changes this BSpline surface into a non-periodic
0328   //! surface along V direction.
0329   //! If this surface is already non-periodic, it is not modified.
0330   //! Note: the poles and knots tables are modified.
0331   Standard_EXPORT void SetVNotPeriodic();
0332 
0333   //! Changes the orientation of this BSpline surface in the
0334   //! U parametric direction. The bounds of the
0335   //! surface are not changed but the given parametric
0336   //! direction is reversed. Hence the orientation of the
0337   //! surface is reversed.
0338   //! The knots and poles tables are modified.
0339   Standard_EXPORT void UReverse() final;
0340 
0341   //! Changes the orientation of this BSpline surface in the
0342   //! V parametric direction. The bounds of the
0343   //! surface are not changed but the given parametric
0344   //! direction is reversed. Hence the orientation of the
0345   //! surface is reversed.
0346   //! The knots and poles tables are modified.
0347   Standard_EXPORT void VReverse() final;
0348 
0349   //! Computes the u parameter on the modified
0350   //! surface, produced by reversing its U parametric
0351   //! direction, for the point of u parameter U, on this BSpline surface.
0352   //! For a BSpline surface, these functions return respectively:
0353   //! - UFirst + ULast - U,
0354   //! where UFirst, ULast are
0355   //! the values of the first and last parameters of this
0356   //! BSpline surface, in the u parametric directions.
0357   Standard_EXPORT double UReversedParameter(const double U) const final;
0358 
0359   //! Computes the v parameter on the modified
0360   //! surface, produced by reversing its V parametric
0361   //! direction, for the point of v parameter V on this BSpline surface.
0362   //! For a BSpline surface, these functions return respectively:
0363   //! - VFirst + VLast - V,
0364   //! VFirst and VLast are
0365   //! the values of the first and last parameters of this
0366   //! BSpline surface, in the v pametric directions.
0367   Standard_EXPORT double VReversedParameter(const double V) const final;
0368 
0369   //! Increases the degrees of this BSpline surface to
0370   //! UDegree and VDegree in the u and v parametric
0371   //! directions respectively. As a result, the tables of poles,
0372   //! weights and multiplicities are modified. The tables of
0373   //! knots is not changed.
0374   //! Note: Nothing is done if the given degree is less than
0375   //! or equal to the current degree in the corresponding
0376   //! parametric direction.
0377   //! Exceptions
0378   //! Standard_ConstructionError if UDegree or
0379   //! VDegree is greater than
0380   //! Geom_BSplineSurface::MaxDegree().
0381   Standard_EXPORT void IncreaseDegree(const int UDegree, const int VDegree);
0382 
0383   //! Inserts into the knots table for the U
0384   //! parametric direction of this BSpline surface:
0385   //! - the values of the array Knots, with their respective
0386   //! multiplicities, Mults.
0387   //! If the knot value to insert already exists in the table, its multiplicity is:
0388   //! - increased by M, if Add is true (the default), or
0389   //! - increased to M, if Add is false.
0390   //! The tolerance criterion used to check the equality of
0391   //! the knots is the larger of the values ParametricTolerance and
0392   //! double::Epsilon(val), where val is the knot value to be inserted.
0393   //! Warning
0394   //! - If a given multiplicity coefficient is null, or negative, nothing is done.
0395   //! - The new multiplicity of a knot is limited to the degree of this BSpline surface in the
0396   //! corresponding parametric direction.
0397   //! Exceptions
0398   //! Standard_ConstructionError if a knot value to
0399   //! insert is outside the bounds of this BSpline surface in
0400   //! the specified parametric direction. The comparison
0401   //! uses the precision criterion ParametricTolerance.
0402   Standard_EXPORT void InsertUKnots(const NCollection_Array1<double>& Knots,
0403                                     const NCollection_Array1<int>&    Mults,
0404                                     const double                      ParametricTolerance = 0.0,
0405                                     const bool                        Add                 = true);
0406 
0407   //! Inserts into the knots table for the V
0408   //! parametric direction of this BSpline surface:
0409   //! - the values of the array Knots, with their respective
0410   //! multiplicities, Mults.
0411   //! If the knot value to insert already exists in the table, its multiplicity is:
0412   //! - increased by M, if Add is true (the default), or
0413   //! - increased to M, if Add is false.
0414   //! The tolerance criterion used to check the equality of
0415   //! the knots is the larger of the values ParametricTolerance and
0416   //! double::Epsilon(val), where val is the knot value to be inserted.
0417   //! Warning
0418   //! - If a given multiplicity coefficient is null, or negative, nothing is done.
0419   //! - The new multiplicity of a knot is limited to the degree of this BSpline surface in the
0420   //! corresponding parametric direction.
0421   //! Exceptions
0422   //! Standard_ConstructionError if a knot value to
0423   //! insert is outside the bounds of this BSpline surface in
0424   //! the specified parametric direction. The comparison
0425   //! uses the precision criterion ParametricTolerance.
0426   Standard_EXPORT void InsertVKnots(const NCollection_Array1<double>& Knots,
0427                                     const NCollection_Array1<int>&    Mults,
0428                                     const double                      ParametricTolerance = 0.0,
0429                                     const bool                        Add                 = true);
0430 
0431   //! Reduces to M the multiplicity of the knot of index
0432   //! Index in the U parametric direction. If M is 0, the knot is removed.
0433   //! With a modification of this type, the table of poles is also modified.
0434   //! Two different algorithms are used systematically to
0435   //! compute the new poles of the surface. For each
0436   //! pole, the distance between the pole calculated
0437   //! using the first algorithm and the same pole
0438   //! calculated using the second algorithm, is checked. If
0439   //! this distance is less than Tolerance it ensures that
0440   //! the surface is not modified by more than Tolerance.
0441   //! Under these conditions, the function returns true;
0442   //! otherwise, it returns false.
0443   //! A low tolerance prevents modification of the
0444   //! surface. A high tolerance "smoothes" the surface.
0445   //! Exceptions
0446   //! Standard_OutOfRange if Index is outside the
0447   //! bounds of the knots table of this BSpline surface.
0448   Standard_EXPORT bool RemoveUKnot(const int Index, const int M, const double Tolerance);
0449 
0450   //! Reduces to M the multiplicity of the knot of index
0451   //! Index in the V parametric direction. If M is 0, the knot is removed.
0452   //! With a modification of this type, the table of poles is also modified.
0453   //! Two different algorithms are used systematically to
0454   //! compute the new poles of the surface. For each
0455   //! pole, the distance between the pole calculated
0456   //! using the first algorithm and the same pole
0457   //! calculated using the second algorithm, is checked. If
0458   //! this distance is less than Tolerance it ensures that
0459   //! the surface is not modified by more than Tolerance.
0460   //! Under these conditions, the function returns true;
0461   //! otherwise, it returns false.
0462   //! A low tolerance prevents modification of the
0463   //! surface. A high tolerance "smoothes" the surface.
0464   //! Exceptions
0465   //! Standard_OutOfRange if Index is outside the
0466   //! bounds of the knots table of this BSpline surface.
0467   Standard_EXPORT bool RemoveVKnot(const int Index, const int M, const double Tolerance);
0468 
0469   //! Increases the multiplicity of the knot of range UIndex
0470   //! in the UKnots sequence.
0471   //! M is the new multiplicity. M must be greater than the
0472   //! previous multiplicity and lower or equal to the degree
0473   //! of the surface in the U parametric direction.
0474   //! Raised if M is not in the range [1, UDegree]
0475   //!
0476   //! Raised if UIndex is not in the range [FirstUKnotIndex,
0477   //! LastUKnotIndex] given by the methods with the same name.
0478   Standard_EXPORT void IncreaseUMultiplicity(const int UIndex, const int M);
0479 
0480   //! Increases until order M the multiplicity of the set of knots
0481   //! FromI1,...., ToI2 in the U direction. This method can be used
0482   //! to make a B_spline surface into a PiecewiseBezier B_spline
0483   //! surface.
0484   //! If <me> was uniform, it can become non uniform.
0485   //!
0486   //! Raised if FromI1 or ToI2 is out of the range [FirstUKnotIndex,
0487   //! LastUKnotIndex].
0488   //!
0489   //! M should be greater than the previous multiplicity of the
0490   //! all the knots FromI1,..., ToI2 and lower or equal to the
0491   //! Degree of the surface in the U parametric direction.
0492   Standard_EXPORT void IncreaseUMultiplicity(const int FromI1, const int ToI2, const int M);
0493 
0494   //! Increments the multiplicity of the consecutives uknots FromI1..ToI2
0495   //! by step. The multiplicity of each knot FromI1,.....,ToI2 must be
0496   //! lower or equal to the UDegree of the B_spline.
0497   //!
0498   //! Raised if FromI1 or ToI2 is not in the range
0499   //! [FirstUKnotIndex, LastUKnotIndex]
0500   //!
0501   //! Raised if one knot has a multiplicity greater than UDegree.
0502   Standard_EXPORT void IncrementUMultiplicity(const int FromI1, const int ToI2, const int Step);
0503 
0504   //! Increases the multiplicity of a knot in the V direction.
0505   //! M is the new multiplicity.
0506   //!
0507   //! M should be greater than the previous multiplicity and lower
0508   //! than the degree of the surface in the V parametric direction.
0509   //!
0510   //! Raised if VIndex is not in the range [FirstVKnotIndex,
0511   //! LastVKnotIndex] given by the methods with the same name.
0512   Standard_EXPORT void IncreaseVMultiplicity(const int VIndex, const int M);
0513 
0514   //! Increases until order M the multiplicity of the set of knots
0515   //! FromI1,...., ToI2 in the V direction. This method can be used to
0516   //! make a BSplineSurface into a PiecewiseBezier B_spline
0517   //! surface. If <me> was uniform, it can become non-uniform.
0518   //!
0519   //! Raised if FromI1 or ToI2 is out of the range [FirstVKnotIndex,
0520   //! LastVKnotIndex] given by the methods with the same name.
0521   //!
0522   //! M should be greater than the previous multiplicity of the
0523   //! all the knots FromI1,..., ToI2 and lower or equal to the
0524   //! Degree of the surface in the V parametric direction.
0525   Standard_EXPORT void IncreaseVMultiplicity(const int FromI1, const int ToI2, const int M);
0526 
0527   //! Increments the multiplicity of the consecutives vknots FromI1..ToI2
0528   //! by step. The multiplicity of each knot FromI1,.....,ToI2 must be
0529   //! lower or equal to the VDegree of the B_spline.
0530   //!
0531   //! Raised if FromI1 or ToI2 is not in the range
0532   //! [FirstVKnotIndex, LastVKnotIndex]
0533   //!
0534   //! Raised if one knot has a multiplicity greater than VDegree.
0535   Standard_EXPORT void IncrementVMultiplicity(const int FromI1, const int ToI2, const int Step);
0536 
0537   //! Inserts a knot value in the sequence of UKnots. If U is a knot
0538   //! value this method increases the multiplicity of the knot if the
0539   //! previous multiplicity was lower than M else it does nothing. The
0540   //! tolerance criterion is ParametricTolerance. ParametricTolerance
0541   //! should be greater or equal than Resolution from package gp.
0542   //!
0543   //! Raised if U is out of the bounds [U1, U2] given by the methods
0544   //! Bounds, the criterion ParametricTolerance is used.
0545   //! Raised if M is not in the range [1, UDegree].
0546   Standard_EXPORT void InsertUKnot(const double U,
0547                                    const int    M,
0548                                    const double ParametricTolerance,
0549                                    const bool   Add = true);
0550 
0551   //! Inserts a knot value in the sequence of VKnots. If V is a knot
0552   //! value this method increases the multiplicity of the knot if the
0553   //! previous multiplicity was lower than M otherwise it does nothing.
0554   //! The tolerance criterion is ParametricTolerance.
0555   //! ParametricTolerance should be greater or equal than Resolution
0556   //! from package gp.
0557   //!
0558   //! raises if V is out of the Bounds [V1, V2] given by the methods
0559   //! Bounds, the criterion ParametricTolerance is used.
0560   //! raises if M is not in the range [1, VDegree].
0561   Standard_EXPORT void InsertVKnot(const double V,
0562                                    const int    M,
0563                                    const double ParametricTolerance,
0564                                    const bool   Add = true);
0565 
0566   //! Segments the surface between U1 and U2 in the U-Direction.
0567   //! between V1 and V2 in the V-Direction.
0568   //! The control points are modified, the first and the last point
0569   //! are not the same.
0570   //!
0571   //! Parameters theUTolerance, theVTolerance define the possible proximity along the corresponding
0572   //! direction of the segment boundaries and B-spline knots to treat them as equal.
0573   //!
0574   //! Warnings :
0575   //! Even if <me> is not closed it can become closed after the
0576   //! segmentation for example if U1 or U2 are out of the bounds
0577   //! of the surface <me> or if the surface makes loop.
0578   //! raises if U2 < U1 or V2 < V1.
0579   //! Standard_DomainError if U2 - U1 exceeds the uperiod for uperiodic surfaces.
0580   //! i.e. ((U2 - U1) - UPeriod) > Precision::PConfusion().
0581   //! Standard_DomainError if V2 - V1 exceeds the vperiod for vperiodic surfaces.
0582   //! i.e. ((V2 - V1) - VPeriod) > Precision::PConfusion()).
0583   Standard_EXPORT void Segment(const double U1,
0584                                const double U2,
0585                                const double V1,
0586                                const double V2,
0587                                const double theUTolerance = Precision::PConfusion(),
0588                                const double theVTolerance = Precision::PConfusion());
0589 
0590   //! Segments the surface between U1 and U2 in the U-Direction.
0591   //! between V1 and V2 in the V-Direction.
0592   //!
0593   //! same as Segment but do nothing if U1 and U2 (resp. V1 and V2) are
0594   //! equal to the bounds in U (resp. in V) of <me>.
0595   //! For example, if <me> is periodic in V, it will be always periodic
0596   //! in V after the segmentation if the bounds in V are unchanged
0597   //!
0598   //! Parameters theUTolerance, theVTolerance define the possible proximity along the corresponding
0599   //! direction of the segment boundaries and B-spline knots to treat them as equal.
0600   //!
0601   //! Warnings :
0602   //! Even if <me> is not closed it can become closed after the
0603   //! segmentation for example if U1 or U2 are out of the bounds
0604   //! of the surface <me> or if the surface makes loop.
0605   //! raises if U2 < U1 or V2 < V1.
0606   //! Standard_DomainError if U2 - U1 exceeds the uperiod for uperiodic surfaces.
0607   //! i.e. ((U2 - U1) - UPeriod) > Precision::PConfusion().
0608   //! Standard_DomainError if V2 - V1 exceeds the vperiod for vperiodic surfaces.
0609   //! i.e. ((V2 - V1) - VPeriod) > Precision::PConfusion()).
0610   Standard_EXPORT void CheckAndSegment(const double U1,
0611                                        const double U2,
0612                                        const double V1,
0613                                        const double V2,
0614                                        const double theUTolerance = Precision::PConfusion(),
0615                                        const double theVTolerance = Precision::PConfusion());
0616 
0617   //! Substitutes the UKnots of range UIndex with K.
0618   //!
0619   //! Raised if UIndex < 1 or UIndex > NbUKnots
0620   //!
0621   //! Raised if K >= UKnots(UIndex+1) or K <= UKnots(UIndex-1)
0622   Standard_EXPORT void SetUKnot(const int UIndex, const double K);
0623 
0624   //! Changes all the U-knots of the surface.
0625   //! The multiplicity of the knots are not modified.
0626   //!
0627   //! Raised if there is an index such that UK (Index+1) <= UK (Index).
0628   //!
0629   //! Raised if UK.Lower() < 1 or UK.Upper() > NbUKnots
0630   Standard_EXPORT void SetUKnots(const NCollection_Array1<double>& UK);
0631 
0632   //! Changes the value of the UKnots of range UIndex and
0633   //! increases its multiplicity.
0634   //!
0635   //! Raised if UIndex is not in the range [FirstUKnotIndex,
0636   //! LastUKnotIndex] given by the methods with the same name.
0637   //!
0638   //! Raised if K >= UKnots(UIndex+1) or K <= UKnots(UIndex-1)
0639   //! M must be lower than UDegree and greater than the previous
0640   //! multiplicity of the knot of range UIndex.
0641   Standard_EXPORT void SetUKnot(const int UIndex, const double K, const int M);
0642 
0643   //! Substitutes the VKnots of range VIndex with K.
0644   //!
0645   //! Raised if VIndex < 1 or VIndex > NbVKnots
0646   //!
0647   //! Raised if K >= VKnots(VIndex+1) or K <= VKnots(VIndex-1)
0648   Standard_EXPORT void SetVKnot(const int VIndex, const double K);
0649 
0650   //! Changes all the V-knots of the surface.
0651   //! The multiplicity of the knots are not modified.
0652   //!
0653   //! Raised if there is an index such that VK (Index+1) <= VK (Index).
0654   //!
0655   //! Raised if VK.Lower() < 1 or VK.Upper() > NbVKnots
0656   Standard_EXPORT void SetVKnots(const NCollection_Array1<double>& VK);
0657 
0658   //! Changes the value of the VKnots of range VIndex and increases
0659   //! its multiplicity.
0660   //!
0661   //! Raised if VIndex is not in the range [FirstVKnotIndex,
0662   //! LastVKnotIndex] given by the methods with the same name.
0663   //!
0664   //! Raised if K >= VKnots(VIndex+1) or K <= VKnots(VIndex-1)
0665   //! M must be lower than VDegree and greater than the previous
0666   //! multiplicity of the knot of range VIndex.
0667   Standard_EXPORT void SetVKnot(const int VIndex, const double K, const int M);
0668 
0669   //! Locates the parametric value U in the sequence of UKnots.
0670   //! If "WithKnotRepetition" is True we consider the knot's
0671   //! representation with repetition of multiple knot value,
0672   //! otherwise we consider the knot's representation with
0673   //! no repetition of multiple knot values.
0674   //! UKnots (I1) <= U <= UKnots (I2)
0675   //! . if I1 = I2 U is a knot value (the tolerance criterion
0676   //! ParametricTolerance is used).
0677   //! . if I1 < 1 => U < UKnots(1) - std::abs(ParametricTolerance)
0678   //! . if I2 > NbUKnots => U > UKnots(NbUKnots)+std::abs(ParametricTolerance)
0679   Standard_EXPORT void LocateU(const double U,
0680                                const double ParametricTolerance,
0681                                int&         I1,
0682                                int&         I2,
0683                                const bool   WithKnotRepetition = false) const;
0684 
0685   //! Locates the parametric value V in the sequence of knots.
0686   //! If "WithKnotRepetition" is True we consider the knot's
0687   //! representation with repetition of multiple knot value,
0688   //! otherwise we consider the knot's representation with
0689   //! no repetition of multiple knot values.
0690   //! VKnots (I1) <= V <= VKnots (I2)
0691   //! . if I1 = I2 V is a knot value (the tolerance criterion
0692   //! ParametricTolerance is used).
0693   //! . if I1 < 1 => V < VKnots(1) - std::abs(ParametricTolerance)
0694   //! . if I2 > NbVKnots => V > VKnots(NbVKnots)+std::abs(ParametricTolerance)
0695   //! poles insertion and removing
0696   //! The following methods are available only if the surface
0697   //! is Uniform or QuasiUniform in the considered direction
0698   //! The knot repartition is modified.
0699   Standard_EXPORT void LocateV(const double V,
0700                                const double ParametricTolerance,
0701                                int&         I1,
0702                                int&         I2,
0703                                const bool   WithKnotRepetition = false) const;
0704 
0705   //! Substitutes the pole of range (UIndex, VIndex) with P.
0706   //! If the surface is rational the weight of range (UIndex, VIndex)
0707   //! is not modified.
0708   //!
0709   //! Raised if UIndex < 1 or UIndex > NbUPoles or VIndex < 1 or
0710   //! VIndex > NbVPoles.
0711   Standard_EXPORT void SetPole(const int UIndex, const int VIndex, const gp_Pnt& P);
0712 
0713   //! Substitutes the pole and the weight of range (UIndex, VIndex)
0714   //! with P and W.
0715   //!
0716   //! Raised if UIndex < 1 or UIndex > NbUPoles or VIndex < 1 or
0717   //! VIndex > NbVPoles.
0718   //! Raised if Weight <= Resolution from package gp.
0719   Standard_EXPORT void SetPole(const int     UIndex,
0720                                const int     VIndex,
0721                                const gp_Pnt& P,
0722                                const double  Weight);
0723 
0724   //! Changes a column of poles or a part of this column.
0725   //! Raised if Vindex < 1 or VIndex > NbVPoles.
0726   //!
0727   //! Raised if CPoles.Lower() < 1 or CPoles.Upper() > NbUPoles.
0728   Standard_EXPORT void SetPoleCol(const int VIndex, const NCollection_Array1<gp_Pnt>& CPoles);
0729 
0730   //! Changes a column of poles or a part of this column with the
0731   //! corresponding weights. If the surface was rational it can
0732   //! become non rational. If the surface was non rational it can
0733   //! become rational.
0734   //! Raised if Vindex < 1 or VIndex > NbVPoles.
0735   //!
0736   //! Raised if CPoles.Lower() < 1 or CPoles.Upper() > NbUPoles
0737   //! Raised if the bounds of CPoleWeights are not the same as the
0738   //! bounds of CPoles.
0739   //! Raised if one of the weight value of CPoleWeights is lower or
0740   //! equal to Resolution from package gp.
0741   Standard_EXPORT void SetPoleCol(const int                         VIndex,
0742                                   const NCollection_Array1<gp_Pnt>& CPoles,
0743                                   const NCollection_Array1<double>& CPoleWeights);
0744 
0745   //! Changes a row of poles or a part of this row with the
0746   //! corresponding weights. If the surface was rational it can
0747   //! become non rational. If the surface was non rational it can
0748   //! become rational.
0749   //! Raised if Uindex < 1 or UIndex > NbUPoles.
0750   //!
0751   //! Raised if CPoles.Lower() < 1 or CPoles.Upper() > NbVPoles
0752   //! raises if the bounds of CPoleWeights are not the same as the
0753   //! bounds of CPoles.
0754   //! Raised if one of the weight value of CPoleWeights is lower or
0755   //! equal to Resolution from package gp.
0756   Standard_EXPORT void SetPoleRow(const int                         UIndex,
0757                                   const NCollection_Array1<gp_Pnt>& CPoles,
0758                                   const NCollection_Array1<double>& CPoleWeights);
0759 
0760   //! Changes a row of poles or a part of this row.
0761   //! Raised if Uindex < 1 or UIndex > NbUPoles.
0762   //!
0763   //! Raised if CPoles.Lower() < 1 or CPoles.Upper() > NbVPoles.
0764   Standard_EXPORT void SetPoleRow(const int UIndex, const NCollection_Array1<gp_Pnt>& CPoles);
0765 
0766   //! Changes the weight of the pole of range UIndex, VIndex.
0767   //! If the surface was non rational it can become rational.
0768   //! If the surface was rational it can become non rational.
0769   //!
0770   //! Raised if UIndex < 1 or UIndex > NbUPoles or VIndex < 1 or
0771   //! VIndex > NbVPoles
0772   //!
0773   //! Raised if weight is lower or equal to Resolution from
0774   //! package gp
0775   Standard_EXPORT void SetWeight(const int UIndex, const int VIndex, const double Weight);
0776 
0777   //! Changes a column of weights of a part of this column.
0778   //!
0779   //! Raised if VIndex < 1 or VIndex > NbVPoles
0780   //!
0781   //! Raised if CPoleWeights.Lower() < 1 or
0782   //! CPoleWeights.Upper() > NbUPoles.
0783   //! Raised if a weight value is lower or equal to Resolution
0784   //! from package gp.
0785   Standard_EXPORT void SetWeightCol(const int                         VIndex,
0786                                     const NCollection_Array1<double>& CPoleWeights);
0787 
0788   //! Changes a row of weights or a part of this row.
0789   //!
0790   //! Raised if UIndex < 1 or UIndex > NbUPoles
0791   //!
0792   //! Raised if CPoleWeights.Lower() < 1 or
0793   //! CPoleWeights.Upper() > NbVPoles.
0794   //! Raised if a weight value is lower or equal to Resolution
0795   //! from package gp.
0796   Standard_EXPORT void SetWeightRow(const int                         UIndex,
0797                                     const NCollection_Array1<double>& CPoleWeights);
0798 
0799   //! Move a point with parameter U and V to P.
0800   //! given u,v as parameters) to reach a new position
0801   //! UIndex1, UIndex2, VIndex1, VIndex2:
0802   //! indicates the poles which can be moved
0803   //! if Problem in BSplineBasis calculation, no change
0804   //! for the curve and
0805   //! UFirstIndex, VLastIndex = 0
0806   //! VFirstIndex, VLastIndex = 0
0807   //!
0808   //! Raised if UIndex1 < UIndex2 or VIndex1 < VIndex2 or
0809   //! UIndex1 < 1 || UIndex1 > NbUPoles or
0810   //! UIndex2 < 1 || UIndex2 > NbUPoles
0811   //! VIndex1 < 1 || VIndex1 > NbVPoles or
0812   //! VIndex2 < 1 || VIndex2 > NbVPoles
0813   //! characteristics of the surface
0814   Standard_EXPORT void MovePoint(const double  U,
0815                                  const double  V,
0816                                  const gp_Pnt& P,
0817                                  const int     UIndex1,
0818                                  const int     UIndex2,
0819                                  const int     VIndex1,
0820                                  const int     VIndex2,
0821                                  int&          UFirstIndex,
0822                                  int&          ULastIndex,
0823                                  int&          VFirstIndex,
0824                                  int&          VLastIndex);
0825 
0826   //! Returns true if the first control points row and the last
0827   //! control points row are identical. The tolerance criterion
0828   //! is Resolution from package gp.
0829   Standard_EXPORT bool IsUClosed() const final;
0830 
0831   //! Returns true if the first control points column and the
0832   //! last last control points column are identical.
0833   //! The tolerance criterion is Resolution from package gp.
0834   Standard_EXPORT bool IsVClosed() const final;
0835 
0836   //! Returns True if the order of continuity of the surface in the
0837   //! U direction is N.
0838   //! Raised if N < 0.
0839   Standard_EXPORT bool IsCNu(const int N) const final;
0840 
0841   //! Returns True if the order of continuity of the surface
0842   //! in the V direction is N.
0843   //! Raised if N < 0.
0844   Standard_EXPORT bool IsCNv(const int N) const final;
0845 
0846   //! Returns True if the surface is closed in the U direction
0847   //! and if the B-spline has been turned into a periodic surface
0848   //! using the function SetUPeriodic.
0849   Standard_EXPORT bool IsUPeriodic() const final;
0850 
0851   //! Returns False if for each row of weights all the weights
0852   //! are identical.
0853   //! The tolerance criterion is resolution from package gp.
0854   //! Example :
0855   //! |1.0, 1.0, 1.0|
0856   //! if Weights =  |0.5, 0.5, 0.5|   returns False
0857   //! |2.0, 2.0, 2.0|
0858   Standard_EXPORT bool IsURational() const;
0859 
0860   //! Returns True if the surface is closed in the V direction
0861   //! and if the B-spline has been turned into a periodic
0862   //! surface using the function SetVPeriodic.
0863   Standard_EXPORT bool IsVPeriodic() const final;
0864 
0865   //! Returns False if for each column of weights all the weights
0866   //! are identical.
0867   //! The tolerance criterion is resolution from package gp.
0868   //! Examples :
0869   //! |1.0, 2.0, 0.5|
0870   //! if Weights =  |1.0, 2.0, 0.5|   returns False
0871   //! |1.0, 2.0, 0.5|
0872   Standard_EXPORT bool IsVRational() const;
0873 
0874   //! Returns the parametric bounds of the surface.
0875   //! Warnings :
0876   //! These parametric values are the bounds of the array of
0877   //! knots UKnots and VKnots only if the first knots and the
0878   //! last knots have a multiplicity equal to UDegree + 1 or
0879   //! VDegree + 1
0880   Standard_EXPORT void Bounds(double& U1, double& U2, double& V1, double& V2) const final;
0881 
0882   //! Returns the continuity of the surface :
0883   //! C0 : only geometric continuity,
0884   //! C1 : continuity of the first derivative all along the Surface,
0885   //! C2 : continuity of the second derivative all along the Surface,
0886   //! C3 : continuity of the third derivative all along the Surface,
0887   //! CN : the order of continuity is infinite.
0888   //! A B-spline surface is infinitely continuously differentiable
0889   //! for the couple of parameters U, V such that U != UKnots(i)
0890   //! and V != VKnots(i). The continuity of the surface at a knot
0891   //! value depends on the multiplicity of this knot.
0892   //! Example :
0893   //! If the surface is C1 in the V direction and C2 in the U
0894   //! direction this function returns Shape = C1.
0895   Standard_EXPORT GeomAbs_Shape Continuity() const final;
0896 
0897   //! Computes the Index of the UKnots which gives the first
0898   //! parametric value of the surface in the U direction.
0899   //! The UIso curve corresponding to this value is a
0900   //! boundary curve of the surface.
0901   Standard_EXPORT int FirstUKnotIndex() const;
0902 
0903   //! Computes the Index of the VKnots which gives the
0904   //! first parametric value of the surface in the V direction.
0905   //! The VIso curve corresponding to this knot is a boundary
0906   //! curve of the surface.
0907   Standard_EXPORT int FirstVKnotIndex() const;
0908 
0909   //! Computes the Index of the UKnots which gives the
0910   //! last parametric value of the surface in the U direction.
0911   //! The UIso curve corresponding to this knot is a boundary
0912   //! curve of the surface.
0913   Standard_EXPORT int LastUKnotIndex() const;
0914 
0915   //! Computes the Index of the VKnots which gives the
0916   //! last parametric value of the surface in the V direction.
0917   //! The VIso curve corresponding to this knot is a
0918   //! boundary curve of the surface.
0919   Standard_EXPORT int LastVKnotIndex() const;
0920 
0921   //! Returns the number of knots in the U direction.
0922   Standard_EXPORT int NbUKnots() const;
0923 
0924   //! Returns number of poles in the U direction.
0925   Standard_EXPORT int NbUPoles() const;
0926 
0927   //! Returns the number of knots in the V direction.
0928   Standard_EXPORT int NbVKnots() const;
0929 
0930   //! Returns the number of poles in the V direction.
0931   Standard_EXPORT int NbVPoles() const;
0932 
0933   //! Returns the pole of range (UIndex, VIndex).
0934   //!
0935   //! Raised if UIndex < 1 or UIndex > NbUPoles or VIndex < 1 or
0936   //! VIndex > NbVPoles.
0937   Standard_EXPORT const gp_Pnt& Pole(const int UIndex, const int VIndex) const;
0938 
0939   //! Returns the poles of the B-spline surface.
0940   //!
0941   //! Raised if the length of P in the U and V direction
0942   //! is not equal to NbUpoles and NbVPoles.
0943   Standard_DEPRECATED("use Poles() returning const reference instead")
0944   Standard_EXPORT void Poles(NCollection_Array2<gp_Pnt>& P) const;
0945 
0946   //! Returns the poles of the B-spline surface.
0947   Standard_EXPORT const NCollection_Array2<gp_Pnt>& Poles() const;
0948 
0949   //! Returns the degree of the normalized B-splines Ni,n in the U
0950   //! direction.
0951   Standard_EXPORT int UDegree() const;
0952 
0953   //! Returns the Knot value of range UIndex.
0954   //! Raised if UIndex < 1 or UIndex > NbUKnots
0955   Standard_EXPORT double UKnot(const int UIndex) const;
0956 
0957   //! Returns NonUniform or Uniform or QuasiUniform or
0958   //! PiecewiseBezier. If all the knots differ by a
0959   //! positive constant from the preceding knot in the U
0960   //! direction the B-spline surface can be :
0961   //! - Uniform if all the knots are of multiplicity 1,
0962   //! - QuasiUniform if all the knots are of multiplicity 1
0963   //! except for the first and last knot which are of
0964   //! multiplicity Degree + 1,
0965   //! - PiecewiseBezier if the first and last knots have
0966   //! multiplicity Degree + 1 and if interior knots have
0967   //! multiplicity Degree
0968   //! otherwise the surface is non uniform in the U direction
0969   //! The tolerance criterion is Resolution from package gp.
0970   Standard_EXPORT GeomAbs_BSplKnotDistribution UKnotDistribution() const;
0971 
0972   //! Returns the knots in the U direction.
0973   //!
0974   //! Raised if the length of Ku is not equal to the number of knots
0975   //! in the U direction.
0976   Standard_DEPRECATED("use UKnots() returning const reference instead")
0977   Standard_EXPORT void UKnots(NCollection_Array1<double>& Ku) const;
0978 
0979   //! Returns the knots in the U direction.
0980   Standard_EXPORT const NCollection_Array1<double>& UKnots() const;
0981 
0982   //! Returns the uknots sequence.
0983   //! In this sequence the knots with a multiplicity greater than 1
0984   //! are repeated.
0985   //! Example :
0986   //! Ku = {k1, k1, k1, k2, k3, k3, k4, k4, k4}
0987   //!
0988   //! Raised if the length of Ku is not equal to NbUPoles + UDegree + 1
0989   Standard_DEPRECATED("use UKnotSequence() returning const reference instead")
0990   Standard_EXPORT void UKnotSequence(NCollection_Array1<double>& Ku) const;
0991 
0992   //! Returns the uknots sequence.
0993   //! In this sequence the knots with a multiplicity greater than 1
0994   //! are repeated.
0995   //! Example :
0996   //! Ku = {k1, k1, k1, k2, k3, k3, k4, k4, k4}
0997   Standard_EXPORT const NCollection_Array1<double>& UKnotSequence() const;
0998 
0999   //! Returns the multiplicity value of knot of range UIndex in
1000   //! the u direction.
1001   //! Raised if UIndex < 1 or UIndex > NbUKnots.
1002   Standard_EXPORT int UMultiplicity(const int UIndex) const;
1003 
1004   //! Returns the multiplicities of the knots in the U direction.
1005   //!
1006   //! Raised if the length of Mu is not equal to the number of
1007   //! knots in the U direction.
1008   Standard_DEPRECATED("use UMultiplicities() returning const reference instead")
1009   Standard_EXPORT void UMultiplicities(NCollection_Array1<int>& Mu) const;
1010 
1011   //! Returns the multiplicities of the knots in the U direction.
1012   Standard_EXPORT const NCollection_Array1<int>& UMultiplicities() const;
1013 
1014   //! Returns the degree of the normalized B-splines Ni,d in the
1015   //! V direction.
1016   Standard_EXPORT int VDegree() const;
1017 
1018   //! Returns the Knot value of range VIndex.
1019   //! Raised if VIndex < 1 or VIndex > NbVKnots
1020   Standard_EXPORT double VKnot(const int VIndex) const;
1021 
1022   //! Returns NonUniform or Uniform or QuasiUniform or
1023   //! PiecewiseBezier. If all the knots differ by a positive
1024   //! constant from the preceding knot in the V direction the
1025   //! B-spline surface can be :
1026   //! - Uniform if all the knots are of multiplicity 1,
1027   //! - QuasiUniform if all the knots are of multiplicity 1
1028   //! except for the first and last knot which are of
1029   //! multiplicity Degree + 1,
1030   //! - PiecewiseBezier if the first and last knots have
1031   //! multiplicity Degree + 1 and if interior knots have
1032   //! multiplicity Degree
1033   //! otherwise the surface is non uniform in the V direction.
1034   //! The tolerance criterion is Resolution from package gp.
1035   Standard_EXPORT GeomAbs_BSplKnotDistribution VKnotDistribution() const;
1036 
1037   //! Returns the knots in the V direction.
1038   //!
1039   //! Raised if the length of Kv is not equal to the number of
1040   //! knots in the V direction.
1041   Standard_DEPRECATED("use VKnots() returning const reference instead")
1042   Standard_EXPORT void VKnots(NCollection_Array1<double>& Kv) const;
1043 
1044   //! Returns the knots in the V direction.
1045   Standard_EXPORT const NCollection_Array1<double>& VKnots() const;
1046 
1047   //! Returns the vknots sequence.
1048   //! In this sequence the knots with a multiplicity greater than 1
1049   //! are repeated.
1050   //! Example :
1051   //! Kv = {k1, k1, k1, k2, k3, k3, k4, k4, k4}
1052   //!
1053   //! Raised if the length of Kv is not equal to NbVPoles + VDegree + 1
1054   Standard_DEPRECATED("use VKnotSequence() returning const reference instead")
1055   Standard_EXPORT void VKnotSequence(NCollection_Array1<double>& Kv) const;
1056 
1057   //! Returns the vknots sequence.
1058   //! In this sequence the knots with a multiplicity greater than 1
1059   //! are repeated.
1060   //! Example :
1061   //! Ku = {k1, k1, k1, k2, k3, k3, k4, k4, k4}
1062   Standard_EXPORT const NCollection_Array1<double>& VKnotSequence() const;
1063 
1064   //! Returns the multiplicity value of knot of range VIndex in
1065   //! the v direction.
1066   //! Raised if VIndex < 1 or VIndex > NbVKnots
1067   Standard_EXPORT int VMultiplicity(const int VIndex) const;
1068 
1069   //! Returns the multiplicities of the knots in the V direction.
1070   //!
1071   //! Raised if the length of Mv is not equal to the number of
1072   //! knots in the V direction.
1073   Standard_DEPRECATED("use VMultiplicities() returning const reference instead")
1074   Standard_EXPORT void VMultiplicities(NCollection_Array1<int>& Mv) const;
1075 
1076   //! Returns the multiplicities of the knots in the V direction.
1077   Standard_EXPORT const NCollection_Array1<int>& VMultiplicities() const;
1078 
1079   //! Returns the weight value of range UIndex, VIndex.
1080   //!
1081   //! Raised if UIndex < 1 or UIndex > NbUPoles or VIndex < 1
1082   //! or VIndex > NbVPoles.
1083   Standard_EXPORT double Weight(const int UIndex, const int VIndex) const;
1084 
1085   //! Returns the weights of the B-spline surface.
1086   //!
1087   //! Raised if the length of W in the U and V direction is
1088   //! not equal to NbUPoles and NbVPoles.
1089   Standard_DEPRECATED("use Weights() returning const pointer instead")
1090   Standard_EXPORT void Weights(NCollection_Array2<double>& W) const;
1091 
1092   //! Returns a const reference to the weights array.
1093   //! For rational surfaces: the internal owning weights array.
1094   //! For non-rational surfaces: a non-owning view of unit weights from BSplSLib.
1095   //! The array is always sized to match NbUPoles() x NbVPoles().
1096   //! @warning Do NOT modify elements through the returned reference.
1097   const NCollection_Array2<double>& WeightsArray() const { return myWeights; }
1098 
1099   //! Returns the weights of the B-spline surface.
1100   //! value and derivatives computation
1101   Standard_EXPORT const NCollection_Array2<double>* Weights() const;
1102 
1103   //! Computes the point of parameter (U, V) on the surface.
1104   //! Raises an exception on failure.
1105   Standard_EXPORT gp_Pnt EvalD0(const double U, const double V) const final;
1106 
1107   //! Computes the point and first partial derivatives at (U, V).
1108   //! Raises an exception if the surface continuity is not C1.
1109   Standard_EXPORT Geom_Surface::ResD1 EvalD1(const double U, const double V) const final;
1110 
1111   //! Computes the point and partial derivatives up to 2nd order at (U, V).
1112   //! Raises an exception if the surface continuity is not C2.
1113   Standard_EXPORT Geom_Surface::ResD2 EvalD2(const double U, const double V) const final;
1114 
1115   //! Computes the point and partial derivatives up to 3rd order at (U, V).
1116   //! Raises an exception if the surface continuity is not C3.
1117   Standard_EXPORT Geom_Surface::ResD3 EvalD3(const double U, const double V) const final;
1118 
1119   //! Computes the derivative of order Nu in U and Nv in V at (U, V).
1120   //! Raises an exception on failure.
1121   //!
1122   //! Raised if the continuity of the surface is not CNu in the U
1123   //! direction and CNv in the V direction.
1124   //!
1125   //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
1126   //!
1127   //! The following functions computes the point for the
1128   //! parametric values (U, V) and the derivatives at
1129   //! this point on the B-spline surface patch delimited
1130   //! with the knots FromUK1, FromVK1 and the knots ToUK2,
1131   //! ToVK2. (U, V) can be out of these parametric bounds
1132   //! but for the computation we only use the definition
1133   //! of the surface between these knots. This method is
1134   //! useful to compute local derivative, if the order of
1135   //! continuity of the whole surface is not greater enough.
1136   //! Inside the parametric knot's domain previously defined
1137   //! the evaluations are the same as if we consider the whole
1138   //! definition of the surface. Of course the evaluations are
1139   //! different outside this parametric domain.
1140   Standard_EXPORT gp_Vec EvalDN(const double U,
1141                                 const double V,
1142                                 const int    Nu,
1143                                 const int    Nv) const final;
1144 
1145   //! Raised if FromUK1 = ToUK2 or FromVK1 = ToVK2.
1146   Standard_EXPORT void LocalD0(const double U,
1147                                const double V,
1148                                const int    FromUK1,
1149                                const int    ToUK2,
1150                                const int    FromVK1,
1151                                const int    ToVK2,
1152                                gp_Pnt&      P) const;
1153 
1154   //! Raised if the local continuity of the surface is not C1
1155   //! between the knots FromUK1, ToUK2 and FromVK1, ToVK2.
1156   //! Raised if FromUK1 = ToUK2 or FromVK1 = ToVK2.
1157   Standard_EXPORT void LocalD1(const double U,
1158                                const double V,
1159                                const int    FromUK1,
1160                                const int    ToUK2,
1161                                const int    FromVK1,
1162                                const int    ToVK2,
1163                                gp_Pnt&      P,
1164                                gp_Vec&      D1U,
1165                                gp_Vec&      D1V) const;
1166 
1167   //! Raised if the local continuity of the surface is not C2
1168   //! between the knots FromUK1, ToUK2 and FromVK1, ToVK2.
1169   //! Raised if FromUK1 = ToUK2 or FromVK1 = ToVK2.
1170   Standard_EXPORT void LocalD2(const double U,
1171                                const double V,
1172                                const int    FromUK1,
1173                                const int    ToUK2,
1174                                const int    FromVK1,
1175                                const int    ToVK2,
1176                                gp_Pnt&      P,
1177                                gp_Vec&      D1U,
1178                                gp_Vec&      D1V,
1179                                gp_Vec&      D2U,
1180                                gp_Vec&      D2V,
1181                                gp_Vec&      D2UV) const;
1182 
1183   //! Raised if the local continuity of the surface is not C3
1184   //! between the knots FromUK1, ToUK2 and FromVK1, ToVK2.
1185   //! Raised if FromUK1 = ToUK2 or FromVK1 = ToVK2.
1186   Standard_EXPORT void LocalD3(const double U,
1187                                const double V,
1188                                const int    FromUK1,
1189                                const int    ToUK2,
1190                                const int    FromVK1,
1191                                const int    ToVK2,
1192                                gp_Pnt&      P,
1193                                gp_Vec&      D1U,
1194                                gp_Vec&      D1V,
1195                                gp_Vec&      D2U,
1196                                gp_Vec&      D2V,
1197                                gp_Vec&      D2UV,
1198                                gp_Vec&      D3U,
1199                                gp_Vec&      D3V,
1200                                gp_Vec&      D3UUV,
1201                                gp_Vec&      D3UVV) const;
1202 
1203   //! Raised if the local continuity of the surface is not CNu
1204   //! between the knots FromUK1, ToUK2 and CNv between the knots
1205   //! FromVK1, ToVK2.
1206   //! Raised if FromUK1 = ToUK2 or FromVK1 = ToVK2.
1207   Standard_EXPORT gp_Vec LocalDN(const double U,
1208                                  const double V,
1209                                  const int    FromUK1,
1210                                  const int    ToUK2,
1211                                  const int    FromVK1,
1212                                  const int    ToVK2,
1213                                  const int    Nu,
1214                                  const int    Nv) const;
1215 
1216   //! Computes the point of parameter U, V on the BSpline surface patch
1217   //! defines between the knots UK1 UK2, VK1, VK2. U can be out of the
1218   //! bounds [Knot UK1, Knot UK2] and V can be outof the bounds
1219   //! [Knot VK1, Knot VK2] but for the computation we only use the
1220   //! definition of the surface between these knot values.
1221   //! Raises if FromUK1 = ToUK2 or FromVK1 = ToVK2.
1222   Standard_EXPORT gp_Pnt LocalValue(const double U,
1223                                     const double V,
1224                                     const int    FromUK1,
1225                                     const int    ToUK2,
1226                                     const int    FromVK1,
1227                                     const int    ToVK2) const;
1228 
1229   //! Computes the U isoparametric curve.
1230   //! A B-spline curve is returned.
1231   Standard_EXPORT occ::handle<Geom_Curve> UIso(const double U) const final;
1232 
1233   //! Computes the V isoparametric curve.
1234   //! A B-spline curve is returned.
1235   Standard_EXPORT occ::handle<Geom_Curve> VIso(const double V) const final;
1236 
1237   //! Computes the U isoparametric curve.
1238   //! If CheckRational=False, no try to make it non-rational.
1239   //! A B-spline curve is returned.
1240   Standard_EXPORT occ::handle<Geom_Curve> UIso(const double U, const bool CheckRational) const;
1241 
1242   //! Computes the V isoparametric curve.
1243   //! If CheckRational=False, no try to make it non-rational.
1244   //! A B-spline curve is returned.
1245   //! transformations
1246   Standard_EXPORT occ::handle<Geom_Curve> VIso(const double V, const bool CheckRational) const;
1247 
1248   //! Applies the transformation T to this BSpline surface.
1249   Standard_EXPORT void Transform(const gp_Trsf& T) final;
1250 
1251   //! Returns the value of the maximum degree of the normalized
1252   //! B-spline basis functions in the u and v directions.
1253   Standard_EXPORT static int MaxDegree();
1254 
1255   //! Computes two tolerance values for this BSpline
1256   //! surface, based on the given tolerance in 3D space
1257   //! Tolerance3D. The tolerances computed are:
1258   //! - UTolerance in the u parametric direction, and
1259   //! - VTolerance in the v parametric direction.
1260   //! If f(u,v) is the equation of this BSpline surface,
1261   //! UTolerance and VTolerance guarantee that :
1262   //! | u1 - u0 | < UTolerance and
1263   //! | v1 - v0 | < VTolerance
1264   //! ====> |f (u1,v1) - f (u0,v0)| < Tolerance3D
1265   Standard_EXPORT void Resolution(const double Tolerance3D, double& UTolerance, double& VTolerance);
1266 
1267   //! Creates a new object which is a copy of this BSpline surface.
1268   Standard_EXPORT occ::handle<Geom_Geometry> Copy() const final;
1269 
1270   //! Dumps the content of me into the stream
1271   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const final;
1272 
1273   DEFINE_STANDARD_RTTIEXT(Geom_BSplineSurface, Geom_BoundedSurface)
1274 
1275 protected:
1276   //! Segments the surface between U1 and U2 in the U-Direction.
1277   //! between V1 and V2 in the V-Direction.
1278   //! The control points are modified, the first and the last point
1279   //! are not the same.
1280   //!
1281   //! Parameters EpsU, EpsV define the proximity along U-Direction and V-Direction respectively.
1282   void segment(const double U1,
1283                const double U2,
1284                const double V1,
1285                const double V2,
1286                const double EpsU,
1287                const double EpsV,
1288                const bool   SegmentInU,
1289                const bool   SegmentInV);
1290 
1291 protected:
1292   //! Recompute the flatknots, the knotsdistribution, the continuity for U.
1293   void updateUKnots();
1294 
1295   //! Recompute the flatknots, the knotsdistribution, the continuity for V.
1296   void updateVKnots();
1297 
1298 private:
1299   NCollection_Array2<gp_Pnt>                 myPoles;
1300   NCollection_Array2<double>                 myWeights;
1301   NCollection_Array1<double>                 myUKnots;
1302   NCollection_Array1<double>                 myVKnots;
1303   NCollection_Array1<double>                 myUFlatKnots;
1304   NCollection_Array1<double>                 myVFlatKnots;
1305   NCollection_Array1<int>                    myUMults;
1306   NCollection_Array1<int>                    myVMults;
1307   occ::handle<GeomEval_RepSurfaceDesc::Base> myEvalRep;
1308   int                                        myUDeg          = 0;
1309   int                                        myVDeg          = 0;
1310   bool                                       myUPeriodic     = false;
1311   bool                                       myVPeriodic     = false;
1312   bool                                       myURational     = false;
1313   bool                                       myVRational     = false;
1314   GeomAbs_BSplKnotDistribution               myUKnotSet      = GeomAbs_NonUniform;
1315   GeomAbs_BSplKnotDistribution               myVKnotSet      = GeomAbs_NonUniform;
1316   GeomAbs_Shape                              myUSmooth       = GeomAbs_C0;
1317   GeomAbs_Shape                              myVSmooth       = GeomAbs_C0;
1318   double                                     myUMaxDerivInv  = 0.0;
1319   double                                     myVMaxDerivInv  = 0.0;
1320   bool                                       myMaxDerivInvOk = false;
1321 };
1322 
1323 #endif // _Geom_BSplineSurface_HeaderFile