1 // Created on: 1993-01-26
2 // Created by: Laurent PAINNOT
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Approx_FitAndDivide2d_HeaderFile
18 #define _Approx_FitAndDivide2d_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <AppParCurves_SequenceOfMultiCurve.hxx>
25 #include <TColStd_SequenceOfReal.hxx>
26 #include <AppParCurves_MultiCurve.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Standard_Real.hxx>
30 #include <AppParCurves_Constraint.hxx>
31 #include <AppCont_Function.hxx>
32 class AppParCurves_MultiCurve;
36 class Approx_FitAndDivide2d
43 //! The MultiLine <Line> will be approximated until tolerances
45 //! The approximation will be done from degreemin to degreemax
46 //! with a cutting if the corresponding boolean is True.
47 Standard_EXPORT Approx_FitAndDivide2d(const AppCont_Function& Line, const Standard_Integer degreemin = 3, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-5, const Standard_Real Tolerance2d = 1.0e-5, const Standard_Boolean cutting = Standard_False, const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint, const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
49 //! Initializes the fields of the algorithm.
50 Standard_EXPORT Approx_FitAndDivide2d(const Standard_Integer degreemin = 3, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-05, const Standard_Real Tolerance2d = 1.0e-05, const Standard_Boolean cutting = Standard_False, const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint, const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
52 //! runs the algorithm after having initialized the fields.
53 Standard_EXPORT void Perform (const AppCont_Function& Line);
55 //! changes the degrees of the approximation.
56 Standard_EXPORT void SetDegrees (const Standard_Integer degreemin, const Standard_Integer degreemax);
58 //! Changes the tolerances of the approximation.
59 Standard_EXPORT void SetTolerances (const Standard_Real Tolerance3d, const Standard_Real Tolerance2d);
61 //! Changes the constraints of the approximation.
62 Standard_EXPORT void SetConstraints (const AppParCurves_Constraint FirstC, const AppParCurves_Constraint LastC);
64 //! Changes the max number of segments, which is allowed for cutting.
65 Standard_EXPORT void SetMaxSegments (const Standard_Integer theMaxSegments);
67 //! Set inverse order of degree selection:
68 //! if theInvOrdr = true, current degree is chosen by inverse order -
69 //! from maxdegree to mindegree.
70 //! By default inverse order is used.
71 Standard_EXPORT void SetInvOrder(const Standard_Boolean theInvOrder);
73 //! Set value of hang checking flag
74 //! if this flag = true, possible hang of algorithm is checked
75 //! and algorithm is forced to stop.
76 //! By default hang checking is used.
77 Standard_EXPORT void SetHangChecking(const Standard_Boolean theHangChecking);
79 //! returns False if at a moment of the approximation,
80 //! the status NoApproximation has been sent by the user
81 //! when more points were needed.
82 Standard_EXPORT Standard_Boolean IsAllApproximated() const;
84 //! returns False if the status NoPointsAdded has been sent.
85 Standard_EXPORT Standard_Boolean IsToleranceReached() const;
87 //! returns the tolerances 2d and 3d of the <Index> MultiCurve.
88 Standard_EXPORT void Error (const Standard_Integer Index, Standard_Real& tol3d, Standard_Real& tol2d) const;
90 //! Returns the number of MultiCurve doing the approximation
92 Standard_EXPORT Standard_Integer NbMultiCurves() const;
94 //! returns the approximation MultiCurve of range <Index>.
95 Standard_EXPORT AppParCurves_MultiCurve Value (const Standard_Integer Index = 1) const;
97 Standard_EXPORT void Parameters (const Standard_Integer Index, Standard_Real& firstp, Standard_Real& lastp) const;
111 //! is internally used by the algorithms.
112 Standard_EXPORT Standard_Boolean Compute (const AppCont_Function& Line, const Standard_Real Ufirst, const Standard_Real Ulast, Standard_Real& TheTol3d, Standard_Real& TheTol2d);
115 AppParCurves_SequenceOfMultiCurve myMultiCurves;
116 TColStd_SequenceOfReal myfirstparam;
117 TColStd_SequenceOfReal mylastparam;
118 AppParCurves_MultiCurve TheMultiCurve;
119 Standard_Boolean alldone;
120 Standard_Boolean tolreached;
121 TColStd_SequenceOfReal Tolers3d;
122 TColStd_SequenceOfReal Tolers2d;
123 Standard_Integer mydegremin;
124 Standard_Integer mydegremax;
125 Standard_Real mytol3d;
126 Standard_Real mytol2d;
127 Standard_Real currenttol3d;
128 Standard_Real currenttol2d;
129 Standard_Boolean mycut;
130 AppParCurves_Constraint myfirstC;
131 AppParCurves_Constraint mylastC;
132 Standard_Integer myMaxSegments;
133 Standard_Boolean myInvOrder;
134 Standard_Boolean myHangChecking;
144 #endif // _Approx_FitAndDivide2d_HeaderFile