Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:58

0001 // Created on: 1995-06-02
0002 // Created by: Xavier BENVENISTE
0003 // Copyright (c) 1995-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 _Approx_SameParameter_HeaderFile
0018 #define _Approx_SameParameter_HeaderFile
0019 
0020 #include <Adaptor3d_CurveOnSurface.hxx>
0021 #include <Adaptor3d_Surface.hxx>
0022 
0023 class Geom_Curve;
0024 class Geom2d_Curve;
0025 class Geom_Surface;
0026 
0027 //! Approximation of a  PCurve  on a surface to  make its
0028 //! parameter be the same that the parameter of a given 3d
0029 //! reference curve.
0030 class Approx_SameParameter 
0031 {
0032 public:
0033 
0034   DEFINE_STANDARD_ALLOC
0035 
0036   //! Warning: the C3D and C2D must have the same parametric domain.
0037   Standard_EXPORT Approx_SameParameter(const Handle(Geom_Curve)& C3D,
0038                                        const Handle(Geom2d_Curve)& C2D,
0039                                        const Handle(Geom_Surface)& S,
0040                                        const Standard_Real Tol);
0041 
0042   //! Warning: the C3D and C2D must have the same parametric domain.
0043   Standard_EXPORT Approx_SameParameter(const Handle(Adaptor3d_Curve)& C3D,
0044                                        const Handle(Geom2d_Curve)& C2D,
0045                                        const Handle(Adaptor3d_Surface)& S,
0046                                        const Standard_Real Tol);
0047 
0048   //! Warning: the C3D and C2D must have the same parametric domain.
0049   Standard_EXPORT Approx_SameParameter(const Handle(Adaptor3d_Curve)& C3D,
0050                                        const Handle(Adaptor2d_Curve2d)& C2D,
0051                                        const Handle(Adaptor3d_Surface)& S,
0052                                        const Standard_Real Tol);
0053 
0054   //!@Returns .false. if calculations failed,
0055   //! .true. if calculations succeed
0056   Standard_Boolean IsDone() const
0057   {
0058     return myDone;
0059   }
0060 
0061   //!@Returns tolerance (maximal distance) between 3d curve
0062   //! and curve on surface, generated by 2d curve and surface. 
0063   Standard_Real TolReached() const
0064   {
0065     return myTolReached;
0066   }
0067 
0068   //! Tells whether the original data had already the same
0069   //! parameter up to the tolerance : in that case nothing
0070   //! is done.
0071   Standard_Boolean IsSameParameter() const
0072   {
0073     return mySameParameter;
0074   }
0075 
0076   //! Returns the 2D curve that has the same parameter as
0077   //! the 3D curve once evaluated on the surface up to the
0078   //! specified tolerance.
0079   Handle(Geom2d_Curve) Curve2d() const
0080   {
0081     return myCurve2d;
0082   }
0083 
0084   //! Returns the 3D curve that has the same parameter as
0085   //! the 3D curve once evaluated on the surface up to the
0086   //! specified tolerance.
0087   Handle(Adaptor3d_Curve) Curve3d() const
0088   {
0089     return myC3d;
0090   }
0091 
0092   //! Returns the 3D curve on surface that has the same parameter as
0093   //! the 3D curve up to the specified tolerance.
0094   Handle(Adaptor3d_CurveOnSurface) CurveOnSurface() const
0095   {
0096     return myCurveOnSurface;
0097   }
0098 
0099 private:
0100 
0101   //! Internal data structure to unify access to the most actively used data.
0102   //! This structure is not intended to be class field since
0103   //! a lot of memory is used in intermediate computations.
0104   struct Approx_SameParameter_Data
0105   {
0106     Adaptor3d_CurveOnSurface myCOnS; // Curve on surface.
0107     Standard_Integer myNbPnt; // Number of points.
0108     Standard_Real *myPC3d; // Parameters on 3d curve.
0109     Standard_Real *myPC2d; // Parameters on 2d curve.
0110 
0111     // Second data arrays. Used in loop over poles.
0112     Standard_Real *myNewPC3d; // Parameters on 3d curve.
0113     Standard_Real *myNewPC2d; // Parameters on 2d curve.
0114 
0115     // Parameters ranges.
0116     Standard_Real myC3dPF; // Curve 3d Parameter First.
0117     Standard_Real myC3dPL; // Curve 3d Parameter Last.
0118     Standard_Real myC2dPF; // Curve 2d Parameter First.
0119     Standard_Real myC2dPL; // Curve 2d Parameter Last.
0120 
0121     Standard_Real myTol; // Working tolerance.
0122 
0123     // Swap data arrays and update number of points.
0124     void Swap(const Standard_Integer theNewNbPoints)
0125     {
0126       myNbPnt = theNewNbPoints;
0127       Standard_Real * temp;
0128 
0129       // 3-D
0130       temp = myPC3d;
0131       myPC3d = myNewPC3d;
0132       myNewPC3d = temp;
0133 
0134       // 2-D
0135       temp = myPC2d;
0136       myPC2d = myNewPC2d;
0137       myNewPC2d = temp;
0138     }
0139   };
0140 
0141 
0142   Approx_SameParameter(const Approx_SameParameter &);
0143   Approx_SameParameter& operator=(const Approx_SameParameter &);
0144 
0145   //! Computes the pcurve (internal use only).
0146   Standard_EXPORT void Build (const Standard_Real Tol);
0147 
0148   //! Computes initial point distribution.
0149   Standard_Boolean BuildInitialDistribution(Approx_SameParameter_Data &theData) const;
0150 
0151   //! Increases initial number of samples in case of the C0 continuity.
0152   //! Return new number of points and corresponding data arrays.
0153   //@return true if new number of samples is good and false otherwise.
0154   Standard_Boolean IncreaseInitialNbSamples(Approx_SameParameter_Data &theData) const;
0155 
0156   //! Computes tangents on boundary points.
0157   //@return true if tangents are not null and false otherwise.
0158   Standard_Boolean ComputeTangents(const Adaptor3d_CurveOnSurface & theCOnS,
0159                                    Standard_Real &theFirstTangent,
0160                                    Standard_Real &theLastTangent) const;
0161 
0162   //! Method to check same parameter state
0163   //! and build dependency between 2d and 3d curves.
0164   //@return true if 2d and 3d curves have same parameter state and false otherwise.
0165   Standard_Boolean CheckSameParameter(Approx_SameParameter_Data &theData,
0166                                       Standard_Real &theSqDist) const;
0167 
0168   //! Computes interpolated values.
0169   //!@Returns .false. if computations failed;
0170   Standard_Boolean Interpolate(const Approx_SameParameter_Data & theData,
0171                    const Standard_Real aTangFirst,
0172                    const Standard_Real aTangLast,
0173                    TColStd_Array1OfReal & thePoles,
0174                    TColStd_Array1OfReal & theFlatKnots) const;
0175 
0176   //! Increases number of poles in poles loop.
0177   //@return true if poles is changed and false otherwise.
0178   Standard_Boolean IncreaseNbPoles(const TColStd_Array1OfReal & thePoles,
0179                                    const TColStd_Array1OfReal & theFlatKnots,
0180                                    Approx_SameParameter_Data & theData,
0181                                    Standard_Real &theBestSqTol) const;
0182 
0183   static const Standard_Integer myNbSamples = 22; // To be consistent with "checkshape".
0184   static const Standard_Integer myMaxArraySize = 1000;
0185   const Standard_Real myDeltaMin; // Initialization is allowed only for integral types.
0186 
0187   Standard_Boolean mySameParameter;
0188   Standard_Boolean myDone;
0189   Standard_Real myTolReached;
0190   Handle(Geom2d_Curve) myCurve2d;
0191   Handle(Adaptor2d_Curve2d) myHCurve2d;
0192   Handle(Adaptor3d_Curve) myC3d;
0193   Handle(Adaptor3d_Surface) mySurf;
0194   Handle(Adaptor3d_CurveOnSurface) myCurveOnSurface;
0195 };
0196 
0197 #endif // _Approx_SameParameter_HeaderFile