1 -- Created on: 1991-07-24
2 -- Created by: Michel CHAUVAT
3 -- Copyright (c) 1991-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.
23 private generic class FuncExtPC from Extrema
30 inherits FunctionWithDerivative from math
31 --- Purpose: Function to find extrema of the distance between a
32 --- point and a curve.
34 uses SequenceOfReal from TColStd,
35 SequenceOfInteger from TColStd
37 raises OutOfRange from Standard,
38 TypeMismatch from Standard
40 private class SeqPC instantiates Sequence from TCollection(POnC);
45 Create returns FuncExtPC;
47 Create (P: Pnt; C: Curve) returns FuncExtPC;
50 Initialize(me: in out; C: Curve)
51 ---Purpose: sets the field mycurve of the function.
54 SetPoint(me: in out; P: Pnt)
55 ---Purpose: sets the field P of the function.
59 -- In all next methods, an exception is raised if the fields
60 -- were not initialized.
62 Value (me: in out; U: Real; F: out Real) returns Boolean;
63 ---Purpose: Calculation of F(U).
65 Derivative (me: in out; U: Real; DF: out Real) returns Boolean;
66 ---Purpose: Calculation of F'(U).
68 Values (me: in out; U: Real; F,DF: out Real) returns Boolean;
69 ---Purpose: Calculation of F(U) and F'(U).
71 GetStateNumber (me: in out) returns Integer
72 ---Purpose: Save the found extremum.
75 NbExt (me) returns Integer
76 ---Purpose: Return the nunber of found extrema.
77 raises TypeMismatch from Standard;
79 SquareDistance (me; N: Integer) returns Real
80 ---Purpose: Returns the Nth distance.
81 raises OutOfRange from Standard,
82 TypeMismatch from Standard;
83 -- if N < 1 or N > NbExt(me).
85 IsMin (me; N: Integer) returns Boolean
86 ---Purpose: Shows if the Nth distance is a minimum.
87 raises OutOfRange from Standard,
88 TypeMismatch from Standard;
89 -- if N < 1 or N > NbExt(me).
91 Point (me; N: Integer) returns POnC
92 ---Purpose: Returns the Nth extremum.
93 raises OutOfRange from Standard,
94 TypeMismatch from Standard;
95 -- if N < 1 or N > NbExt(me).
97 SubIntervalInitialize(me: in out; theUfirst, theUlast: Real from Standard);
98 ---Purpose: Determines boundaries of subinterval for find of root.
100 SearchOfTolerance(me: in out) returns Real from Standard;
101 ---Purpose: Computes a Tol value. If 1st derivative of curve
102 -- |D1|<Tol, it is considered D1=0.
107 myC : Address from Standard;
109 myU : Real; -- current
110 myPc : Pnt; -- current point
111 myD1f : Real; -- value of derivative of the function
113 mySqDist: SequenceOfReal from TColStd;
114 myIsMin: SequenceOfInteger from TColStd;
120 myTol: Real from Standard; -- toolerance for derivate
122 --Supremum of search 1st non-zero derivative
123 myMaxDerivOrder: Integer from Standard;
125 --boundaries of subinterval for find of root
126 myUinfium, myUsupremum: Real from Standard;