42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Approx_FitAndDivide_HeaderFile |
18 | #define _Approx_FitAndDivide_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
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; |
33 | |
34 | |
35 | |
36 | class Approx_FitAndDivide |
37 | { |
38 | public: |
39 | |
40 | DEFINE_STANDARD_ALLOC |
41 | |
42 | |
36b9ff75 |
43 | //! The MultiLine <Line> will be approximated until tolerances |
44 | //! will be reached. |
45 | //! The approximation will be done from degreemin to degreemax |
46 | //! with a cutting if the corresponding boolean is True. |
42cf5bc1 |
47 | Standard_EXPORT Approx_FitAndDivide(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); |
48 | |
36b9ff75 |
49 | //! Initializes the fields of the algorithm. |
42cf5bc1 |
50 | Standard_EXPORT Approx_FitAndDivide(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); |
51 | |
36b9ff75 |
52 | //! runs the algorithm after having initialized the fields. |
42cf5bc1 |
53 | Standard_EXPORT void Perform (const AppCont_Function& Line); |
54 | |
36b9ff75 |
55 | //! changes the degrees of the approximation. |
42cf5bc1 |
56 | Standard_EXPORT void SetDegrees (const Standard_Integer degreemin, const Standard_Integer degreemax); |
57 | |
36b9ff75 |
58 | //! Changes the tolerances of the approximation. |
42cf5bc1 |
59 | Standard_EXPORT void SetTolerances (const Standard_Real Tolerance3d, const Standard_Real Tolerance2d); |
60 | |
36b9ff75 |
61 | //! Changes the constraints of the approximation. |
42cf5bc1 |
62 | Standard_EXPORT void SetConstraints (const AppParCurves_Constraint FirstC, const AppParCurves_Constraint LastC); |
f998596a |
63 | |
64 | //! Changes the max number of segments, which is allowed for cutting. |
65 | Standard_EXPORT void SetMaxSegments (const Standard_Integer theMaxSegments); |
42cf5bc1 |
66 | |
ba7f665d |
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); |
72 | |
13dd311c |
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); |
78 | |
36b9ff75 |
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. |
42cf5bc1 |
82 | Standard_EXPORT Standard_Boolean IsAllApproximated() const; |
83 | |
36b9ff75 |
84 | //! returns False if the status NoPointsAdded has been sent. |
42cf5bc1 |
85 | Standard_EXPORT Standard_Boolean IsToleranceReached() const; |
86 | |
36b9ff75 |
87 | //! returns the tolerances 2d and 3d of the <Index> MultiCurve. |
42cf5bc1 |
88 | Standard_EXPORT void Error (const Standard_Integer Index, Standard_Real& tol3d, Standard_Real& tol2d) const; |
89 | |
36b9ff75 |
90 | //! Returns the number of MultiCurve doing the approximation |
91 | //! of the MultiLine. |
42cf5bc1 |
92 | Standard_EXPORT Standard_Integer NbMultiCurves() const; |
93 | |
36b9ff75 |
94 | //! returns the approximation MultiCurve of range <Index>. |
42cf5bc1 |
95 | Standard_EXPORT AppParCurves_MultiCurve Value (const Standard_Integer Index = 1) const; |
96 | |
97 | Standard_EXPORT void Parameters (const Standard_Integer Index, Standard_Real& firstp, Standard_Real& lastp) const; |
98 | |
99 | |
100 | |
101 | |
102 | protected: |
103 | |
104 | |
105 | |
106 | |
107 | |
108 | private: |
109 | |
110 | |
36b9ff75 |
111 | //! is internally used by the algorithms. |
42cf5bc1 |
112 | Standard_EXPORT Standard_Boolean Compute (const AppCont_Function& Line, const Standard_Real Ufirst, const Standard_Real Ulast, Standard_Real& TheTol3d, Standard_Real& TheTol2d); |
113 | |
114 | |
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; |
f998596a |
132 | Standard_Integer myMaxSegments; |
ba7f665d |
133 | Standard_Boolean myInvOrder; |
13dd311c |
134 | Standard_Boolean myHangChecking; |
42cf5bc1 |
135 | |
136 | |
137 | }; |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | |
145 | #endif // _Approx_FitAndDivide_HeaderFile |