7fd59977 |
1 | -- File: Extrema_GenLocateExtPC.cdl |
2 | -- Created: Tue Jul 18 17:40:06 1995 |
3 | -- Author: Modelistation |
4 | -- <model@metrox> |
5 | ---Copyright: Matra Datavision 1995 |
6 | |
7 | |
8 | |
9 | generic class GenLocateExtPC from Extrema |
10 | (Curve as any; |
11 | Tool as any; -- as ToolCurve(Curve); |
12 | POnC as any; |
13 | Pnt as any; |
14 | Vec as any ) |
15 | |
16 | ---Purpose: It calculates the distance between a point and a |
17 | -- curve with a close point. |
18 | -- This distance can be a minimum or a maximum. |
19 | |
20 | |
21 | raises DomainError from Standard, |
22 | TypeMismatch from Standard, |
23 | NotDone from StdFail |
24 | |
25 | private class PCLocF instantiates FuncExtPC (Curve, Tool, POnC, Pnt, Vec); |
26 | |
27 | is |
28 | Create returns GenLocateExtPC; |
29 | |
30 | Create (P: Pnt; C: Curve; U0: Real; TolU: Real) |
31 | returns GenLocateExtPC |
32 | ---Purpose: Calculates the distance with a close point. |
33 | -- The close point is defined by the parameter value |
34 | -- U0. |
35 | -- The function F(u)=distance(P,C(u)) has an extremum |
36 | -- when g(u)=dF/du=0. The algorithm searchs a zero |
37 | -- near the close point. |
38 | -- TolU is used to decide to stop the iterations. |
39 | -- At the nth iteration, the criteria is: |
40 | -- abs(Un - Un-1) < TolU. |
41 | raises DomainError; |
42 | -- if U0 is outside the definition range of the curve. |
43 | |
44 | |
45 | Create (P: Pnt; C: Curve; U0: Real; Umin, Usup: Real; TolU: Real) |
46 | returns GenLocateExtPC |
47 | ---Purpose: Calculates the distance with a close point. |
48 | -- The close point is defined by the parameter value |
49 | -- U0. |
50 | -- The function F(u)=distance(P,C(u)) has an extremum |
51 | -- when g(u)=dF/du=0. The algorithm searchs a zero |
52 | -- near the close point. |
53 | -- Zeros are searched between Umin et Usup. |
54 | -- TolU is used to decide to stop the iterations. |
55 | -- At the nth iteration, the criteria is: |
56 | -- abs(Un - Un-1) < TolU. |
57 | raises DomainError; |
58 | -- if U0 is outside the definition range of the curve. |
59 | |
60 | |
61 | |
62 | Initialize(me: in out; C: Curve; Umin, Usup: Real; TolU: Real) |
63 | ---Purpose: sets the fields of the algorithm. |
64 | is static; |
65 | |
66 | Perform(me: in out; P: Pnt; U0: Real) |
67 | ---Purpose: the algorithm is done with the point P. |
68 | -- An exception is raised if the fields have not |
69 | -- been initialized. |
70 | raises TypeMismatch from Standard |
71 | is static; |
72 | |
73 | IsDone (me) returns Boolean |
74 | ---Purpose: Returns True if the distance is found. |
75 | is static; |
76 | |
77 | SquareDistance (me) returns Real |
78 | ---Purpose: Returns the value of the extremum square distance. |
79 | raises NotDone from StdFail |
80 | -- if IsDone(me)=False. |
81 | is static; |
82 | |
83 | IsMin (me) returns Boolean |
84 | ---Purpose: Returns True if the extremum distance is a minimum. |
85 | raises NotDone from StdFail |
86 | -- if IsDone(me)=False. |
87 | is static; |
88 | |
89 | Point (me) returns POnC |
90 | ---Purpose: Returns the point of the extremum distance. |
91 | raises NotDone from StdFail |
92 | -- if IsDone(me)=False. |
93 | is static; |
94 | |
95 | |
96 | fields |
97 | myDone : Boolean; |
98 | mytolU : Real; |
99 | myumin: Real; |
100 | myusup: Real; |
101 | myF: PCLocF; |
102 | |
103 | end GenLocateExtPC; |