1 -- Created on: 1993-09-22
2 -- Created by: Modelistation
3 -- Copyright (c) 1993-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 BSpGradient 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 MultiBSpCurve from AppParCurves,
34 HArray1OfConstraintCouple from AppParCurves,
35 Array1OfReal from TColStd,
36 Array1OfInteger from TColStd
39 raises OutOfRange from Standard,
43 private class BSpParLeastSquare instantiates LeastSquare from AppParCurves
44 (MultiLine, ToolLine);
46 private class BSpParFunction instantiates BSpFunction from AppParCurves
47 (MultiLine, ToolLine, BSpParLeastSquare);
50 class BSpGradient_BFGS from AppParCurves
51 inherits BFGS from math
52 uses MultipleVarFunctionWithGradient from math,
57 Create ( F : in out MultipleVarFunctionWithGradient from math ;
58 StartingPoint : Vector from math ;
59 Tolerance3d : Real from Standard ;
60 Tolerance2d : Real from Standard ;
61 Eps : Real from Standard ;
62 NbIterations : Integer from Standard = 200 );
64 IsSolutionReached ( me ;
65 F : in out MultipleVarFunctionWithGradient from math )
66 returns Boolean from Standard is redefined ;
70 myTol3d : Real from Standard ;
71 myTol2d : Real from Standard ;
73 end BSpGradient_BFGS from AppParCurves ;
76 Create(SSP: MultiLine; FirstPoint, LastPoint: Integer;
77 TheConstraints: HArray1OfConstraintCouple;
78 Parameters: in out Vector;
79 Knots: Array1OfReal; Mults: Array1OfInteger;
81 Tol3d, Tol2d: Real; NbIterations: Integer = 1)
82 ---Purpose: Tries to minimize the sum (square(||Qui - Bi*Pi||))
83 -- where Pui describe the approximating BSpline curves'Poles
84 -- and Qi the MultiLine points with a parameter ui.
85 -- In this algorithm, the parameters ui are the unknowns.
86 -- The tolerance required on this sum is given by Tol.
87 -- The desired degree of the resulting curve is Deg.
89 returns BSpGradient from AppParCurves;
92 Create(SSP: MultiLine; FirstPoint, LastPoint: Integer;
93 TheConstraints: HArray1OfConstraintCouple;
94 Parameters: in out Vector;
95 Knots: Array1OfReal; Mults: Array1OfInteger;
97 Tol3d, Tol2d: Real; NbIterations: Integer;
98 lambda1, lambda2: Real)
99 ---Purpose: Tries to minimize the sum (square(||Qui - Bi*Pi||))
100 -- where Pui describe the approximating BSpline curves'Poles
101 -- and Qi the MultiLine points with a parameter ui.
102 -- In this algorithm, the parameters ui are the unknowns.
103 -- The tolerance required on this sum is given by Tol.
104 -- The desired degree of the resulting curve is Deg.
106 returns BSpGradient from AppParCurves;
109 Perform(me: in out; SSP: MultiLine; FirstPoint, LastPoint: Integer;
110 TheConstraints: HArray1OfConstraintCouple;
111 Parameters: in out Vector;
112 Knots: Array1OfReal; Mults: Array1OfInteger;
114 Tol3d, Tol2d: Real; NbIterations: Integer = 200)
119 ---Purpose: returns True if all has been correctly done.
126 ---Purpose: returns all the BSpline curves approximating the
127 -- MultiLine SSP after minimization of the parameter.
129 returns MultiBSpCurve from AppParCurves
130 raises NotDone from StdFail
134 Error(me; Index: Integer)
135 ---Purpose: returns the difference between the old and the new
137 -- An exception is raised if NotDone.
138 -- An exception is raised if Index<1 or Index>NbParameters.
141 raises NotDone from StdFail,
142 OutOfRange from Standard
147 ---Purpose: returns the maximum difference between the old and the
148 -- new approximation.
151 raises NotDone from StdFail
156 ---Purpose: returns the maximum difference between the old and the
157 -- new approximation.
160 raises NotDone from StdFail
165 ---Purpose: returns the average error between the old and the
166 -- new approximation.
169 raises NotDone from StdFail
175 SCU: MultiBSpCurve from AppParCurves;
176 ParError: Vector from math;
184 end BSpGradient from AppParCurves;