Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1991-10-03
0002 // Created by: Jean Claude 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 _Geom2dConvert_HeaderFile
0018 #define _Geom2dConvert_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 <TColGeom2d_Array1OfBSplineCurve.hxx>
0029 #include <TColStd_Array1OfReal.hxx>
0030 #include <TColGeom2d_HArray1OfBSplineCurve.hxx>
0031 #include <TColStd_HArray1OfInteger.hxx>
0032 class Geom2d_BSplineCurve;
0033 class Geom2d_Curve;
0034 
0035 
0036 
0037 //! This package provides an implementation of algorithms to do
0038 //! the conversion between equivalent geometric entities from
0039 //! package Geom2d.
0040 //! It gives the possibility :
0041 //! . to obtain the B-spline representation of bounded curves.
0042 //! . to split a B-spline curve into several B-spline curves
0043 //! with some constraints of continuity,
0044 //! . to convert a B-spline curve into several Bezier curves
0045 //! or surfaces.
0046 //! All the geometric entities used in this package are bounded.
0047 //! References :
0048 //! . Generating the Bezier Points of B-spline curves and surfaces
0049 //! (Wolfgang Bohm) CAGD volume 13 number 6 november 1981
0050 //! . On NURBS: A Survey  (Leslie Piegl) IEEE Computer Graphics and
0051 //! Application January 1991
0052 //! . Curve and surface construction using rational B-splines
0053 //! (Leslie Piegl and Wayne Tiller) CAD Volume 19 number 9 november
0054 //! 1987
0055 //! . A survey of curve and surface methods in CAGD (Wolfgang BOHM)
0056 //! CAGD 1 1984
0057 class Geom2dConvert 
0058 {
0059 public:
0060 
0061   DEFINE_STANDARD_ALLOC
0062 
0063   
0064   //! -- Convert a curve to BSpline  by Approximation
0065   //!
0066   //! This method computes the arc of B-spline curve between the two
0067   //! knots FromK1 and ToK2.  If C is periodic the arc has the same
0068   //! orientation as C if SameOrientation = Standard_True.
0069   //! If C is not periodic  SameOrientation is not used for the
0070   //! computation and C is oriented from the knot fromK1 to the
0071   //! knot toK2.
0072   //! We just keep the local definition of C between the knots
0073   //! FromK1 and ToK2.  The returned B-spline curve has its first
0074   //! and last knots with a multiplicity equal to degree + 1, where
0075   //! degree is the polynomial degree of C.
0076   //! The indexes of the knots FromK1 and ToK2 doesn't include the
0077   //! repetition of multiple knots in their definition.
0078   //!
0079   //! Raised if FromK1 or ToK2 are out of the bounds
0080   //! [FirstUKnotIndex, LastUKnotIndex]
0081   //! Raised if FromK1 = ToK2
0082   Standard_EXPORT static Handle(Geom2d_BSplineCurve) SplitBSplineCurve (const Handle(Geom2d_BSplineCurve)& C,
0083                                                                         const Standard_Integer FromK1,
0084                                                                         const Standard_Integer ToK2,
0085                                                                         const Standard_Boolean SameOrientation = Standard_True);
0086   
0087 
0088   //! This function computes the segment of B-spline curve between the
0089   //! parametric values FromU1, ToU2.
0090   //! If C is periodic the arc has the same orientation as C if
0091   //! SameOrientation = True.
0092   //! If C is not periodic SameOrientation is not used for the
0093   //! computation and C is oriented fromU1 toU2.
0094   //! If U1 and U2 and two parametric values we consider that
0095   //! U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and
0096   //! ParametricTolerance must  be greater or equal to Resolution
0097   //! from package gp.
0098   //!
0099   //! Raised if FromU1 or ToU2 are out of the parametric bounds of the
0100   //! curve (The tolerance criterion is ParametricTolerance).
0101   //! Raised if Abs (FromU1 - ToU2) <= ParametricTolerance
0102   //! Raised if ParametricTolerance < Resolution from gp.
0103   Standard_EXPORT static Handle(Geom2d_BSplineCurve) SplitBSplineCurve (const Handle(Geom2d_BSplineCurve)& C,
0104                                                                         const Standard_Real FromU1,
0105                                                                         const Standard_Real ToU2,
0106                                                                         const Standard_Real ParametricTolerance,
0107                                                                         const Standard_Boolean SameOrientation = Standard_True);
0108   
0109   //! This function converts a non infinite curve from
0110   //! Geom into a  B-spline curve.  C must  be  an ellipse or a
0111   //! circle or a trimmed conic  or a trimmed  line or a Bezier
0112   //! curve or a trimmed  Bezier curve or a  BSpline curve or  a
0113   //! trimmed BSpline   curve  or an  Offset  curve or a  trimmed
0114   //! Offset curve.
0115   //! The returned B-spline is not periodic except if C is a
0116   //! Circle or an Ellipse.
0117   //! ParameterisationType applies only if the curve is a Circle
0118   //! or an ellipse :
0119   //! TgtThetaOver2,
0120   //! TgtThetaOver2_1,
0121   //! TgtThetaOver2_2,
0122   //! TgtThetaOver2_3,
0123   //! TgtThetaOver2_4,
0124   //! Purpose: this is the classical rational parameterisation
0125   //! 2
0126   //! 1 - t
0127   //! cos(theta) = ------
0128   //! 2
0129   //! 1 + t
0130   //!
0131   //! 2t
0132   //! sin(theta) = ------
0133   //! 2
0134   //! 1 + t
0135   //!
0136   //! t = tan (theta/2)
0137   //!
0138   //! with TgtThetaOver2  the routine will compute the number of spans
0139   //! using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1
0140   //! with TgtThetaOver2_N, N  spans will be forced: an error will
0141   //! be raized if (ULast - UFirst) >= PI and N = 1,
0142   //! ULast - UFirst >= 2 PI and N = 2
0143   //!
0144   //! QuasiAngular,
0145   //! here t is a rational function that approximates
0146   //! theta ----> tan(theta/2).
0147   //! Nevetheless the composing with above function yields exact
0148   //! functions whose square sum up to 1
0149   //! RationalC1 ;
0150   //! t is replaced by a polynomial function of u so as to grant
0151   //! C1 contiuity across knots.
0152   //! Exceptions
0153   //! Standard_DomainError if the curve C is infinite.
0154   //! Standard_ConstructionError:
0155   //! -   if C is a complete circle or ellipse, and if
0156   //! Parameterisation is not equal to
0157   //! Convert_TgtThetaOver2 or to Convert_RationalC1, or
0158   //! -   if C is a trimmed circle or ellipse and if
0159   //! Parameterisation is equal to
0160   //! Convert_TgtThetaOver2_1 and if U2 - U1 >
0161   //! 0.9999 * Pi where U1 and U2 are
0162   //! respectively the first and the last parameters of the
0163   //! trimmed curve (this method of parameterization
0164   //! cannot be used to convert a half-circle or a
0165   //! half-ellipse, for example), or
0166   //! -   if C is a trimmed circle or ellipse and
0167   //! Parameterisation is equal to
0168   //! Convert_TgtThetaOver2_2 and U2 - U1 >
0169   //! 1.9999 * Pi where U1 and U2 are
0170   //! respectively the first and the last parameters of the
0171   //! trimmed curve (this method of parameterization
0172   //! cannot be used to convert a quasi-complete circle or ellipse).
0173   Standard_EXPORT static Handle(Geom2d_BSplineCurve) CurveToBSplineCurve (const Handle(Geom2d_Curve)& C,
0174                                                                           const Convert_ParameterisationType Parameterisation = Convert_TgtThetaOver2);
0175   
0176   //! This Method concatenates G1 the ArrayOfCurves as far
0177   //! as it is possible.
0178   //! ArrayOfCurves[0..N-1]
0179   //! ArrayOfToler contains the  biggest tolerance of the two
0180   //! points shared by two consecutives curves.
0181   //! Its dimension: [0..N-2]
0182   //! ClosedFlag     indicates if the ArrayOfCurves is closed.
0183   //! In this case ClosedTolerance contains the biggest tolerance
0184   //! of the two points which are at the closure.
0185   //! Otherwise its value is 0.0
0186   //! ClosedFlag becomes False on the output
0187   //! if it is impossible to build closed curve.
0188   Standard_EXPORT static void ConcatG1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves,
0189                                         const TColStd_Array1OfReal& ArrayOfToler,
0190                                         Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated,
0191                                         Standard_Boolean& ClosedFlag,
0192                                         const Standard_Real ClosedTolerance);
0193   
0194   //! This Method concatenates C1 the ArrayOfCurves as far
0195   //! as it is possible.
0196   //! ArrayOfCurves[0..N-1]
0197   //! ArrayOfToler contains the  biggest tolerance of the two
0198   //! points shared by two consecutives curves.
0199   //! Its dimension: [0..N-2]
0200   //! ClosedFlag     indicates if the ArrayOfCurves is closed.
0201   //! In this case ClosedTolerance contains the biggest tolerance
0202   //! of the two points which are at the closure.
0203   //! Otherwise its value is 0.0
0204   //! ClosedFlag becomes False on the output
0205   //! if it is impossible to build closed curve.
0206   Standard_EXPORT static void ConcatC1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves,
0207                                         const TColStd_Array1OfReal& ArrayOfToler,
0208                                         Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
0209                                         Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated,
0210                                         Standard_Boolean& ClosedFlag,
0211                                         const Standard_Real ClosedTolerance);
0212   
0213   //! This Method concatenates C1 the ArrayOfCurves as far
0214   //! as it is possible.
0215   //! ArrayOfCurves[0..N-1]
0216   //! ArrayOfToler contains the  biggest tolerance of the two
0217   //! points shared by two consecutives curves.
0218   //! Its dimension: [0..N-2]
0219   //! ClosedFlag     indicates if the ArrayOfCurves is closed.
0220   //! In this case ClosedTolerance contains the biggest tolerance
0221   //! of the two points which are at the closure.
0222   //! Otherwise its value is 0.0
0223   //! ClosedFlag becomes False on the output
0224   //! if it is impossible to build closed curve.
0225   Standard_EXPORT static void ConcatC1 (TColGeom2d_Array1OfBSplineCurve& ArrayOfCurves,
0226                                         const TColStd_Array1OfReal& ArrayOfToler,
0227                                         Handle(TColStd_HArray1OfInteger)& ArrayOfIndices,
0228                                         Handle(TColGeom2d_HArray1OfBSplineCurve)& ArrayOfConcatenated,
0229                                         Standard_Boolean& ClosedFlag,
0230                                         const Standard_Real ClosedTolerance,
0231                                         const Standard_Real AngularTolerance);
0232   
0233   //! This Method reduces as   far as it  is possible the
0234   //! multiplicities of  the  knots of  the BSpline BS.(keeping  the geometry).
0235   //! It returns a new BSpline which could still be C0.
0236   //! tolerance is a geometrical tolerance
0237   Standard_EXPORT static void C0BSplineToC1BSplineCurve (Handle(Geom2d_BSplineCurve)& BS,
0238                                                          const Standard_Real Tolerance);
0239   
0240   //! This Method   reduces as far  as  it is possible  the
0241   //! multiplicities  of  the knots  of the BSpline  BS.(keeping the geometry).
0242   //! It returns an array of BSpline C1.
0243   //! Tolerance is a geometrical tolerance
0244   Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom2d_BSplineCurve)& BS,
0245                                                                 Handle(TColGeom2d_HArray1OfBSplineCurve)& tabBS,
0246                                                                 const Standard_Real Tolerance);
0247   
0248   //! This Method   reduces as far  as  it is possible  the
0249   //! multiplicities  of  the knots  of the BSpline  BS.(keeping the geometry).
0250   //! It returns an array of BSpline C1.
0251   //! tolerance is a geometrical tolerance
0252   Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve (const Handle(Geom2d_BSplineCurve)& BS,
0253                                                                 Handle(TColGeom2d_HArray1OfBSplineCurve)& tabBS,
0254                                                                 const Standard_Real AngularTolerance,
0255                                                                 const Standard_Real Tolerance);
0256 
0257 };
0258 
0259 #endif // _Geom2dConvert_HeaderFile