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 <Standard_DomainError.hxx>
19 #include <math_FunctionRoot.hxx>
21 //=======================================================================
22 //function : Extrema_GenLocateExtPC
24 //=======================================================================
26 Extrema_GenLocateExtPC::Extrema_GenLocateExtPC()
27 : myDone(Standard_False),
35 //=======================================================================
36 //function : Extrema_GenLocateExtPC
38 //=======================================================================
40 Extrema_GenLocateExtPC::Extrema_GenLocateExtPC (const Pnt& P,
42 const Standard_Real U0,
43 const Standard_Real TolU)
45 Initialize(C, Tool::FirstParameter(C), Tool::LastParameter(C), TolU);
50 //=======================================================================
51 //function : Extrema_GenLocateExtPC
53 //=======================================================================
55 Extrema_GenLocateExtPC::Extrema_GenLocateExtPC (const Pnt& P,
57 const Standard_Real U0,
58 const Standard_Real Umin,
59 const Standard_Real Usup,
60 const Standard_Real TolU)
62 Initialize(C, Umin, Usup, TolU);
67 //=======================================================================
68 //function : Initialize
70 //=======================================================================
72 void Extrema_GenLocateExtPC::Initialize(const Curve& C,
73 const Standard_Real Umin,
74 const Standard_Real Usup,
75 const Standard_Real TolU)
77 myDone = Standard_False;
85 //=======================================================================
88 //=======================================================================
90 void Extrema_GenLocateExtPC::Perform(const Pnt& P,
91 const Standard_Real U0)
93 /*-----------------------------------------------------------------------------
95 Recherche de la valeur de parametre U telle que:
96 - dist(P,C(u)) passe par un extremum,
97 - U soit la solution la plus proche de U0.
100 Si U est solution, alors F(U)=(C(U)-P).C'(U) = 0.
101 Le probleme consiste a rechercher, dans l'intervalle de definition
102 de la courbe, la racine de F la plus proche de U0.
103 On utilise la classe math_FunctionRoot avec les arguments de
104 construction suivants:
105 - F: Extrema_FuncExtPC cree a partir de P et C,
108 - Uinf: borne inferieure de l'intervalle de definition,
109 - Ulast: borne superieure de l'intervalle de definition,
111 -----------------------------------------------------------------------------*/
114 math_FunctionRoot S (myF, U0, mytolU, myumin, myusup);
117 Standard_Real uu, ff;
120 if(myF.Value(uu, ff)) {
121 if (Abs(ff) >= 1.e-07) myDone = Standard_False;
123 else myDone = Standard_False;
127 //=======================================================================
130 //=======================================================================
132 Standard_Boolean Extrema_GenLocateExtPC::IsDone () const
138 //=======================================================================
141 //=======================================================================
143 Standard_Real Extrema_GenLocateExtPC::SquareDistance() const
147 throw StdFail_NotDone();
149 return myF.SquareDistance(1);
153 //=======================================================================
156 //=======================================================================
158 Standard_Boolean Extrema_GenLocateExtPC::IsMin () const
162 throw StdFail_NotDone();
168 //=======================================================================
171 //=======================================================================
173 const POnC & Extrema_GenLocateExtPC::Point () const
177 throw StdFail_NotDone();