42cf5bc1 |
1 | // Created on: 1991-12-02 |
2 | // Created by: Laurent PAINNOT |
3 | // Copyright (c) 1991-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 _AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute_HeaderFile |
18 | #define _AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
42cf5bc1 |
24 | #include <AppDef_MultiLine.hxx> |
42cf5bc1 |
25 | #include <Standard_Integer.hxx> |
42cf5bc1 |
26 | #include <Standard_Real.hxx> |
42cf5bc1 |
27 | #include <AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute.hxx> |
28 | #include <TColStd_HArray1OfInteger.hxx> |
29 | #include <AppParCurves_HArray1OfConstraintCouple.hxx> |
30 | #include <math_MultipleVarFunctionWithGradient.hxx> |
31 | #include <TColStd_Array1OfReal.hxx> |
32 | #include <TColStd_Array1OfInteger.hxx> |
33 | #include <math_IntegerVector.hxx> |
34 | #include <AppParCurves_Constraint.hxx> |
35 | class AppDef_MultiLine; |
36 | class AppDef_MyLineTool; |
37 | class AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute; |
38 | class AppParCurves_MultiBSpCurve; |
39 | class math_Matrix; |
40 | |
41 | |
42 | |
43 | class AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute : public math_MultipleVarFunctionWithGradient |
44 | { |
45 | public: |
46 | |
47 | DEFINE_STANDARD_ALLOC |
48 | |
49 | |
36b9ff75 |
50 | //! initializes the fields of the function. The approximating |
51 | //! curve has <NbPol> control points. |
42cf5bc1 |
52 | Standard_EXPORT AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute(const AppDef_MultiLine& SSP, const Standard_Integer FirstPoint, const Standard_Integer LastPoint, const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const math_Vector& Parameters, const TColStd_Array1OfReal& Knots, const TColStd_Array1OfInteger& Mults, const Standard_Integer NbPol); |
53 | |
36b9ff75 |
54 | //! returns the number of variables of the function. It |
55 | //! corresponds to the number of MultiPoints. |
42cf5bc1 |
56 | Standard_EXPORT Standard_Integer NbVariables() const; |
57 | |
36b9ff75 |
58 | //! this method computes the new approximation of the |
59 | //! MultiLine |
60 | //! SSP and calculates F = sum (||Pui - Bi*Pi||2) for each |
61 | //! point of the MultiLine. |
42cf5bc1 |
62 | Standard_EXPORT Standard_Boolean Value (const math_Vector& X, Standard_Real& F); |
63 | |
36b9ff75 |
64 | //! returns the gradient G of the sum above for the |
65 | //! parameters Xi. |
42cf5bc1 |
66 | Standard_EXPORT Standard_Boolean Gradient (const math_Vector& X, math_Vector& G); |
67 | |
36b9ff75 |
68 | //! returns the value F=sum(||Pui - Bi*Pi||)2. |
69 | //! returns the value G = grad(F) for the parameters Xi. |
42cf5bc1 |
70 | Standard_EXPORT Standard_Boolean Values (const math_Vector& X, Standard_Real& F, math_Vector& G); |
71 | |
36b9ff75 |
72 | //! returns the new parameters of the MultiLine. |
42cf5bc1 |
73 | Standard_EXPORT const math_Vector& NewParameters() const; |
74 | |
36b9ff75 |
75 | //! returns the MultiBSpCurve approximating the set after |
76 | //! computing the value F or Grad(F). |
42cf5bc1 |
77 | Standard_EXPORT AppParCurves_MultiBSpCurve CurveValue(); |
78 | |
36b9ff75 |
79 | //! returns the distance between the MultiPoint of range |
80 | //! IPoint and the curve CurveIndex. |
42cf5bc1 |
81 | Standard_EXPORT Standard_Real Error (const Standard_Integer IPoint, const Standard_Integer CurveIndex); |
82 | |
36b9ff75 |
83 | //! returns the maximum distance between the points |
84 | //! and the MultiBSpCurve. |
42cf5bc1 |
85 | Standard_EXPORT Standard_Real MaxError3d() const; |
86 | |
36b9ff75 |
87 | //! returns the maximum distance between the points |
88 | //! and the MultiBSpCurve. |
42cf5bc1 |
89 | Standard_EXPORT Standard_Real MaxError2d() const; |
90 | |
36b9ff75 |
91 | //! returns the function matrix used to approximate the |
92 | //! multiline. |
42cf5bc1 |
93 | Standard_EXPORT const math_Matrix& FunctionMatrix() const; |
94 | |
36b9ff75 |
95 | //! returns the derivative function matrix used to approximate the |
96 | //! multiline. |
42cf5bc1 |
97 | Standard_EXPORT const math_Matrix& DerivativeFunctionMatrix() const; |
98 | |
36b9ff75 |
99 | //! Returns the indexes of the first non null values of |
100 | //! A and DA. |
101 | //! The values are non null from Index(ieme point) +1 |
102 | //! to Index(ieme point) + degree +1. |
42cf5bc1 |
103 | Standard_EXPORT const math_IntegerVector& Index() const; |
104 | |
105 | Standard_EXPORT AppParCurves_Constraint FirstConstraint (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const Standard_Integer FirstPoint) const; |
106 | |
107 | Standard_EXPORT AppParCurves_Constraint LastConstraint (const Handle(AppParCurves_HArray1OfConstraintCouple)& TheConstraints, const Standard_Integer LastPoint) const; |
108 | |
109 | Standard_EXPORT void SetFirstLambda (const Standard_Real l1); |
110 | |
111 | Standard_EXPORT void SetLastLambda (const Standard_Real l2); |
112 | |
113 | |
114 | |
115 | |
116 | protected: |
117 | |
118 | |
36b9ff75 |
119 | //! this method is used each time Value or Gradient is |
120 | //! needed. |
42cf5bc1 |
121 | Standard_EXPORT void Perform (const math_Vector& X); |
122 | |
123 | |
124 | |
125 | |
126 | private: |
127 | |
128 | |
129 | |
130 | Standard_Boolean Done; |
131 | AppDef_MultiLine MyMultiLine; |
132 | AppParCurves_MultiBSpCurve MyMultiBSpCurve; |
133 | Standard_Integer nbpoles; |
134 | math_Vector myParameters; |
135 | Standard_Real FVal; |
136 | math_Vector ValGrad_F; |
137 | math_Matrix MyF; |
138 | math_Matrix PTLX; |
139 | math_Matrix PTLY; |
140 | math_Matrix PTLZ; |
141 | math_Matrix A; |
142 | math_Matrix DA; |
143 | AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute MyLeastSquare; |
144 | Standard_Boolean Contraintes; |
145 | Standard_Integer NbP; |
146 | Standard_Integer NbCu; |
147 | Standard_Integer Adeb; |
148 | Standard_Integer Afin; |
149 | Handle(TColStd_HArray1OfInteger) tabdim; |
150 | Standard_Real ERR3d; |
151 | Standard_Real ERR2d; |
152 | Standard_Integer FirstP; |
153 | Standard_Integer LastP; |
154 | Handle(AppParCurves_HArray1OfConstraintCouple) myConstraints; |
155 | Standard_Real mylambda1; |
156 | Standard_Real mylambda2; |
157 | |
158 | |
159 | }; |
160 | |
161 | |
162 | |
163 | |
164 | |
165 | |
166 | |
167 | #endif // _AppDef_BSpParFunctionOfMyBSplGradientOfBSplineCompute_HeaderFile |