Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1996-11-08
0002 // Created by: Jean Claude VAUTHIER
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 _GCPnts_TangentialDeflection_HeaderFile
0018 #define _GCPnts_TangentialDeflection_HeaderFile
0019 
0020 #include <TColgp_SequenceOfPnt.hxx>
0021 #include <TColStd_SequenceOfReal.hxx>
0022 #include <gp_Pnt.hxx>
0023 #include <math_Function.hxx>
0024 #include <math_MultipleVarFunction.hxx>
0025 #include <Adaptor3d_Curve.hxx>
0026 #include <Adaptor2d_Curve2d.hxx>
0027 
0028 //! Computes a set of  points on a curve from package
0029 //! Adaptor3d  such  as between  two successive   points
0030 //! P1(u1)and P2(u2) :
0031 //! @code
0032 //! . ||P1P3^P3P2||/||P1P3||*||P3P2||<AngularDeflection
0033 //! . ||P1P2^P1P3||/||P1P2||<CurvatureDeflection
0034 //! @endcode
0035 //! where P3 is the point of abscissa ((u1+u2)/2), with
0036 //! u1 the abscissa of the point P1 and u2 the abscissa
0037 //! of the point P2.
0038 //!
0039 //! ^ is the cross product of two vectors, and ||P1P2||
0040 //! the magnitude of the vector P1P2.
0041 //!
0042 //! The conditions AngularDeflection > gp::Resolution()
0043 //! and CurvatureDeflection > gp::Resolution() must be
0044 //! satisfied at the construction time.
0045 //!
0046 //! A minimum number of points can be fixed for a linear or circular element.
0047 //! Example:
0048 //! @code
0049 //! Handle(Geom_BezierCurve) aCurve = new Geom_BezierCurve (thePoles);
0050 //! GeomAdaptor_Curve aCurveAdaptor (aCurve);
0051 //! double aCDeflect  = 0.01; // Curvature deflection
0052 //! double anADeflect = 0.09; // Angular   deflection
0053 //!
0054 //! GCPnts_TangentialDeflection aPointsOnCurve;
0055 //! aPointsOnCurve.Initialize (aCurveAdaptor, anADeflect, aCDeflect);
0056 //! for (int i = 1; i <= aPointsOnCurve.NbPoints(); ++i)
0057 //! {
0058 //!   double aU   = aPointsOnCurve.Parameter (i);
0059 //!   gp_Pnt aPnt = aPointsOnCurve.Value (i);
0060 //! }
0061 //! @endcode
0062 class GCPnts_TangentialDeflection 
0063 {
0064 public:
0065 
0066   DEFINE_STANDARD_ALLOC
0067 
0068   //! Empty constructor.
0069   //! @sa Initialize()
0070   Standard_EXPORT GCPnts_TangentialDeflection();
0071 
0072   //! Constructor for 3D curve.
0073   //! @param theC [in] 3d curve
0074   //! @param theAngularDeflection   [in] angular deflection in radians
0075   //! @param theCurvatureDeflection [in] linear deflection
0076   //! @param theMinimumOfPoints [in] minimum number of points
0077   //! @param theUTol   [in] tolerance in curve parametric scope
0078   //! @param theMinLen [in] minimal length
0079   Standard_EXPORT GCPnts_TangentialDeflection (const Adaptor3d_Curve& theC,
0080                                                const Standard_Real theAngularDeflection, const Standard_Real theCurvatureDeflection,
0081                                                const Standard_Integer theMinimumOfPoints = 2,
0082                                                const Standard_Real theUTol = 1.0e-9,
0083                                                const Standard_Real theMinLen = 1.0e-7);
0084 
0085   //! Constructor for 3D curve with restricted range.
0086   //! @param theC [in] 3d curve
0087   //! @param theFirstParameter [in] first parameter on curve
0088   //! @param theLastParameter  [in] last  parameter on curve
0089   //! @param theAngularDeflection   [in] angular deflection in radians
0090   //! @param theCurvatureDeflection [in] linear deflection
0091   //! @param theMinimumOfPoints [in] minimum number of points
0092   //! @param theUTo  l [in] tolerance in curve parametric scope
0093   //! @param theMinLen [in] minimal length
0094   Standard_EXPORT GCPnts_TangentialDeflection (const Adaptor3d_Curve& theC,
0095                                                const Standard_Real theFirstParameter, const Standard_Real theLastParameter,
0096                                                const Standard_Real theAngularDeflection, const Standard_Real theCurvatureDeflection,
0097                                                const Standard_Integer theMinimumOfPoints = 2,
0098                                                const Standard_Real theUTol = 1.0e-9,
0099                                                const Standard_Real theMinLen = 1.0e-7);
0100 
0101   //! Constructor for 2D curve.
0102   //! @param theC [in] 2d curve
0103   //! @param theAngularDeflection   [in] angular deflection in radians
0104   //! @param theCurvatureDeflection [in] linear deflection
0105   //! @param theMinimumOfPoints [in] minimum number of points
0106   //! @param theUTol   [in] tolerance in curve parametric scope
0107   //! @param theMinLen [in] minimal length
0108   Standard_EXPORT GCPnts_TangentialDeflection (const Adaptor2d_Curve2d& theC,
0109                                                const Standard_Real theAngularDeflection, const Standard_Real theCurvatureDeflection,
0110                                                const Standard_Integer theMinimumOfPoints = 2,
0111                                                const Standard_Real theUTol = 1.0e-9,
0112                                                const Standard_Real theMinLen = 1.0e-7);
0113 
0114   //! Constructor for 2D curve with restricted range.
0115   //! @param theC [in] 2d curve
0116   //! @param theFirstParameter [in] first parameter on curve
0117   //! @param theLastParameter  [in] last  parameter on curve
0118   //! @param theAngularDeflection   [in] angular deflection in radians
0119   //! @param theCurvatureDeflection [in] linear deflection
0120   //! @param theMinimumOfPoints [in] minimum number of points
0121   //! @param theUTol   [in] tolerance in curve parametric scope
0122   //! @param theMinLen [in] minimal length
0123   Standard_EXPORT GCPnts_TangentialDeflection (const Adaptor2d_Curve2d& theC,
0124                                                const Standard_Real theFirstParameter, const Standard_Real theLastParameter,
0125                                                const Standard_Real theAngularDeflection, const Standard_Real theCurvatureDeflection,
0126                                                const Standard_Integer theMinimumOfPoints = 2,
0127                                                const Standard_Real theUTol = 1.0e-9,
0128                                                const Standard_Real theMinLen = 1.0e-7);
0129 
0130   //! Initialize algorithm for 3D curve.
0131   //! @param theC [in] 3d curve
0132   //! @param theAngularDeflection   [in] angular deflection in radians
0133   //! @param theCurvatureDeflection [in] linear deflection
0134   //! @param theMinimumOfPoints [in] minimum number of points
0135   //! @param theUTol   [in] tolerance in curve parametric scope
0136   //! @param theMinLen [in] minimal length
0137   Standard_EXPORT void Initialize (const Adaptor3d_Curve& theC,
0138                                    const Standard_Real theAngularDeflection, const Standard_Real theCurvatureDeflection,
0139                                    const Standard_Integer theMinimumOfPoints = 2,
0140                                    const Standard_Real theUTol = 1.0e-9,
0141                                    const Standard_Real theMinLen = 1.0e-7);
0142 
0143   //! Initialize algorithm for 3D curve with restricted range.
0144   //! @param theC [in] 3d curve
0145   //! @param theFirstParameter [in] first parameter on curve
0146   //! @param theLastParameter  [in] last  parameter on curve
0147   //! @param theAngularDeflection   [in] angular deflection in radians
0148   //! @param theCurvatureDeflection [in] linear deflection
0149   //! @param theMinimumOfPoints [in] minimum number of points
0150   //! @param theUTol   [in] tolerance in curve parametric scope
0151   //! @param theMinLen [in] minimal length
0152   Standard_EXPORT void Initialize (const Adaptor3d_Curve& theC,
0153                                    const Standard_Real theFirstParameter, const Standard_Real theLastParameter,
0154                                    const Standard_Real theAngularDeflection, const Standard_Real theCurvatureDeflection,
0155                                    const Standard_Integer theMinimumOfPoints = 2,
0156                                    const Standard_Real theUTol = 1.0e-9,
0157                                    const Standard_Real theMinLen = 1.0e-7);
0158 
0159   //! Initialize algorithm for 2D curve.
0160   //! @param theC [in] 2d curve
0161   //! @param theAngularDeflection   [in] angular deflection in radians
0162   //! @param theCurvatureDeflection [in] linear deflection
0163   //! @param theMinimumOfPoints [in] minimum number of points
0164   //! @param theUTol   [in] tolerance in curve parametric scope
0165   //! @param theMinLen [in] minimal length
0166   Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& theC,
0167                                    const Standard_Real theAngularDeflection, const Standard_Real theCurvatureDeflection,
0168                                    const Standard_Integer theMinimumOfPoints = 2,
0169                                    const Standard_Real theUTol = 1.0e-9,
0170                                    const Standard_Real theMinLen = 1.0e-7);
0171 
0172   //! Initialize algorithm for 2D curve with restricted range.
0173   //! @param theC [in] 2d curve
0174   //! @param theFirstParameter [in] first parameter on curve
0175   //! @param theLastParameter  [in] last  parameter on curve
0176   //! @param theAngularDeflection   [in] angular deflection in radians
0177   //! @param theCurvatureDeflection [in] linear deflection
0178   //! @param theMinimumOfPoints [in] minimum number of points
0179   //! @param theUTol   [in] tolerance in curve parametric scope
0180   //! @param theMinLen [in] minimal length
0181   Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& theC,
0182                                    const Standard_Real theFirstParameter, const Standard_Real theLastParameter,
0183                                    const Standard_Real theAngularDeflection, const Standard_Real theCurvatureDeflection,
0184                                    const Standard_Integer theMinimumOfPoints = 2,
0185                                    const Standard_Real theUTol = 1.0e-9,
0186                                    const Standard_Real theMinLen = 1.0e-7);
0187 
0188   //! Add point to already calculated points (or replace existing)
0189   //! Returns index of new added point
0190   //! or founded with parametric tolerance (replaced if theIsReplace is true)
0191   Standard_EXPORT Standard_Integer AddPoint (const gp_Pnt& thePnt,
0192                                              const Standard_Real theParam,
0193                                              const Standard_Boolean theIsReplace = Standard_True);
0194 
0195   Standard_Integer NbPoints () const
0196   {
0197     return myParameters.Length ();
0198   }
0199 
0200   Standard_Real Parameter (const Standard_Integer I) const
0201   {
0202     return myParameters.Value (I);
0203   }
0204 
0205   gp_Pnt Value (const Standard_Integer I) const
0206   {
0207     return myPoints.Value (I);
0208   }
0209 
0210   //! Computes angular step for the arc using the given parameters.
0211   Standard_EXPORT static Standard_Real ArcAngularStep (const Standard_Real theRadius,
0212                                                        const Standard_Real theLinearDeflection,
0213                                                        const Standard_Real theAngularDeflection,
0214                                                        const Standard_Real theMinLength);
0215 
0216 private:
0217 
0218   template<class TheCurve>
0219   void initialize (const TheCurve& theC,
0220                    const Standard_Real theFirstParameter, const Standard_Real theLastParameter,
0221                    const Standard_Real theAngularDeflection, const Standard_Real theCurvatureDeflection,
0222                    const Standard_Integer theMinimumOfPoints,
0223                    const Standard_Real theUTol,
0224                    const Standard_Real theMinLen);
0225 
0226   template<class TheCurve>
0227   void PerformLinear (const TheCurve& theC);
0228 
0229   template<class TheCurve>
0230   void PerformCircular (const TheCurve& theC);
0231 
0232   //! Respecting the angle and the deflection,
0233   //! we impose a minimum number of points on a curve.
0234   template<class TheCurve>
0235   void PerformCurve (const TheCurve& theC);
0236 
0237   template<class TheCurve>
0238   void EvaluateDu (const TheCurve& theC,
0239                    const Standard_Real theU,
0240                    gp_Pnt& theP,
0241                    Standard_Real& theDu,
0242                    Standard_Boolean& theNotDone) const;
0243 
0244   //! Estimation of maximal deflection for interval [theU1, theU2]
0245   template<class TheCurve>
0246   void EstimDefl (const TheCurve& theC,
0247                   const Standard_Real theU1, const Standard_Real theU2,
0248                   Standard_Real& theMaxDefl, Standard_Real& theUMax);
0249 
0250 private:
0251   Standard_Real myAngularDeflection;
0252   Standard_Real myCurvatureDeflection;
0253   Standard_Real myUTol;
0254   Standard_Integer myMinNbPnts;
0255   Standard_Real myMinLen;
0256   Standard_Real myLastU;
0257   Standard_Real myFirstu;
0258   TColgp_SequenceOfPnt   myPoints;
0259   TColStd_SequenceOfReal myParameters;
0260 };
0261 
0262 #endif // _GCPnts_TangentialDeflection_HeaderFile