1 #include <Standard_OutOfRange.hxx>
4 void Extrema_CurveLocator::Locate (const Pnt& P, const Curve1& C,
5 const Standard_Integer NbU,
8 /*-----------------------------------------------------------------------------
10 Recherche, parmi un echantillon de 'NbU' points de la courbe C, du
11 point le plus proche du point P.
12 L'echantillonnage est fait a parametre constant sur l'intervalle de
13 definition de la courbe.
14 -----------------------------------------------------------------------------*/
16 if (NbU < 2) { Standard_OutOfRange::Raise(); }
18 Standard_Real U = Tool1::FirstParameter(C);
19 Standard_Real PasU = (Tool1::LastParameter(C) - U)/ (NbU - 1);
20 Standard_Real Dist2Min = RealLast(), UMin=0;
24 for ( Standard_Integer NoSample = 1; NoSample < NbU; NoSample++, U += PasU) {
25 Pt = Tool1::Value(C, U);
26 Dist2 = Pt.SquareDistance(P);
27 if (Dist2 < Dist2Min) {
33 Papp.SetValues(UMin,PntMin);
38 void Extrema_CurveLocator::Locate (const Pnt& P, const Curve1& C,
39 const Standard_Integer NbU,
40 const Standard_Real Umin,
41 const Standard_Real Usup,
44 /*-----------------------------------------------------------------------------
46 Recherche, parmi un echantillon de 'NbU' points de la courbe C, du
47 point le plus proche du point P.
48 L'echantillonnage est fait a parametre constant sur l'intervalle de
49 definition de la courbe.
50 -----------------------------------------------------------------------------*/
52 if (NbU < 2) { Standard_OutOfRange::Raise(); }
53 Standard_Real U1, U2, U11, U12;
54 Standard_Real Uinf = Tool1::FirstParameter(C);
55 Standard_Real Ulast = Tool1::LastParameter(C);
58 U1 = Min(Uinf, Ulast);
59 U2 = Max(Uinf, Ulast);
60 U11 = Min(Umin, Usup);
61 U12 = Max(Umin, Usup);
63 if (U11 < U1 - RealEpsilon()) U11 = U1;
64 if (U12 > U2 + RealEpsilon()) U12 = U2;
66 Standard_Real U = U11;
67 Standard_Real PasU = (U12 - U)/ (NbU - 1);
68 Standard_Real Dist2Min = RealLast(), UMin=0;
72 for ( Standard_Integer NoSample = 1; NoSample < NbU; NoSample++, U += PasU) {
73 Pt = Tool1::Value(C, U);
74 Dist2 = Pt.SquareDistance(P);
75 if (Dist2 < Dist2Min) {
81 Papp.SetValues(UMin, PntMin);