|
|
| 21 |
|
21 |
|
| 22 |
#include <ns3/simulator.h> |
22 |
#include <ns3/simulator.h> |
| 23 |
#include <ns3/position-allocator.h> |
23 |
#include <ns3/position-allocator.h> |
|
|
24 |
#include <ns3/building-list.h> |
| 24 |
#include <ns3/mobility-building-info.h> |
25 |
#include <ns3/mobility-building-info.h> |
| 25 |
#include <ns3/pointer.h> |
26 |
#include <ns3/pointer.h> |
| 26 |
#include <ns3/log.h> |
27 |
#include <ns3/log.h> |
| 27 |
#include <ns3/assert.h> |
28 |
#include <ns3/assert.h> |
|
|
29 |
#include <ns3/mobility-model.h> |
| 28 |
|
30 |
|
| 29 |
namespace ns3 { |
31 |
namespace ns3 { |
| 30 |
|
32 |
|
|
Lines 53-59
MobilityBuildingInfo::MobilityBuildingInfo ()
|
Link Here
|
|---|
|
| 53 |
m_roomY = 1; |
55 |
m_roomY = 1; |
| 54 |
} |
56 |
} |
| 55 |
|
57 |
|
| 56 |
|
|
|
| 57 |
MobilityBuildingInfo::MobilityBuildingInfo (Ptr<Building> building) |
58 |
MobilityBuildingInfo::MobilityBuildingInfo (Ptr<Building> building) |
| 58 |
: m_myBuilding (building) |
59 |
: m_myBuilding (building) |
| 59 |
{ |
60 |
{ |
|
|
| 68 |
MobilityBuildingInfo::IsIndoor (void) |
69 |
MobilityBuildingInfo::IsIndoor (void) |
| 69 |
{ |
70 |
{ |
| 70 |
NS_LOG_FUNCTION (this); |
71 |
NS_LOG_FUNCTION (this); |
|
|
72 |
MakeConsistent (); |
| 71 |
return (m_indoor); |
73 |
return (m_indoor); |
| 72 |
} |
74 |
} |
| 73 |
|
75 |
|
|
|
| 75 |
MobilityBuildingInfo::IsOutdoor (void) |
77 |
MobilityBuildingInfo::IsOutdoor (void) |
| 76 |
{ |
78 |
{ |
| 77 |
NS_LOG_FUNCTION (this); |
79 |
NS_LOG_FUNCTION (this); |
|
|
80 |
MakeConsistent (); |
| 78 |
return (!m_indoor); |
81 |
return (!m_indoor); |
| 79 |
} |
82 |
} |
| 80 |
|
83 |
|
|
Lines 87-93
MobilityBuildingInfo::SetIndoor (Ptr<Building> building, uint8_t nfloor, uint8_t
|
Link Here
|
|---|
|
| 87 |
m_nFloor = nfloor; |
90 |
m_nFloor = nfloor; |
| 88 |
m_roomX = nroomx; |
91 |
m_roomX = nroomx; |
| 89 |
m_roomY = nroomy; |
92 |
m_roomY = nroomy; |
| 90 |
|
|
|
| 91 |
|
93 |
|
| 92 |
NS_ASSERT (m_roomX > 0); |
94 |
NS_ASSERT (m_roomX > 0); |
| 93 |
NS_ASSERT (m_roomX <= building->GetNRoomsX ()); |
95 |
NS_ASSERT (m_roomX <= building->GetNRoomsX ()); |
|
Lines 155-159
MobilityBuildingInfo::GetBuilding ()
|
Link Here
|
|---|
|
| 155 |
return (m_myBuilding); |
157 |
return (m_myBuilding); |
| 156 |
} |
158 |
} |
| 157 |
|
159 |
|
| 158 |
|
160 |
void |
|
|
161 |
MobilityBuildingInfo::MakeConsistent () |
| 162 |
{ |
| 163 |
Ptr<MobilityModel> mm = this->GetObject<MobilityModel>(); |
| 164 |
bool found = false; |
| 165 |
for (BuildingList::Iterator bit = BuildingList::Begin (); bit != BuildingList::End (); ++bit) |
| 166 |
{ |
| 167 |
NS_LOG_LOGIC ("checking building " << (*bit)->GetId () << " with boundaries " << (*bit)->GetBoundaries ()); |
| 168 |
Vector pos = mm->GetPosition (); |
| 169 |
if ((*bit)->IsInside (pos)) |
| 170 |
{ |
| 171 |
NS_LOG_LOGIC ("MobilityBuildingInfo " << this << " pos " << mm->GetPosition () << " falls inside building " << (*bit)->GetId ()); |
| 172 |
NS_ABORT_MSG_UNLESS (found == false, " MobilityBuildingInfo already inside another building!"); |
| 173 |
found = true; |
| 174 |
uint16_t floor = (*bit)->GetFloor (pos); |
| 175 |
uint16_t roomX = (*bit)->GetRoomX (pos); |
| 176 |
uint16_t roomY = (*bit)->GetRoomY (pos); |
| 177 |
SetIndoor (*bit, floor, roomX, roomY); |
| 178 |
} |
| 179 |
} |
| 180 |
if (!found) |
| 181 |
{ |
| 182 |
NS_LOG_LOGIC ("MobilityBuildingInfo " << this << " pos " << mm->GetPosition () << " is outdoor"); |
| 183 |
SetOutdoor (); |
| 184 |
} |
| 185 |
|
| 186 |
} |
| 187 |
|
| 159 |
} // namespace |
188 |
} // namespace |