1 // File: Extrema_GenLocateExtPC.gxx
2 // Created: Tue Jul 18 17:40:47 1995
3 // Author: Modelistation
7 #include <StdFail_NotDone.hxx>
8 #include <Standard_DomainError.hxx>
9 #include <math_FunctionRoot.hxx>
11 //=======================================================================
12 //function : Extrema_GenLocateExtPC
14 //=======================================================================
16 Extrema_GenLocateExtPC::Extrema_GenLocateExtPC()
18 myDone = Standard_False;
22 //=======================================================================
23 //function : Extrema_GenLocateExtPC
25 //=======================================================================
27 Extrema_GenLocateExtPC::Extrema_GenLocateExtPC (const Pnt& P,
29 const Standard_Real U0,
30 const Standard_Real TolU)
32 Initialize(C, Tool::FirstParameter(C), Tool::LastParameter(C), TolU);
37 //=======================================================================
38 //function : Extrema_GenLocateExtPC
40 //=======================================================================
42 Extrema_GenLocateExtPC::Extrema_GenLocateExtPC (const Pnt& P,
44 const Standard_Real U0,
45 const Standard_Real Umin,
46 const Standard_Real Usup,
47 const Standard_Real TolU)
49 Initialize(C, Umin, Usup, TolU);
54 //=======================================================================
55 //function : Initialize
57 //=======================================================================
59 void Extrema_GenLocateExtPC::Initialize(const Curve& C,
60 const Standard_Real Umin,
61 const Standard_Real Usup,
62 const Standard_Real TolU)
64 myDone = Standard_False;
72 //=======================================================================
75 //=======================================================================
77 void Extrema_GenLocateExtPC::Perform(const Pnt& P,
78 const Standard_Real U0)
80 /*-----------------------------------------------------------------------------
82 Recherche de la valeur de parametre U telle que:
83 - dist(P,C(u)) passe par un extremum,
84 - U soit la solution la plus proche de U0.
87 Si U est solution, alors F(U)=(C(U)-P).C'(U) = 0.
88 Le probleme consiste a rechercher, dans l'intervalle de definition
89 de la courbe, la racine de F la plus proche de U0.
90 On utilise la classe math_FunctionRoot avec les arguments de
91 construction suivants:
92 - F: Extrema_FuncExtPC cree a partir de P et C,
95 - Uinf: borne inferieure de l'intervalle de definition,
96 - Ulast: borne superieure de l'intervalle de definition,
98 -----------------------------------------------------------------------------*/
101 math_FunctionRoot S (myF, U0, mytolU, myumin, myusup);
104 Standard_Real uu, ff;
107 if(myF.Value(uu, ff)) {
108 if (Abs(ff) >= 1.e-07) myDone = Standard_False;
110 else myDone = Standard_False;
114 //=======================================================================
117 //=======================================================================
119 Standard_Boolean Extrema_GenLocateExtPC::IsDone () const
125 //=======================================================================
128 //=======================================================================
130 Standard_Real Extrema_GenLocateExtPC::SquareDistance() const
132 if (!myDone) { StdFail_NotDone::Raise(); }
133 return myF.SquareDistance(1);
137 //=======================================================================
140 //=======================================================================
142 Standard_Boolean Extrema_GenLocateExtPC::IsMin () const
144 if (!myDone) { StdFail_NotDone::Raise(); }
149 //=======================================================================
152 //=======================================================================
154 POnC Extrema_GenLocateExtPC::Point () const
156 if (!myDone) { StdFail_NotDone::Raise(); }