7fd59977 |
1 | -- File: Extrema_GenExtCC.cdl |
2 | -- Created: Tue Jul 18 17:41:35 1995 |
3 | -- Author: Modelistation |
4 | -- <model@metrox> |
5 | ---Copyright: Matra Datavision 1995 |
6 | |
7 | |
8 | |
9 | generic class GenExtCC from Extrema |
10 | (Curve1 as any; |
11 | Tool1 as any; -- as ToolCurve(Curve1) |
12 | Curve2 as any; |
13 | Tool2 as any; -- as ToolCurve(Curve2) |
14 | Cache as Transient from Standard; -- CurveCache from Extrema |
15 | ArrayOfPnt as Transient from Standard; -- as returned by Extrema_CurveCache::Points() |
16 | POnC as any; |
17 | Pnt as any; |
18 | Vec as any) |
19 | |
20 | ---Purpose: It calculates all the distance between two curves. |
21 | -- These distances can be maximum or minimum. |
22 | |
23 | raises InfiniteSolutions from StdFail, |
24 | NotDone from StdFail, |
25 | OutOfRange from Standard |
26 | |
27 | private class CCF instantiates FuncExtCC from Extrema (Curve1, Tool1, |
28 | Curve2, Tool2, |
29 | POnC, Pnt, Vec); |
30 | |
31 | is |
32 | |
33 | Create returns GenExtCC; |
34 | ---Purpose: Calculates all the distances as above |
35 | -- between Uinf and Usup for C1 and between Vinf and Vsup |
36 | -- for C2. |
37 | |
38 | Create (C1: Curve1; C2: Curve2; NbU,NbV: Integer; TolU,TolV: Real) returns GenExtCC; |
39 | ---Purpose: It calculates all the distances. |
40 | -- The function F(u,v)=distance(C1(u),C2(v)) has an |
41 | -- extremum when gradient(f)=0. The algorithm searchs |
42 | -- all the zeros. |
43 | -- NbU,NbV are used to locate the close points to |
44 | -- find the zeros. They must be great enough such that |
45 | -- if there is N extrema, there will be N extrema |
46 | -- between the segment and the grid. |
47 | -- TolU and TolV are used to determinethe conditions |
48 | -- to stop the iterations; at the iteration number n: |
49 | -- (Un - Un-1) < TolU and (Vn - Vn-1) < TolV . |
50 | |
51 | Create (C1: Curve1; C2: Curve2; Uinf, Usup, Vinf, Vsup: Real; |
52 | NbU,NbV: Integer; TolU,TolV: Real) returns GenExtCC; |
53 | ---Purpose: Calculates all the distances as above |
54 | -- between Uinf and Usup for C1 and between Vinf and Vsup |
55 | -- for C2. |
56 | |
57 | SetCurveCache (me: in out; theRank: Integer; theCache: Cache); |
58 | ---Purpose: |
59 | |
60 | SetTolerance (me: in out; Tol: Real); |
61 | ---Purpose: |
62 | |
63 | Perform(me: in out) is static; |
64 | ---Purpose: Performs calculations. |
65 | |
66 | |
67 | IsDone (me) returns Boolean |
68 | ---Purpose: Returns True if the distances are found. |
69 | is static; |
70 | |
71 | NbExt (me) returns Integer |
72 | ---Purpose: Returns the number of extremum distances. |
73 | raises NotDone from StdFail, |
74 | -- if IsDone(me)=False. |
75 | InfiniteSolutions from StdFail |
76 | -- if IsParallel(me)= True. |
77 | is static; |
78 | |
79 | SquareDistance (me; N: Integer =1) returns Real |
80 | ---Purpose: Returns the value of the Nth square extremum distance. |
81 | raises NotDone from StdFail, |
82 | -- if IsDone(me)=False. |
83 | InfiniteSolutions from StdFail, |
84 | -- if IsParallel(me)= True and N > 1. |
85 | OutOfRange |
86 | -- if N < 1 or N > NbExt(me) |
87 | is static; |
88 | |
89 | Points (me; N: Integer; P1,P2: out POnC) |
90 | ---Purpose: Returns the points of the Nth extremum distance. |
91 | -- P1 is on the first curve, P2 on the second one. |
92 | raises NotDone from StdFail, |
93 | -- if IsDone(me)=False. |
94 | InfiniteSolutions from StdFail, |
95 | -- if IsParallel(me)= True. |
96 | OutOfRange |
97 | -- if N < 1 or N > NbExt(me) |
98 | is static; |
99 | |
100 | fields |
101 | myF : CCF from Extrema; |
102 | myDone : Boolean; |
103 | myCache: Cache [2]; |
104 | |
105 | end GenExtCC; |