0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / Select2D / Select2D_SensitiveCircle.cxx
CommitLineData
b311480e 1// Created on: 1995-01-30
2// Created by: Mister rmi
3// Copyright (c) 1995-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <Select2D_SensitiveCircle.ixx>
24#include <BndLib.hxx>
25#include <Bnd_Box2d.hxx>
26
27//=====================================================
28// Function : Create
29// Purpose :Constructor
30//=====================================================
31
32
33Select2D_SensitiveCircle::
34Select2D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId,
35 const gp_Circ2d& aCirc,
36 const Select2D_TypeOfSelection atype):
37Select2D_SensitiveEntity(OwnerId),
38myCirc(aCirc),
39mytype(atype){}
40
41
42//=====================================================
43// Function : Areas
44// Purpose :
45//=====================================================
46
47void Select2D_SensitiveCircle::
48Areas (SelectBasics_ListOfBox2d& boxes)
49{
50 Bnd_Box2d abox;
51 BndLib::Add(myCirc,myCirc.Radius()/100.,abox);
52 boxes.Append(abox);
53}
54
55
56//=====================================================
57// Function : Matches
58// Purpose :
59//=====================================================
60Standard_Boolean Select2D_SensitiveCircle::
61Matches (const Standard_Real X,
62 const Standard_Real Y,
63 const Standard_Real aTol,
64 Standard_Real& DMin)
65{
66 Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol;
67
68 switch(mytype){
69 case Select2D_TOS_INTERIOR:
70 {
71 if(myCirc.Contains(gp_Pnt2d(X,Y),TheTol) )
72 {DMin=0.;
73 return Standard_True;}
74 else
75 {DMin=myCirc.Distance(gp_Pnt2d(X,Y));}
76 }
77 case Select2D_TOS_BOUNDARY:
78 {
79 DMin = myCirc.Distance(gp_Pnt2d(X,Y));
80 if(DMin<= TheTol) return Standard_True;
81
82 }
83 }
84 return Standard_False;
85}
86
87Standard_Boolean Select2D_SensitiveCircle::
88Matches (const Standard_Real XMin,
89 const Standard_Real YMin,
90 const Standard_Real XMax,
91 const Standard_Real YMax,
92 const Standard_Real aTol)
93{
94 Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol;
95
96 Bnd_Box2d abox, BoundBox;
97 BoundBox.Update(XMin-TheTol,YMin-TheTol,XMax+TheTol,YMax+TheTol);
98 BndLib::Add(myCirc,myCirc.Radius()/100.,abox);
99
100 if(BoundBox.IsOut(abox)) return Standard_False;
101 return Standard_True;
102}
103
104
105