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
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.
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>
30 //=======================================================================
31 //function : Extrema_GenExtPC
33 //=======================================================================
35 Extrema_GenExtPC::Extrema_GenExtPC () {
36 myDone = Standard_False;
37 myInit = Standard_False;
42 //=======================================================================
43 //function : Extrema_GenExtPC
45 //=======================================================================
47 Extrema_GenExtPC::Extrema_GenExtPC (const Pnt& P,
49 const Standard_Integer NbSample,
50 const Standard_Real TolU,
51 const Standard_Real TolF) : myF (P,C)
53 Initialize(C, NbSample, TolU, TolF);
58 //=======================================================================
59 //function : Extrema_GenExtPC
61 //=======================================================================
63 Extrema_GenExtPC::Extrema_GenExtPC (const Pnt& P,
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)
71 Initialize(C, NbSample, Umin, Usup, TolU, TolF);
76 //=======================================================================
77 //function : Initialize
79 //=======================================================================
81 void Extrema_GenExtPC::Initialize(const Curve& C,
82 const Standard_Integer NbU,
83 const Standard_Real TolU,
84 const Standard_Real TolF)
86 myInit = Standard_True;
91 myumin = Tool::FirstParameter(C);
92 myusup = Tool::LastParameter(C);
95 //=======================================================================
96 //function : Initialize
98 //=======================================================================
100 void 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)
107 myInit = Standard_True;
117 //=======================================================================
118 //function : Initialize
120 //=======================================================================
122 void 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)
135 //=======================================================================
136 //function : Initialize
138 //=======================================================================
140 void Extrema_GenExtPC::Initialize(const Curve& C)
147 //=======================================================================
150 //=======================================================================
152 void Extrema_GenExtPC::Perform(const Pnt& P)
153 /*-----------------------------------------------------------------------------
155 Recherche des valeurs de parametre u telle que dist(P,C(u)) passe
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,
171 -----------------------------------------------------------------------------*/
174 myDone = Standard_False;
176 math_FunctionRoots S (myF, myumin, myusup, mynbsample, mytolu, mytolF, mytolF);
178 S.IsAllNull()) { return; }
180 myDone = Standard_True;
185 //=======================================================================
188 //=======================================================================
190 Standard_Boolean Extrema_GenExtPC::IsDone () const {
196 //=======================================================================
199 //=======================================================================
201 Standard_Integer Extrema_GenExtPC::NbExt () const {
203 if (!IsDone()) { StdFail_NotDone::Raise(); }
208 //=======================================================================
211 //=======================================================================
213 Standard_Real Extrema_GenExtPC::SquareDistance (const Standard_Integer N) const {
215 if (!IsDone()) { StdFail_NotDone::Raise(); }
216 return myF.SquareDistance(N);
220 //=======================================================================
223 //=======================================================================
225 Standard_Boolean Extrema_GenExtPC::IsMin (const Standard_Integer N) const {
227 if (!IsDone()) { StdFail_NotDone::Raise(); }
232 //=======================================================================
235 //=======================================================================
237 POnC Extrema_GenExtPC::Point (const Standard_Integer N) const
239 if (!IsDone()) { StdFail_NotDone::Raise(); }
242 //=============================================================================