7fd59977 |
1 | -- File: Extrema_GenExtPC.cdl |
2 | -- Created: Tue Jul 18 17:38:32 1995 |
3 | -- Author: Modelistation |
4 | -- <model@metrox> |
5 | ---Copyright: Matra Datavision 1995 |
6 | |
7 | |
8 | generic class GenExtPC from Extrema (Curve as any; |
9 | Tool as any; --as ToolCurve(Curve) |
10 | POnC as any; |
11 | Pnt as any; |
12 | Vec as any) |
13 | |
14 | ---Purpose: It calculates all the distances between a point |
15 | -- and a curve. |
16 | -- These distances can be minimum or maximum. |
17 | |
18 | |
19 | raises NotDone from StdFail, |
20 | OutOfRange from Standard, |
21 | TypeMismatch from Standard |
22 | |
23 | private class PCF instantiates FuncExtPC from Extrema (Curve, Tool, POnC, Pnt, Vec); |
24 | |
25 | is |
26 | |
27 | Create returns GenExtPC; |
28 | |
29 | |
30 | Create (P: Pnt; C: Curve; NbU: Integer; TolU,TolF: Real) |
31 | returns GenExtPC; |
32 | ---Purpose: It calculates all the distances. |
33 | -- The function F(u)=distance(P,C(u)) has an extremum |
34 | -- when g(u)=dF/du=0. The algorithm searchs all the |
35 | -- zeros inside the definition range of the curve. |
36 | -- NbU is used to locate the close points to |
37 | -- find the zeros. |
38 | -- Tol and TolU are used to decide to stop the |
39 | -- iterations according to the following condition: |
40 | -- if n is the number of iterations, |
41 | -- abs(Un-Un-1) < TolU and abs(F(Un)-F(Un-1)) < Tol. |
42 | |
43 | |
44 | Create (P: Pnt; C: Curve; NbU: Integer; Umin, Usup: Real; TolU,TolF: Real) |
45 | returns GenExtPC; |
46 | ---Purpose: It calculates all the distances. |
47 | -- The function F(u)=distance(P,C(u)) has an extremum |
48 | -- when g(u)=dF/du=0. The algorithm searchs all the |
49 | -- zeros inside the definition range of the curve. |
50 | -- NbU is used to locate the close points to |
51 | -- find the zeros. |
52 | -- Zeros are searched between umin and usup. |
53 | -- Tol and TolU are used to decide to stop the |
54 | -- iterations according to the following condition: |
55 | -- if n is the number of iterations, |
56 | -- abs(Un-Un-1) < TolU and abs(F(Un)-F(Un-1)) < Tol. |
57 | |
58 | |
59 | |
60 | Initialize(me: in out; C: Curve; NbU: Integer; TolU, TolF: Real) |
61 | ---Purpose: sets the fields of the algorithm. |
62 | is static; |
63 | |
64 | |
65 | Initialize(me: in out; C: Curve; NbU: Integer; |
66 | Umin, Usup: Real; TolU, TolF: Real) |
67 | ---Purpose: sets the fields of the algorithm. |
68 | is static; |
69 | |
70 | Initialize(me: in out; C: Curve) |
71 | ---Purpose: sets the fields of the algorithm. |
72 | is static; |
73 | |
74 | Initialize(me: in out; NbU: Integer; Umin, Usup: Real; TolU, TolF: Real) |
75 | ---Purpose: sets the fields of the algorithm. |
76 | is static; |
77 | |
78 | |
79 | Perform(me: in out; P: Pnt) |
80 | ---Purpose: the algorithm is done with the point P. |
81 | -- An exception is raised if the fields have not |
82 | -- been initialized. |
83 | raises TypeMismatch from Standard |
84 | is static; |
85 | |
86 | |
87 | IsDone (me) returns Boolean |
88 | ---Purpose: True if the distances are found. |
89 | raises TypeMismatch from Standard |
90 | is static; |
91 | |
92 | NbExt (me) returns Integer |
93 | ---Purpose: Returns the number of extremum distances. |
94 | raises TypeMismatch from Standard, |
95 | NotDone from StdFail |
96 | -- if IsDone(me)=False. |
97 | is static; |
98 | |
99 | SquareDistance (me; N: Integer) returns Real |
100 | ---Purpose: Returns the value of the Nth extremum square distance. |
101 | raises TypeMismatch from Standard, |
102 | NotDone from StdFail, |
103 | -- if IsDone(me)=False. |
104 | OutOfRange from Standard |
105 | -- if N < 1 or N > NbPoints(me). |
106 | is static; |
107 | |
108 | |
109 | IsMin (me; N: Integer) returns Boolean |
110 | ---Purpose: Returns True if the Nth extremum distance is a |
111 | -- minimum. |
112 | raises TypeMismatch from Standard, |
113 | NotDone from StdFail, |
114 | -- if IsDone(me)=False. |
115 | OutOfRange from Standard |
116 | -- if N < 1 or N > NbPoints(me). |
117 | is static; |
118 | |
119 | |
120 | Point (me; N: Integer) returns POnC |
121 | ---Purpose: Returns the point of the Nth extremum distance. |
122 | raises TypeMismatch from Standard, |
123 | NotDone from StdFail, |
124 | -- if IsDone(me)=False. |
125 | OutOfRange from Standard |
126 | -- if N < 1 or N > NbPoints(me). |
127 | is static; |
128 | |
129 | |
130 | |
131 | fields |
132 | myDone : Boolean; |
133 | myInit: Boolean; |
134 | mynbsample: Integer; |
135 | myumin: Real; |
136 | myusup: Real; |
137 | mytolu: Real; |
138 | mytolF: Real; |
139 | myF : PCF; |
140 | |
141 | end GenExtPC; |
142 | |