View | Details | Raw Unified | Return to bug 3018
Collapse All | Expand All

(-)a/src/buildings/helper/buildings-helper.cc (-22 / +1 lines)
 Lines 79-106   void Link Here 
79
BuildingsHelper::MakeConsistent (Ptr<MobilityModel> mm)
79
BuildingsHelper::MakeConsistent (Ptr<MobilityModel> mm)
80
{
80
{
81
  Ptr<MobilityBuildingInfo> bmm = mm->GetObject<MobilityBuildingInfo> ();
81
  Ptr<MobilityBuildingInfo> bmm = mm->GetObject<MobilityBuildingInfo> ();
82
  bool found = false;
82
  bmm->MakeConsistent ();
83
  for (BuildingList::Iterator bit = BuildingList::Begin (); bit != BuildingList::End (); ++bit)
84
    {
85
      NS_LOG_LOGIC ("checking building " << (*bit)->GetId () << " with boundaries " << (*bit)->GetBoundaries ());
86
      Vector pos = mm->GetPosition ();
87
      if ((*bit)->IsInside (pos))
88
        {
89
          NS_LOG_LOGIC ("MobilityBuildingInfo " << bmm << " pos " << mm->GetPosition () << " falls inside building " << (*bit)->GetId ());
90
          NS_ABORT_MSG_UNLESS (found == false, " MobilityBuildingInfo already inside another building!");		
91
          found = true;
92
          uint16_t floor = (*bit)->GetFloor (pos);
93
          uint16_t roomX = (*bit)->GetRoomX (pos);
94
          uint16_t roomY = (*bit)->GetRoomY (pos);	   
95
          bmm->SetIndoor (*bit, floor, roomX, roomY);	      
96
        }		    	  
97
    }
98
  if (!found)
99
    {
100
      NS_LOG_LOGIC ("MobilityBuildingInfo " << bmm << " pos " << mm->GetPosition ()  << " is outdoor");
101
      bmm->SetOutdoor ();
102
    }
103
104
}
83
}
105
84
106
} // namespace ns3
85
} // namespace ns3
(-)a/src/buildings/model/mobility-building-info.cc (-3 / +32 lines)
 Lines 21-30    Link Here 
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
{
 Lines 68-73   bool Link Here 
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
 Lines 75-80   bool Link Here 
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
(-)a/src/buildings/model/mobility-building-info.h (-3 / +4 lines)
 Lines 31-41    Link Here 
31
#include <ns3/building.h>
31
#include <ns3/building.h>
32
#include <ns3/constant-velocity-helper.h>
32
#include <ns3/constant-velocity-helper.h>
33
33
34
35
36
namespace ns3 {
34
namespace ns3 {
37
35
38
39
/**
36
/**
40
 * \ingroup buildings
37
 * \ingroup buildings
41
 * \brief mobility buildings information (to be used by mobility models)
38
 * \brief mobility buildings information (to be used by mobility models)
 Lines 107-112   public: Link Here 
107
   */
104
   */
108
  Ptr<Building> GetBuilding ();
105
  Ptr<Building> GetBuilding ();
109
106
107
  /**
108
   * Make this object consistent with respect to the buildings
109
   */
110
  void MakeConsistent ();
110
111
111
112
112
private:
113
private:

Return to bug 3018