1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#include <Standard_OutOfRange.hxx>
void Extrema_CurveLocator::Locate (const Pnt& P, const Curve1& C,
const Standard_Integer NbU,
POnC& Papp) {
/*-----------------------------------------------------------------------------
Fonction:
Recherche, parmi un echantillon de 'NbU' points de la courbe C, du
point le plus proche du point P.
L'echantillonnage est fait a parametre constant sur l'intervalle de
definition de la courbe.
-----------------------------------------------------------------------------*/
if (NbU < 2) { Standard_OutOfRange::Raise(); }
Standard_Real U = Tool1::FirstParameter(C);
Standard_Real PasU = (Tool1::LastParameter(C) - U)/ (NbU - 1);
Standard_Real Dist2Min = RealLast(), UMin=0;
Pnt PntMin;
Standard_Real Dist2;
Pnt Pt;
for ( Standard_Integer NoSample = 1; NoSample < NbU; NoSample++, U += PasU) {
Pt = Tool1::Value(C, U);
Dist2 = Pt.SquareDistance(P);
if (Dist2 < Dist2Min) {
Dist2Min = Dist2;
UMin = U;
PntMin = Pt;
}
}
Papp.SetValues(UMin,PntMin);
}
void Extrema_CurveLocator::Locate (const Pnt& P, const Curve1& C,
const Standard_Integer NbU,
const Standard_Real Umin,
const Standard_Real Usup,
POnC& Papp) {
/*-----------------------------------------------------------------------------
Fonction:
Recherche, parmi un echantillon de 'NbU' points de la courbe C, du
point le plus proche du point P.
L'echantillonnage est fait a parametre constant sur l'intervalle de
definition de la courbe.
-----------------------------------------------------------------------------*/
if (NbU < 2) { Standard_OutOfRange::Raise(); }
Standard_Real U1, U2, U11, U12;
Standard_Real Uinf = Tool1::FirstParameter(C);
Standard_Real Ulast = Tool1::LastParameter(C);
U1 = Min(Uinf, Ulast);
U2 = Max(Uinf, Ulast);
U11 = Min(Umin, Usup);
U12 = Max(Umin, Usup);
if (U11 < U1 - RealEpsilon()) U11 = U1;
if (U12 > U2 + RealEpsilon()) U12 = U2;
Standard_Real U = U11;
Standard_Real PasU = (U12 - U)/ (NbU - 1);
Standard_Real Dist2Min = RealLast(), UMin=0;
Pnt PntMin;
Standard_Real Dist2;
Pnt Pt;
for ( Standard_Integer NoSample = 1; NoSample < NbU; NoSample++, U += PasU) {
Pt = Tool1::Value(C, U);
Dist2 = Pt.SquareDistance(P);
if (Dist2 < Dist2Min) {
Dist2Min = Dist2;
UMin = U;
PntMin = Pt;
}
}
Papp.SetValues(UMin, PntMin);
}
|