0022627: Change OCCT memory management defaults
[occt.git] / src / Select2D / Select2D_SensitiveCircle.cxx
1 // Copyright:   Matra-Datavision 1995
2 // File:        Select2D_SensitiveCircle.cxx
3 // Created:     Mon Jan 30 16:58:02 1995
4 // Author:      Mister rmi
5 //              <rmi>
6
7
8 #include <Select2D_SensitiveCircle.ixx>
9 #include <BndLib.hxx>
10 #include <Bnd_Box2d.hxx>
11
12 //=====================================================
13 // Function : Create
14 // Purpose  :Constructor
15 //=====================================================
16
17
18 Select2D_SensitiveCircle::
19 Select2D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
20                          const gp_Circ2d& aCirc,
21                          const Select2D_TypeOfSelection atype):
22 Select2D_SensitiveEntity(OwnerId),
23 myCirc(aCirc),
24 mytype(atype){}
25
26
27 //=====================================================
28 // Function : Areas
29 // Purpose  :
30 //=====================================================
31
32 void Select2D_SensitiveCircle::
33 Areas (SelectBasics_ListOfBox2d& boxes) 
34 {
35   Bnd_Box2d abox;
36   BndLib::Add(myCirc,myCirc.Radius()/100.,abox);
37   boxes.Append(abox);
38 }
39
40
41 //=====================================================
42 // Function : Matches
43 // Purpose  :
44 //=====================================================
45 Standard_Boolean Select2D_SensitiveCircle::
46 Matches (const Standard_Real X,
47          const Standard_Real Y,
48          const Standard_Real aTol,
49          Standard_Real& DMin)
50 {
51   Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol;
52
53   switch(mytype){
54   case Select2D_TOS_INTERIOR:
55     {
56       if(myCirc.Contains(gp_Pnt2d(X,Y),TheTol) )
57         {DMin=0.;
58          return Standard_True;}
59       else 
60         {DMin=myCirc.Distance(gp_Pnt2d(X,Y));}
61     }
62   case Select2D_TOS_BOUNDARY:
63     {
64       DMin = myCirc.Distance(gp_Pnt2d(X,Y));
65       if(DMin<= TheTol) return Standard_True;
66       
67     }
68   }  
69   return Standard_False;
70 }
71
72 Standard_Boolean Select2D_SensitiveCircle::
73 Matches (const Standard_Real XMin,
74          const Standard_Real YMin,
75          const Standard_Real XMax,
76          const Standard_Real YMax,
77          const Standard_Real aTol)
78 {
79   Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol;
80
81   Bnd_Box2d abox, BoundBox;
82   BoundBox.Update(XMin-TheTol,YMin-TheTol,XMax+TheTol,YMax+TheTol);
83   BndLib::Add(myCirc,myCirc.Radius()/100.,abox);
84
85   if(BoundBox.IsOut(abox)) return Standard_False;
86  return Standard_True;
87 }
88  
89
90