1 // Created on: 1995-07-18
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <StdFail_NotDone.hxx>
18 #include <math_DirectPolynomialRoots.hxx>
19 #include <math_FunctionRoots.hxx>
20 #include <Standard_OutOfRange.hxx>
21 #include <Standard_NotImplemented.hxx>
24 //=======================================================================
25 //function : Extrema_GenExtPC
27 //=======================================================================
29 Extrema_GenExtPC::Extrema_GenExtPC () {
30 myDone = Standard_False;
31 myInit = Standard_False;
36 //=======================================================================
37 //function : Extrema_GenExtPC
39 //=======================================================================
41 Extrema_GenExtPC::Extrema_GenExtPC (const Pnt& P,
43 const Standard_Integer NbSample,
44 const Standard_Real TolU,
45 const Standard_Real TolF) : myF (P,C)
47 Initialize(C, NbSample, TolU, TolF);
52 //=======================================================================
53 //function : Extrema_GenExtPC
55 //=======================================================================
57 Extrema_GenExtPC::Extrema_GenExtPC (const Pnt& P,
59 const Standard_Integer NbSample,
60 const Standard_Real Umin,
61 const Standard_Real Usup,
62 const Standard_Real TolU,
63 const Standard_Real TolF) : myF (P,C)
65 Initialize(C, NbSample, Umin, Usup, TolU, TolF);
70 //=======================================================================
71 //function : Initialize
73 //=======================================================================
75 void Extrema_GenExtPC::Initialize(const Curve& C,
76 const Standard_Integer NbU,
77 const Standard_Real TolU,
78 const Standard_Real TolF)
80 myInit = Standard_True;
85 myumin = Tool::FirstParameter(C);
86 myusup = Tool::LastParameter(C);
89 //=======================================================================
90 //function : Initialize
92 //=======================================================================
94 void Extrema_GenExtPC::Initialize(const Curve& C,
95 const Standard_Integer NbU,
96 const Standard_Real Umin,
97 const Standard_Real Usup,
98 const Standard_Real TolU,
99 const Standard_Real TolF)
101 myInit = Standard_True;
111 //=======================================================================
112 //function : Initialize
114 //=======================================================================
116 void Extrema_GenExtPC::Initialize(const Standard_Integer NbU,
117 const Standard_Real Umin,
118 const Standard_Real Usup,
119 const Standard_Real TolU,
120 const Standard_Real TolF)
129 //=======================================================================
130 //function : Initialize
132 //=======================================================================
134 void Extrema_GenExtPC::Initialize(const Curve& C)
141 //=======================================================================
144 //=======================================================================
146 void Extrema_GenExtPC::Perform(const Pnt& P)
147 /*-----------------------------------------------------------------------------
149 Recherche des valeurs de parametre u telle que dist(P,C(u)) passe
153 Si U est solution, alors (C(U)-P).C'(U) = 0.
154 Le probleme consiste a rechercher les racines de cette fonction
155 dans l'intervalle de definition de la courbe.
156 On utilise la classe math_FunctionRoots avec les arguments de
157 construction suivant:
158 - F: Extrema_FuncExtPC cree a partir de P et C,
159 - Uinf: borne inferieure de l'intervalle de definition,
160 - Usup: borne superieure de l'intervalle de definition,
165 -----------------------------------------------------------------------------*/
168 myF.SubIntervalInitialize(myumin,myusup);
169 myDone = Standard_False;
171 math_FunctionRoots S (myF, myumin, myusup, mynbsample, mytolu, mytolF, mytolF);
173 S.IsAllNull()) { return; }
175 myDone = Standard_True;
180 //=======================================================================
183 //=======================================================================
185 Standard_Boolean Extrema_GenExtPC::IsDone () const {
191 //=======================================================================
194 //=======================================================================
196 Standard_Integer Extrema_GenExtPC::NbExt () const {
198 if (!IsDone()) { throw StdFail_NotDone(); }
203 //=======================================================================
206 //=======================================================================
208 Standard_Real Extrema_GenExtPC::SquareDistance (const Standard_Integer N) const
210 if ((N < 1) || (N > NbExt()))
212 throw Standard_OutOfRange();
215 return myF.SquareDistance(N);
219 //=======================================================================
222 //=======================================================================
224 Standard_Boolean Extrema_GenExtPC::IsMin (const Standard_Integer N) const {
226 if ((N < 1) || (N > NbExt()))
228 throw Standard_OutOfRange();
235 //=======================================================================
238 //=======================================================================
240 const POnC & Extrema_GenExtPC::Point (const Standard_Integer N) const
242 if ((N < 1) || (N > NbExt()))
244 throw Standard_OutOfRange();
249 //=============================================================================