21 #include <ns3/mobility-building-info.h>
22 #include "ns3/mobility-model.h"
23 #include "ns3/buildings-helper.h"
24 #include "ns3/random-variable-stream.h"
25 #include "ns3/double.h"
26 #include "ns3/uinteger.h"
28 #include "ns3/boolean.h"
31 #include "ns3/building.h"
34 #include "ns3/building-list.h"
45 m_rand = CreateObject<UniformRandomVariable> ();
51 static TypeId tid =
TypeId (
"ns3::RandomBuildingPositionAllocator")
53 .SetGroupName (
"Mobility")
55 .AddAttribute (
"WithReplacement",
56 "If true, the building will be randomly selected with replacement. "
57 "If false, no replacement will occur, until the list of buildings "
58 "to select becomes empty, at which point it will be filled again "
59 "with the list of all buildings.",
62 MakeBooleanChecker ());
92 b->GetAttribute (
"Boundaries", bv);
112 m_rand = CreateObject<UniformRandomVariable> ();
118 static TypeId tid =
TypeId (
"ns3::RandomRoomPositionAllocator")
120 .SetGroupName (
"Mobility")
136 for (uint32_t rx = 1; rx <= (*bit)->GetNRoomsX (); ++rx)
138 for (uint32_t ry = 1; ry <= (*bit)->GetNRoomsY (); ++ry)
140 for (uint32_t f = 1; f <= (*bit)->GetNFloors (); ++f)
147 NS_LOG_LOGIC (
"adding room (" << rx <<
", " << ry <<
", " << f <<
")");
161 r.
b->GetAttribute (
"Boundaries", bv);
163 double rdx = (box.
xMax - box.
xMin) / r.
b->GetNRoomsX ();
164 double rdy = (box.
yMax - box.
yMin) / r.
b->GetNRoomsY ();
165 double rdz = (box.
zMax - box.
zMin) / r.
b->GetNFloors ();
166 double x1 = box.
xMin + rdx * (r.
roomx - 1);
168 double y1 = box.
yMin + rdy * (r.
roomy -1);
170 double z1 = box.
zMin + rdz * (r.
floor - 1);
173 <<
" (" << x1 <<
"," << x2 <<
") "
174 <<
"x (" << y1 <<
"," << y2 <<
") "
175 <<
"x (" << z1 <<
"," << z2 <<
") ");
199 NS_FATAL_ERROR (
" Constructor \"SameRoomPositionAllocator ()\" should not be used");
206 m_rand = CreateObject<UniformRandomVariable> ();
212 NS_ASSERT_MSG (mm,
"no mobility model aggregated to this node");
214 NS_ASSERT_MSG (bmm,
"MobilityBuildingInfo has not been aggregated to this node mobility model");
222 static TypeId tid =
TypeId (
"ns3::SameRoomPositionAllocator")
224 .SetGroupName (
"Mobility")
240 NS_LOG_LOGIC (
"considering node " << (*m_nodeIt)->GetId ());
242 NS_ASSERT_MSG (mm,
"no mobility model aggregated to this node");
244 NS_ASSERT_MSG (bmm,
"MobilityBuildingInfo has not been aggregated to this node mobility model");
247 uint32_t roomx = bmm->GetRoomNumberX ();
248 uint32_t roomy = bmm->GetRoomNumberY ();
249 uint32_t floor = bmm->GetFloorNumber ();
250 NS_LOG_LOGIC (
"considering building " << bmm->GetBuilding ()->GetId () <<
" room (" << roomx <<
", " << roomy <<
", " << floor <<
")");
255 b->GetAttribute (
"Boundaries", bv);
257 double rdx = (box.
xMax - box.
xMin) / b->GetNRoomsX ();
258 double rdy = (box.
yMax - box.
yMin) / b->GetNRoomsY ();
259 double rdz = (box.
zMax - box.
zMin) / b->GetNFloors ();
260 double x1 = box.
xMin + rdx * (roomx - 1);
261 double x2 = box.
xMin + rdx * roomx;
262 double y1 = box.
yMin + rdy * (roomy -1);
263 double y2 = box.
yMin + rdy * roomy;
264 double z1 = box.
zMin + rdz * (floor - 1);
265 double z2 = box.
zMin + rdz * floor;
267 <<
" (" << x1 <<
"," << x2 <<
") "
268 <<
"x (" << y1 <<
"," << y2 <<
") "
269 <<
"x (" << z1 <<
"," << z2 <<
") ");
294 m_rand = CreateObject<UniformRandomVariable> ();
304 static TypeId tid =
TypeId (
"ns3::FixedRoomPositionAllocator")
306 .SetGroupName (
"Mobility")
319 Box box =
bptr->GetBoundaries ();
320 double rdx = (box.xMax - box.xMin) /
bptr->GetNRoomsX ();
321 double rdy = (box.yMax - box.yMin) /
bptr->GetNRoomsY ();
322 double rdz = (box.zMax - box.zMin) /
bptr->GetNFloors ();
323 double x1 = box.xMin + rdx * (
roomx - 1);
324 double x2 = box.xMin + rdx *
roomx;
325 double y1 = box.yMin + rdy * (
roomy -1);
326 double y2 = box.yMin + rdy *
roomy;
327 double z1 = box.zMin + rdz * (
floor - 1);
328 double z2 = box.zMin + rdz *
floor;
330 <<
" (" << x1 <<
"," << x2 <<
") "
331 <<
"x (" << y1 <<
"," << y2 <<
") "
332 <<
"x (" << z1 <<
"," << z2 <<
") ");
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
FixedRoomPositionAllocator(uint32_t x, uint32_t y, uint32_t z, Ptr< Building > b)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
std::vector< Ptr< Node > >::const_iterator Iterator
static uint32_t GetNBuildings(void)
static Ptr< Building > GetBuilding(uint32_t n)
static TypeId GetTypeId(void)
#define NS_LOG_COMPONENT_DEFINE(name)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
static Iterator End(void)
static Iterator Begin(void)
virtual Vector GetNext(void) const
#define NS_FATAL_ERROR(msg)
fatal error handling
static void MakeConsistent(Ptr< MobilityModel > bmm)
Keep track of the current position and velocity of an object.
RandomBuildingPositionAllocator()
static TypeId GetTypeId(void)
int64_t AssignStreams(int64_t)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
int64_t AssignStreams(int64_t stream)
virtual Vector GetNext(void) const
std::vector< Ptr< Building > >::const_iterator Iterator
hold objects of type ns3::Box
#define NS_LOG_LOGIC(msg)
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
keep track of a set of node pointers.
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
SameRoomPositionAllocator()
#define NS_ASSERT_MSG(condition, message)
int64_t AssignStreams(int64_t stream)
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
std::vector< Ptr< Building > > m_buildingListWithoutReplacement
mobility buildings information (to be used by mobility models)
static TypeId GetTypeId(void)
static TypeId GetTypeId(void)
virtual Vector GetNext(void) const
Ptr< T > GetObject(void) const
NodeContainer::Iterator m_nodeIt
virtual Vector GetNext(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
RandomRoomPositionAllocator()
int64_t AssignStreams(int64_t)
Allocate a set of positions. The allocation strategy is implemented in subclasses.
std::vector< RoomInfo > m_roomListWithoutReplacement