0032951: Coding - get rid of unused headers [GeomConvert to IGESBasic]
[occt.git] / src / GeomInt / GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox.hxx
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_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox_HeaderFile
18 #define _GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <AppParCurves_Constraint.hxx>
25 #include <AppParCurves_MultiBSpCurve.hxx>
26 #include <TColStd_HArray1OfReal.hxx>
27 #include <TColStd_HArray1OfInteger.hxx>
28 #include <math_Matrix.hxx>
29 #include <math_Vector.hxx>
30 #include <math_IntegerVector.hxx>
31 #include <Standard_Real.hxx>
32 #include <Standard_Integer.hxx>
33 #include <TColStd_Array1OfReal.hxx>
34 #include <TColStd_Array1OfInteger.hxx>
35 class StdFail_NotDone;
36 class Standard_OutOfRange;
37 class Standard_DimensionError;
38 class Standard_NoSuchObject;
39 class GeomInt_TheMultiLineOfWLApprox;
40 class GeomInt_TheMultiLineToolOfWLApprox;
41 class AppParCurves_MultiCurve;
42 class AppParCurves_MultiBSpCurve;
43 class math_Matrix;
44
45
46
47 class GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox 
48 {
49 public:
50
51   DEFINE_STANDARD_ALLOC
52
53   
54   //! given a MultiLine, this algorithm computes the least
55   //! square resolution using the Householder-QR method.
56   //! If the first and/or the last point is a constraint
57   //! point, the value of the tangency or curvature is
58   //! computed in the resolution.
59   //! NbPol is the number of control points wanted
60   //! for the approximating curves.
61   //! The system to solve is the following:
62   //! A X = B.
63   //! Where A is the Bernstein matrix computed with the
64   //! parameters, B the points coordinates and X the poles
65   //! solutions.
66   //! The matrix A is the same for each coordinate x, y and z
67   //! and is also the same for each MultiLine point because
68   //! they are approximated in parallel(so with the same
69   //! parameter, only the vector B changes).
70   Standard_EXPORT GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& SSP, const Standard_Integer FirstPoint, const Standard_Integer LastPoint, const AppParCurves_Constraint FirstCons, const AppParCurves_Constraint LastCons, const math_Vector& Parameters, const Standard_Integer NbPol);
71   
72   //! Initializes the fields of the object.
73   Standard_EXPORT GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& SSP, const Standard_Integer FirstPoint, const Standard_Integer LastPoint, const AppParCurves_Constraint FirstCons, const AppParCurves_Constraint LastCons, const Standard_Integer NbPol);
74   
75   //! given a MultiLine, this algorithm computes the least
76   //! square resolution using the Householder-QR method.
77   //! If the first and/or the last point is a constraint
78   //! point, the value of the tangency or curvature is
79   //! computed in the resolution.
80   //! Deg is the degree wanted for the approximating curves.
81   //! The system to solve is the following:
82   //! A X = B.
83   //! Where A is the BSpline functions matrix computed with
84   //! <parameters>, B the points coordinates and X the poles
85   //! solutions.
86   //! The matrix A is the same for each coordinate x, y and z
87   //! and is also the same for each MultiLine point because
88   //! they are approximated in parallel(so with the same
89   //! parameter, only the vector B changes).
90   Standard_EXPORT GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& SSP, const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Mults, const Standard_Integer FirstPoint, const Standard_Integer LastPoint, const AppParCurves_Constraint FirstCons, const AppParCurves_Constraint LastCons, const math_Vector& Parameters, const Standard_Integer NbPol);
91   
92   //! Initializes the fields of the object.
93   Standard_EXPORT GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox(const GeomInt_TheMultiLineOfWLApprox& SSP, const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Mults, const Standard_Integer FirstPoint, const Standard_Integer LastPoint, const AppParCurves_Constraint FirstCons, const AppParCurves_Constraint LastCons, const Standard_Integer NbPol);
94   
95   //! Is used after having initialized the fields.
96   //! The case "CurvaturePoint" is not treated in this method.
97   Standard_EXPORT void Perform (const math_Vector& Parameters);
98   
99   //! Is used after having initialized the fields.
100   Standard_EXPORT void Perform (const math_Vector& Parameters, const Standard_Real l1, const Standard_Real l2);
101   
102   //! Is used after having initialized the fields.
103   //! <V1t> is the tangent vector at the first point.
104   //! <V2t> is the tangent vector at the last point.
105   Standard_EXPORT void Perform (const math_Vector& Parameters, const math_Vector& V1t, const math_Vector& V2t, const Standard_Real l1, const Standard_Real l2);
106   
107   //! Is used after having initialized the fields.
108   //! <V1t> is the tangent vector at the first point.
109   //! <V2t> is the tangent vector at the last point.
110   //! <V1c> is the tangent vector at the first point.
111   //! <V2c> is the tangent vector at the last point.
112   Standard_EXPORT void Perform (const math_Vector& Parameters, const math_Vector& V1t, const math_Vector& V2t, const math_Vector& V1c, const math_Vector& V2c, const Standard_Real l1, const Standard_Real l2);
113   
114   //! returns True if all has been correctly done.
115   Standard_EXPORT Standard_Boolean IsDone() const;
116   
117   //! returns the result of the approximation, i.e. all the
118   //! Curves.
119   //! An exception is raised if NotDone.
120   Standard_EXPORT AppParCurves_MultiCurve BezierValue();
121   
122   //! returns the result of the approximation, i.e. all the
123   //! Curves.
124   //! An exception is raised if NotDone.
125   Standard_EXPORT const AppParCurves_MultiBSpCurve& BSplineValue();
126   
127   //! returns the function matrix used to approximate the
128   //! set.
129   Standard_EXPORT const math_Matrix& FunctionMatrix() const;
130   
131   //! returns the derivative function matrix used
132   //! to approximate the set.
133   Standard_EXPORT const math_Matrix& DerivativeFunctionMatrix() const;
134   
135   //! returns the maximum errors between the MultiLine
136   //! and the approximation curves. F is the sum of the square
137   //! distances. Grad is the derivative vector of the
138   //! function F.
139   Standard_EXPORT void ErrorGradient (math_Vector& Grad, Standard_Real& F, Standard_Real& MaxE3d, Standard_Real& MaxE2d);
140   
141   //! returns the distances between the points of the
142   //! multiline and the approximation curves.
143   Standard_EXPORT const math_Matrix& Distance();
144   
145   //! returns the maximum errors between the MultiLine
146   //! and the approximation curves. F is the sum of the square
147   //! distances.
148   Standard_EXPORT void Error (Standard_Real& F, Standard_Real& MaxE3d, Standard_Real& MaxE2d);
149   
150   //! returns the value (P2 - P1)/ V1 if the first point
151   //! was a tangency point.
152   Standard_EXPORT Standard_Real FirstLambda() const;
153   
154   //! returns the value (PN - PN-1)/ VN if the last point
155   //! was a tangency point.
156   Standard_EXPORT Standard_Real LastLambda() const;
157   
158   //! returns the matrix of points value.
159   Standard_EXPORT const math_Matrix& Points() const;
160   
161   //! returns the matrix of resulting control points value.
162   Standard_EXPORT const math_Matrix& Poles() const;
163   
164   //! Returns the indexes of the first non null values of
165   //! A and DA.
166   //! The values are non null from Index(ieme point) +1
167   //! to Index(ieme point) + degree +1.
168   Standard_EXPORT const math_IntegerVector& KIndex() const;
169
170
171
172
173 protected:
174
175   
176   //! is used by the constructors above.
177   Standard_EXPORT void Init (const GeomInt_TheMultiLineOfWLApprox& SSP, const Standard_Integer FirstPoint, const Standard_Integer LastPoint);
178   
179   //! returns the number of second member columns.
180   //! Is used internally to initialize the fields.
181   Standard_EXPORT Standard_Integer NbBColumns (const GeomInt_TheMultiLineOfWLApprox& SSP) const;
182   
183   //! returns the first point being fitted.
184   Standard_EXPORT Standard_Integer TheFirstPoint (const AppParCurves_Constraint FirstCons, const Standard_Integer FirstPoint) const;
185   
186   //! returns the last point being fitted.
187   Standard_EXPORT Standard_Integer TheLastPoint (const AppParCurves_Constraint LastCons, const Standard_Integer LastPoint) const;
188   
189   //! Affects the fields in the case of a constraint point.
190   Standard_EXPORT void Affect (const GeomInt_TheMultiLineOfWLApprox& SSP, const Standard_Integer Index, AppParCurves_Constraint& Cons, math_Vector& Vt, math_Vector& Vc);
191   
192   Standard_EXPORT void ComputeFunction (const math_Vector& Parameters);
193   
194   Standard_EXPORT void SearchIndex (math_IntegerVector& Index);
195   
196   //! computes internal matrixes for the resolution
197   Standard_EXPORT void MakeTAA (math_Vector& TheA, math_Vector& TheB);
198   
199   //! computes internal matrixes for the resolution
200   Standard_EXPORT void MakeTAA (math_Vector& TheA);
201   
202   //! computes internal matrixes for the resolution
203   Standard_EXPORT void MakeTAA (math_Vector& TheA, math_Matrix& TheB);
204
205
206
207
208 private:
209
210
211
212   AppParCurves_Constraint FirstConstraint;
213   AppParCurves_Constraint LastConstraint;
214   AppParCurves_MultiBSpCurve SCU;
215   Handle(TColStd_HArray1OfReal) myknots;
216   Handle(TColStd_HArray1OfInteger) mymults;
217   math_Matrix mypoles;
218   math_Matrix A;
219   math_Matrix DA;
220   math_Matrix B2;
221   math_Matrix mypoints;
222   math_Vector Vflatknots;
223   math_Vector Vec1t;
224   math_Vector Vec1c;
225   math_Vector Vec2t;
226   math_Vector Vec2c;
227   math_Matrix theError;
228   math_IntegerVector myindex;
229   Standard_Real lambda1;
230   Standard_Real lambda2;
231   Standard_Integer FirstP;
232   Standard_Integer LastP;
233   Standard_Integer Nlignes;
234   Standard_Integer Ninc;
235   Standard_Integer NA;
236   Standard_Integer myfirstp;
237   Standard_Integer mylastp;
238   Standard_Integer resinit;
239   Standard_Integer resfin;
240   Standard_Integer nbP2d;
241   Standard_Integer nbP;
242   Standard_Integer nbpoles;
243   Standard_Integer deg;
244   Standard_Boolean done;
245   Standard_Boolean iscalculated;
246   Standard_Boolean isready;
247
248
249 };
250
251
252
253
254
255
256
257 #endif // _GeomInt_BSpParLeastSquareOfMyBSplGradientOfTheComputeLineOfWLApprox_HeaderFile