22 #include "ns3/buildings-module.h"
23 #include "ns3/core-module.h"
24 #include "ns3/mobility-module.h"
25 #include "ns3/network-module.h"
39 std::ofstream outFile;
40 outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc);
41 if (!outFile.is_open())
50 Box box = (*it)->GetBoundaries();
51 outFile <<
"set object " << index <<
" rect from " << box.
xMin <<
"," << box.
yMin <<
" to "
52 << box.
xMax <<
"," << box.
yMax << std::endl;
62 main(
int argc,
char* argv[])
66 cmd.Parse(argc, argv);
69 double buildingSizeX = 100;
70 double buildingSizeY = 50;
71 double streetWidth = 25;
72 double buildingHeight = 10;
73 uint32_t numBuildingsX = 10;
74 uint32_t numBuildingsY = 10;
75 double maxAxisX = (buildingSizeX + streetWidth) * numBuildingsX;
76 double maxAxisY = (buildingSizeY + streetWidth) * numBuildingsY;
78 std::vector<Ptr<Building>> buildingVector;
79 for (uint32_t buildingIdX = 0; buildingIdX < numBuildingsX; ++buildingIdX)
81 for (uint32_t buildingIdY = 0; buildingIdY < numBuildingsY; ++buildingIdY)
84 building = CreateObject<Building>();
86 building->SetBoundaries(
Box(buildingIdX * (buildingSizeX + streetWidth),
87 buildingIdX * (buildingSizeX + streetWidth) + buildingSizeX,
88 buildingIdY * (buildingSizeY + streetWidth),
89 buildingIdY * (buildingSizeY + streetWidth) + buildingSizeY,
92 building->SetNRoomsX(1);
93 building->SetNRoomsY(1);
94 building->SetNFloors(1);
95 buildingVector.push_back(building);
109 "ns3::RandomWalk2dOutdoorMobilityModel",
111 RectangleValue(
Rectangle(-streetWidth, maxAxisX, -streetWidth, maxAxisY)));
123 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.
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 Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
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.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
#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.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
@ LOG_LEVEL_LOGIC
LOG_LOGIC and above.
void PrintGnuplottableBuildingListToFile(std::string filename)
Print the buildings list in a format that can be used by Gnuplot to draw them.