0024043: Performance improvements: Modeling Algorithms
[occt.git] / src / Extrema / Extrema_GenLocateExtPC.cdl
1 -- Created on: 1995-07-18
2 -- Created by: Modelistation
3 -- Copyright (c) 1995-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
5 --
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.
10 --
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.
13 --
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.
20
21
22
23
24 generic class   GenLocateExtPC from Extrema 
25 (Curve    as any;
26  Tool     as any;    -- as ToolCurve(Curve);
27  POnC     as any;
28  Pnt      as any;
29  Vec      as any )  
30                                            
31         ---Purpose: It calculates the distance between a point and a
32         --          curve with a close point.
33         --          This distance can be a minimum or a maximum.
34
35
36 raises  DomainError  from Standard,
37         TypeMismatch from Standard,
38         NotDone      from StdFail
39         
40 private  class PCLocF instantiates FuncExtPC (Curve, Tool, POnC, Pnt, Vec);
41
42 is
43     Create returns GenLocateExtPC;
44
45     Create (P: Pnt; C: Curve; U0: 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         --          TolU is used to decide to stop the iterations.
54         --          At the nth iteration, the criteria is:
55         --           abs(Un - Un-1) < TolU.
56         raises  DomainError;
57                 -- if U0 is outside the definition range of the curve.
58
59
60     Create (P: Pnt; C: Curve; U0: Real; Umin, Usup: Real; TolU: Real)
61         returns GenLocateExtPC
62         ---Purpose: Calculates the distance with a close point.
63         --          The close point is defined by the parameter value
64         --          U0.
65         --          The function F(u)=distance(P,C(u)) has an extremum
66         --          when g(u)=dF/du=0. The algorithm searchs a zero 
67         --          near the close point.
68         --          Zeros are searched between Umin et Usup.
69         --          TolU is used to decide to stop the iterations.
70         --          At the nth iteration, the criteria is:
71         --           abs(Un - Un-1) < TolU.
72         raises  DomainError;
73                 -- if U0 is outside the definition range of the curve.
74
75
76
77     Initialize(me: in out; C: Curve; Umin, Usup: Real; TolU: Real)
78         ---Purpose: sets the fields of the algorithm.
79     is static;
80
81     Perform(me: in out; P: Pnt; U0: Real)
82         ---Purpose: the algorithm is done with the point P.
83         --          An exception is raised if the fields have not
84         --          been initialized.  
85     raises TypeMismatch from Standard
86     is static;
87
88     IsDone (me) returns Boolean
89         ---Purpose: Returns True if the distance is found.
90         is static;
91
92     SquareDistance (me) returns Real
93         ---Purpose: Returns the value of the extremum square distance.
94         raises  NotDone from StdFail
95                 -- if IsDone(me)=False.
96         is static;
97
98     IsMin (me) returns Boolean
99         ---Purpose: Returns True if the extremum distance is a minimum.
100         raises  NotDone from StdFail
101                 -- if IsDone(me)=False.
102         is static;
103
104     Point (me) returns POnC
105         ---Purpose: Returns the point of the extremum distance.
106         raises  NotDone from StdFail
107                 -- if IsDone(me)=False.
108         is static;
109     
110
111 fields
112     myDone : Boolean;
113     mytolU : Real;
114     myumin:  Real;
115     myusup:  Real;
116     myF:     PCLocF;
117
118 end GenLocateExtPC;