Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:20:21

0001 // Created on: 1996-03-12
0002 // Created by: Bruno DUMORTIER
0003 // Copyright (c) 1996-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 _GeomConvert_BSplineSurfaceToBezierSurface_HeaderFile
0018 #define _GeomConvert_BSplineSurfaceToBezierSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <Geom_BezierSurface.hxx>
0026 #include <NCollection_Array2.hxx>
0027 #include <NCollection_Array1.hxx>
0028 class Geom_BSplineSurface;
0029 class Geom_BezierSurface;
0030 
0031 //! This algorithm converts a B-spline surface into several
0032 //! Bezier surfaces. It uses an algorithm of knot insertion.
0033 //! A BSplineSurfaceToBezierSurface object provides a framework for:
0034 //! -   defining the BSpline surface to be converted,
0035 //! -   implementing the construction algorithm, and
0036 //! -   consulting the results.
0037 //! References :
0038 //! Generating the Bezier points of B-spline curves and surfaces
0039 //! (Wolfgang Bohm) CAD volume 13 number 6 november 1981
0040 class GeomConvert_BSplineSurfaceToBezierSurface
0041 {
0042 public:
0043   DEFINE_STANDARD_ALLOC
0044 
0045   //! Computes all the data needed to convert
0046   //! -   the BSpline surface BasisSurface into a series of adjacent Bezier surfaces.
0047   //! The result consists of a grid of BasisSurface patches
0048   //! limited by isoparametric curves corresponding to knot
0049   //! values, both in the u and v parametric directions of
0050   //! the surface. A row in the grid corresponds to a series
0051   //! of adjacent patches, all limited by the same two
0052   //! u-isoparametric curves. A column in the grid
0053   //! corresponds to a series of adjacent patches, all
0054   //! limited by the same two v-isoparametric curves.
0055   //! Use the available interrogation functions to ascertain
0056   //! the number of computed Bezier patches, and then to
0057   //! construct each individual Bezier surface (or all Bezier surfaces).
0058   //! Note: ParametricTolerance is not used.
0059   Standard_EXPORT GeomConvert_BSplineSurfaceToBezierSurface(
0060     const occ::handle<Geom_BSplineSurface>& BasisSurface);
0061 
0062   //! Computes all the data needed to convert
0063   //! the patch of the BSpline surface BasisSurface
0064   //! limited by the two parameter values U1 and U2 in
0065   //! the u parametric direction, and by the two
0066   //! parameter values V1 and V2 in the v parametric
0067   //! direction, into a series of adjacent Bezier surfaces.
0068   //! The result consists of a grid of BasisSurface patches
0069   //! limited by isoparametric curves corresponding to knot
0070   //! values, both in the u and v parametric directions of
0071   //! the surface. A row in the grid corresponds to a series
0072   //! of adjacent patches, all limited by the same two
0073   //! u-isoparametric curves. A column in the grid
0074   //! corresponds to a series of adjacent patches, all
0075   //! limited by the same two v-isoparametric curves.
0076   //! Use the available interrogation functions to ascertain
0077   //! the number of computed Bezier patches, and then to
0078   //! construct each individual Bezier surface (or all Bezier surfaces).
0079   //! Note: ParametricTolerance is not used. Raises DomainError
0080   //! if U1 or U2 or V1 or V2 are out of the parametric bounds
0081   //! of the basis surface [FirstUKnotIndex, LastUKnotIndex] ,
0082   //! [FirstVKnotIndex, LastVKnotIndex] The tolerance criterion is
0083   //! ParametricTolerance.
0084   //! Raised if U2 - U1 <= ParametricTolerance or
0085   //! V2 - V1 <= ParametricTolerance.
0086   Standard_EXPORT GeomConvert_BSplineSurfaceToBezierSurface(
0087     const occ::handle<Geom_BSplineSurface>& BasisSurface,
0088     const double                            U1,
0089     const double                            U2,
0090     const double                            V1,
0091     const double                            V2,
0092     const double                            ParametricTolerance);
0093 
0094   //! Constructs and returns the Bezier surface of indices
0095   //! (UIndex, VIndex) to the patch grid computed on the
0096   //! BSpline surface analyzed by this algorithm.
0097   //! This Bezier surface has the same orientation as the
0098   //! BSpline surface analyzed in this framework.
0099   //! UIndex is an index common to a row in the patch
0100   //! grid. A row in the grid corresponds to a series of
0101   //! adjacent patches, all limited by the same two
0102   //! u-isoparametric curves of the surface. VIndex is an
0103   //! index common to a column in the patch grid. A column
0104   //! in the grid corresponds to a series of adjacent
0105   //! patches, all limited by the same two v-isoparametric
0106   //! curves of the surface.
0107   //! Exceptions
0108   //! Standard_OutOfRange if:
0109   //! -   UIndex is less than 1 or greater than the number
0110   //! of rows in the patch grid computed on the BSpline
0111   //! surface analyzed by this algorithm (as returned by
0112   //! the function NbUPatches); or if
0113   //! -   VIndex is less than 1 or greater than the number
0114   //! of columns in the patch grid computed on the
0115   //! BSpline surface analyzed by this algorithm (as
0116   //! returned by the function NbVPatches).
0117   Standard_EXPORT occ::handle<Geom_BezierSurface> Patch(const int UIndex, const int VIndex);
0118 
0119   //! Constructs all the Bezier surfaces whose data is
0120   //! computed by this algorithm, and loads them into the Surfaces table.
0121   //! These Bezier surfaces have the same orientation as
0122   //! the BSpline surface analyzed in this framework.
0123   //! The Surfaces array is organised in the same way as
0124   //! the patch grid computed on the BSpline surface
0125   //! analyzed by this algorithm. A row in the array
0126   //! corresponds to a series of adjacent patches, all
0127   //! limited by the same two u-isoparametric curves of
0128   //! the surface. A column in the array corresponds to a
0129   //! series of adjacent patches, all limited by the same two
0130   //! v-isoparametric curves of the surface.
0131   //! Exceptions
0132   //! Standard_DimensionError if the Surfaces array
0133   //! was not created with the following bounds:
0134   //! -   1, and the number of adjacent patch series in the
0135   //! u parametric direction of the patch grid computed
0136   //! on the BSpline surface, analyzed by this algorithm
0137   //! (as given by the function NbUPatches) as row bounds,
0138   //! -   1, and the number of adjacent patch series in the
0139   //! v parametric direction of the patch grid computed
0140   //! on the BSpline surface, analyzed by this algorithm
0141   //! (as given by the function NbVPatches) as column bounds.
0142   Standard_EXPORT void Patches(NCollection_Array2<occ::handle<Geom_BezierSurface>>& Surfaces);
0143 
0144   //! This methode returns the bspline's u-knots associated to
0145   //! the converted Patches
0146   //! Raised if the length of Curves is not equal to
0147   //! NbUPatches + 1
0148   Standard_EXPORT void UKnots(NCollection_Array1<double>& TKnots) const;
0149 
0150   //! This methode returns the bspline's v-knots associated to
0151   //! the converted Patches
0152   //! Raised if the length of Curves is not equal to
0153   //! NbVPatches + 1
0154   Standard_EXPORT void VKnots(NCollection_Array1<double>& TKnots) const;
0155 
0156   //! Returns the number of Bezier surfaces in the U direction.
0157   //! If at the creation time you have decomposed the basis Surface
0158   //! between the parametric values UFirst, ULast the number of
0159   //! Bezier surfaces in the U direction depends on the number of
0160   //! knots included inside the interval [UFirst, ULast].
0161   //! If you have decomposed the whole basis B-spline surface the
0162   //! number of Bezier surfaces NbUPatches is equal to the number of
0163   //! UKnots less one.
0164   Standard_EXPORT int NbUPatches() const;
0165 
0166   //! Returns the number of Bezier surfaces in the V direction.
0167   //! If at the creation time you have decomposed the basis surface
0168   //! between the parametric values VFirst, VLast the number of
0169   //! Bezier surfaces in the V direction depends on the number of
0170   //! knots included inside the interval [VFirst, VLast].
0171   //! If you have decomposed the whole basis B-spline surface the
0172   //! number of Bezier surfaces NbVPatches is equal to the number of
0173   //! VKnots less one.
0174   Standard_EXPORT int NbVPatches() const;
0175 
0176 private:
0177   occ::handle<Geom_BSplineSurface> mySurface;
0178 };
0179 
0180 #endif // _GeomConvert_BSplineSurfaceToBezierSurface_HeaderFile