Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1991-10-03
0002 // Created by: JeanClaude VAUTHIER 
0003 // Copyright (c) 1991-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_HeaderFile
0018 #define _GeomConvert_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <Standard_Boolean.hxx>
0026 #include <Standard_Real.hxx>
0027 #include <Convert_ParameterisationType.hxx>
0028 #include <TColGeom_Array1OfBSplineCurve.hxx>
0029 #include <TColStd_Array1OfReal.hxx>
0030 #include <TColGeom_HArray1OfBSplineCurve.hxx>
0031 #include <TColStd_HArray1OfInteger.hxx>
0032 class Geom_BSplineCurve;
0033 class Geom_BSplineSurface;
0034 class Geom_Curve;
0035 class Geom_Surface;
0036 
0037 
0038 //! The GeomConvert package provides some global functions as follows
0039 //! -   converting classical Geom curves into BSpline curves,
0040 //! -   segmenting BSpline curves, particularly at knots
0041 //! values: this function may be used in conjunction with the
0042 //! GeomConvert_BSplineCurveKnotSplitting
0043 //! class to segment a BSpline curve into arcs which
0044 //! comply with required continuity levels,
0045 //! -   converting classical Geom surfaces into BSpline surfaces, and
0046 //! -   segmenting BSpline surfaces, particularly at
0047 //! knots values: this function may be used in conjunction with the
0048 //! GeomConvert_BSplineSurfaceKnotSplitting
0049 //! class to segment a BSpline surface into patches
0050 //! which comply with required continuity levels.
0051 //! All geometric entities used in this package are bounded.
0052 //!
0053 //! References :
0054 //! . Generating the Bezier Points of B-spline curves and surfaces
0055 //! (Wolfgang Bohm) CAGD volume 13 number 6 november 1981
0056 //! . On NURBS: A Survey  (Leslie Piegl) IEEE Computer Graphics and
0057 //! Application January 1991
0058 //! . Curve and surface construction using rational B-splines
0059 //! (Leslie Piegl and Wayne Tiller) CAD Volume 19 number 9 november
0060 //! 1987
0061 //! . A survey of curve and surface methods in CAGD (Wolfgang BOHM)
0062 //! CAGD 1 1984
0063 class GeomConvert 
0064 {
0065 public:
0066 
0067   DEFINE_STANDARD_ALLOC
0068 
0069   
0070   //! Convert a curve from Geom by an approximation method
0071   //!
0072   //! This method computes the arc of B-spline curve between the two
0073   //! knots FromK1 and ToK2.  If C is periodic the arc has the same
0074   //! orientation as C if SameOrientation = Standard_True.
0075   //! If C is not periodic  SameOrientation is not used for the
0076   //! computation and C is oriented from the knot fromK1 to the knot toK2.
0077   //! We just keep the local definition of C between the knots
0078   //! FromK1 and ToK2.  The returned B-spline curve has its first
0079   //! and last knots with a multiplicity equal to degree + 1, where
0080   //! degree is the polynomial degree of C.
0081   //! The indexes of the knots FromK1 and ToK2 doesn't include the
0082   //! repetition of multiple knots in their definition.
0083   //! Raised if FromK1 = ToK2
0084   //! Raised if FromK1 or ToK2 are out of the bounds
0085   //! [FirstUKnotIndex, LastUKnotIndex]
0086   Standard_EXPORT static Handle(Geom_BSplineCurve) SplitBSplineCurve (const Handle(Geom_BSplineCurve)& C,
0087                                                                       const Standard_Integer FromK1,
0088                                                                       const Standard_Integer ToK2,
0089                                                                       const Standard_Boolean SameOrientation = Standard_True);
0090   
0091 
0092   //! This function computes the segment of B-spline curve between the
0093   //! parametric values FromU1, ToU2.
0094   //! If C is periodic the arc has the same orientation as C if
0095   //! SameOrientation = True.
0096   //! If C is not periodic SameOrientation is not used for the
0097   //! computation and C is oriented fromU1 toU2.
0098   //! If U1 and U2 and two parametric values we consider that
0099   //! U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and
0100   //! ParametricTolerance must  be greater or equal to Resolution
0101   //! from package gp.
0102   //!
0103   //! Raised if FromU1 or ToU2 are out of the parametric bounds of the
0104   //! curve (The tolerance criterion is ParametricTolerance).
0105   //! Raised if Abs (FromU1 - ToU2) <= ParametricTolerance
0106   //! Raised if ParametricTolerance < Resolution from gp.
0107   Standard_EXPORT static Handle(Geom_BSplineCurve) SplitBSplineCurve (const Handle(Geom_BSplineCurve)& C,
0108                                                                       const Standard_Real FromU1,
0109                                                                       const Standard_Real ToU2,
0110                                                                       const Standard_Real ParametricTolerance,
0111                                                                       const Standard_Boolean SameOrientation = Standard_True);
0112   
0113 
0114   //! Computes the B-spline surface patche between the knots values
0115   //! FromUK1, ToUK2, FromVK1, ToVK2.
0116   //! If S is periodic in one direction the patche has the same
0117   //! orientation as S in this direction if the flag is true in this
0118   //! direction (SameUOrientation, SameVOrientation).
0119   //! If S is not periodic SameUOrientation and SameVOrientation are not
0120   //! used for the computation and S is oriented FromUK1 ToUK2 and
0121   //! FromVK1 ToVK2.
0122   //! Raised if
0123   //! FromUK1 = ToUK2 or FromVK1 = ToVK2
0124   //! FromUK1 or ToUK2 are out of the bounds
0125   //! [FirstUKnotIndex, LastUKnotIndex]
0126   //! FromVK1 or ToVK2 are out of the bounds
0127   //! [FirstVKnotIndex, LastVKnotIndex]
0128   Standard_EXPORT static Handle(Geom_BSplineSurface) SplitBSplineSurface (const Handle(Geom_BSplineSurface)& S,
0129                                                                           const Standard_Integer FromUK1,
0130                                                                           const Standard_Integer ToUK2,
0131                                                                           const Standard_Integer FromVK1,
0132                                                                           const Standard_Integer ToVK2,
0133                                                                           const Standard_Boolean SameUOrientation = Standard_True,
0134                                                                           const Standard_Boolean SameVOrientation = Standard_True);
0135   
0136 
0137   //! This method splits a B-spline surface patche between the
0138   //! knots values FromK1, ToK2 in one direction.
0139   //! If USplit = True then the splitting direction is the U parametric
0140   //! direction else it is the V parametric direction.
0141   //! If S is periodic in the considered direction the patche has the
0142   //! same orientation as S in this direction if SameOrientation is True
0143   //! If S is not periodic in this direction SameOrientation is not used
0144   //! for the computation and S is oriented FromK1 ToK2.
0145   //! Raised if FromK1 = ToK2 or if
0146   //! FromK1 or ToK2 are out of the bounds
0147   //! [FirstUKnotIndex, LastUKnotIndex] in the
0148   //! considered parametric direction.
0149   Standard_EXPORT static Handle(Geom_BSplineSurface) SplitBSplineSurface (const Handle(Geom_BSplineSurface)& S,
0150                                                                           const Standard_Integer FromK1,
0151                                                                           const Standard_Integer ToK2,
0152                                                                           const Standard_Boolean USplit,
0153                                                                           const Standard_Boolean SameOrientation = Standard_True);
0154   
0155 
0156   //! This method computes the B-spline surface patche between the
0157   //! parametric values FromU1, ToU2, FromV1, ToV2.
0158   //! If S is periodic in one direction the patche has the same
0159   //! orientation as S in this direction if the flag is True in this
0160   //! direction (SameUOrientation, SameVOrientation).
0161   //! If S is not periodic SameUOrientation and SameVOrientation are not
0162   //! used for the computation and S is oriented FromU1 ToU2 and
0163   //! FromV1 ToV2.
0164   //! If U1 and U2 and two parametric values we consider that U1 = U2 if
0165   //! Abs (U1 - U2) <= ParametricTolerance and ParametricTolerance must
0166   //! be greater or equal to Resolution from package gp.
0167   //!
0168   //! Raised if FromU1 or ToU2 or FromV1 or ToU2 are out of the
0169   //! parametric bounds of the surface (the tolerance criterion is
0170   //! ParametricTolerance).
0171   //! Raised if Abs (FromU1 - ToU2) <= ParametricTolerance or
0172   //! Abs (FromV1 - ToV2) <= ParametricTolerance.
0173   //! Raised if ParametricTolerance < Resolution.
0174   Standard_EXPORT static Handle(Geom_BSplineSurface) SplitBSplineSurface (const Handle(Geom_BSplineSurface)& S,
0175                                                                           const Standard_Real FromU1,
0176                                                                           const Standard_Real ToU2,
0177                                                                           const Standard_Real FromV1,
0178                                                                           const Standard_Real ToV2,
0179                                                                           const Standard_Real ParametricTolerance,
0180                                                                           const Standard_Boolean SameUOrientation = Standard_True,
0181                                                                           const Standard_Boolean SameVOrientation = Standard_True);
0182   
0183 
0184   //! This method splits the B-spline surface S in one direction
0185   //! between the parametric values FromParam1, ToParam2.
0186   //! If USplit = True then the Splitting direction is the U parametric
0187   //! direction else it is the V parametric direction.
0188   //! If S is periodic in the considered direction the patche has
0189   //! the same orientation as S in this direction if SameOrientation
0190   //! is true.
0191   //! If S is not periodic in the considered direction SameOrientation
0192   //! is not used for the computation and S is oriented FromParam1
0193   //! ToParam2.
0194   //! If U1 and U2 and two parametric values we consider that U1 = U2
0195   //! if Abs (U1 - U2) <= ParametricTolerance and ParametricTolerance
0196   //! must be greater or equal to Resolution from package gp.
0197   //!
0198   //! Raises if FromParam1 or ToParam2 are out of the parametric bounds
0199   //! of the surface in the considered direction.
0200   //! Raises if Abs (FromParam1 - ToParam2) <= ParametricTolerance.
0201   Standard_EXPORT static Handle(Geom_BSplineSurface) SplitBSplineSurface (const Handle(Geom_BSplineSurface)& S,
0202                                                                           const Standard_Real FromParam1,
0203                                                                           const Standard_Real ToParam2,
0204                                                                           const Standard_Boolean USplit,
0205                                                                           const Standard_Real ParametricTolerance,
0206                                                                           const Standard_Boolean SameOrientation = Standard_True);
0207   
0208   //! This function converts a non infinite curve from
0209   //! Geom into a  B-spline curve.  C must be   an ellipse or  a
0210   //! circle  or a trimmed conic  or a trimmed  line or a Bezier
0211   //! curve or a trimmed  Bezier curve or a  BSpline curve or  a
0212   //! trimmed  BSpline curve or  an  OffsetCurve.  The returned  B-spline is
0213   //! not periodic except  if C is a Circle  or an  Ellipse.  If
0214   //! the  Parameterisation is  QuasiAngular than  the returned
0215   //! curve is NOT periodic  in case a  periodic Geom_Circle or
0216   //! Geom_Ellipse.  For TgtThetaOver2_1 and TgtThetaOver2_2 the
0217   //! method   raises  an exception  in    case  of a  periodic
0218   //! Geom_Circle or a Geom_Ellipse ParameterisationType applies
0219   //! only    if  the curve  is   a  Circle  or  an   ellipse :
0220   //! TgtThetaOver2,  -- TgtThetaOver2_1, -- TgtThetaOver2_2, --
0221   //! TgtThetaOver2_3, -- TgtThetaOver2_4,
0222   //!
0223   //! Purpose: this is the classical rational parameterisation
0224   //! 2
0225   //! 1 - t
0226   //! cos(theta) = ------
0227   //! 2
0228   //! 1 + t
0229   //!
0230   //! 2t
0231   //! sin(theta) = ------
0232   //! 2
0233   //! 1 + t
0234   //!
0235   //! t = tan (theta/2)
0236   //!
0237   //! with TgtThetaOver2  the routine will compute the number of spans
0238   //! using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1
0239   //! with TgtThetaOver2_N, N  spans will be forced: an error will
0240   //! be raized if (ULast - UFirst) >= PI and N = 1,
0241   //! ULast - UFirst >= 2 PI and N = 2
0242   //!
0243   //! QuasiAngular,
0244   //! here t is a rational function that approximates
0245   //! theta ----> tan(theta/2).
0246   //! Nevetheless the composing with above function yields exact
0247   //! functions whose square sum up to 1
0248   //! RationalC1 ;
0249   //! t is replaced by a polynomial function of u so as to grant
0250   //! C1 contiuity across knots.
0251   //! Exceptions
0252   //! Standard_DomainError:
0253   //! -   if the curve C is infinite, or
0254   //! -   if C is a (complete) circle or ellipse, and Parameterisation is equal to
0255   //! Convert_TgtThetaOver2_1 or Convert_TgtThetaOver2_2.
0256   //! Standard_ConstructionError:
0257   //! -   if C is a (complete) circle or ellipse, and if Parameterisation is not equal to
0258   //! Convert_TgtThetaOver2, Convert_RationalC1,
0259   //! Convert_QuasiAngular (the curve is converted
0260   //! in these three cases) or to Convert_TgtThetaOver2_1 or
0261   //! Convert_TgtThetaOver2_2 (another exception is raised in these two cases).
0262   //! -   if C is a trimmed circle or ellipse, if Parameterisation is equal to
0263   //! Convert_TgtThetaOver2_1 and if U2 - U1 > 0.9999 * Pi, where U1 and U2 are
0264   //! respectively the first and the last parameters of the
0265   //! trimmed curve (this method of parameterization
0266   //! cannot be used to convert a half-circle or a half-ellipse, for example), or
0267   //! -   if C is a trimmed circle or ellipse, if
0268   //! Parameterisation is equal to Convert_TgtThetaOver2_2 and U2 - U1 >
0269   //! 1.9999 * Pi where U1 and U2 are
0270   //! respectively the first and the last parameters of the
0271   //! trimmed curve (this method of parameterization
0272   //! cannot be used to convert a quasi-complete circle or ellipse).
0273   Standard_EXPORT static Handle(Geom_BSplineCurve) CurveToBSplineCurve (const Handle(Geom_Curve)& C,
0274                                                                         const Convert_ParameterisationType Parameterisation = Convert_TgtThetaOver2);
0275   
0276 
0277   //! This algorithm converts a non infinite surface from Geom
0278   //! into a B-spline surface.
0279   //! S must be a trimmed plane or a trimmed cylinder or a trimmed cone
0280   //! or a trimmed sphere or a trimmed torus or a sphere or a torus or
0281   //! a Bezier surface of a trimmed Bezier surface or a trimmed swept
0282   //! surface with a corresponding basis curve which can be turned into
0283   //! a B-spline curve   (see the method CurveToBSplineCurve).
0284   //! Raises DomainError if the type of the surface is not previously defined.
0285   Standard_EXPORT static Handle(Geom_BSplineSurface) SurfaceToBSplineSurface (const Handle(Geom_Surface)& S);
0286   
0287   //! This Method concatenates G1 the ArrayOfCurves as far
0288   //! as it  is possible.
0289   //! ArrayOfCurves[0..N-1]
0290   //! ArrayOfToler contains the  biggest tolerance of the two
0291   //! points shared by two consecutives curves.
0292   //! Its dimension: [0..N-2]
0293   //! ClosedFlag     indicates if the ArrayOfCurves is closed.
0294   //! In this case ClosedTolerance contains the biggest tolerance
0295   //! of the two points which are at the closure.
0296   //! Otherwise its value is 0.0
0297   //! ClosedFlag becomes False on the output
0298   //! if it is impossible to build closed curve.
0299   Standard_EXPORT static void ConcatG1 (TColGeom_Array1OfBSplineCurve& ArrayOfCurves,
0300                                         const TColStd_Array1OfReal& ArrayOfToler,
0301                                         Handle(TColGeom_HArray1OfBSplineCurve)& ArrayOfConcatenated,
0302                                         Standard_Boolean& ClosedFlag,
0303                                         const Standard_Real ClosedTolerance);
0304   
0305   //! This Method concatenates C1 the ArrayOfCurves as far
0306   //! as it is possible.
0307   //! ArrayOfCurves[0..N-1]
0308   //! ArrayOfToler contains the  biggest tolerance of the two
0309   //! points shared by two consecutives curves.
0310   //! Its dimension: [0..N-2]
0311   //! ClosedFlag     indicates if the ArrayOfCurves is closed.
0312   //! In this case ClosedTolerance contains the biggest tolerance
0313   //! of the two points which are at the closure.
0314   //! Otherwise its value is 0.0
0315   //! ClosedFlag becomes False on the output
0316   //! if it is impossible to build closed curve.
0317   Standard_EXPORT static void ConcatC1 (TColGeom_Array1OfBSplineCurve& ArrayOfCurves,
0318                                         const TColStd_Array1OfReal& ArrayOfToler,
0319                                         Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
0320                                         Handle(TColGeom_HArray1OfBSplineCurve)& ArrayOfConcatenated,
0321                                         Standard_Boolean& ClosedFlag,
0322                                         const Standard_Real ClosedTolerance);
0323   
0324   //! This Method concatenates C1 the ArrayOfCurves as far
0325   //! as it is possible.
0326   //! ArrayOfCurves[0..N-1]
0327   //! ArrayOfToler contains the  biggest tolerance of the two
0328   //! points shared by two consecutives curves.
0329   //! Its dimension: [0..N-2]
0330   //! ClosedFlag     indicates if the ArrayOfCurves is closed.
0331   //! In this case ClosedTolerance contains the biggest tolerance
0332   //! of the two points which are at the closure.
0333   //! Otherwise its value is 0.0
0334   //! ClosedFlag becomes False on the output
0335   //! if it is impossible to build closed curve.
0336   Standard_EXPORT static void ConcatC1 (TColGeom_Array1OfBSplineCurve& ArrayOfCurves,
0337                                         const TColStd_Array1OfReal& ArrayOfToler,
0338                                         Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
0339                                         Handle(TColGeom_HArray1OfBSplineCurve)& ArrayOfConcatenated,
0340                                         Standard_Boolean& ClosedFlag,
0341                                         const Standard_Real ClosedTolerance,
0342                                         const Standard_Real AngularTolerance);
0343   
0344   //! This  Method reduces as far as   it is possible the
0345   //! multiplicities of  the  knots of  the BSpline BS.(keeping  the
0346   //! geometry).  It returns a new BSpline which  could still be C0.
0347   //! tolerance is a  geometrical tolerance.
0348   //! The  Angular toleranceis in radians  and measures  the angle of
0349   //! the tangents  on  the left and on  the right  to decide if  the
0350   //! curve is G1 or not at a given point
0351   Standard_EXPORT static void C0BSplineToC1BSplineCurve (Handle(Geom_BSplineCurve)& BS,
0352                                                          const Standard_Real tolerance,
0353                                                          const Standard_Real AngularTolerance = 1.0e-7);
0354   
0355   //! This Method   reduces as far  as  it is possible  the
0356   //! multiplicities  of  the knots  of the BSpline  BS.(keeping the geometry).
0357   //! It returns an array of BSpline C1. tolerance is a geometrical tolerance.
0358   Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom_BSplineCurve)& BS,
0359                                                                 Handle(TColGeom_HArray1OfBSplineCurve)& tabBS,
0360                                                                 const Standard_Real tolerance);
0361   
0362   //! This   Method reduces as far   as it is  possible the
0363   //! multiplicities of  the  knots of  the  BSpline BS.(keeping the
0364   //! geometry).  It returns an array of BSpline C1.  tolerance is a
0365   //! geometrical tolerance : it  allows for the maximum deformation
0366   //! The  Angular tolerance is in  radians and measures the angle of
0367   //! the tangents on the left and on the right to decide if the curve
0368   //! is C1 or not at a given point
0369   Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom_BSplineCurve)& BS,
0370                                                                 Handle(TColGeom_HArray1OfBSplineCurve)& tabBS,
0371                                                                 const Standard_Real AngularTolerance,
0372                                                                 const Standard_Real tolerance);
0373 
0374 };
0375 
0376 #endif // _GeomConvert_HeaderFile