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()
28 myDone = Standard_False;
32 //=======================================================================
33 //function : Extrema_GenLocateExtPC
35 //=======================================================================
37 Extrema_GenLocateExtPC::Extrema_GenLocateExtPC (const Pnt& P,
39 const Standard_Real U0,
40 const Standard_Real TolU)
42 Initialize(C, Tool::FirstParameter(C), Tool::LastParameter(C), TolU);
47 //=======================================================================
48 //function : Extrema_GenLocateExtPC
50 //=======================================================================
52 Extrema_GenLocateExtPC::Extrema_GenLocateExtPC (const Pnt& P,
54 const Standard_Real U0,
55 const Standard_Real Umin,
56 const Standard_Real Usup,
57 const Standard_Real TolU)
59 Initialize(C, Umin, Usup, TolU);
64 //=======================================================================
65 //function : Initialize
67 //=======================================================================
69 void Extrema_GenLocateExtPC::Initialize(const Curve& C,
70 const Standard_Real Umin,
71 const Standard_Real Usup,
72 const Standard_Real TolU)
74 myDone = Standard_False;
82 //=======================================================================
85 //=======================================================================
87 void Extrema_GenLocateExtPC::Perform(const Pnt& P,
88 const Standard_Real U0)
90 /*-----------------------------------------------------------------------------
92 Recherche de la valeur de parametre U telle que:
93 - dist(P,C(u)) passe par un extremum,
94 - U soit la solution la plus proche de U0.
97 Si U est solution, alors F(U)=(C(U)-P).C'(U) = 0.
98 Le probleme consiste a rechercher, dans l'intervalle de definition
99 de la courbe, la racine de F la plus proche de U0.
100 On utilise la classe math_FunctionRoot avec les arguments de
101 construction suivants:
102 - F: Extrema_FuncExtPC cree a partir de P et C,
105 - Uinf: borne inferieure de l'intervalle de definition,
106 - Ulast: borne superieure de l'intervalle de definition,
108 -----------------------------------------------------------------------------*/
111 math_FunctionRoot S (myF, U0, mytolU, myumin, myusup);
114 Standard_Real uu, ff;
117 if(myF.Value(uu, ff)) {
118 if (Abs(ff) >= 1.e-07) myDone = Standard_False;
120 else myDone = Standard_False;
124 //=======================================================================
127 //=======================================================================
129 Standard_Boolean Extrema_GenLocateExtPC::IsDone () const
135 //=======================================================================
138 //=======================================================================
140 Standard_Real Extrema_GenLocateExtPC::SquareDistance() const
144 throw StdFail_NotDone();
146 return myF.SquareDistance(1);
150 //=======================================================================
153 //=======================================================================
155 Standard_Boolean Extrema_GenLocateExtPC::IsMin () const
159 throw StdFail_NotDone();
165 //=======================================================================
168 //=======================================================================
170 const POnC & Extrema_GenLocateExtPC::Point () const
174 throw StdFail_NotDone();