Integration of OCCT 6.5.0 from SVN
[occt.git] / src / Select2D / Select2D_SensitivePoint.cxx
1 // Copyright:   Matra- ()Datavision 1995
2 // File:        Select2D_SensitivePoint.cxx
3 // Created:     Thu Jan 26 16:37:33 1995
4 // Author:      Mister rmi
5 //              <rmi>
6
7 #include <Select2D_SensitivePoint.ixx>
8 #include <Bnd_Box2d.hxx>
9 #include <gp_Vec2d.hxx>
10 #include <gp_Lin2d.hxx>
11
12 //==================================
13 //function : Constructor
14 //purpose  : 
15 //==================================
16
17 Select2D_SensitivePoint::
18 Select2D_SensitivePoint(const Handle(SelectBasics_EntityOwner)& OwnerId,
19                         const gp_Pnt2d& Location,
20                         const Standard_Real InitSensitivity):
21 Select2D_SensitiveEntity(OwnerId),
22 mylocation(Location),
23 mysensitivity(InitSensitivity)
24 {}
25
26
27 //==================================
28 //function : Areas
29 //purpose  : 
30 //==================================
31
32 void Select2D_SensitivePoint::
33 Areas (SelectBasics_ListOfBox2d& boxes)
34 { Bnd_Box2d abox;
35  abox.Set(mylocation);
36  abox.Enlarge(mysensitivity);
37  boxes.Append(abox);
38 }
39  
40 //==================================
41 //function : Matches
42 //purpose  : 
43 //==================================
44
45
46 Standard_Boolean Select2D_SensitivePoint::
47 Matches (const Standard_Real X,
48          const Standard_Real Y,
49          const Standard_Real aTol,
50          Standard_Real& MinDist)
51 {
52   Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol;
53   MinDist = mylocation.Distance(gp_Pnt2d(X,Y));
54   if(MinDist<=TheTol+mysensitivity) return Standard_True;
55   return Standard_False;
56 }
57
58 Standard_Boolean Select2D_SensitivePoint::
59 Matches (const Standard_Real XMin,
60          const Standard_Real YMin,
61          const Standard_Real XMax,
62          const Standard_Real YMax,
63          const Standard_Real aTol)
64 {//distance point-Line....
65 #ifdef DEB
66   Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol;
67 #endif
68   Standard_Real MinDist = gp_Lin2d(gp_Pnt2d(XMin,YMin),
69                      gp_Vec2d(gp_Pnt2d(XMin,YMin),
70                               gp_Pnt2d(XMax,YMax))
71                      ).Distance(mylocation);
72   
73   return (MinDist<=aTol+mysensitivity);
74 }
75
76
77
78