42cf5bc1 |
1 | // Created on: 1995-01-27 |
2 | // Created by: Jacques GOUSSARD |
3 | // Copyright (c) 1995-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 _GeomInt_TheComputeLineOfWLApprox_HeaderFile |
18 | #define _GeomInt_TheComputeLineOfWLApprox_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <AppParCurves_MultiBSpCurve.hxx> |
25 | #include <Standard_Boolean.hxx> |
26 | #include <Approx_ParametrizationType.hxx> |
27 | #include <TColStd_HArray1OfReal.hxx> |
28 | #include <TColStd_HArray1OfInteger.hxx> |
29 | #include <AppParCurves_HArray1OfConstraintCouple.hxx> |
30 | #include <Standard_Integer.hxx> |
31 | #include <Standard_Real.hxx> |
32 | #include <AppParCurves_Constraint.hxx> |
33 | #include <math_Vector.hxx> |
34 | #include <TColStd_Array1OfReal.hxx> |
35 | #include <TColStd_Array1OfInteger.hxx> |
36 | class GeomInt_TheMultiLineOfWLApprox; |
37 | class GeomInt_TheMultiLineToolOfWLApprox; |
38 | class GeomInt_MyBSplGradientOfTheComputeLineOfWLApprox; |
39 | class GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox; |
40 | class GeomInt_BSpParFunctionOfMyBSplGradientOfTheComputeLineOfWLApprox; |
41 | class GeomInt_BSpGradient_BFGSOfMyBSplGradientOfTheComputeLineOfWLApprox; |
42 | class GeomInt_MyGradientbisOfTheComputeLineOfWLApprox; |
43 | class GeomInt_ParLeastSquareOfMyGradientbisOfTheComputeLineOfWLApprox; |
44 | class GeomInt_ResConstraintOfMyGradientbisOfTheComputeLineOfWLApprox; |
45 | class GeomInt_ParFunctionOfMyGradientbisOfTheComputeLineOfWLApprox; |
46 | class GeomInt_Gradient_BFGSOfMyGradientbisOfTheComputeLineOfWLApprox; |
47 | class AppParCurves_MultiBSpCurve; |
48 | class AppParCurves_MultiCurve; |
49 | |
50 | |
51 | |
52 | class GeomInt_TheComputeLineOfWLApprox |
53 | { |
54 | public: |
55 | |
56 | DEFINE_STANDARD_ALLOC |
57 | |
58 | |
36b9ff75 |
59 | //! The MultiLine <Line> will be approximated until tolerances |
60 | //! will be reached. |
61 | //! The approximation will be done from degreemin to degreemax |
62 | //! with a cutting if the corresponding boolean is True. |
63 | //! If <Squares> is True, the computation will be done with |
64 | //! no iteration at all. |
65 | //! |
66 | //! The multiplicities of the internal knots is set by |
67 | //! default. |
42cf5bc1 |
68 | Standard_EXPORT GeomInt_TheComputeLineOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-3, const Standard_Real Tolerance2d = 1.0e-6, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Approx_ParametrizationType parametrization = Approx_ChordLength, const Standard_Boolean Squares = Standard_False); |
69 | |
36b9ff75 |
70 | //! The MultiLine <Line> will be approximated until tolerances |
71 | //! will be reached. |
72 | //! The approximation will be done from degreemin to degreemax |
73 | //! with a cutting if the corresponding boolean is True. |
74 | //! If <Squares> is True, the computation will be done with |
75 | //! no iteration at all. |
42cf5bc1 |
76 | Standard_EXPORT GeomInt_TheComputeLineOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& Line, const math_Vector& Parameters, const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-03, const Standard_Real Tolerance2d = 1.0e-06, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Standard_Boolean Squares = Standard_False); |
77 | |
36b9ff75 |
78 | //! Initializes the fields of the algorithm. |
42cf5bc1 |
79 | Standard_EXPORT GeomInt_TheComputeLineOfWLApprox(const math_Vector& Parameters, const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-03, const Standard_Real Tolerance2d = 1.0e-06, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Standard_Boolean Squares = Standard_False); |
80 | |
36b9ff75 |
81 | //! Initializes the fields of the algorithm. |
42cf5bc1 |
82 | Standard_EXPORT GeomInt_TheComputeLineOfWLApprox(const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-03, const Standard_Real Tolerance2d = 1.0e-06, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Approx_ParametrizationType parametrization = Approx_ChordLength, const Standard_Boolean Squares = Standard_False); |
83 | |
36b9ff75 |
84 | //! Constructs an interpolation of the MultiLine <Line> |
85 | //! The result will be a C2 curve of degree 3. |
42cf5bc1 |
86 | Standard_EXPORT void Interpol (const GeomInt_TheMultiLineOfWLApprox& Line); |
87 | |
36b9ff75 |
88 | //! Initializes the fields of the algorithm. |
42cf5bc1 |
89 | Standard_EXPORT void Init (const Standard_Integer degreemin = 4, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-03, const Standard_Real Tolerance2d = 1.0e-06, const Standard_Integer NbIterations = 5, const Standard_Boolean cutting = Standard_True, const Approx_ParametrizationType parametrization = Approx_ChordLength, const Standard_Boolean Squares = Standard_False); |
90 | |
36b9ff75 |
91 | //! runs the algorithm after having initialized the fields. |
42cf5bc1 |
92 | Standard_EXPORT void Perform (const GeomInt_TheMultiLineOfWLApprox& Line); |
93 | |
36b9ff75 |
94 | //! The approximation will begin with the |
95 | //! set of parameters <ThePar>. |
42cf5bc1 |
96 | Standard_EXPORT void SetParameters (const math_Vector& ThePar); |
97 | |
36b9ff75 |
98 | //! The approximation will be done with the |
99 | //! set of knots <Knots>. The multiplicities will be set |
100 | //! with the degree and the desired continuity. |
42cf5bc1 |
101 | Standard_EXPORT void SetKnots (const TColStd_Array1OfReal& Knots); |
102 | |
36b9ff75 |
103 | //! The approximation will be done with the |
104 | //! set of knots <Knots> and the multiplicities <Mults>. |
42cf5bc1 |
105 | Standard_EXPORT void SetKnotsAndMultiplicities (const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Mults); |
106 | |
36b9ff75 |
107 | //! changes the degrees of the approximation. |
42cf5bc1 |
108 | Standard_EXPORT void SetDegrees (const Standard_Integer degreemin, const Standard_Integer degreemax); |
109 | |
36b9ff75 |
110 | //! Changes the tolerances of the approximation. |
42cf5bc1 |
111 | Standard_EXPORT void SetTolerances (const Standard_Real Tolerance3d, const Standard_Real Tolerance2d); |
112 | |
36b9ff75 |
113 | //! sets the continuity of the spline. |
114 | //! if C = 2, the spline will be C2. |
42cf5bc1 |
115 | Standard_EXPORT void SetContinuity (const Standard_Integer C); |
116 | |
36b9ff75 |
117 | //! changes the first and the last constraint points. |
42cf5bc1 |
118 | Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC); |
d1775ee9 |
119 | |
120 | //! Sets periodic flag. |
121 | //! If thePeriodic = Standard_True, algorith tries to build periodic |
122 | //! multicurve using corresponding C1 boundary condition for first and last multipoints. |
123 | //! Multiline must be closed. |
124 | Standard_EXPORT void SetPeriodic(const Standard_Boolean thePeriodic); |
125 | |
36b9ff75 |
126 | //! returns False if at a moment of the approximation, |
127 | //! the status NoApproximation has been sent by the user |
128 | //! when more points were needed. |
42cf5bc1 |
129 | Standard_EXPORT Standard_Boolean IsAllApproximated() const; |
130 | |
36b9ff75 |
131 | //! returns False if the status NoPointsAdded has been sent. |
42cf5bc1 |
132 | Standard_EXPORT Standard_Boolean IsToleranceReached() const; |
133 | |
36b9ff75 |
134 | //! returns the tolerances 2d and 3d of the MultiBSpCurve. |
42cf5bc1 |
135 | Standard_EXPORT void Error (Standard_Real& tol3d, Standard_Real& tol2d) const; |
136 | |
36b9ff75 |
137 | //! returns the result of the approximation. |
42cf5bc1 |
138 | Standard_EXPORT const AppParCurves_MultiBSpCurve& Value() const; |
139 | |
36b9ff75 |
140 | //! returns the result of the approximation. |
42cf5bc1 |
141 | Standard_EXPORT AppParCurves_MultiBSpCurve& ChangeValue(); |
142 | |
36b9ff75 |
143 | //! returns the new parameters of the approximation |
144 | //! corresponding to the points of the MultiBSpCurve. |
42cf5bc1 |
145 | Standard_EXPORT const TColStd_Array1OfReal& Parameters() const; |
146 | |
147 | |
148 | |
149 | |
150 | protected: |
151 | |
152 | |
153 | |
154 | |
155 | |
156 | private: |
157 | |
158 | |
36b9ff75 |
159 | //! is internally used in the algorithm. |
42cf5bc1 |
160 | Standard_EXPORT Standard_Boolean Compute (const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer fpt, const Standard_Integer lpt, math_Vector& Para, const TColStd_Array1OfReal& Knots, TColStd_Array1OfInteger& Mults); |
161 | |
36b9ff75 |
162 | //! is internally used in the algorithm. |
42cf5bc1 |
163 | Standard_EXPORT Standard_Boolean ComputeCurve (const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer firspt, const Standard_Integer lastpt); |
164 | |
36b9ff75 |
165 | //! computes new parameters between firstP and lastP. |
42cf5bc1 |
166 | Standard_EXPORT void Parameters (const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer firstP, const Standard_Integer LastP, math_Vector& TheParameters) const; |
167 | |
168 | Standard_EXPORT Standard_Real SearchFirstLambda (const GeomInt_TheMultiLineOfWLApprox& Line, const math_Vector& Para, const TColStd_Array1OfReal& Knots, const math_Vector& V, const Standard_Integer index) const; |
169 | |
170 | Standard_EXPORT Standard_Real SearchLastLambda (const GeomInt_TheMultiLineOfWLApprox& Line, const math_Vector& Para, const TColStd_Array1OfReal& Knots, const math_Vector& V, const Standard_Integer index) const; |
171 | |
172 | Standard_EXPORT void TangencyVector (const GeomInt_TheMultiLineOfWLApprox& Line, const AppParCurves_MultiCurve& C, const Standard_Real U, math_Vector& V) const; |
173 | |
174 | Standard_EXPORT void FirstTangencyVector (const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer index, math_Vector& V) const; |
175 | |
176 | Standard_EXPORT void LastTangencyVector (const GeomInt_TheMultiLineOfWLApprox& Line, const Standard_Integer index, math_Vector& V) const; |
177 | |
178 | Standard_EXPORT void FindRealConstraints (const GeomInt_TheMultiLineOfWLApprox& Line); |
179 | |
180 | |
181 | AppParCurves_MultiBSpCurve TheMultiBSpCurve; |
182 | Standard_Boolean alldone; |
183 | Standard_Boolean tolreached; |
184 | Approx_ParametrizationType Par; |
185 | Handle(TColStd_HArray1OfReal) myParameters; |
186 | Handle(TColStd_HArray1OfReal) myfirstParam; |
187 | Handle(TColStd_HArray1OfReal) myknots; |
188 | Handle(TColStd_HArray1OfInteger) mymults; |
189 | Standard_Boolean myhasknots; |
190 | Standard_Boolean myhasmults; |
191 | Handle(AppParCurves_HArray1OfConstraintCouple) myConstraints; |
192 | Standard_Integer mydegremin; |
193 | Standard_Integer mydegremax; |
194 | Standard_Real mytol3d; |
195 | Standard_Real mytol2d; |
196 | Standard_Real currenttol3d; |
197 | Standard_Real currenttol2d; |
198 | Standard_Boolean mycut; |
199 | Standard_Boolean mysquares; |
200 | Standard_Integer myitermax; |
201 | AppParCurves_Constraint myfirstC; |
202 | AppParCurves_Constraint mylastC; |
203 | AppParCurves_Constraint realfirstC; |
204 | AppParCurves_Constraint reallastC; |
205 | Standard_Integer mycont; |
206 | Standard_Real mylambda1; |
207 | Standard_Real mylambda2; |
d1775ee9 |
208 | Standard_Boolean myPeriodic; |
42cf5bc1 |
209 | |
210 | |
211 | }; |
212 | |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | |
219 | #endif // _GeomInt_TheComputeLineOfWLApprox_HeaderFile |