0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / AppParCurves / AppParCurves_BSpGradient.cdl
CommitLineData
b311480e 1-- Created on: 1993-09-22
2-- Created by: Modelistation
3-- Copyright (c) 1993-1999 Matra Datavision
4-- Copyright (c) 1999-2012 OPEN CASCADE SAS
5--
6-- The content of this file is subject to the Open CASCADE Technology Public
7-- License Version 6.5 (the "License"). You may not use the content of this file
8-- except in compliance with the License. Please obtain a copy of the License
9-- at http://www.opencascade.org and read it completely before using this file.
10--
11-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13--
14-- The Original Code and all software distributed under the License is
15-- distributed on an "AS IS" basis, without warranty of any kind, and the
16-- Initial Developer hereby disclaims all such warranties, including without
17-- limitation, any warranties of merchantability, fitness for a particular
18-- purpose or non-infringement. Please see the License for the specific terms
19-- and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23
24generic class BSpGradient from AppParCurves
25 (MultiLine as any;
26 ToolLine as any) -- as ToolLine(MultiLine)
27
28
29 ---Purpose: This algorithm uses the algorithms LeastSquare,
30 -- ResConstraint and a gradient method to approximate a set
31 -- of points (AppDef_MultiLine) with a minimization of the
32 -- sum(square(|F(i)-Qi|)) by changing the parameter.
33 -- The algorithm used is from of the mathematical
34 -- package: math_BFGS, a gradient method.
35
36
37
38uses Vector from math,
39 MultipleVarFunctionWithGradient from math,
40 MultiBSpCurve from AppParCurves,
41 HArray1OfConstraintCouple from AppParCurves,
42 Array1OfReal from TColStd,
43 Array1OfInteger from TColStd
44
45
46raises OutOfRange from Standard,
47 NotDone from StdFail
48
49
50private class BSpParLeastSquare instantiates LeastSquare from AppParCurves
51 (MultiLine, ToolLine);
52
53private class BSpParFunction instantiates BSpFunction from AppParCurves
54 (MultiLine, ToolLine, BSpParLeastSquare);
55
56
57class BSpGradient_BFGS from AppParCurves
58 inherits BFGS from math
59 uses MultipleVarFunctionWithGradient from math,
60 Vector from math
61
62 is
63
64 Create ( F : in out MultipleVarFunctionWithGradient from math ;
65 StartingPoint : Vector from math ;
66 Tolerance3d : Real from Standard ;
67 Tolerance2d : Real from Standard ;
68 Eps : Real from Standard ;
69 NbIterations : Integer from Standard = 200 );
70
71 IsSolutionReached ( me ;
72 F : in out MultipleVarFunctionWithGradient from math )
73 returns Boolean from Standard is redefined ;
74
75 fields
76
77 myTol3d : Real from Standard ;
78 myTol2d : Real from Standard ;
79
80 end BSpGradient_BFGS from AppParCurves ;
81is
82
83 Create(SSP: MultiLine; FirstPoint, LastPoint: Integer;
84 TheConstraints: HArray1OfConstraintCouple;
85 Parameters: in out Vector;
86 Knots: Array1OfReal; Mults: Array1OfInteger;
87 Deg: Integer;
88 Tol3d, Tol2d: Real; NbIterations: Integer = 1)
89 ---Purpose: Tries to minimize the sum (square(||Qui - Bi*Pi||))
90 -- where Pui describe the approximating BSpline curves'Poles
91 -- and Qi the MultiLine points with a parameter ui.
92 -- In this algorithm, the parameters ui are the unknowns.
93 -- The tolerance required on this sum is given by Tol.
94 -- The desired degree of the resulting curve is Deg.
95
96 returns BSpGradient from AppParCurves;
97
98
99 Create(SSP: MultiLine; FirstPoint, LastPoint: Integer;
100 TheConstraints: HArray1OfConstraintCouple;
101 Parameters: in out Vector;
102 Knots: Array1OfReal; Mults: Array1OfInteger;
103 Deg: Integer;
104 Tol3d, Tol2d: Real; NbIterations: Integer;
105 lambda1, lambda2: Real)
106 ---Purpose: Tries to minimize the sum (square(||Qui - Bi*Pi||))
107 -- where Pui describe the approximating BSpline curves'Poles
108 -- and Qi the MultiLine points with a parameter ui.
109 -- In this algorithm, the parameters ui are the unknowns.
110 -- The tolerance required on this sum is given by Tol.
111 -- The desired degree of the resulting curve is Deg.
112
113 returns BSpGradient from AppParCurves;
114
115
116 Perform(me: in out; SSP: MultiLine; FirstPoint, LastPoint: Integer;
117 TheConstraints: HArray1OfConstraintCouple;
118 Parameters: in out Vector;
119 Knots: Array1OfReal; Mults: Array1OfInteger;
120 Deg: Integer;
121 Tol3d, Tol2d: Real; NbIterations: Integer = 200)
122 is static protected;
123
124
125 IsDone(me)
126 ---Purpose: returns True if all has been correctly done.
127
128 returns Boolean
129 is static;
130
131
132 Value(me)
133 ---Purpose: returns all the BSpline curves approximating the
134 -- MultiLine SSP after minimization of the parameter.
135
136 returns MultiBSpCurve from AppParCurves
137 raises NotDone from StdFail
138 is static;
139
140
141 Error(me; Index: Integer)
142 ---Purpose: returns the difference between the old and the new
143 -- approximation.
144 -- An exception is raised if NotDone.
145 -- An exception is raised if Index<1 or Index>NbParameters.
146
147 returns Real
148 raises NotDone from StdFail,
149 OutOfRange from Standard
150 is static;
151
152
153 MaxError3d(me)
154 ---Purpose: returns the maximum difference between the old and the
155 -- new approximation.
156
157 returns Real
158 raises NotDone from StdFail
159 is static;
160
161
162 MaxError2d(me)
163 ---Purpose: returns the maximum difference between the old and the
164 -- new approximation.
165
166 returns Real
167 raises NotDone from StdFail
168 is static;
169
170
171 AverageError(me)
172 ---Purpose: returns the average error between the old and the
173 -- new approximation.
174
175 returns Real
176 raises NotDone from StdFail
177 is static;
178
179
180fields
181
182SCU: MultiBSpCurve from AppParCurves;
183ParError: Vector from math;
184AvError: Real;
185MError3d: Real;
186MError2d: Real;
187mylambda1: Real;
188mylambda2: Real;
189Done: Boolean;
190
191end BSpGradient from AppParCurves;