# HG changeset patch # Parent bb7fc90f72ad94e47d01dbca0ad1f0732d7c19eb diff --git a/examples/tutorial/third.cc b/examples/tutorial/third.cc --- a/examples/tutorial/third.cc +++ b/examples/tutorial/third.cc @@ -128,7 +128,7 @@ "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", - "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); + "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -50, 50))); mobility.Install (wifiStaNodes); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); diff --git a/examples/tutorial/third.py b/examples/tutorial/third.py --- a/examples/tutorial/third.py +++ b/examples/tutorial/third.py @@ -103,7 +103,7 @@ "MinY", ns.core.DoubleValue (0.0), "DeltaX", ns.core.DoubleValue(5.0), "DeltaY", ns.core.DoubleValue(10.0), "GridWidth", ns.core.UintegerValue(3), "LayoutType", ns.core.StringValue("RowFirst")) -mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", "Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle (-50, 50, -50, 50))) +mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", "Bounds", ns.mobility.Rectangle2dValue(ns.mobility.Rectangle2d (-50, 50, -50, 50))) mobility.Install(wifiStaNodes) mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel") diff --git a/examples/wireless/mixed-wired-wireless.cc b/examples/wireless/mixed-wired-wireless.cc --- a/examples/wireless/mixed-wired-wireless.cc +++ b/examples/wireless/mixed-wired-wireless.cc @@ -72,6 +72,7 @@ #include "ns3/olsr-helper.h" #include "ns3/csma-helper.h" #include "ns3/animation-interface.h" +#include "ns3/rectangle-2d.h" using namespace ns3; @@ -192,7 +193,7 @@ "GridWidth", UintegerValue (5), "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel", - "Bounds", RectangleValue (Rectangle (-500, 500, -500, 500)), + "Bounds", Rectangle2dValue (Rectangle2d (-500, 500, -500, 500)), "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=2]"), "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.2]")); mobility.Install (backbone); @@ -333,7 +334,7 @@ mobility.PushReferenceMobilityModel (backbone.Get (i)); mobility.SetPositionAllocator (subnetAlloc); mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel", - "Bounds", RectangleValue (Rectangle (-10, 10, -10, 10)), + "Bounds", Rectangle2dValue (Rectangle2d (-10, 10, -10, 10)), "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=3]"), "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.4]")); mobility.Install (stas); diff --git a/examples/wireless/mixed-wired-wireless.py b/examples/wireless/mixed-wired-wireless.py --- a/examples/wireless/mixed-wired-wireless.py +++ b/examples/wireless/mixed-wired-wireless.py @@ -170,7 +170,7 @@ "GridWidth", ns.core.UintegerValue(5), "LayoutType", ns.core.StringValue("RowFirst")) mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel", - "Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle(-500, 500, -500, 500)), + "Bounds", ns.mobility.Rectangle2dValue(ns.mobility.Rectangle2d(-500, 500, -500, 500)), "Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=2]"), "Pause", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0.2]")) mobility.Install(backbone) @@ -298,7 +298,7 @@ mobility.PushReferenceMobilityModel(backbone.Get(i)) mobility.SetPositionAllocator(subnetAlloc) mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel", - "Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle(-10, 10, -10, 10)), + "Bounds", ns.mobility.Rectangle2dValue(ns.mobility.Rectangle2d(-10, 10, -10, 10)), "Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=3]"), "Pause", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0.4]")) mobility.Install(stas) diff --git a/examples/wireless/multirate.cc b/examples/wireless/multirate.cc --- a/examples/wireless/multirate.cc +++ b/examples/wireless/multirate.cc @@ -66,7 +66,7 @@ #include "ns3/olsr-helper.h" #include "ns3/ipv4-static-routing-helper.h" #include "ns3/ipv4-list-routing-helper.h" -#include "ns3/rectangle.h" +#include "ns3/rectangle-2d.h" #include "ns3/flow-monitor-helper.h" using namespace ns3; @@ -451,9 +451,8 @@ if (enableMobility && enableRouting) { - //Rectangle (xMin, xMax, yMin, yMax) mobil.SetMobilityModel ("ns3::RandomDirection2dMobilityModel", - "Bounds", RectangleValue (Rectangle (0, 500, 0, 500)), + "Bounds", Rectangle2dValue (Rectangle2d (0, 500, 0, 500)), "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=10]"), "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.2]")); } diff --git a/examples/wireless/wifi-blockack.cc b/examples/wireless/wifi-blockack.cc --- a/examples/wireless/wifi-blockack.cc +++ b/examples/wireless/wifi-blockack.cc @@ -52,7 +52,7 @@ #include "ns3/on-off-helper.h" #include "ns3/yans-wifi-channel.h" #include "ns3/mobility-model.h" -#include "ns3/rectangle.h" +#include "ns3/rectangle-2d.h" #include "ns3/internet-stack-helper.h" #include "ns3/ipv4-address-helper.h" #include "ns3/ipv4-global-routing-helper.h" @@ -110,7 +110,7 @@ "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", - "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); + "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -50, 50))); mobility.Install (sta); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); diff --git a/examples/wireless/wifi-wired-bridging.cc b/examples/wireless/wifi-wired-bridging.cc --- a/examples/wireless/wifi-wired-bridging.cc +++ b/examples/wireless/wifi-wired-bridging.cc @@ -55,6 +55,7 @@ #include "ns3/animation-interface.h" #include "ns3/bridge-helper.h" #include "ns3/packet-socket-address.h" +#include "ns3/rectangle-2d.h" using namespace ns3; @@ -143,7 +144,7 @@ "Mode", StringValue ("Time"), "Time", StringValue ("2s"), "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"), - "Bounds", RectangleValue (Rectangle (wifiX, wifiX + 5.0,0.0, (nStas + 1) * 5.0))); + "Bounds", Rectangle2dValue (Rectangle2d (wifiX, wifiX + 5.0,0.0, (nStas + 1) * 5.0))); mobility.Install (sta); wifiMac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid)); diff --git a/src/mobility/doc/mobility.rst b/src/mobility/doc/mobility.rst --- a/src/mobility/doc/mobility.rst +++ b/src/mobility/doc/mobility.rst @@ -85,7 +85,7 @@ There are also some additional related structures used to support mobility models. -- Rectangle +- Rectangle2d - Box - Waypoint @@ -234,7 +234,7 @@ .. sourcecode:: cpp mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", - "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); + "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -50, 50))); Once the helper is configured, it is typically passed a container, such as: diff --git a/src/mobility/examples/mobility-trace-example.cc b/src/mobility/examples/mobility-trace-example.cc --- a/src/mobility/examples/mobility-trace-example.cc +++ b/src/mobility/examples/mobility-trace-example.cc @@ -43,7 +43,7 @@ "Mode", StringValue ("Time"), "Time", StringValue ("2s"), "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"), - "Bounds", RectangleValue (Rectangle (0.0, 20.0, 0.0, 20.0))); + "Bounds", Rectangle2dValue (Rectangle2d (0.0, 20.0, 0.0, 20.0))); mobility.Install (sta); // Set mobility random number streams to fixed values mobility.AssignStreams (sta, 0); diff --git a/src/mobility/model/constant-velocity-helper.cc b/src/mobility/model/constant-velocity-helper.cc --- a/src/mobility/model/constant-velocity-helper.cc +++ b/src/mobility/model/constant-velocity-helper.cc @@ -18,7 +18,7 @@ * Author: Mathieu Lacage */ #include "ns3/simulator.h" -#include "ns3/rectangle.h" +#include "ns3/rectangle-2d.h" #include "ns3/box.h" #include "ns3/log.h" #include "constant-velocity-helper.h" @@ -95,7 +95,7 @@ } void -ConstantVelocityHelper::UpdateWithBounds (const Rectangle &bounds) const +ConstantVelocityHelper::UpdateWithBounds (const Rectangle2d &bounds) const { NS_LOG_FUNCTION (this << bounds); Update (); diff --git a/src/mobility/model/constant-velocity-helper.h b/src/mobility/model/constant-velocity-helper.h --- a/src/mobility/model/constant-velocity-helper.h +++ b/src/mobility/model/constant-velocity-helper.h @@ -26,7 +26,7 @@ namespace ns3 { -class Rectangle; +class Rectangle2d; /** * \ingroup mobility @@ -83,7 +83,7 @@ * Update position, if not paused, from last position and time of last update * \param rectangle 2D bounding rectangle for resulting position; object will not move outside the rectangle */ - void UpdateWithBounds (const Rectangle &rectangle) const; + void UpdateWithBounds (const Rectangle2d &rectangle) const; /** * Update position, if not paused, from last position and time of last update * \param bounds 3D bounding box for resulting position; object will not move outside the box diff --git a/src/mobility/model/random-direction-2d-mobility-model.cc b/src/mobility/model/random-direction-2d-mobility-model.cc --- a/src/mobility/model/random-direction-2d-mobility-model.cc +++ b/src/mobility/model/random-direction-2d-mobility-model.cc @@ -40,9 +40,9 @@ .SetGroupName ("Mobility") .AddConstructor () .AddAttribute ("Bounds", "The 2d bounding area", - RectangleValue (Rectangle (-100, 100, -100, 100)), - MakeRectangleAccessor (&RandomDirection2dMobilityModel::m_bounds), - MakeRectangleChecker ()) + Rectangle2dValue (Rectangle2d (-100, 100, -100, 100)), + MakeRectangle2dAccessor (&RandomDirection2dMobilityModel::m_bounds), + MakeRectangle2dChecker ()) .AddAttribute ("Speed", "A random variable to control the speed (m/s).", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"), MakePointerAccessor (&RandomDirection2dMobilityModel::m_speed), @@ -119,16 +119,16 @@ Vector position = m_helper.GetCurrentPosition (); switch (m_bounds.GetClosestSide (position)) { - case Rectangle::RIGHT: + case Rectangle2d::RIGHT: direction += M_PI / 2; break; - case Rectangle::LEFT: + case Rectangle2d::LEFT: direction += -M_PI / 2; break; - case Rectangle::TOP: + case Rectangle2d::TOP: direction += M_PI; break; - case Rectangle::BOTTOM: + case Rectangle2d::BOTTOM: direction += 0.0; break; } diff --git a/src/mobility/model/random-direction-2d-mobility-model.h b/src/mobility/model/random-direction-2d-mobility-model.h --- a/src/mobility/model/random-direction-2d-mobility-model.h +++ b/src/mobility/model/random-direction-2d-mobility-model.h @@ -24,7 +24,7 @@ #include "ns3/ptr.h" #include "ns3/nstime.h" #include "ns3/event-id.h" -#include "ns3/rectangle.h" +#include "ns3/rectangle-2d.h" #include "ns3/random-variable-stream.h" #include "mobility-model.h" #include "constant-velocity-helper.h" @@ -77,7 +77,7 @@ virtual int64_t DoAssignStreams (int64_t); Ptr m_direction; //!< rv to control direction - Rectangle m_bounds; //!< the 2D bounding area + Rectangle2d m_bounds; //!< the 2D bounding area Ptr m_speed; //!< a random variable to control speed Ptr m_pause; //!< a random variable to control pause EventId m_event; //!< event ID of next scheduled event diff --git a/src/mobility/model/random-walk-2d-mobility-model.cc b/src/mobility/model/random-walk-2d-mobility-model.cc --- a/src/mobility/model/random-walk-2d-mobility-model.cc +++ b/src/mobility/model/random-walk-2d-mobility-model.cc @@ -41,9 +41,9 @@ .AddConstructor () .AddAttribute ("Bounds", "Bounds of the area to cruise.", - RectangleValue (Rectangle (0.0, 100.0, 0.0, 100.0)), - MakeRectangleAccessor (&RandomWalk2dMobilityModel::m_bounds), - MakeRectangleChecker ()) + Rectangle2dValue (Rectangle2d (0.0, 100.0, 0.0, 100.0)), + MakeRectangle2dAccessor (&RandomWalk2dMobilityModel::m_bounds), + MakeRectangle2dChecker ()) .AddAttribute ("Time", "Change current direction and speed after moving for this delay.", TimeValue (Seconds (1.0)), @@ -136,12 +136,12 @@ Vector speed = m_helper.GetVelocity (); switch (m_bounds.GetClosestSide (position)) { - case Rectangle::RIGHT: - case Rectangle::LEFT: + case Rectangle2d::RIGHT: + case Rectangle2d::LEFT: speed.x = -speed.x; break; - case Rectangle::TOP: - case Rectangle::BOTTOM: + case Rectangle2d::TOP: + case Rectangle2d::BOTTOM: speed.y = -speed.y; break; } diff --git a/src/mobility/model/random-walk-2d-mobility-model.h b/src/mobility/model/random-walk-2d-mobility-model.h --- a/src/mobility/model/random-walk-2d-mobility-model.h +++ b/src/mobility/model/random-walk-2d-mobility-model.h @@ -23,7 +23,7 @@ #include "ns3/object.h" #include "ns3/nstime.h" #include "ns3/event-id.h" -#include "ns3/rectangle.h" +#include "ns3/rectangle-2d.h" #include "ns3/random-variable-stream.h" #include "mobility-model.h" #include "constant-velocity-helper.h" @@ -86,7 +86,7 @@ Time m_modeTime; //!< Change current direction and speed after this delay Ptr m_speed; //!< rv for picking speed Ptr m_direction; //!< rv for picking direction - Rectangle m_bounds; //!< Bounds of the area to cruise + Rectangle2d m_bounds; //!< Bounds of the area to cruise }; diff --git a/src/mobility/model/rectangle.cc b/src/mobility/model/rectangle-2d.cc rename from src/mobility/model/rectangle.cc rename to src/mobility/model/rectangle-2d.cc --- a/src/mobility/model/rectangle.cc +++ b/src/mobility/model/rectangle-2d.cc @@ -17,17 +17,18 @@ * * Author: Mathieu Lacage */ -#include "rectangle.h" + +#include +#include +#include #include "ns3/vector.h" #include "ns3/assert.h" #include "ns3/fatal-error.h" -#include -#include -#include +#include "rectangle-2d.h" namespace ns3 { -Rectangle::Rectangle (double _xMin, double _xMax, +Rectangle2d::Rectangle2d (double _xMin, double _xMax, double _yMin, double _yMax) : xMin (_xMin), xMax (_xMax), @@ -36,7 +37,7 @@ { } -Rectangle::Rectangle () +Rectangle2d::Rectangle2d () : xMin (0.0), xMax (0.0), yMin (0.0), @@ -45,15 +46,15 @@ } bool -Rectangle::IsInside (const Vector &position) const +Rectangle2d::IsInside (const Vector &position) const { return position.x <= this->xMax && position.x >= this->xMin && position.y <= this->yMax && position.y >= this->yMin; } -Rectangle::Side -Rectangle::GetClosestSide (const Vector &position) const +Rectangle2d::Side +Rectangle2d::GetClosestSide (const Vector &position) const { double xMinDist = std::abs (position.x - this->xMin); double xMaxDist = std::abs (this->xMax - position.x); @@ -86,7 +87,7 @@ } Vector -Rectangle::CalculateIntersection (const Vector ¤t, const Vector &speed) const +Rectangle2d::CalculateIntersection (const Vector ¤t, const Vector &speed) const { NS_ASSERT (IsInside (current)); double xMaxY = current.y + (this->xMax - current.x) / speed.x * speed.y; @@ -122,7 +123,7 @@ } -ATTRIBUTE_HELPER_CPP (Rectangle); +ATTRIBUTE_HELPER_CPP (Rectangle2d); /** * \brief Stream insertion operator. @@ -132,7 +133,7 @@ * \returns a reference to the stream */ std::ostream & -operator << (std::ostream &os, const Rectangle &rectangle) +operator << (std::ostream &os, const Rectangle2d &rectangle) { os << rectangle.xMin << "|" << rectangle.xMax << "|" << rectangle.yMin << "|" << rectangle.yMax; return os; @@ -145,7 +146,7 @@ * \returns a reference to the stream */ std::istream & -operator >> (std::istream &is, Rectangle &rectangle) +operator >> (std::istream &is, Rectangle2d &rectangle) { char c1, c2, c3; is >> rectangle.xMin >> c1 >> rectangle.xMax >> c2 >> rectangle.yMin >> c3 >> rectangle.yMax; diff --git a/src/mobility/model/rectangle.h b/src/mobility/model/rectangle-2d.h rename from src/mobility/model/rectangle.h rename to src/mobility/model/rectangle-2d.h --- a/src/mobility/model/rectangle.h +++ b/src/mobility/model/rectangle-2d.h @@ -17,8 +17,8 @@ * * Author: Mathieu Lacage */ -#ifndef RECTANGLE_H -#define RECTANGLE_H +#ifndef RECTANGLE_2D_H +#define RECTANGLE_2D_H #include "ns3/attribute.h" #include "ns3/attribute-helper.h" @@ -31,7 +31,7 @@ * \brief a 2d rectangle * \see attribute_Rectangle */ -class Rectangle +class Rectangle2d { public: /** @@ -51,12 +51,12 @@ * * Create a rectangle. */ - Rectangle (double _xMin, double _xMax, + Rectangle2d (double _xMin, double _xMax, double _yMin, double _yMax); /** * Create a zero-sized rectangle located at coordinates (0.0,0.0) */ - Rectangle (); + Rectangle2d (); /** * \param position the position to test. * \return true if the input position is located within the rectangle, false otherwise. @@ -91,11 +91,11 @@ double yMax; //!< The y coordinate of the top bound of the rectangle }; -std::ostream &operator << (std::ostream &os, const Rectangle &rectangle); -std::istream &operator >> (std::istream &is, Rectangle &rectangle); +std::ostream &operator << (std::ostream &os, const Rectangle2d &rectangle); +std::istream &operator >> (std::istream &is, Rectangle2d &rectangle); -ATTRIBUTE_HELPER_HEADER (Rectangle); +ATTRIBUTE_HELPER_HEADER (Rectangle2d); } // namespace ns3 -#endif /* RECTANGLE_H */ +#endif /* RECTANGLE_2D_H */ diff --git a/src/mobility/test/mobility-trace-test-suite.cc b/src/mobility/test/mobility-trace-test-suite.cc --- a/src/mobility/test/mobility-trace-test-suite.cc +++ b/src/mobility/test/mobility-trace-test-suite.cc @@ -26,7 +26,7 @@ #include "ns3/uinteger.h" #include "ns3/string.h" #include "ns3/simulator.h" -#include "ns3/rectangle.h" +#include "ns3/rectangle-2d.h" #include "ns3/mobility-model.h" #include "ns3/mobility-helper.h" #include "ns3/node-container.h" @@ -83,7 +83,7 @@ "Mode", StringValue ("Time"), "Time", StringValue ("2s"), "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"), - "Bounds", RectangleValue (Rectangle (0.0, 20.0, 0.0, 20.0))); + "Bounds", Rectangle2dValue (Rectangle2d (0.0, 20.0, 0.0, 20.0))); mobility.Install (sta); // Set mobility random number streams to fixed values mobility.AssignStreams (sta, 0); diff --git a/src/mobility/wscript b/src/mobility/wscript --- a/src/mobility/wscript +++ b/src/mobility/wscript @@ -16,7 +16,7 @@ 'model/random-direction-2d-mobility-model.cc', 'model/random-walk-2d-mobility-model.cc', 'model/random-waypoint-mobility-model.cc', - 'model/rectangle.cc', + 'model/rectangle-2d.cc', 'model/steady-state-random-waypoint-mobility-model.cc', 'model/waypoint.cc', 'model/waypoint-mobility-model.cc', @@ -48,7 +48,7 @@ 'model/hierarchical-mobility-model.h', 'model/mobility-model.h', 'model/position-allocator.h', - 'model/rectangle.h', + 'model/rectangle-2d.h', 'model/random-direction-2d-mobility-model.h', 'model/random-walk-2d-mobility-model.h', 'model/random-waypoint-mobility-model.h', diff --git a/src/mpi/examples/third-distributed.cc b/src/mpi/examples/third-distributed.cc --- a/src/mpi/examples/third-distributed.cc +++ b/src/mpi/examples/third-distributed.cc @@ -181,7 +181,7 @@ "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", - "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); + "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -50, 50))); mobility.Install (wifiStaNodes); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); diff --git a/src/netanim/examples/wireless-animation.cc b/src/netanim/examples/wireless-animation.cc --- a/src/netanim/examples/wireless-animation.cc +++ b/src/netanim/examples/wireless-animation.cc @@ -107,7 +107,7 @@ "GridWidth", UintegerValue (5), "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", - "Bounds", RectangleValue (Rectangle (-50, 50, -25, 50))); + "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -25, 50))); mobility.Install (wifiStaNodes); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (wifiApNode); diff --git a/src/netanim/model/animation-interface.h b/src/netanim/model/animation-interface.h --- a/src/netanim/model/animation-interface.h +++ b/src/netanim/model/animation-interface.h @@ -40,7 +40,7 @@ #include "ns3/lte-ue-net-device.h" #include "ns3/lte-enb-net-device.h" #include "ns3/uan-phy-gen.h" -#include "ns3/rectangle.h" +#include "ns3/rectangle-2d.h" #include "ns3/ipv4.h" #include "ns3/ipv4-l3-protocol.h" @@ -631,7 +631,7 @@ Time m_wifiMacCountersPollInterval; ///< wifi MAC counters poll interval Time m_wifiPhyCountersStopTime; ///< wifi Phy counters stop time Time m_wifiPhyCountersPollInterval; ///< wifi Phy counters poll interval - static Rectangle * userBoundary; ///< user boundary + static Rectangle2d * userBoundary; ///< user boundary bool m_trackPackets; ///< track packets // Counter ID