Integration of OCCT 6.5.0 from SVN
[occt.git] / src / Select3D / Select3D_SensitiveEntity.cxx
CommitLineData
7fd59977 1
2// Copyright: Matra-Datavision 1995
3// File: Select3D_SensitiveEntity.cxx
4// Created: Mon Mar 13 17:55:29 1995
5// Author: Robert COUBLANC
6// <rob>
7
8
9
10#include <Select3D_SensitiveEntity.ixx>
11#include <Precision.hxx>
12#include <SelectBasics_EntityOwner.hxx>
13#include <Select3D_Macro.hxx>
14
15//=======================================================================
16//function : Select3D_SensitiveEntity
17//purpose :
18//=======================================================================
19
20Select3D_SensitiveEntity::Select3D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& OwnerId):
21SelectBasics_SensitiveEntity(OwnerId),
22mylastprj(NULL),
23mylastdepth(0.0)
24{}
25
26//=======================================================================
27//function : Project
28//purpose :
29//=======================================================================
30
31void Select3D_SensitiveEntity::Project(const Select3D_Projector& aPrj)
32{
33 mylastprj = (Standard_Address*)&aPrj;
34}
35
36//=======================================================================
37//function : Matches
38//purpose :
39//=======================================================================
40
41Standard_Boolean Select3D_SensitiveEntity::Matches(const Standard_Real X,
42 const Standard_Real Y,
43 const Standard_Real aTol,
44 Standard_Real& DMin)
45{
46 gp_Lin L;
47 if(mylastprj!=NULL)
48 L = (* ((Select3D_Projector*) mylastprj)).Shoot(X,Y);
49 SetLastDepth( ComputeDepth(L) );
50
51 return (Abs(mylastdepth)>Precision::Confusion());
52}
53
54//=======================================================================
55//function : Matches
56//purpose :
57//=======================================================================
58
59Standard_Boolean Select3D_SensitiveEntity::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{
65 return Standard_False;
66}
67
68//=======================================================================
69//function : Matches
70//purpose :
71//=======================================================================
72
73Standard_Boolean Select3D_SensitiveEntity::Matches(const TColgp_Array1OfPnt2d& aPoly,
74 const Bnd_Box2d& aBox,
75 const Standard_Real aTol)
76{
77 return Standard_False;
78}
79
80//=======================================================================
81//function : Dump
82//purpose :
83//=======================================================================
84
85void Select3D_SensitiveEntity::Dump(Standard_OStream& S,const Standard_Boolean FullDump) const
86{
87 S<<"\tSensitive Entity 3D"<<endl;
88}
89
90//=======================================================================
91//function : DumpBox
92//purpose :
93//=======================================================================
94
95void Select3D_SensitiveEntity::DumpBox(Standard_OStream& S,const Bnd_Box2d& b2d)
96{
97 if(!b2d.IsVoid()){
98 Standard_Real xmin,ymin,xmax,ymax;
99 b2d.Get(xmin,ymin,xmax,ymax);
100 S<<"\t\t\tBox2d: PMIN ["<<xmin<<" , "<<ymin<<"]"<<endl;
101 S<<"\t\t\t PMAX ["<<xmax<<" , "<<ymax<<"]"<<endl;
102 }
103
104}
105
106//=======================================================================
107//function : ResetLocation
108//purpose :
109//=======================================================================
110
111void Select3D_SensitiveEntity::ResetLocation()
112{
113}
114
115//=======================================================================
116//function : SetLocation
117//purpose :
118//=======================================================================
119
120void Select3D_SensitiveEntity::SetLocation(const TopLoc_Location&)
121{
122}
123
124//=======================================================================
125//function : UpdateLocation
126//purpose :
127//=======================================================================
128
129void Select3D_SensitiveEntity::UpdateLocation(const TopLoc_Location& aLoc)
130{
131 if(aLoc.IsIdentity() || aLoc == Location()) return;
132 if(!HasLocation())
133 SetLocation(aLoc);
134 else {
135 TopLoc_Location compLoc = aLoc * Location();
136 SetLocation(compLoc);}
137}
138
139//=======================================================================
140//function : Location
141//purpose :
142//=======================================================================
143
144const TopLoc_Location& Select3D_SensitiveEntity::Location() const
145{
146 static TopLoc_Location anIdentity;
147 Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
148 return anOwner.IsNull() ? anIdentity : anOwner->Location();
149}
150
151//=======================================================================
152//function : HasLocation
153//purpose :
154//=======================================================================
155
156Standard_Boolean Select3D_SensitiveEntity::HasLocation() const
157{
158 Handle(SelectBasics_EntityOwner) anOwner = OwnerId();
159 return (!anOwner.IsNull() && anOwner->HasLocation());
160}
161
162//=======================================================================
163//function : Is3D
164//purpose :
165//=======================================================================
166
167Standard_Boolean Select3D_SensitiveEntity::Is3D() const
168{return Standard_True;}
169
170//=======================================================================
171//function : Depth
172//purpose :
173//=======================================================================
174
175Standard_Real Select3D_SensitiveEntity::Depth() const
176{return mylastdepth;}
177
178//=======================================================================
179//function : GetEyeLine
180//purpose :
181//=======================================================================
182
183gp_Lin Select3D_SensitiveEntity::GetEyeLine(const Standard_Real X,
184 const Standard_Real Y) const
185{
186 gp_Lin L;
187 if(mylastprj!=NULL)
188 L = (* ((Select3D_Projector*) mylastprj)).Shoot(X,Y);
189 return L;
190}
191
192//=======================================================================
193//function : MaxBoxes
194//purpose :
195//=======================================================================
196
197Standard_Integer Select3D_SensitiveEntity::MaxBoxes() const
198{return 1;}
199
200//=======================================================================
201//function : SetLastPrj
202//purpose :
203//=======================================================================
204
205void Select3D_SensitiveEntity::SetLastPrj(const Select3D_Projector& aprj)
206{ mylastprj = (Standard_Address*)& aprj;}
207
208
209//=======================================================================
210//function : GetConnected
211//purpose :
212//=======================================================================
213
214Handle(Select3D_SensitiveEntity) Select3D_SensitiveEntity::GetConnected(const TopLoc_Location&)
215{
216 Handle(Select3D_SensitiveEntity) NiouEnt;
217 return NiouEnt;
218}
219
220//=======================================================================
221//function : GetConnected
222//purpose :
223//=======================================================================
224void Select3D_SensitiveEntity::SetLastDepth(const Standard_Real aDepth)
225{
226 mylastdepth = DToF(aDepth);
227}