Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 09:15:48

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 <gp_Pnt.hxx>
0025 #include <NCollection_Array2.hxx>
0026 #include <Standard_Integer.hxx>
0027 #include <GeomAbs_Shape.hxx>
0028 #include <Approx_ParametrizationType.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) + std::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 NCollection_Array2<gp_Pnt>& Points,
0093                                                  const int                         DegMin = 3,
0094                                                  const int                         DegMax = 8,
0095                                                  const GeomAbs_Shape Continuity = GeomAbs_C2,
0096                                                  const double        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 NCollection_Array2<gp_Pnt>& Points,
0107                                                  const Approx_ParametrizationType  ParType,
0108                                                  const int                         DegMin = 3,
0109                                                  const int                         DegMax = 8,
0110                                                  const GeomAbs_Shape Continuity = GeomAbs_C2,
0111                                                  const double        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 NCollection_Array2<gp_Pnt>& Points,
0119                                                  const double                      Weight1,
0120                                                  const double                      Weight2,
0121                                                  const double                      Weight3,
0122                                                  const int                         DegMax = 8,
0123                                                  const GeomAbs_Shape Continuity = GeomAbs_C2,
0124                                                  const double        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, Y0 + (j-1)*dY, ZPoints(i,j) )
0131   //!
0132   //! The resulting BSpline will have the following
0133   //! properties:
0134   //! 1- his degree will be in the range [Degmin,Degmax]
0135   //! 2- his continuity will be at least <Continuity>
0136   //! 3- the distance from the point <Points> to the
0137   //! BSpline will be lower to Tol3D
0138   //! 4- the parametrization of the surface will verify:
0139   //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
0140 
0141   Standard_EXPORT GeomAPI_PointsToBSplineSurface(const NCollection_Array2<double>& ZPoints,
0142                                                  const double                      X0,
0143                                                  const double                      dX,
0144                                                  const double                      Y0,
0145                                                  const double                      dY,
0146                                                  const int                         DegMin = 3,
0147                                                  const int                         DegMax = 8,
0148                                                  const GeomAbs_Shape Continuity = GeomAbs_C2,
0149                                                  const double        Tol3D      = 1.0e-3);
0150 
0151   //! Approximates a BSpline Surface passing through an
0152   //! array of Point. The resulting BSpline will have
0153   //! the following properties:
0154   //! 1- his degree will be in the range [Degmin,Degmax]
0155   //! 2- his continuity will be at least <Continuity>
0156   //! 3- the distance from the point <Points> to the
0157   //! BSpline will be lower to Tol3D.
0158 
0159   Standard_EXPORT void Init(const NCollection_Array2<gp_Pnt>& Points,
0160                             const int                         DegMin     = 3,
0161                             const int                         DegMax     = 8,
0162                             const GeomAbs_Shape               Continuity = GeomAbs_C2,
0163                             const double                      Tol3D      = 1.0e-3);
0164 
0165   //! Interpolates a BSpline Surface passing through an
0166   //! array of Point. The resulting BSpline will have
0167   //! the following properties:
0168   //! 1- his degree will be 3.
0169   //! 2- his continuity will be C2.
0170 
0171   Standard_EXPORT void Interpolate(const NCollection_Array2<gp_Pnt>& Points,
0172                                    const bool                        thePeriodic = false);
0173 
0174   //! Interpolates a BSpline Surface passing through an
0175   //! array of Point. The resulting BSpline will have
0176   //! the following properties:
0177   //! 1- his degree will be 3.
0178   //! 2- his continuity will be C2.
0179 
0180   Standard_EXPORT void Interpolate(const NCollection_Array2<gp_Pnt>& Points,
0181                                    const Approx_ParametrizationType  ParType,
0182                                    const bool                        thePeriodic = false);
0183 
0184   //! Approximates a BSpline Surface passing through an
0185   //! array of Points.
0186   //!
0187   //! The points will be constructed as follow:
0188   //! P(i,j) = gp_Pnt( X0 + (i-1)*dX, Y0 + (j-1)*dY, ZPoints(i,j) )
0189   //!
0190   //! The resulting BSpline will have the following
0191   //! properties:
0192   //! 1- his degree will be in the range [Degmin,Degmax]
0193   //! 2- his continuity will be at least <Continuity>
0194   //! 3- the distance from the point <Points> to the
0195   //! BSpline will be lower to Tol3D
0196   //! 4- the parametrization of the surface will verify:
0197   //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
0198 
0199   Standard_EXPORT void Init(const NCollection_Array2<double>& ZPoints,
0200                             const double                      X0,
0201                             const double                      dX,
0202                             const double                      Y0,
0203                             const double                      dY,
0204                             const int                         DegMin     = 3,
0205                             const int                         DegMax     = 8,
0206                             const GeomAbs_Shape               Continuity = GeomAbs_C2,
0207                             const double                      Tol3D      = 1.0e-3);
0208 
0209   //! Interpolates a BSpline Surface passing through an
0210   //! array of Points.
0211   //!
0212   //! The points will be constructed as follow:
0213   //! P(i,j) = gp_Pnt( X0 + (i-1)*dX, Y0 + (j-1)*dY, ZPoints(i,j) )
0214   //!
0215   //! The resulting BSpline will have the following
0216   //! properties:
0217   //! 1- his degree will be 3
0218   //! 2- his continuity will be C2.
0219   //! 4- the parametrization of the surface will verify:
0220   //! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
0221 
0222   Standard_EXPORT void Interpolate(const NCollection_Array2<double>& ZPoints,
0223                                    const double                      X0,
0224                                    const double                      dX,
0225                                    const double                      Y0,
0226                                    const double                      dY);
0227 
0228   //! Approximates a BSpline Surface passing through an
0229   //! array of Point. The resulting BSpline will have
0230   //! the following properties:
0231   //! 1- his degree will be in the range [Degmin,Degmax]
0232   //! 2- his continuity will be at least <Continuity>
0233   //! 3- the distance from the point <Points> to the
0234   //! BSpline will be lower to Tol3D.
0235 
0236   Standard_EXPORT void Init(const NCollection_Array2<gp_Pnt>& Points,
0237                             const Approx_ParametrizationType  ParType,
0238                             const int                         DegMin      = 3,
0239                             const int                         DegMax      = 8,
0240                             const GeomAbs_Shape               Continuity  = GeomAbs_C2,
0241                             const double                      Tol3D       = 1.0e-3,
0242                             const bool                        thePeriodic = false);
0243 
0244   //! Approximates a BSpline Surface passing through an
0245   //! array of point using variational smoothing algorithm,
0246   //! which tries to minimize additional criterium:
0247   //! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion.
0248 
0249   Standard_EXPORT void Init(const NCollection_Array2<gp_Pnt>& Points,
0250                             const double                      Weight1,
0251                             const double                      Weight2,
0252                             const double                      Weight3,
0253                             const int                         DegMax     = 8,
0254                             const GeomAbs_Shape               Continuity = GeomAbs_C2,
0255                             const double                      Tol3D      = 1.0e-3);
0256 
0257   //! Returns the approximate BSpline Surface
0258   Standard_EXPORT const occ::handle<Geom_BSplineSurface>& Surface() const;
0259   Standard_EXPORT operator occ::handle<Geom_BSplineSurface>() const;
0260 
0261   Standard_EXPORT bool IsDone() const;
0262 
0263 private:
0264   bool                             myIsDone;
0265   occ::handle<Geom_BSplineSurface> mySurface;
0266 };
0267 
0268 #endif // _GeomAPI_PointsToBSplineSurface_HeaderFile