Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:38

0001 // Created on: 1996-06-06
0002 // Created by: Philippe MANGIN
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_CompBezierSurfacesToBSplineSurface_HeaderFile
0018 #define _GeomConvert_CompBezierSurfacesToBSplineSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <TColStd_HArray1OfInteger.hxx>
0026 #include <TColStd_HArray1OfReal.hxx>
0027 #include <TColgp_HArray2OfPnt.hxx>
0028 #include <TColGeom_Array2OfBezierSurface.hxx>
0029 #include <TColStd_Array1OfReal.hxx>
0030 #include <GeomAbs_Shape.hxx>
0031 
0032 
0033 //! An algorithm to convert a grid of adjacent
0034 //! non-rational Bezier surfaces (with continuity CM) into a
0035 //! BSpline surface (with continuity CM).
0036 //! A CompBezierSurfacesToBSplineSurface object
0037 //! provides a framework for:
0038 //! -   defining the grid of adjacent Bezier surfaces
0039 //! which is to be converted into a BSpline surface,
0040 //! -   implementing the computation algorithm, and
0041 //! -   consulting the results.
0042 //! Warning
0043 //! Do not attempt to convert rational Bezier surfaces using such an algorithm.
0044 //! Input is array of Bezier patch
0045 //! 1    2    3     4  -> VIndex [1, NbVPatches] -> VDirection
0046 //! -----------------------
0047 //! 1    |    |    |    |      |
0048 //! -----------------------
0049 //! 2    |    |    |    |      |
0050 //! -----------------------
0051 //! 3    |    |    |    |      |
0052 //! -----------------------
0053 //! UIndex [1, NbUPatches]  Udirection
0054 //!
0055 //! Warning! Patches must have compatible parametrization
0056 class GeomConvert_CompBezierSurfacesToBSplineSurface 
0057 {
0058 public:
0059 
0060   DEFINE_STANDARD_ALLOC
0061 
0062   
0063   //! Computes all the data needed to build a "C0"
0064   //! continuous BSpline surface equivalent to the grid of
0065   //! adjacent non-rational Bezier surfaces Beziers.
0066   //! Each surface in the Beziers grid becomes a natural
0067   //! patch, limited by knots values, on the BSpline surface
0068   //! whose data is computed. Surfaces in the grid must
0069   //! satisfy the following conditions:
0070   //! -   Coincident bounding curves between two
0071   //! consecutive surfaces in a row of the Beziers grid
0072   //! must be u-isoparametric bounding curves of these two surfaces.
0073   //! -   Coincident bounding curves between two
0074   //! consecutive surfaces in a column of the Beziers
0075   //! grid must be v-isoparametric bounding curves of these two surfaces.
0076   //! The BSpline surface whose data is computed has the
0077   //! following characteristics:
0078   //! -   Its degree in the u (respectively v) parametric
0079   //! direction is equal to that of the Bezier surface
0080   //! which has the highest degree in the u
0081   //! (respectively v) parametric direction in the Beziers grid.
0082   //! -   It is a "Piecewise Bezier" in both u and v
0083   //! parametric directions, i.e.:
0084   //! -   the knots are regularly spaced in each
0085   //! parametric direction (i.e. the difference between
0086   //! two consecutive knots is a constant), and
0087   //! -   all the multiplicities of the surface knots in a
0088   //! given parametric direction are equal to
0089   //! Degree, which is the degree of the BSpline
0090   //! surface in this parametric direction, except for
0091   //! the first and last knots for which the multiplicity is
0092   //! equal to Degree + 1.
0093   //! -   Coincident bounding curves between two
0094   //! consecutive columns of Bezier surfaces in the
0095   //! Beziers grid become u-isoparametric curves,
0096   //! corresponding to knots values of the BSpline surface.
0097   //! -   Coincident bounding curves between two
0098   //! consecutive rows of Bezier surfaces in the Beziers
0099   //! grid become v-isoparametric curves
0100   //! corresponding to knots values of the BSpline surface.
0101   //! Use the available consultation functions to access the
0102   //! computed data. This data may be used to construct the BSpline surface.
0103   //! Warning
0104   //! The surfaces in the Beziers grid must be adjacent, i.e.
0105   //! two consecutive Bezier surfaces in the grid (in a row
0106   //! or column) must have a coincident bounding curve. In
0107   //! addition, the location of the parameterization on each
0108   //! of these surfaces (i.e. the relative location of u and v
0109   //! isoparametric curves on the surface) is of importance
0110   //! with regard to the positioning of the surfaces in the
0111   //! Beziers grid. Care must be taken with respect to the
0112   //! above, as these properties are not checked and an
0113   //! error may occur if they are not satisfied.
0114   //! Exceptions
0115   //! Standard_NotImplemented if one of the Bezier
0116   //! surfaces of the Beziers grid is rational.
0117   Standard_EXPORT GeomConvert_CompBezierSurfacesToBSplineSurface(const TColGeom_Array2OfBezierSurface& Beziers);
0118   
0119   //! Build an Ci uniform (Rational) BSpline surface
0120   //! The highest Continuity Ci is imposed, like the
0121   //! maximal deformation is lower than <Tolerance>.
0122   //! Warning:  The Continuity C0 is imposed without any check.
0123   Standard_EXPORT GeomConvert_CompBezierSurfacesToBSplineSurface(const TColGeom_Array2OfBezierSurface& Beziers, const Standard_Real Tolerance, const Standard_Boolean RemoveKnots = Standard_True);
0124   
0125   //! Computes all the data needed to construct a BSpline
0126   //! surface equivalent to the adjacent non-rational
0127   //! Bezier surfaces Beziers grid.
0128   //! Each surface in the Beziers grid becomes a natural
0129   //! patch, limited by knots values, on the BSpline surface
0130   //! whose data is computed. Surfaces in the grid must
0131   //! satisfy the following conditions:
0132   //! -   Coincident bounding curves between two
0133   //! consecutive surfaces in a row of the Beziers grid
0134   //! must be u-isoparametric bounding curves of these two surfaces.
0135   //! -   Coincident bounding curves between two
0136   //! consecutive surfaces in a column of the Beziers
0137   //! grid must be v-isoparametric bounding curves of these two surfaces.
0138   //! The BSpline surface whose data is computed has the
0139   //! following characteristics:
0140   //! -   Its degree in the u (respectively v) parametric
0141   //! direction is equal to that of the Bezier surface
0142   //! which has the highest degree in the u
0143   //! (respectively v) parametric direction in the Beziers grid.
0144   //! -   Coincident bounding curves between two
0145   //! consecutive columns of Bezier surfaces in the
0146   //! Beziers grid become u-isoparametric curves
0147   //! corresponding to knots values of the BSpline surface.
0148   //! -   Coincident bounding curves between two
0149   //! consecutive rows of Bezier surfaces in the Beziers
0150   //! grid become v-isoparametric curves
0151   //! corresponding to knots values of the BSpline surface.
0152   //! Knots values of the BSpline surface are given in the two tables:
0153   //! -   UKnots for the u parametric direction (which
0154   //! corresponds to the order of Bezier surface columns in the Beziers grid), and
0155   //! -   VKnots for the v parametric direction (which
0156   //! corresponds to the order of Bezier surface rows in the Beziers grid).
0157   //! The dimensions of UKnots (respectively VKnots)
0158   //! must be equal to the number of columns (respectively,
0159   //! rows) of the Beziers grid, plus 1 .
0160   //! UContinuity and VContinuity, which are both
0161   //! defaulted to GeomAbs_C0, specify the required
0162   //! continuity on the BSpline surface. If the required
0163   //! degree of continuity is greater than 0 in a given
0164   //! parametric direction, a deformation is applied locally
0165   //! on the initial surface (as defined by the Beziers grid)
0166   //! to satisfy this condition. This local deformation is not
0167   //! applied however, if it is greater than Tolerance
0168   //! (defaulted to 1.0 e-7). In such cases, the
0169   //! continuity condition is not satisfied, and the function
0170   //! IsDone will return false. A small tolerance value
0171   //! prevents any modification of the surface and a large
0172   //! tolerance value "smoothes" the surface.
0173   //! Use the available consultation functions to access the
0174   //! computed data. This data may be used to construct the BSpline surface.
0175   //! Warning
0176   //! The surfaces in the Beziers grid must be adjacent, i.e.
0177   //! two consecutive Bezier surfaces in the grid (in a row
0178   //! or column) must have a coincident bounding curve. In
0179   //! addition, the location of the parameterization on each
0180   //! of these surfaces (i.e. the relative location of u and v
0181   //! isoparametric curves on the surface) is of importance
0182   //! with regard to the positioning of the surfaces in the
0183   //! Beziers grid. Care must be taken with respect to the
0184   //! above, as these properties are not checked and an
0185   //! error may occur if they are not satisfied.
0186   //! Exceptions
0187   //! Standard_DimensionMismatch:
0188   //! -   if the number of knots in the UKnots table (i.e. the
0189   //! length of the UKnots array) is not equal to the
0190   //! number of columns of Bezier surfaces in the
0191   //! Beziers grid plus 1, or
0192   //! -   if the number of knots in the VKnots table (i.e. the
0193   //! length of the VKnots array) is not equal to the
0194   //! number of rows of Bezier surfaces in the Beziers grid, plus 1.
0195   //! Standard_ConstructionError:
0196   //! -   if UContinuity and VContinuity are not equal to
0197   //! one of the following values: GeomAbs_C0,
0198   //! GeomAbs_C1, GeomAbs_C2 and GeomAbs_C3; or
0199   //! -   if the number of columns in the Beziers grid is
0200   //! greater than 1, and the required degree of
0201   //! continuity in the u parametric direction is greater
0202   //! than that of the Bezier surface with the highest
0203   //! degree in the u parametric direction (in the Beziers grid), minus 1; or
0204   //! -   if the number of rows in the Beziers grid is
0205   //! greater than 1, and the required degree of
0206   //! continuity in the v parametric direction is greater
0207   //! than that of the Bezier surface with the highest
0208   //! degree in the v parametric direction (in the Beziers grid), minus 1 .
0209   //! Standard_NotImplemented if one of the Bezier
0210   //! surfaces in the Beziers grid is rational.
0211   Standard_EXPORT GeomConvert_CompBezierSurfacesToBSplineSurface(const TColGeom_Array2OfBezierSurface& Beziers, const TColStd_Array1OfReal& UKnots, const TColStd_Array1OfReal& VKnots, const GeomAbs_Shape UContinuity = GeomAbs_C0, const GeomAbs_Shape VContinuity = GeomAbs_C0, const Standard_Real Tolerance = 1.0e-4);
0212   
0213   //! Returns the number of knots in the U direction
0214   //! of the BSpline surface whose data is computed in this framework.
0215     Standard_Integer NbUKnots() const;
0216   
0217   //! Returns number of poles in the U direction
0218   //! of the BSpline surface whose data is computed in this framework.
0219     Standard_Integer NbUPoles() const;
0220   
0221   //! Returns the number of knots in the V direction
0222   //! of the BSpline surface whose data is computed in this framework.
0223     Standard_Integer NbVKnots() const;
0224   
0225   //! Returns the number of poles in the V direction
0226   //! of the BSpline surface whose data is computed in this framework.
0227     Standard_Integer NbVPoles() const;
0228   
0229   //! Returns the table of poles of the BSpline surface
0230   //! whose data is computed in this framework.
0231     const Handle(TColgp_HArray2OfPnt)& Poles() const;
0232   
0233   //! Returns the knots table for the u parametric
0234   //! direction of the BSpline surface whose data is computed in this framework.
0235     const Handle(TColStd_HArray1OfReal)& UKnots() const;
0236   
0237   //! Returns the degree for the u  parametric
0238   //! direction of the BSpline surface whose data is computed in this framework.
0239     Standard_Integer UDegree() const;
0240   
0241   //! Returns the knots table for the v parametric
0242   //! direction of the BSpline surface whose data is computed in this framework.
0243     const Handle(TColStd_HArray1OfReal)& VKnots() const;
0244   
0245   //! Returns the degree for the v  parametric
0246   //! direction of the BSpline surface whose data is computed in this framework.
0247     Standard_Integer VDegree() const;
0248   
0249 
0250   //! Returns the multiplicities table for the u
0251   //! parametric direction of the knots of the BSpline
0252   //! surface whose data is computed in this framework.
0253     const Handle(TColStd_HArray1OfInteger)& UMultiplicities() const;
0254   
0255   //! -- Returns the multiplicities table for the v
0256   //! parametric direction of the knots of the BSpline
0257   //! surface whose data is computed in this framework.
0258     const Handle(TColStd_HArray1OfInteger)& VMultiplicities() const;
0259   
0260   //! Returns true if the conversion was successful.
0261   //! Unless an exception was raised at the time of
0262   //! construction, the conversion of the Bezier surface
0263   //! grid assigned to this algorithm is always carried out.
0264   //! IsDone returns false if the constraints defined at the
0265   //! time of construction cannot be respected. This occurs
0266   //! when there is an incompatibility between a required
0267   //! degree of continuity on the BSpline surface, and the
0268   //! maximum tolerance accepted for local deformations
0269   //! of the surface. In such a case the computed data
0270   //! does not satisfy all the initial constraints.
0271   Standard_EXPORT Standard_Boolean IsDone() const;
0272 
0273 
0274 
0275 
0276 protected:
0277 
0278 
0279 
0280 
0281 
0282 private:
0283 
0284   
0285   //! It used internally by the constructors.
0286   Standard_EXPORT void Perform (const TColGeom_Array2OfBezierSurface& Beziers);
0287 
0288 
0289   Standard_Integer myUDegree;
0290   Standard_Integer myVDegree;
0291   Handle(TColStd_HArray1OfInteger) myVMults;
0292   Handle(TColStd_HArray1OfInteger) myUMults;
0293   Handle(TColStd_HArray1OfReal) myUKnots;
0294   Handle(TColStd_HArray1OfReal) myVKnots;
0295   Handle(TColgp_HArray2OfPnt) myPoles;
0296   Standard_Boolean isrational;
0297   Standard_Boolean myDone;
0298 
0299 
0300 };
0301 
0302 
0303 #include <GeomConvert_CompBezierSurfacesToBSplineSurface.lxx>
0304 
0305 
0306 
0307 
0308 
0309 #endif // _GeomConvert_CompBezierSurfacesToBSplineSurface_HeaderFile