Commit | Line | Data |
---|---|---|
b311480e | 1 | -- Created on: 1991-07-24 |
2 | -- Created by: Michel CHAUVAT | |
3 | -- Copyright (c) 1991-1999 Matra Datavision | |
973c2be1 | 4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | -- |
973c2be1 | 6 | -- This file is part of Open CASCADE Technology software library. |
b311480e | 7 | -- |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 13 | -- |
973c2be1 | 14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. | |
7fd59977 | 16 | |
17 | private generic class FuncExtPC from Extrema | |
18 | (Curve as any; | |
19 | Tool as any; | |
20 | POnC as any; | |
21 | Pnt as any; | |
22 | Vec as any) | |
23 | ||
24 | inherits FunctionWithDerivative from math | |
0d969553 Y |
25 | --- Purpose: Function to find extrema of the distance between a |
26 | --- point and a curve. | |
7fd59977 | 27 | |
28 | uses SequenceOfReal from TColStd, | |
29 | SequenceOfInteger from TColStd | |
30 | ||
31 | raises OutOfRange from Standard, | |
32 | TypeMismatch from Standard | |
33 | ||
34 | private class SeqPC instantiates Sequence from TCollection(POnC); | |
35 | ||
36 | ||
37 | is | |
38 | ||
39 | Create returns FuncExtPC; | |
40 | ||
41 | Create (P: Pnt; C: Curve) returns FuncExtPC; | |
42 | ---Purpose: | |
43 | ||
44 | Initialize(me: in out; C: Curve) | |
45 | ---Purpose: sets the field mycurve of the function. | |
46 | is static; | |
47 | ||
48 | SetPoint(me: in out; P: Pnt) | |
49 | ---Purpose: sets the field P of the function. | |
50 | is static; | |
51 | ||
52 | ||
53 | -- In all next methods, an exception is raised if the fields | |
54 | -- were not initialized. | |
55 | ||
56 | Value (me: in out; U: Real; F: out Real) returns Boolean; | |
0d969553 | 57 | ---Purpose: Calculation of F(U). |
7fd59977 | 58 | |
59 | Derivative (me: in out; U: Real; DF: out Real) returns Boolean; | |
0d969553 | 60 | ---Purpose: Calculation of F'(U). |
7fd59977 | 61 | |
62 | Values (me: in out; U: Real; F,DF: out Real) returns Boolean; | |
0d969553 | 63 | ---Purpose: Calculation of F(U) and F'(U). |
7fd59977 | 64 | |
65 | GetStateNumber (me: in out) returns Integer | |
0d969553 | 66 | ---Purpose: Save the found extremum. |
7fd59977 | 67 | is redefined; |
68 | ||
69 | NbExt (me) returns Integer | |
0d969553 | 70 | ---Purpose: Return the nunber of found extrema. |
7fd59977 | 71 | raises TypeMismatch from Standard; |
72 | ||
73 | SquareDistance (me; N: Integer) returns Real | |
0d969553 | 74 | ---Purpose: Returns the Nth distance. |
7fd59977 | 75 | raises OutOfRange from Standard, |
76 | TypeMismatch from Standard; | |
0d969553 | 77 | -- if N < 1 or N > NbExt(me). |
7fd59977 | 78 | |
79 | IsMin (me; N: Integer) returns Boolean | |
0d969553 | 80 | ---Purpose: Shows if the Nth distance is a minimum. |
7fd59977 | 81 | raises OutOfRange from Standard, |
82 | TypeMismatch from Standard; | |
0d969553 | 83 | -- if N < 1 or N > NbExt(me). |
7fd59977 | 84 | |
85 | Point (me; N: Integer) returns POnC | |
5d99f2c8 | 86 | ---C++: return const & |
0d969553 | 87 | ---Purpose: Returns the Nth extremum. |
7fd59977 | 88 | raises OutOfRange from Standard, |
89 | TypeMismatch from Standard; | |
0d969553 | 90 | -- if N < 1 or N > NbExt(me). |
7fd59977 | 91 | |
32ca7a51 | 92 | SubIntervalInitialize(me: in out; theUfirst, theUlast: Real from Standard); |
93 | ---Purpose: Determines boundaries of subinterval for find of root. | |
94 | ||
95 | SearchOfTolerance(me: in out) returns Real from Standard; | |
96 | ---Purpose: Computes a Tol value. If 1st derivative of curve | |
97 | -- |D1|<Tol, it is considered D1=0. | |
98 | ||
99 | ||
7fd59977 | 100 | fields |
101 | myP : Pnt; | |
102 | myC : Address from Standard; | |
103 | ||
0d969553 Y |
104 | myU : Real; -- current |
105 | myPc : Pnt; -- current point | |
106 | myD1f : Real; -- value of derivative of the function | |
7fd59977 | 107 | |
108 | mySqDist: SequenceOfReal from TColStd; | |
109 | myIsMin: SequenceOfInteger from TColStd; | |
110 | myPoint: SeqPC; | |
111 | myPinit: Boolean; | |
112 | myCinit: Boolean; | |
113 | myD1Init: Boolean; | |
32ca7a51 | 114 | |
115 | myTol: Real from Standard; -- toolerance for derivate | |
116 | ||
117 | --Supremum of search 1st non-zero derivative | |
118 | myMaxDerivOrder: Integer from Standard; | |
119 | ||
120 | --boundaries of subinterval for find of root | |
121 | myUinfium, myUsupremum: Real from Standard; | |
122 | ||
7fd59977 | 123 | |
124 | end FuncExtPC; |