1 -- Created on: 1992-10-19
2 -- Created by: Laurent PAINNOT
3 -- Copyright (c) 1992-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
22 generic class GExtPC from Extrema(
29 TheSequenceOfPOnC as any)
30 ---Purpose: It calculates all the distances between a point and a
31 -- curve. The Algorithm finds the C2 intervals on the
35 SequenceOfBoolean from TColStd,
36 SequenceOfReal from TColStd,
37 CurveType from GeomAbs
41 OutOfRange from Standard,
42 TypeMismatch from Standard
45 class EPC instantiates GenExtPC from Extrema
53 Create returns GExtPC;
57 Uinf, Usup : Real from Standard;
58 TolF : Real from Standard = 1.0e-10)
59 ---Purpose: It calculates all the distances.
60 -- The function F(u)=distance(P,C(u)) has an extremum
61 -- when g(u)=dF/du=0. The algorithm searchs all the
62 -- zeros inside the definition range of the curve.
63 -- Zeros are searched between uinf and usup.
64 -- Tol is used to decide to stop the
65 -- iterations according to the following condition:
66 -- if n is the number of iterations,
67 -- the algorithm stops when abs(F(Un)-F(Un-1)) < Tol.
72 TolF : Real from Standard = 1.0e-10)
73 ---Purpose: It calculates all the distances.
74 -- The function F(u)=distance(P,C(u)) has an extremum
75 -- when g(u)=dF/du=0. The algorithm searchs all the
76 -- zeros inside the definition range of the curve.
77 -- Tol is used to decide to stop the
78 -- iterations according to the following condition:
79 -- if n is the number of iterations,
80 -- the algorithm stops when abs(F(Un)-F(Un-1)) < Tol.
83 Initialize(me : in out; C : TheCurve;
84 Uinf, Usup : Real from Standard;
85 TolF : Real from Standard = 1.0e-10)
86 ---Purpose: initializes the fields of the algorithm.
89 Perform(me: in out; P: ThePoint)
90 ---Purpose: An exception is raised if the fields have not been
92 raises TypeMismatch from Standard
95 IntervalPerform(me: in out; P: ThePoint)
98 IsDone(me) returns Boolean from Standard
99 ---Purpose: True if the distances are found.
102 SquareDistance(me; N: Integer from Standard) returns Real from Standard
103 ---Purpose: Returns the value of the <N>th extremum square distance.
104 raises NotDone from StdFail,
105 OutOfRange from Standard
108 NbExt(me) returns Integer from Standard
109 ---Purpose: Returns the number of extremum distances.
110 raises NotDone from StdFail
113 IsMin(me; N: Integer from Standard) returns Boolean from Standard
114 ---Purpose: Returns True if the <N>th extremum distance is a
116 raises NotDone from StdFail,
117 OutOfRange from Standard
120 Point(me; N: Integer from Standard) returns ThePOnC
121 ---C++: return const &
122 ---Purpose: Returns the point of the <N>th extremum distance.
123 raises NotDone from StdFail,
124 OutOfRange from Standard
127 TrimmedSquareDistances(me; dist1: out Real from Standard;
128 dist2: out Real from Standard;
131 ---Purpose: if the curve is a trimmed curve,
132 -- dist1 is a square distance between <P> and the point
133 -- of parameter FirstParameter <P1> and
134 -- dist2 is a square distance between <P> and the point
135 -- of parameter LastParameter <P2>.
141 myC: Address from Standard;
144 myExtPElC: TheExtPElC;
145 mypoint: TheSequenceOfPOnC;
146 mydone: Boolean from Standard;
147 mydist1: Real from Standard;
148 mydist2: Real from Standard;
149 myExtPC: EPC from Extrema;
150 mytolu: Real from Standard;
151 mytolf: Real from Standard;
152 mysample: Integer from Standard;
153 myintuinf: Real from Standard;
154 myintusup: Real from Standard;
155 myuinf: Real from Standard;
156 myusup: Real from Standard;
157 type: CurveType from GeomAbs;
158 myismin: SequenceOfBoolean from TColStd;
159 mySqDist: SequenceOfReal from TColStd;