1 -- Created on: 1991-07-25
2 -- Created by: Laurent PAINNOT
3 -- Copyright (c) 1991-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
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.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 generic class Gradient from AppParCurves
19 ToolLine as any) -- as ToolLine(MultiLine)
22 ---Purpose: This algorithm uses the algorithms LeastSquare,
23 -- ResConstraint and a gradient method to approximate a set
24 -- of points (AppDef_MultiLine) with a minimization of the
25 -- sum(square(|F(i)-Qi|)) by changing the parameter.
26 -- The algorithm used is from of the mathematical
27 -- package: math_BFGS, a gradient method.
31 uses Vector from math,
32 MultipleVarFunctionWithGradient from math,
33 MultiCurve from AppParCurves,
34 HArray1OfConstraintCouple from AppParCurves
37 raises OutOfRange from Standard,
41 private class ParLeastSquare instantiates LeastSquare from AppParCurves
42 (MultiLine, ToolLine);
44 private class ResConstraint instantiates ResolConstraint from AppParCurves
45 (MultiLine, ToolLine);
47 private class ParFunction instantiates Function from AppParCurves
48 (MultiLine, ToolLine, ParLeastSquare, ResConstraint);
50 class Gradient_BFGS from AppParCurves
51 inherits BFGS from math
52 uses MultipleVarFunctionWithGradient from math,
56 Create ( F : in out MultipleVarFunctionWithGradient from math ;
57 StartingPoint : Vector from math ;
58 Tolerance3d : Real from Standard ;
59 Tolerance2d : Real from Standard ;
60 Eps : Real from Standard ;
61 NbIterations : Integer from Standard = 200 );
63 IsSolutionReached ( me ;
64 F : in out MultipleVarFunctionWithGradient from math )
65 returns Boolean from Standard is redefined ;
69 myTol3d : Real from Standard ;
70 myTol2d : Real from Standard ;
72 end Gradient_BFGS from AppParCurves ;
76 Create(SSP: MultiLine; FirstPoint, LastPoint: Integer;
77 TheConstraints: HArray1OfConstraintCouple;
78 Parameters: in out Vector; Deg: Integer;
79 Tol3d, Tol2d: Real; NbIterations: Integer = 200)
80 ---Purpose: Tries to minimize the sum (square(||Qui - Bi*Pi||))
81 -- where Pui describe the approximating Bezier curves'Poles
82 -- and Qi the MultiLine points with a parameter ui.
83 -- In this algorithm, the parameters ui are the unknowns.
84 -- The tolerance required on this sum is given by Tol.
85 -- The desired degree of the resulting curve is Deg.
87 returns Gradient from AppParCurves;
91 ---Purpose: returns True if all has been correctly done.
98 ---Purpose: returns all the Bezier curves approximating the
99 -- MultiLine SSP after minimization of the parameter.
101 returns MultiCurve from AppParCurves
102 raises NotDone from StdFail
106 Error(me; Index: Integer)
107 ---Purpose: returns the difference between the old and the new
109 -- An exception is raised if NotDone.
110 -- An exception is raised if Index<1 or Index>NbParameters.
113 raises NotDone from StdFail,
114 OutOfRange from Standard
119 ---Purpose: returns the maximum difference between the old and the
120 -- new approximation.
123 raises NotDone from StdFail
128 ---Purpose: returns the maximum difference between the old and the
129 -- new approximation.
132 raises NotDone from StdFail
137 ---Purpose: returns the average error between the old and the
138 -- new approximation.
141 raises NotDone from StdFail
147 SCU: MultiCurve from AppParCurves;
148 ParError: Vector from math;
154 end Gradient from AppParCurves;