23 #include "ns3/buildings-module.h"
24 #include "ns3/mobility-module.h"
25 #include "ns3/core-module.h"
26 #include "ns3/network-module.h"
35 std::ofstream outFile;
36 outFile.open (filename.c_str (), std::ios_base::out | std::ios_base::trunc);
37 if (!outFile.is_open ())
46 Box box = (*it)->GetBoundaries ();
47 outFile <<
"set object " << index
48 <<
" rect from " << box.
xMin <<
"," << box.
yMin
49 <<
" to " << box.
xMax <<
"," << box.
yMax
61 main (
int argc,
char *argv[])
65 cmd.Parse (argc, argv);
68 double buildingSizeX = 100;
69 double buildingSizeY = 50;
70 double streetWidth = 25;
71 double buildingHeight = 10;
72 uint32_t numBuildingsX = 10;
73 uint32_t numBuildingsY = 10;
74 double maxAxisX = (buildingSizeX + streetWidth) * numBuildingsX;
75 double maxAxisY = (buildingSizeY + streetWidth) * numBuildingsY;
77 std::vector<Ptr<Building> > buildingVector;
78 for (uint32_t buildingIdX = 0; buildingIdX < numBuildingsX; ++buildingIdX)
80 for (uint32_t buildingIdY = 0; buildingIdY < numBuildingsY; ++buildingIdY)
83 building = CreateObject<Building> ();
85 building->SetBoundaries (
Box (buildingIdX * (buildingSizeX + streetWidth),
86 buildingIdX * (buildingSizeX + streetWidth) + buildingSizeX,
87 buildingIdY * (buildingSizeY + streetWidth),
88 buildingIdY * (buildingSizeY + streetWidth) + buildingSizeY,
89 0.0, buildingHeight));
90 building->SetNRoomsX (1);
91 building->SetNRoomsY (1);
92 building->SetNFloors (1);
93 buildingVector.push_back (building);
106 mobility.SetMobilityModel (
"ns3::RandomWalk2dOutdoorMobilityModel",
108 Rectangle (-streetWidth, maxAxisX, -streetWidth, maxAxisY)));
119 mobility.SetPositionAllocator (position);
Manage ASCII trace files for device models.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
double yMax
The y coordinate of the top bound of the box.
double xMin
The x coordinate of the left bound of the box.
double yMin
The y coordinate of the bottom bound of the box.
double xMax
The x coordinate of the right bound of the box.
std::vector< Ptr< Building > >::const_iterator Iterator
Const Iterator.
static Iterator End(void)
static Iterator Begin(void)
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Helper class used to assign positions and mobility models to nodes.
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
keep track of a set of node pointers.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
AttributeValue implementation for Rectangle.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static void Run(void)
Run the simulation.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ LOG_LEVEL_LOGIC
LOG_LOGIC and above.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
void PrintGnuplottableBuildingListToFile(std::string filename)