Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:16:36

0001 // Copyright (c) 2021 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _BRepLib_ValidateEdge_HeaderFile
0015 #define _BRepLib_ValidateEdge_HeaderFile
0016 
0017 #include <Standard_TypeDef.hxx>
0018 #include <Standard_Handle.hxx>
0019 
0020 class Adaptor3d_Curve;
0021 class Adaptor3d_CurveOnSurface;
0022 
0023 //! Computes the max distance between 3D-curve and curve on surface.
0024 //! This class uses 2 methods: approximate using finite
0025 //! number of points (default) and exact
0026 class BRepLib_ValidateEdge
0027 {
0028 public:
0029   //! Initialization constructor
0030   Standard_EXPORT BRepLib_ValidateEdge(const occ::handle<Adaptor3d_Curve> theReferenceCurve,
0031                                        const occ::handle<Adaptor3d_CurveOnSurface> theOtherCurve,
0032                                        bool theSameParameter);
0033 
0034   //! Sets method to calculate distance: Calculating in finite number of points (if theIsExact
0035   //! is false, faster, but possible not correct result) or exact calculating by using
0036   //! BRepLib_CheckCurveOnSurface class (if theIsExact is true, slowly, but more correctly).
0037   //! Exact method is used only when edge is SameParameter.
0038   //! Default method is calculating in finite number of points
0039   void SetExactMethod(bool theIsExact) { myIsExactMethod = theIsExact; }
0040 
0041   //! Returns true if exact method selected
0042   bool IsExactMethod() { return myIsExactMethod; }
0043 
0044   //! Sets parallel flag
0045   void SetParallel(bool theIsMultiThread) { myIsMultiThread = theIsMultiThread; }
0046 
0047   //! Returns true if parallel flag is set
0048   bool IsParallel() { return myIsMultiThread; }
0049 
0050   //! Set control points number (if you need a value other than 22)
0051   void SetControlPointsNumber(int theControlPointsNumber)
0052   {
0053     myControlPointsNumber = theControlPointsNumber;
0054   }
0055 
0056   //! Sets limit to compute a distance in the Process() function. If the distance greater than
0057   //! theToleranceForChecking the Process() function stopped. Use this in case checking of
0058   //! tolerance for best performcnce. Has no effect in case using exact method.
0059   void SetExitIfToleranceExceeded(double theToleranceForChecking);
0060 
0061   //! Computes the max distance for the 3d curve <myReferenceCurve>
0062   //! and curve on surface <myOtherCurve>. If the SetExitIfToleranceExceeded()
0063   //!  function was called before <myCalculatedDistance> contains first
0064   //! greater than SetExitIfToleranceExceeded() parameter value. In case
0065   //! using exact method always computes real max distance.
0066   Standard_EXPORT void Process();
0067 
0068   //! Returns true if the distance has been found for all points
0069   bool IsDone() const { return myIsDone; }
0070 
0071   //! Returns true if computed distance is less than <theToleranceToCheck>
0072   Standard_EXPORT bool CheckTolerance(double theToleranceToCheck);
0073 
0074   //! Returns max distance
0075   Standard_EXPORT double GetMaxDistance();
0076 
0077   //! Increase <theToleranceToUpdate> if max distance is greater than <theToleranceToUpdate>
0078   Standard_EXPORT void UpdateTolerance(double& theToleranceToUpdate);
0079 
0080 private:
0081   //! Adds some margin for distance checking
0082   double correctTolerance(double theTolerance);
0083 
0084   //! Calculating in finite number of points
0085   void processApprox();
0086 
0087   //! Calculating by using BRepLib_CheckCurveOnSurface class
0088   void processExact();
0089 
0090 private:
0091   occ::handle<Adaptor3d_Curve>          myReferenceCurve;
0092   occ::handle<Adaptor3d_CurveOnSurface> myOtherCurve;
0093   bool                                  mySameParameter;
0094   int                                   myControlPointsNumber;
0095   double                                myToleranceForChecking;
0096   double                                myCalculatedDistance;
0097   bool                                  myExitIfToleranceExceeded;
0098   bool                                  myIsDone;
0099   bool                                  myIsExactMethod;
0100   bool                                  myIsMultiThread;
0101 };
0102 
0103 #endif // _BRepLib_ValidateEdge_HeaderFile