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
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.
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.
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.
24 generic class BSpGradient from AppParCurves
26 ToolLine as any) -- as ToolLine(MultiLine)
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.
38 uses Vector from math,
39 MultipleVarFunctionWithGradient from math,
40 MultiBSpCurve from AppParCurves,
41 HArray1OfConstraintCouple from AppParCurves,
42 Array1OfReal from TColStd,
43 Array1OfInteger from TColStd
46 raises OutOfRange from Standard,
50 private class BSpParLeastSquare instantiates LeastSquare from AppParCurves
51 (MultiLine, ToolLine);
53 private class BSpParFunction instantiates BSpFunction from AppParCurves
54 (MultiLine, ToolLine, BSpParLeastSquare);
57 class BSpGradient_BFGS from AppParCurves
58 inherits BFGS from math
59 uses MultipleVarFunctionWithGradient from math,
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 );
71 IsSolutionReached ( me ;
72 F : in out MultipleVarFunctionWithGradient from math )
73 returns Boolean from Standard is redefined ;
77 myTol3d : Real from Standard ;
78 myTol2d : Real from Standard ;
80 end BSpGradient_BFGS from AppParCurves ;
83 Create(SSP: MultiLine; FirstPoint, LastPoint: Integer;
84 TheConstraints: HArray1OfConstraintCouple;
85 Parameters: in out Vector;
86 Knots: Array1OfReal; Mults: Array1OfInteger;
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.
96 returns BSpGradient from AppParCurves;
99 Create(SSP: MultiLine; FirstPoint, LastPoint: Integer;
100 TheConstraints: HArray1OfConstraintCouple;
101 Parameters: in out Vector;
102 Knots: Array1OfReal; Mults: Array1OfInteger;
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.
113 returns BSpGradient from AppParCurves;
116 Perform(me: in out; SSP: MultiLine; FirstPoint, LastPoint: Integer;
117 TheConstraints: HArray1OfConstraintCouple;
118 Parameters: in out Vector;
119 Knots: Array1OfReal; Mults: Array1OfInteger;
121 Tol3d, Tol2d: Real; NbIterations: Integer = 200)
126 ---Purpose: returns True if all has been correctly done.
133 ---Purpose: returns all the BSpline curves approximating the
134 -- MultiLine SSP after minimization of the parameter.
136 returns MultiBSpCurve from AppParCurves
137 raises NotDone from StdFail
141 Error(me; Index: Integer)
142 ---Purpose: returns the difference between the old and the new
144 -- An exception is raised if NotDone.
145 -- An exception is raised if Index<1 or Index>NbParameters.
148 raises NotDone from StdFail,
149 OutOfRange from Standard
154 ---Purpose: returns the maximum difference between the old and the
155 -- new approximation.
158 raises NotDone from StdFail
163 ---Purpose: returns the maximum difference between the old and the
164 -- new approximation.
167 raises NotDone from StdFail
172 ---Purpose: returns the average error between the old and the
173 -- new approximation.
176 raises NotDone from StdFail
182 SCU: MultiBSpCurve from AppParCurves;
183 ParError: Vector from math;
191 end BSpGradient from AppParCurves;