b311480e |
1 | -- Created on: 1993-09-21 |
2 | -- Created by: Modelistation |
3 | -- Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | -- |
973c2be1 |
6 | -- This file is part of Open CASCADE Technology software library. |
b311480e |
7 | -- |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | -- |
973c2be1 |
14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | generic class BSpFunction from AppParCurves ( |
18 | MultiLine as any; |
19 | ToolLine as any; -- as ToolLine(MultiLine) |
20 | Squares as any) |
21 | |
22 | inherits MultipleVarFunctionWithGradient from math |
23 | |
24 | ---Purpose: This function inherits MultipleVarFunctionWithGradient to be |
25 | -- used in the mathematical algorithm BFGS. |
26 | -- It computes the value of the function |
27 | -- F=sum(||Qui - B*Pi||)2 where Pi are Poles of the BSpline |
28 | -- curves approximating the given MultiLine SSP and ui the |
29 | -- parameters associated to the points Qi of SSP. |
30 | -- It also computes the gradient for values ui of the parameter. |
31 | |
32 | |
33 | uses MultiBSpCurve from AppParCurves, |
34 | HArray1OfConstraintCouple from AppParCurves, |
35 | Constraint from AppParCurves, |
36 | Vector from math, |
37 | IntegerVector from math, |
38 | Matrix from math, |
39 | HArray1OfInteger from TColStd, |
40 | Array1OfReal from TColStd, |
41 | Array1OfInteger from TColStd |
42 | |
43 | is |
44 | |
45 | Create(SSP: MultiLine; FirstPoint, LastPoint: Integer; |
46 | TheConstraints: HArray1OfConstraintCouple; |
47 | Parameters: Vector; Knots: Array1OfReal; |
48 | Mults: Array1OfInteger; NbPol: Integer) |
49 | ---Purpose: initializes the fields of the function. The approximating |
50 | -- curve has <NbPol> control points. |
51 | |
52 | returns BSpFunction from AppParCurves; |
53 | |
54 | |
55 | NbVariables(me) |
56 | ---Purpose: returns the number of variables of the function. It |
57 | -- corresponds to the number of MultiPoints. |
58 | |
59 | returns Integer |
60 | is static; |
61 | |
62 | |
63 | |
64 | Perform(me: in out; X: Vector) |
65 | ---Purpose: this method is used each time Value or Gradient is |
66 | -- needed. |
67 | |
68 | is static protected; |
69 | |
70 | |
71 | Value(me: in out; X: Vector; F: out Real) |
72 | ---Purpose: this method computes the new approximation of the |
73 | -- MultiLine |
74 | -- SSP and calculates F = sum (||Pui - Bi*Pi||2) for each |
75 | -- point of the MultiLine. |
76 | |
77 | returns Boolean |
78 | is static; |
79 | |
80 | |
81 | Gradient(me: in out; X: Vector; G: out Vector) |
82 | ---Purpose: returns the gradient G of the sum above for the |
83 | -- parameters Xi. |
84 | |
85 | returns Boolean |
86 | is static; |
87 | |
88 | |
89 | Values(me: in out; X: Vector; F: out Real; G: out Vector) |
90 | ---Purpose: returns the value F=sum(||Pui - Bi*Pi||)2. |
91 | -- returns the value G = grad(F) for the parameters Xi. |
92 | |
93 | returns Boolean |
94 | is static; |
95 | |
96 | |
97 | |
98 | NewParameters(me) |
99 | ---Purpose: returns the new parameters of the MultiLine. |
100 | ---C++: return const& |
101 | returns Vector |
102 | is static; |
103 | |
104 | |
105 | CurveValue(me: in out) |
106 | ---Purpose: returns the MultiBSpCurve approximating the set after |
107 | -- computing the value F or Grad(F). |
108 | |
109 | returns MultiBSpCurve from AppParCurves |
110 | is static; |
111 | |
112 | |
113 | Error(me: in out; IPoint, CurveIndex: Integer) |
114 | ---Purpose: returns the distance between the MultiPoint of range |
115 | -- IPoint and the curve CurveIndex. |
116 | |
117 | returns Real |
118 | is static; |
119 | |
120 | |
121 | MaxError3d(me) |
122 | ---Purpose: returns the maximum distance between the points |
123 | -- and the MultiBSpCurve. |
124 | |
125 | returns Real |
126 | is static; |
127 | |
128 | MaxError2d(me) |
129 | ---Purpose: returns the maximum distance between the points |
130 | -- and the MultiBSpCurve. |
131 | |
132 | returns Real |
133 | is static; |
134 | |
135 | |
136 | FunctionMatrix(me) |
137 | ---Purpose: returns the function matrix used to approximate the |
138 | -- multiline. |
139 | ---C++: return const& |
140 | |
141 | returns Matrix from math |
142 | is static; |
143 | |
144 | |
145 | DerivativeFunctionMatrix(me) |
146 | ---Purpose: returns the derivative function matrix used to approximate the |
147 | -- multiline. |
148 | ---C++: return const& |
149 | |
150 | returns Matrix from math |
151 | is static; |
152 | |
153 | |
154 | |
155 | Index(me) |
156 | ---Purpose: Returns the indexes of the first non null values of |
157 | -- A and DA. |
158 | -- The values are non null from Index(ieme point) +1 |
159 | -- to Index(ieme point) + degree +1. |
160 | ---C++: return const& |
161 | |
162 | returns IntegerVector |
163 | is static; |
164 | |
165 | |
166 | FirstConstraint(me; TheConstraints: HArray1OfConstraintCouple; |
167 | FirstPoint: Integer) |
168 | ---Purpose: |
169 | |
170 | returns Constraint from AppParCurves |
171 | is static; |
172 | |
173 | |
174 | LastConstraint(me; TheConstraints: HArray1OfConstraintCouple; |
175 | LastPoint: Integer) |
176 | ---Purpose: |
177 | |
178 | returns Constraint from AppParCurves |
179 | is static; |
180 | |
181 | |
182 | |
183 | SetFirstLambda(me: in out; l1: Real) |
184 | is static; |
185 | |
186 | |
187 | SetLastLambda(me: in out; l2: Real) |
188 | is static; |
189 | |
190 | |
191 | fields |
192 | |
193 | Done: Boolean; |
194 | MyMultiLine : MultiLine; |
195 | MyMultiBSpCurve: MultiBSpCurve from AppParCurves; |
196 | nbpoles: Integer; |
197 | myParameters: Vector; |
198 | FVal: Real; |
199 | ValGrad_F: Vector from math; |
200 | MyF: Matrix from math; |
201 | PTLX : Matrix from math; |
202 | PTLY : Matrix from math; |
203 | PTLZ : Matrix from math; |
204 | A: Matrix from math; |
205 | DA: Matrix from math; |
206 | MyLeastSquare : Squares; |
207 | Contraintes: Boolean; |
208 | NbP: Integer; |
209 | NbCu: Integer; |
210 | Adeb: Integer; |
211 | Afin: Integer; |
212 | tabdim: HArray1OfInteger from TColStd; |
213 | ERR3d: Real; |
214 | ERR2d: Real; |
215 | FirstP: Integer; |
216 | LastP: Integer; |
217 | myConstraints: HArray1OfConstraintCouple from AppParCurves; |
218 | mylambda1: Real; |
219 | mylambda2: Real; |
220 | |
221 | end BSpFunction; |