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