1 // Copyright (c) 2021 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13 
14 
15 #ifndef _BRepLib_ValidateEdge_HeaderFile
16 #define _BRepLib_ValidateEdge_HeaderFile
17 
18 #include<Standard_TypeDef.hxx>
19 #include<Standard_Handle.hxx>
20 
21 class Adaptor3d_Curve;
22 class Adaptor3d_CurveOnSurface;
23 
24 //! Computes the max distance between 3D-curve and curve on
25 //! surface in fixed points number
26 class BRepLib_ValidateEdge
27 {
28 public:
29   //! Initialization constructor
30   Standard_EXPORT BRepLib_ValidateEdge(const Handle(Adaptor3d_Curve) theReferenceCurve,
31                                        const Handle(Adaptor3d_CurveOnSurface) theOtherCurve,
32                                        Standard_Boolean theSameParameter);
33 
34   //! Set control points number (if you need a value other than 22)
SetControlPointsNumber(Standard_Integer theControlPointsNumber)35   void SetControlPointsNumber(Standard_Integer theControlPointsNumber)
36   {
37     myControlPointsNumber = theControlPointsNumber;
38   }
39 
40   //! Sets the maximal allowed distance in the Process() function. If the distance greater than
41   //! theToleranceForChecking the Process() function stops. Use this for best performance
42   //! in case of checking of tolerance.
43   Standard_EXPORT void SetExitIfToleranceExceeded(Standard_Real theToleranceForChecking);
44 
45   //! Computes the max distance for the 3d curve <myReferenceCurve>
46   //! and curve on surface <myOtherCurve>. If the SetExitIfToleranceExceeded()
47   //!  function was called before <myCalculatedDistance> contains first
48   //! greater than SetExitIfToleranceExceeded() parameter value
49   Standard_EXPORT void Process();
50 
51   //! Returns true if the distance has been found for all points
IsDone()52   Standard_Boolean IsDone()
53   {
54     return myIsDone;
55   }
56 
57   //! Returns true if computed distance is less than <theToleranceToCheck>
58   Standard_EXPORT Standard_Boolean CheckTolerance(Standard_Real theToleranceToCheck);
59 
60   //! Returns max distance
61   Standard_EXPORT Standard_Real GetMaxDistance();
62 
63   //! Increase <theToleranceToUpdate> if max distance is greater than <theToleranceToUpdate>
64   Standard_EXPORT void UpdateTolerance(Standard_Real& theToleranceToUpdate);
65 
66 private:
67   //! Adds some margin for distance checking
68   Standard_Real correctTolerance(Standard_Real theTolerance);
69 
70 private:
71   Handle(Adaptor3d_Curve) myReferenceCurve;
72   Handle(Adaptor3d_CurveOnSurface) myOtherCurve;
73   Standard_Boolean mySameParameter;
74   Standard_Integer myControlPointsNumber;
75   Standard_Real myToleranceForChecking;
76   Standard_Real myCalculatedDistance;
77   Standard_Boolean myExitIfToleranceExceeded;
78   Standard_Boolean myIsDone;
79 };
80 
81 #endif  // _BRepLib_ValidateEdge_HeaderFile