0022241: The bug is appendix to the Salome Bug 0021148
[occt.git] / src / Extrema / Extrema_GenExtPC.gxx
CommitLineData
7fd59977 1// File: Extrema_GenExtPC.gxx
2// Created: Tue Jul 18 17:39:15 1995
3// Author: Modelistation
4// <model@metrox>
5
6
7#include <StdFail_NotDone.hxx>
8#include <math_DirectPolynomialRoots.hxx>
9#include <math_FunctionRoots.hxx>
10#include <Standard_OutOfRange.hxx>
11#include <Standard_NotImplemented.hxx>
12
13
14//=======================================================================
15//function : Extrema_GenExtPC
16//purpose :
17//=======================================================================
18
19Extrema_GenExtPC::Extrema_GenExtPC () {
20 myDone = Standard_False;
21 myInit = Standard_False;
22}
23
24
25
26//=======================================================================
27//function : Extrema_GenExtPC
28//purpose :
29//=======================================================================
30
31Extrema_GenExtPC::Extrema_GenExtPC (const Pnt& P,
32 const Curve& C,
33 const Standard_Integer NbSample,
34 const Standard_Real TolU,
35 const Standard_Real TolF) : myF (P,C)
36{
37 Initialize(C, NbSample, TolU, TolF);
38 Perform(P);
39}
40
41
42//=======================================================================
43//function : Extrema_GenExtPC
44//purpose :
45//=======================================================================
46
47Extrema_GenExtPC::Extrema_GenExtPC (const Pnt& P,
48 const Curve& C,
49 const Standard_Integer NbSample,
50 const Standard_Real Umin,
51 const Standard_Real Usup,
52 const Standard_Real TolU,
53 const Standard_Real TolF) : myF (P,C)
54{
55 Initialize(C, NbSample, Umin, Usup, TolU, TolF);
56 Perform(P);
57}
58
59
60//=======================================================================
61//function : Initialize
62//purpose :
63//=======================================================================
64
65void Extrema_GenExtPC::Initialize(const Curve& C,
66 const Standard_Integer NbU,
67 const Standard_Real TolU,
68 const Standard_Real TolF)
69{
70 myInit = Standard_True;
71 mynbsample = NbU;
72 mytolu = TolU;
73 mytolF = TolF;
74 myF.Initialize(C);
75 myumin = Tool::FirstParameter(C);
76 myusup = Tool::LastParameter(C);
77}
78
79//=======================================================================
80//function : Initialize
81//purpose :
82//=======================================================================
83
84void Extrema_GenExtPC::Initialize(const Curve& C,
85 const Standard_Integer NbU,
86 const Standard_Real Umin,
87 const Standard_Real Usup,
88 const Standard_Real TolU,
89 const Standard_Real TolF)
90{
91 myInit = Standard_True;
92 mynbsample = NbU;
93 mytolu = TolU;
94 mytolF = TolF;
95 myF.Initialize(C);
96 myumin = Umin;
97 myusup = Usup;
98}
99
100
101//=======================================================================
102//function : Initialize
103//purpose :
104//=======================================================================
105
106void Extrema_GenExtPC::Initialize(const Standard_Integer NbU,
107 const Standard_Real Umin,
108 const Standard_Real Usup,
109 const Standard_Real TolU,
110 const Standard_Real TolF)
111{
112 mynbsample = NbU;
113 mytolu = TolU;
114 mytolF = TolF;
115 myumin = Umin;
116 myusup = Usup;
117}
118
119//=======================================================================
120//function : Initialize
121//purpose :
122//=======================================================================
123
124void Extrema_GenExtPC::Initialize(const Curve& C)
125{
126 myF.Initialize(C);
127}
128
129
130
131//=======================================================================
132//function : Perform
133//purpose :
134//=======================================================================
135
136void Extrema_GenExtPC::Perform(const Pnt& P)
137/*-----------------------------------------------------------------------------
138Fonction:
139 Recherche des valeurs de parametre u telle que dist(P,C(u)) passe
140 par un extremum.
141
142Methode:
143 Si U est solution, alors (C(U)-P).C'(U) = 0.
144 Le probleme consiste a rechercher les racines de cette fonction
145 dans l'intervalle de definition de la courbe.
146 On utilise la classe math_FunctionRoots avec les arguments de
147 construction suivant:
148 - F: Extrema_FuncExtPC cree a partir de P et C,
149 - Uinf: borne inferieure de l'intervalle de definition,
150 - Usup: borne superieure de l'intervalle de definition,
151 - NbSample,
152 - TolU,
153 - TolF,
154 - TolF.
155-----------------------------------------------------------------------------*/
156{
157 myF.SetPoint(P);
158 myDone = Standard_False;
159
160 math_FunctionRoots S (myF, myumin, myusup, mynbsample, mytolu, mytolF, mytolF);
161 if (!S.IsDone() ||
162 S.IsAllNull()) { return; }
163
164 myDone = Standard_True;
165}
166
167
168
169//=======================================================================
170//function : IsDone
171//purpose :
172//=======================================================================
173
174Standard_Boolean Extrema_GenExtPC::IsDone () const {
175
176 return myDone;
177}
178
179
180//=======================================================================
181//function : NbExt
182//purpose :
183//=======================================================================
184
185Standard_Integer Extrema_GenExtPC::NbExt () const {
186
187 if (!IsDone()) { StdFail_NotDone::Raise(); }
188 return myF.NbExt();
189}
190
191
192//=======================================================================
193//function : Value
194//purpose :
195//=======================================================================
196
197Standard_Real Extrema_GenExtPC::SquareDistance (const Standard_Integer N) const {
198
199 if (!IsDone()) { StdFail_NotDone::Raise(); }
200 return myF.SquareDistance(N);
201}
202
203
204//=======================================================================
205//function : IsMin
206//purpose :
207//=======================================================================
208
209Standard_Boolean Extrema_GenExtPC::IsMin (const Standard_Integer N) const {
210
211 if (!IsDone()) { StdFail_NotDone::Raise(); }
212 return myF.IsMin(N);
213}
214
215
216//=======================================================================
217//function : Point
218//purpose :
219//=======================================================================
220
221POnC Extrema_GenExtPC::Point (const Standard_Integer N) const
222{
223 if (!IsDone()) { StdFail_NotDone::Raise(); }
224 return myF.Point(N);
225}
226//=============================================================================