Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 09:16:24

0001 // Created on: 1995-01-16
0002 // Created by: Remi LEQUETTE
0003 // Copyright (c) 1995-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 _GeomAPI_PointsToBSplineSurface_HeaderFile
0018 #define _GeomAPI_PointsToBSplineSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TColgp_Array2OfPnt.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <GeomAbs_Shape.hxx>
0027 #include <Approx_ParametrizationType.hxx>
0028 #include <TColStd_Array2OfReal.hxx>
0029 class Geom_BSplineSurface;
0030 
0031 //! This class is used to approximate or interpolate
0032 //! a BSplineSurface passing through an  Array2 of
0033 //! points, with a given continuity.
0034 //! Describes functions for building a BSpline
0035 //! surface which approximates or interpolates a set of points.
0036 //! A PointsToBSplineSurface object provides a framework for:
0037 //! -   defining the data of the BSpline surface to be built,
0038 //! -   implementing the approximation algorithm
0039 //! or the interpolation algorithm, and consulting the results.
0040 //! In fact, class contains 3 algorithms, 2 for approximation and 1
0041 //! for interpolation.
0042 //! First approximation algorithm is based on usual least square criterium:
0043 //! minimization of square distance between samplimg points and result surface.
0044 //! Second approximation algorithm uses least square criterium and additional
0045 //! minimization of some local characteristic of surface (first, second and third
0046 //! partial derivative), which allows managing shape of surface.
0047 //! Interpolation algorithm produces surface, which passes through sampling points.
0048 //!
0049 //! There is accordance between parametrization of result surface S(U, V) and
0050 //! indexes of array Points(i, j): first index corresponds U parameter of surface,
0051 //! second - V parameter of surface.
0052 //! So, points of any j-th column Points(*, j) represent any V isoline of surface,
0053 //! points of any i-th row Point(i, *) represent any U isoline of surface.
0054 //!
0055 //! For each sampling point parameters U, V are calculated according to
0056 //! type of parametrization, which can be Approx_ChordLength, Approx_Centripetal
0057 //! or Approx_IsoParametric. Default value is Approx_ChordLength.
0058 //! For ChordLength parametrisation U(i) = U(i-1) + P(i).Distance(P(i-1)),
0059 //! For Centripetal type  U(i) = U(i-1) + Sqrt(P(i).Distance(P(i-1))).
0060 //! Centripetal type can get better result for irregular distances between points.
0061 //!
0062 //! Approximation and interpolation algorithms can build periodical surface along U
0063 //! direction, which corresponds columns of array Points(i, j),
0064 //! if corresponding parameter (thePeriodic, see comments below) of called
0065 //! methods is set to True. Algorithm uses first row Points(1, *) as periodic boundary,
0066 //! so to avoid getting wrong surface it is necessary to keep distance between
0067 //! corresponding points of first and last rows of Points:
0068 //! Points(1, *) != Points(Upper, *).
0069 
0070 class GeomAPI_PointsToBSplineSurface
0071 {
0072 public:
0073   DEFINE_STANDARD_ALLOC
0074 
0075   //! Constructs an empty algorithm for
0076   //! approximation or interpolation of a surface.
0077   //! Use:
0078   //! -   an Init function to define and build the
0079   //! BSpline surface by approximation, or
0080   //! -   an Interpolate function to define and build
0081   //! the BSpline surface by interpolation.
0082   Standard_EXPORT GeomAPI_PointsToBSplineSurface();
0083 
0084   //! Approximates  a BSpline  Surface passing  through  an
0085   //! array of  Points.  The resulting BSpline will  have
0086   //! the following properties:
0087   //! 1- his degree will be in the range [Degmin,Degmax]
0088   //! 2- his  continuity will be  at  least <Continuity>
0089   //! 3- the distance from the point <Points> to the
0090   //! BSpline will be lower to Tol3D.
0091 
0092   Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
0093                                                  const Standard_Integer    DegMin     = 3,
0094                                                  const Standard_Integer    DegMax     = 8,
0095                                                  const GeomAbs_Shape       Continuity = GeomAbs_C2,
0096                                                  const Standard_Real       Tol3D      = 1.0e-3);
0097 
0098   //! Approximates  a BSpline  Surface passing  through  an
0099   //! array of  Points.  The resulting BSpline will  have
0100   //! the following properties:
0101   //! 1- his degree will be in the range [Degmin,Degmax]
0102   //! 2- his  continuity will be  at  least <Continuity>
0103   //! 3- the distance from the point <Points> to the
0104   //! BSpline will be lower to Tol3D.
0105 
0106   Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt&        Points,
0107                                                  const Approx_ParametrizationType ParType,
0108                                                  const Standard_Integer           DegMin = 3,
0109                                                  const Standard_Integer           DegMax = 8,
0110                                                  const GeomAbs_Shape Continuity = GeomAbs_C2,
0111                                                  const Standard_Real Tol3D      = 1.0e-3);
0112 
0113   //! Approximates  a BSpline  Surface passing  through  an
0114   //! array of  points using variational smoothing algorithm,
0115   //! which tries to minimize additional criterium:
0116   //! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion.
0117 
0118   Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
0119                                                  const Standard_Real       Weight1,
0120                                                  const Standard_Real       Weight2,
0121                                                  const Standard_Real       Weight3,
0122                                                  const Standard_Integer    DegMax     = 8,
0123                                                  const GeomAbs_Shape       Continuity = GeomAbs_C2,
0124                                                  const Standard_Real       Tol3D      = 1.0e-3);
0125 
0126   //! Approximates  a BSpline  Surface passing  through  an
0127   //! array of  Points.
0128   //!
0129   //! The points will be constructed as follow:
0130   //! P(i,j) = gp_Pnt( X0 + (i-1)*dX ,
0131   //! Y0 + (j-1)*dY ,
0132   //! ZPoints(i,j)   )
0133   //!
0134   //! The resulting BSpline will  have the following
0135   //! properties:
0136   //! 1- his degree will be in the range [Degmin,Degmax]
0137   //! 2- his  continuity will be  at  least <Continuity>
0138   //! 3- the distance from the point <Points> to the
0139   //! BSpline will be lower to Tol3D
0140   //! 4- the parametrization of the surface will verify:
0141   //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
0142 
0143   Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColStd_Array2OfReal& ZPoints,
0144                                                  const Standard_Real         X0,
0145                                                  const Standard_Real         dX,
0146                                                  const Standard_Real         Y0,
0147                                                  const Standard_Real         dY,
0148                                                  const Standard_Integer      DegMin = 3,
0149                                                  const Standard_Integer      DegMax = 8,
0150                                                  const GeomAbs_Shape Continuity     = GeomAbs_C2,
0151                                                  const Standard_Real Tol3D          = 1.0e-3);
0152 
0153   //! Approximates  a BSpline Surface passing  through  an
0154   //! array of  Point.  The resulting BSpline will  have
0155   //! the following properties:
0156   //! 1- his degree will be in the range [Degmin,Degmax]
0157   //! 2- his  continuity will be  at  least <Continuity>
0158   //! 3- the distance from the point <Points> to the
0159   //! BSpline will be lower to Tol3D.
0160 
0161   Standard_EXPORT void Init(const TColgp_Array2OfPnt& Points,
0162                             const Standard_Integer    DegMin     = 3,
0163                             const Standard_Integer    DegMax     = 8,
0164                             const GeomAbs_Shape       Continuity = GeomAbs_C2,
0165                             const Standard_Real       Tol3D      = 1.0e-3);
0166 
0167   //! Interpolates  a BSpline Surface passing  through  an
0168   //! array of  Point.  The resulting BSpline will  have
0169   //! the following properties:
0170   //! 1- his degree will be 3.
0171   //! 2- his  continuity will be  C2.
0172 
0173   Standard_EXPORT void Interpolate(const TColgp_Array2OfPnt& Points,
0174                                    const Standard_Boolean    thePeriodic = Standard_False);
0175 
0176   //! Interpolates  a BSpline Surface passing  through  an
0177   //! array of  Point.  The resulting BSpline will  have
0178   //! the following properties:
0179   //! 1- his degree will be 3.
0180   //! 2- his  continuity will be  C2.
0181 
0182   Standard_EXPORT void Interpolate(const TColgp_Array2OfPnt&        Points,
0183                                    const Approx_ParametrizationType ParType,
0184                                    const Standard_Boolean           thePeriodic = Standard_False);
0185 
0186   //! Approximates  a BSpline  Surface passing  through  an
0187   //! array of  Points.
0188   //!
0189   //! The points will be constructed as follow:
0190   //! P(i,j) = gp_Pnt( X0 + (i-1)*dX ,
0191   //! Y0 + (j-1)*dY ,
0192   //! ZPoints(i,j)   )
0193   //!
0194   //! The resulting BSpline will  have the following
0195   //! properties:
0196   //! 1- his degree will be in the range [Degmin,Degmax]
0197   //! 2- his  continuity will be  at  least <Continuity>
0198   //! 3- the distance from the point <Points> to the
0199   //! BSpline will be lower to Tol3D
0200   //! 4- the parametrization of the surface will verify:
0201   //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
0202 
0203   Standard_EXPORT void Init(const TColStd_Array2OfReal& ZPoints,
0204                             const Standard_Real         X0,
0205                             const Standard_Real         dX,
0206                             const Standard_Real         Y0,
0207                             const Standard_Real         dY,
0208                             const Standard_Integer      DegMin     = 3,
0209                             const Standard_Integer      DegMax     = 8,
0210                             const GeomAbs_Shape         Continuity = GeomAbs_C2,
0211                             const Standard_Real         Tol3D      = 1.0e-3);
0212 
0213   //! Interpolates  a BSpline  Surface passing  through  an
0214   //! array of  Points.
0215   //!
0216   //! The points will be constructed as follow:
0217   //! P(i,j) = gp_Pnt( X0 + (i-1)*dX ,
0218   //! Y0 + (j-1)*dY ,
0219   //! ZPoints(i,j)   )
0220   //!
0221   //! The resulting BSpline will  have the following
0222   //! properties:
0223   //! 1- his degree will be 3
0224   //! 2- his  continuity will be  C2.
0225   //! 4- the parametrization of the surface will verify:
0226   //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
0227 
0228   Standard_EXPORT void Interpolate(const TColStd_Array2OfReal& ZPoints,
0229                                    const Standard_Real         X0,
0230                                    const Standard_Real         dX,
0231                                    const Standard_Real         Y0,
0232                                    const Standard_Real         dY);
0233 
0234   //! Approximates  a BSpline Surface passing  through  an
0235   //! array of  Point.  The resulting BSpline will  have
0236   //! the following properties:
0237   //! 1- his degree will be in the range [Degmin,Degmax]
0238   //! 2- his  continuity will be  at  least <Continuity>
0239   //! 3- the distance from the point <Points> to the
0240   //! BSpline will be lower to Tol3D.
0241 
0242   Standard_EXPORT void Init(const TColgp_Array2OfPnt&        Points,
0243                             const Approx_ParametrizationType ParType,
0244                             const Standard_Integer           DegMin      = 3,
0245                             const Standard_Integer           DegMax      = 8,
0246                             const GeomAbs_Shape              Continuity  = GeomAbs_C2,
0247                             const Standard_Real              Tol3D       = 1.0e-3,
0248                             const Standard_Boolean           thePeriodic = Standard_False);
0249 
0250   //! Approximates  a BSpline Surface passing  through  an
0251   //! array of  point using variational smoothing algorithm,
0252   //! which tries to minimize additional criterium:
0253   //! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion.
0254 
0255   Standard_EXPORT void Init(const TColgp_Array2OfPnt& Points,
0256                             const Standard_Real       Weight1,
0257                             const Standard_Real       Weight2,
0258                             const Standard_Real       Weight3,
0259                             const Standard_Integer    DegMax     = 8,
0260                             const GeomAbs_Shape       Continuity = GeomAbs_C2,
0261                             const Standard_Real       Tol3D      = 1.0e-3);
0262 
0263   //! Returns the approximate BSpline Surface
0264   Standard_EXPORT const Handle(Geom_BSplineSurface)& Surface() const;
0265   Standard_EXPORT                                    operator Handle(Geom_BSplineSurface)() const;
0266 
0267   Standard_EXPORT Standard_Boolean IsDone() const;
0268 
0269 protected:
0270 private:
0271   Standard_Boolean            myIsDone;
0272   Handle(Geom_BSplineSurface) mySurface;
0273 };
0274 
0275 #endif // _GeomAPI_PointsToBSplineSurface_HeaderFile