b311480e |
1 | -- Created on: 1991-09-20 |
2 | -- Created by: Laurent PAINNOT |
3 | -- Copyright (c) 1991-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 Function from AppParCurves ( |
18 | MultiLine as any; |
19 | ToolLine as any; -- as ToolLine(MultiLine) |
20 | Squares as any; |
21 | ResolCons as any) |
22 | |
23 | inherits MultipleVarFunctionWithGradient from math |
24 | |
25 | ---Purpose: This function inherits MultipleVarFunctionWithGradient to be |
26 | -- used in the mathematical algorithm BFGS. |
27 | -- It computes the value of the function |
28 | -- F=sum(||Qui - B*Pi||)2 where Pi are Poles of the Bezier curves |
29 | -- approximating the given MultiLine SSP and ui the parameters |
30 | -- associated to the points Qi of SSP. |
31 | -- It also computes the gradient for values ui of the parameter. |
32 | |
33 | |
34 | uses MultiCurve from AppParCurves, |
35 | HArray1OfConstraintCouple from AppParCurves, |
36 | Constraint from AppParCurves, |
37 | Vector from math, |
38 | Matrix from math, |
39 | HArray1OfInteger from TColStd |
40 | |
41 | is |
42 | |
43 | Create(SSP: MultiLine; FirstPoint, LastPoint: Integer; |
44 | TheConstraints: HArray1OfConstraintCouple; |
45 | Parameters: Vector; Deg: Integer) |
46 | ---Purpose: initializes the fields of the function. The approximating |
47 | -- curve has the desired degree Deg. |
48 | |
49 | returns Function from AppParCurves; |
50 | |
51 | |
52 | NbVariables(me) |
53 | ---Purpose: returns the number of variables of the function. It |
54 | -- corresponds to the number of MultiPoints. |
55 | |
56 | returns Integer |
57 | is static; |
58 | |
59 | |
60 | |
61 | Perform(me: in out; X: Vector) |
62 | ---Purpose: this method is used each time Value or Gradient is |
63 | -- needed. |
64 | |
65 | is static protected; |
66 | |
67 | |
68 | Value(me: in out; X: Vector; F: out Real) |
69 | ---Purpose: this method computes the new approximation of the |
70 | -- MultiLine |
71 | -- SSP and calculates F = sum (||Pui - Bi*Pi||2) for each |
72 | -- point of the MultiLine. |
73 | |
74 | returns Boolean |
75 | is static; |
76 | |
77 | |
78 | Gradient(me: in out; X: Vector; G: out Vector) |
79 | ---Purpose: returns the gradient G of the sum above for the |
80 | -- parameters Xi. |
81 | |
82 | returns Boolean |
83 | is static; |
84 | |
85 | |
86 | Values(me: in out; X: Vector; F: out Real; G: out Vector) |
87 | ---Purpose: returns the value F=sum(||Pui - Bi*Pi||)2. |
88 | -- returns the value G = grad(F) for the parameters Xi. |
89 | |
90 | returns Boolean |
91 | is static; |
92 | |
93 | |
94 | |
95 | NewParameters(me) |
96 | ---Purpose: returns the new parameters of the MultiLine. |
97 | ---C++: return const& |
98 | returns Vector |
99 | is static; |
100 | |
101 | |
102 | CurveValue(me: in out) |
103 | ---Purpose: returns the MultiCurve approximating the set after |
104 | -- computing the value F or Grad(F). |
105 | ---C++: return const& |
106 | returns MultiCurve from AppParCurves |
107 | is static; |
108 | |
109 | |
110 | Error(me; IPoint, CurveIndex: Integer) |
111 | ---Purpose: returns the distance between the MultiPoint of range |
112 | -- IPoint and the curve CurveIndex. |
113 | |
114 | returns Real |
115 | is static; |
116 | |
117 | |
118 | MaxError3d(me) |
119 | ---Purpose: returns the maximum distance between the points |
120 | -- and the MultiCurve. |
121 | |
122 | returns Real |
123 | is static; |
124 | |
125 | MaxError2d(me) |
126 | ---Purpose: returns the maximum distance between the points |
127 | -- and the MultiCurve. |
128 | |
129 | returns Real |
130 | is static; |
131 | |
132 | |
133 | FirstConstraint(me; TheConstraints: HArray1OfConstraintCouple; |
134 | FirstPoint: Integer) |
135 | ---Purpose: |
136 | |
137 | returns Constraint from AppParCurves |
138 | is static; |
139 | |
140 | |
141 | LastConstraint(me; TheConstraints: HArray1OfConstraintCouple; |
142 | LastPoint: Integer) |
143 | ---Purpose: |
144 | |
145 | returns Constraint from AppParCurves |
146 | is static; |
147 | |
148 | |
149 | fields |
150 | |
151 | Done: Boolean; |
152 | MyMultiLine : MultiLine; |
153 | MyMultiCurve: MultiCurve from AppParCurves; |
154 | Degre: Integer; |
155 | myParameters: Vector; |
156 | FVal: Real; |
157 | ValGrad_F: Vector from math; |
158 | MyF: Matrix from math; |
159 | PTLX : Matrix from math; |
160 | PTLY : Matrix from math; |
161 | PTLZ : Matrix from math; |
162 | A: Matrix from math; |
163 | DA: Matrix from math; |
164 | MyLeastSquare : Squares; |
165 | Contraintes: Boolean; |
166 | NbP: Integer; |
167 | NbCu: Integer; |
168 | Adeb: Integer; |
169 | Afin: Integer; |
170 | tabdim: HArray1OfInteger from TColStd; |
171 | ERR3d: Real; |
172 | ERR2d: Real; |
173 | FirstP: Integer; |
174 | LastP: Integer; |
175 | myConstraints: HArray1OfConstraintCouple from AppParCurves; |
176 | |
177 | end Function; |