mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-26 23:07:01 +08:00
163 lines
5.2 KiB
Plaintext
Executable File
163 lines
5.2 KiB
Plaintext
Executable File
-- Created on: 1991-07-25
|
|
-- Created by: Laurent PAINNOT
|
|
-- Copyright (c) 1991-1999 Matra Datavision
|
|
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
|
--
|
|
-- The content of this file is subject to the Open CASCADE Technology Public
|
|
-- License Version 6.5 (the "License"). You may not use the content of this file
|
|
-- except in compliance with the License. Please obtain a copy of the License
|
|
-- at http://www.opencascade.org and read it completely before using this file.
|
|
--
|
|
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
|
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
|
--
|
|
-- The Original Code and all software distributed under the License is
|
|
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
|
-- Initial Developer hereby disclaims all such warranties, including without
|
|
-- limitation, any warranties of merchantability, fitness for a particular
|
|
-- purpose or non-infringement. Please see the License for the specific terms
|
|
-- and conditions governing the rights and limitations under the License.
|
|
|
|
|
|
|
|
|
|
|
|
generic class Gradient from AppParCurves
|
|
(MultiLine as any;
|
|
ToolLine as any) -- as ToolLine(MultiLine)
|
|
|
|
|
|
---Purpose: This algorithm uses the algorithms LeastSquare,
|
|
-- ResConstraint and a gradient method to approximate a set
|
|
-- of points (AppDef_MultiLine) with a minimization of the
|
|
-- sum(square(|F(i)-Qi|)) by changing the parameter.
|
|
-- The algorithm used is from of the mathematical
|
|
-- package: math_BFGS, a gradient method.
|
|
|
|
|
|
|
|
uses Vector from math,
|
|
MultipleVarFunctionWithGradient from math,
|
|
MultiCurve from AppParCurves,
|
|
HArray1OfConstraintCouple from AppParCurves
|
|
|
|
|
|
raises OutOfRange from Standard,
|
|
NotDone from StdFail
|
|
|
|
|
|
private class ParLeastSquare instantiates LeastSquare from AppParCurves
|
|
(MultiLine, ToolLine);
|
|
|
|
private class ResConstraint instantiates ResolConstraint from AppParCurves
|
|
(MultiLine, ToolLine);
|
|
|
|
private class ParFunction instantiates Function from AppParCurves
|
|
(MultiLine, ToolLine, ParLeastSquare, ResConstraint);
|
|
|
|
class Gradient_BFGS from AppParCurves
|
|
inherits BFGS from math
|
|
uses MultipleVarFunctionWithGradient from math,
|
|
Vector from math
|
|
is
|
|
|
|
Create ( F : in out MultipleVarFunctionWithGradient from math ;
|
|
StartingPoint : Vector from math ;
|
|
Tolerance3d : Real from Standard ;
|
|
Tolerance2d : Real from Standard ;
|
|
Eps : Real from Standard ;
|
|
NbIterations : Integer from Standard = 200 );
|
|
|
|
IsSolutionReached ( me ;
|
|
F : in out MultipleVarFunctionWithGradient from math )
|
|
returns Boolean from Standard is redefined ;
|
|
|
|
fields
|
|
|
|
myTol3d : Real from Standard ;
|
|
myTol2d : Real from Standard ;
|
|
|
|
end Gradient_BFGS from AppParCurves ;
|
|
|
|
is
|
|
|
|
Create(SSP: MultiLine; FirstPoint, LastPoint: Integer;
|
|
TheConstraints: HArray1OfConstraintCouple;
|
|
Parameters: in out Vector; Deg: Integer;
|
|
Tol3d, Tol2d: Real; NbIterations: Integer = 200)
|
|
---Purpose: Tries to minimize the sum (square(||Qui - Bi*Pi||))
|
|
-- where Pui describe the approximating Bezier curves'Poles
|
|
-- and Qi the MultiLine points with a parameter ui.
|
|
-- In this algorithm, the parameters ui are the unknowns.
|
|
-- The tolerance required on this sum is given by Tol.
|
|
-- The desired degree of the resulting curve is Deg.
|
|
|
|
returns Gradient from AppParCurves;
|
|
|
|
|
|
IsDone(me)
|
|
---Purpose: returns True if all has been correctly done.
|
|
|
|
returns Boolean
|
|
is static;
|
|
|
|
|
|
Value(me)
|
|
---Purpose: returns all the Bezier curves approximating the
|
|
-- MultiLine SSP after minimization of the parameter.
|
|
|
|
returns MultiCurve from AppParCurves
|
|
raises NotDone from StdFail
|
|
is static;
|
|
|
|
|
|
Error(me; Index: Integer)
|
|
---Purpose: returns the difference between the old and the new
|
|
-- approximation.
|
|
-- An exception is raised if NotDone.
|
|
-- An exception is raised if Index<1 or Index>NbParameters.
|
|
|
|
returns Real
|
|
raises NotDone from StdFail,
|
|
OutOfRange from Standard
|
|
is static;
|
|
|
|
|
|
MaxError3d(me)
|
|
---Purpose: returns the maximum difference between the old and the
|
|
-- new approximation.
|
|
|
|
returns Real
|
|
raises NotDone from StdFail
|
|
is static;
|
|
|
|
|
|
MaxError2d(me)
|
|
---Purpose: returns the maximum difference between the old and the
|
|
-- new approximation.
|
|
|
|
returns Real
|
|
raises NotDone from StdFail
|
|
is static;
|
|
|
|
|
|
AverageError(me)
|
|
---Purpose: returns the average error between the old and the
|
|
-- new approximation.
|
|
|
|
returns Real
|
|
raises NotDone from StdFail
|
|
is static;
|
|
|
|
|
|
fields
|
|
|
|
SCU: MultiCurve from AppParCurves;
|
|
ParError: Vector from math;
|
|
AvError: Real;
|
|
MError3d: Real;
|
|
MError2d: Real;
|
|
Done: Boolean;
|
|
|
|
end Gradient from AppParCurves;
|