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

(-)a/examples/tutorial/third.cc (-1 / +1 lines)
 Lines 128-134    Link Here 
128
                                 "LayoutType", StringValue ("RowFirst"));
128
                                 "LayoutType", StringValue ("RowFirst"));
129
129
130
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
130
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
131
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
131
                             "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -50, 50)));
132
  mobility.Install (wifiStaNodes);
132
  mobility.Install (wifiStaNodes);
133
133
134
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
134
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
(-)a/examples/tutorial/third.py (-1 / +1 lines)
 Lines 103-109    Link Here 
103
								"MinY", ns.core.DoubleValue (0.0), "DeltaX", ns.core.DoubleValue(5.0), "DeltaY", ns.core.DoubleValue(10.0), 
103
								"MinY", ns.core.DoubleValue (0.0), "DeltaX", ns.core.DoubleValue(5.0), "DeltaY", ns.core.DoubleValue(10.0), 
104
                                 "GridWidth", ns.core.UintegerValue(3), "LayoutType", ns.core.StringValue("RowFirst"))
104
                                 "GridWidth", ns.core.UintegerValue(3), "LayoutType", ns.core.StringValue("RowFirst"))
105
                                 
105
                                 
106
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", "Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle (-50, 50, -50, 50)))
106
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", "Bounds", ns.mobility.Rectangle2dValue(ns.mobility.Rectangle2d (-50, 50, -50, 50)))
107
mobility.Install(wifiStaNodes)
107
mobility.Install(wifiStaNodes)
108
108
109
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel")
109
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel")
(-)a/examples/wireless/mixed-wired-wireless.cc (-2 / +3 lines)
 Lines 72-77    Link Here 
72
#include "ns3/olsr-helper.h"
72
#include "ns3/olsr-helper.h"
73
#include "ns3/csma-helper.h"
73
#include "ns3/csma-helper.h"
74
#include "ns3/animation-interface.h"
74
#include "ns3/animation-interface.h"
75
#include "ns3/rectangle-2d.h"
75
76
76
using namespace ns3;
77
using namespace ns3;
77
78
 Lines 192-198    Link Here 
192
                                 "GridWidth", UintegerValue (5),
193
                                 "GridWidth", UintegerValue (5),
193
                                 "LayoutType", StringValue ("RowFirst"));
194
                                 "LayoutType", StringValue ("RowFirst"));
194
  mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
195
  mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
195
                             "Bounds", RectangleValue (Rectangle (-500, 500, -500, 500)),
196
                             "Bounds", Rectangle2dValue (Rectangle2d (-500, 500, -500, 500)),
196
                             "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=2]"),
197
                             "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=2]"),
197
                             "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"));
198
                             "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"));
198
  mobility.Install (backbone);
199
  mobility.Install (backbone);
 Lines 333-339    Link Here 
333
      mobility.PushReferenceMobilityModel (backbone.Get (i));
334
      mobility.PushReferenceMobilityModel (backbone.Get (i));
334
      mobility.SetPositionAllocator (subnetAlloc);
335
      mobility.SetPositionAllocator (subnetAlloc);
335
      mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
336
      mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
336
                                 "Bounds", RectangleValue (Rectangle (-10, 10, -10, 10)),
337
                                 "Bounds", Rectangle2dValue (Rectangle2d (-10, 10, -10, 10)),
337
                                 "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=3]"),
338
                                 "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=3]"),
338
                                 "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.4]"));
339
                                 "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.4]"));
339
      mobility.Install (stas);
340
      mobility.Install (stas);
(-)a/examples/wireless/mixed-wired-wireless.py (-2 / +2 lines)
 Lines 170-176    Link Here 
170
                                  "GridWidth", ns.core.UintegerValue(5),
170
                                  "GridWidth", ns.core.UintegerValue(5),
171
                                  "LayoutType", ns.core.StringValue("RowFirst"))
171
                                  "LayoutType", ns.core.StringValue("RowFirst"))
172
    mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel",
172
    mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel",
173
                               "Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle(-500, 500, -500, 500)),
173
                               "Bounds", ns.mobility.Rectangle2dValue(ns.mobility.Rectangle2d(-500, 500, -500, 500)),
174
                               "Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=2]"),
174
                               "Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=2]"),
175
                               "Pause", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"))
175
                               "Pause", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"))
176
    mobility.Install(backbone)
176
    mobility.Install(backbone)
 Lines 298-304    Link Here 
298
        mobility.PushReferenceMobilityModel(backbone.Get(i))
298
        mobility.PushReferenceMobilityModel(backbone.Get(i))
299
        mobility.SetPositionAllocator(subnetAlloc)
299
        mobility.SetPositionAllocator(subnetAlloc)
300
        mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel",
300
        mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel",
301
                                  "Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle(-10, 10, -10, 10)),
301
                                  "Bounds", ns.mobility.Rectangle2dValue(ns.mobility.Rectangle2d(-10, 10, -10, 10)),
302
                                  "Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=3]"),
302
                                  "Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=3]"),
303
                                  "Pause", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0.4]"))
303
                                  "Pause", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0.4]"))
304
        mobility.Install(stas)
304
        mobility.Install(stas)
(-)a/examples/wireless/multirate.cc (-3 / +2 lines)
 Lines 66-72    Link Here 
66
#include "ns3/olsr-helper.h"
66
#include "ns3/olsr-helper.h"
67
#include "ns3/ipv4-static-routing-helper.h"
67
#include "ns3/ipv4-static-routing-helper.h"
68
#include "ns3/ipv4-list-routing-helper.h"
68
#include "ns3/ipv4-list-routing-helper.h"
69
#include "ns3/rectangle.h"
69
#include "ns3/rectangle-2d.h"
70
#include "ns3/flow-monitor-helper.h"
70
#include "ns3/flow-monitor-helper.h"
71
71
72
using namespace ns3;
72
using namespace ns3;
 Lines 451-459    Link Here 
451
451
452
  if (enableMobility && enableRouting)
452
  if (enableMobility && enableRouting)
453
    {
453
    {
454
      //Rectangle (xMin, xMax, yMin, yMax)
455
      mobil.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
454
      mobil.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
456
                              "Bounds", RectangleValue (Rectangle (0, 500, 0, 500)),
455
                              "Bounds", Rectangle2dValue (Rectangle2d (0, 500, 0, 500)),
457
                              "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=10]"),
456
                              "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=10]"),
458
                              "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"));
457
                              "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"));
459
    }
458
    }
(-)a/examples/wireless/wifi-blockack.cc (-2 / +2 lines)
 Lines 52-58    Link Here 
52
#include "ns3/on-off-helper.h"
52
#include "ns3/on-off-helper.h"
53
#include "ns3/yans-wifi-channel.h"
53
#include "ns3/yans-wifi-channel.h"
54
#include "ns3/mobility-model.h"
54
#include "ns3/mobility-model.h"
55
#include "ns3/rectangle.h"
55
#include "ns3/rectangle-2d.h"
56
#include "ns3/internet-stack-helper.h"
56
#include "ns3/internet-stack-helper.h"
57
#include "ns3/ipv4-address-helper.h"
57
#include "ns3/ipv4-address-helper.h"
58
#include "ns3/ipv4-global-routing-helper.h"
58
#include "ns3/ipv4-global-routing-helper.h"
 Lines 110-116    Link Here 
110
                                 "LayoutType", StringValue ("RowFirst"));
110
                                 "LayoutType", StringValue ("RowFirst"));
111
111
112
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
112
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
113
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
113
                             "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -50, 50)));
114
  mobility.Install (sta);
114
  mobility.Install (sta);
115
115
116
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
116
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
(-)a/examples/wireless/wifi-wired-bridging.cc (-1 / +2 lines)
 Lines 55-60    Link Here 
55
#include "ns3/animation-interface.h"
55
#include "ns3/animation-interface.h"
56
#include "ns3/bridge-helper.h"
56
#include "ns3/bridge-helper.h"
57
#include "ns3/packet-socket-address.h"
57
#include "ns3/packet-socket-address.h"
58
#include "ns3/rectangle-2d.h"
58
59
59
using namespace ns3;
60
using namespace ns3;
60
61
 Lines 143-149    Link Here 
143
                                 "Mode", StringValue ("Time"),
144
                                 "Mode", StringValue ("Time"),
144
                                 "Time", StringValue ("2s"),
145
                                 "Time", StringValue ("2s"),
145
                                 "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"),
146
                                 "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"),
146
                                 "Bounds", RectangleValue (Rectangle (wifiX, wifiX + 5.0,0.0, (nStas + 1) * 5.0)));
147
                                 "Bounds", Rectangle2dValue (Rectangle2d (wifiX, wifiX + 5.0,0.0, (nStas + 1) * 5.0)));
147
      mobility.Install (sta);
148
      mobility.Install (sta);
148
      wifiMac.SetType ("ns3::StaWifiMac",
149
      wifiMac.SetType ("ns3::StaWifiMac",
149
                       "Ssid", SsidValue (ssid));
150
                       "Ssid", SsidValue (ssid));
(-)a/src/mobility/doc/mobility.rst (-2 / +2 lines)
 Lines 85-91    Link Here 
85
There are also some additional related structures used to support
85
There are also some additional related structures used to support
86
mobility models.
86
mobility models.
87
87
88
- Rectangle
88
- Rectangle2d
89
- Box
89
- Box
90
- Waypoint
90
- Waypoint
91
91
 Lines 234-240    Link Here 
234
.. sourcecode:: cpp
234
.. sourcecode:: cpp
235
235
236
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
236
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
237
    "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
237
    "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -50, 50)));
238
238
239
Once the helper is configured, it is typically passed a container, such as:
239
Once the helper is configured, it is typically passed a container, such as:
240
240
(-)a/src/mobility/examples/mobility-trace-example.cc (-1 / +1 lines)
 Lines 43-49    Link Here 
43
                             "Mode", StringValue ("Time"),
43
                             "Mode", StringValue ("Time"),
44
                             "Time", StringValue ("2s"),
44
                             "Time", StringValue ("2s"),
45
                             "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"),
45
                             "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"),
46
                             "Bounds", RectangleValue (Rectangle (0.0, 20.0, 0.0, 20.0)));
46
                             "Bounds", Rectangle2dValue (Rectangle2d (0.0, 20.0, 0.0, 20.0)));
47
  mobility.Install (sta);
47
  mobility.Install (sta);
48
  // Set mobility random number streams to fixed values
48
  // Set mobility random number streams to fixed values
49
  mobility.AssignStreams (sta, 0);
49
  mobility.AssignStreams (sta, 0);
(-)a/src/mobility/model/constant-velocity-helper.cc (-2 / +2 lines)
 Lines 18-24    Link Here 
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
 */
19
 */
20
#include "ns3/simulator.h"
20
#include "ns3/simulator.h"
21
#include "ns3/rectangle.h"
21
#include "ns3/rectangle-2d.h"
22
#include "ns3/box.h"
22
#include "ns3/box.h"
23
#include "ns3/log.h"
23
#include "ns3/log.h"
24
#include "constant-velocity-helper.h"
24
#include "constant-velocity-helper.h"
 Lines 95-101    Link Here 
95
}
95
}
96
96
97
void
97
void
98
ConstantVelocityHelper::UpdateWithBounds (const Rectangle &bounds) const
98
ConstantVelocityHelper::UpdateWithBounds (const Rectangle2d &bounds) const
99
{
99
{
100
  NS_LOG_FUNCTION (this << bounds);
100
  NS_LOG_FUNCTION (this << bounds);
101
  Update ();
101
  Update ();
(-)a/src/mobility/model/constant-velocity-helper.h (-2 / +2 lines)
 Lines 26-32    Link Here 
26
26
27
namespace ns3 {
27
namespace ns3 {
28
28
29
class Rectangle;
29
class Rectangle2d;
30
30
31
/**
31
/**
32
 * \ingroup mobility
32
 * \ingroup mobility
 Lines 83-89    Link Here 
83
   * Update position, if not paused, from last position and time of last update
83
   * Update position, if not paused, from last position and time of last update
84
   * \param rectangle 2D bounding rectangle for resulting position; object will not move outside the rectangle 
84
   * \param rectangle 2D bounding rectangle for resulting position; object will not move outside the rectangle 
85
   */
85
   */
86
  void UpdateWithBounds (const Rectangle &rectangle) const;
86
  void UpdateWithBounds (const Rectangle2d &rectangle) const;
87
  /**
87
  /**
88
   * Update position, if not paused, from last position and time of last update
88
   * Update position, if not paused, from last position and time of last update
89
   * \param bounds 3D bounding box for resulting position; object will not move outside the box 
89
   * \param bounds 3D bounding box for resulting position; object will not move outside the box 
(-)a/src/mobility/model/random-direction-2d-mobility-model.cc (-7 / +7 lines)
 Lines 40-48    Link Here 
40
    .SetGroupName ("Mobility")
40
    .SetGroupName ("Mobility")
41
    .AddConstructor<RandomDirection2dMobilityModel> ()
41
    .AddConstructor<RandomDirection2dMobilityModel> ()
42
    .AddAttribute ("Bounds", "The 2d bounding area",
42
    .AddAttribute ("Bounds", "The 2d bounding area",
43
                   RectangleValue (Rectangle (-100, 100, -100, 100)),
43
                   Rectangle2dValue (Rectangle2d (-100, 100, -100, 100)),
44
                   MakeRectangleAccessor (&RandomDirection2dMobilityModel::m_bounds),
44
                   MakeRectangle2dAccessor (&RandomDirection2dMobilityModel::m_bounds),
45
                   MakeRectangleChecker ())
45
                   MakeRectangle2dChecker ())
46
    .AddAttribute ("Speed", "A random variable to control the speed (m/s).",
46
    .AddAttribute ("Speed", "A random variable to control the speed (m/s).",
47
                   StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"),
47
                   StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"),
48
                   MakePointerAccessor (&RandomDirection2dMobilityModel::m_speed),
48
                   MakePointerAccessor (&RandomDirection2dMobilityModel::m_speed),
 Lines 119-134    Link Here 
119
  Vector position = m_helper.GetCurrentPosition ();
119
  Vector position = m_helper.GetCurrentPosition ();
120
  switch (m_bounds.GetClosestSide (position))
120
  switch (m_bounds.GetClosestSide (position))
121
    {
121
    {
122
    case Rectangle::RIGHT:
122
    case Rectangle2d::RIGHT:
123
      direction += M_PI / 2;
123
      direction += M_PI / 2;
124
      break;
124
      break;
125
    case Rectangle::LEFT:
125
    case Rectangle2d::LEFT:
126
      direction += -M_PI / 2;
126
      direction += -M_PI / 2;
127
      break;
127
      break;
128
    case Rectangle::TOP:
128
    case Rectangle2d::TOP:
129
      direction += M_PI;
129
      direction += M_PI;
130
      break;
130
      break;
131
    case Rectangle::BOTTOM:
131
    case Rectangle2d::BOTTOM:
132
      direction += 0.0;
132
      direction += 0.0;
133
      break;
133
      break;
134
    }
134
    }
(-)a/src/mobility/model/random-direction-2d-mobility-model.h (-2 / +2 lines)
 Lines 24-30    Link Here 
24
#include "ns3/ptr.h"
24
#include "ns3/ptr.h"
25
#include "ns3/nstime.h"
25
#include "ns3/nstime.h"
26
#include "ns3/event-id.h"
26
#include "ns3/event-id.h"
27
#include "ns3/rectangle.h"
27
#include "ns3/rectangle-2d.h"
28
#include "ns3/random-variable-stream.h"
28
#include "ns3/random-variable-stream.h"
29
#include "mobility-model.h"
29
#include "mobility-model.h"
30
#include "constant-velocity-helper.h"
30
#include "constant-velocity-helper.h"
 Lines 77-83    Link Here 
77
  virtual int64_t DoAssignStreams (int64_t);
77
  virtual int64_t DoAssignStreams (int64_t);
78
78
79
  Ptr<UniformRandomVariable> m_direction; //!< rv to control direction
79
  Ptr<UniformRandomVariable> m_direction; //!< rv to control direction
80
  Rectangle m_bounds; //!< the 2D bounding area
80
  Rectangle2d m_bounds; //!< the 2D bounding area
81
  Ptr<RandomVariableStream> m_speed; //!< a random variable to control speed
81
  Ptr<RandomVariableStream> m_speed; //!< a random variable to control speed
82
  Ptr<RandomVariableStream> m_pause; //!< a random variable to control pause 
82
  Ptr<RandomVariableStream> m_pause; //!< a random variable to control pause 
83
  EventId m_event; //!< event ID of next scheduled event
83
  EventId m_event; //!< event ID of next scheduled event
(-)a/src/mobility/model/random-walk-2d-mobility-model.cc (-7 / +7 lines)
 Lines 41-49    Link Here 
41
    .AddConstructor<RandomWalk2dMobilityModel> ()
41
    .AddConstructor<RandomWalk2dMobilityModel> ()
42
    .AddAttribute ("Bounds",
42
    .AddAttribute ("Bounds",
43
                   "Bounds of the area to cruise.",
43
                   "Bounds of the area to cruise.",
44
                   RectangleValue (Rectangle (0.0, 100.0, 0.0, 100.0)),
44
                   Rectangle2dValue (Rectangle2d (0.0, 100.0, 0.0, 100.0)),
45
                   MakeRectangleAccessor (&RandomWalk2dMobilityModel::m_bounds),
45
                   MakeRectangle2dAccessor (&RandomWalk2dMobilityModel::m_bounds),
46
                   MakeRectangleChecker ())
46
                   MakeRectangle2dChecker ())
47
    .AddAttribute ("Time",
47
    .AddAttribute ("Time",
48
                   "Change current direction and speed after moving for this delay.",
48
                   "Change current direction and speed after moving for this delay.",
49
                   TimeValue (Seconds (1.0)),
49
                   TimeValue (Seconds (1.0)),
 Lines 136-147    Link Here 
136
  Vector speed = m_helper.GetVelocity ();
136
  Vector speed = m_helper.GetVelocity ();
137
  switch (m_bounds.GetClosestSide (position))
137
  switch (m_bounds.GetClosestSide (position))
138
    {
138
    {
139
    case Rectangle::RIGHT:
139
    case Rectangle2d::RIGHT:
140
    case Rectangle::LEFT:
140
    case Rectangle2d::LEFT:
141
      speed.x = -speed.x;
141
      speed.x = -speed.x;
142
      break;
142
      break;
143
    case Rectangle::TOP:
143
    case Rectangle2d::TOP:
144
    case Rectangle::BOTTOM:
144
    case Rectangle2d::BOTTOM:
145
      speed.y = -speed.y;
145
      speed.y = -speed.y;
146
      break;
146
      break;
147
    }
147
    }
(-)a/src/mobility/model/random-walk-2d-mobility-model.h (-2 / +2 lines)
 Lines 23-29    Link Here 
23
#include "ns3/object.h"
23
#include "ns3/object.h"
24
#include "ns3/nstime.h"
24
#include "ns3/nstime.h"
25
#include "ns3/event-id.h"
25
#include "ns3/event-id.h"
26
#include "ns3/rectangle.h"
26
#include "ns3/rectangle-2d.h"
27
#include "ns3/random-variable-stream.h"
27
#include "ns3/random-variable-stream.h"
28
#include "mobility-model.h"
28
#include "mobility-model.h"
29
#include "constant-velocity-helper.h"
29
#include "constant-velocity-helper.h"
 Lines 86-92    Link Here 
86
  Time m_modeTime; //!< Change current direction and speed after this delay
86
  Time m_modeTime; //!< Change current direction and speed after this delay
87
  Ptr<RandomVariableStream> m_speed; //!< rv for picking speed
87
  Ptr<RandomVariableStream> m_speed; //!< rv for picking speed
88
  Ptr<RandomVariableStream> m_direction; //!< rv for picking direction
88
  Ptr<RandomVariableStream> m_direction; //!< rv for picking direction
89
  Rectangle m_bounds; //!< Bounds of the area to cruise
89
  Rectangle2d m_bounds; //!< Bounds of the area to cruise
90
};
90
};
91
91
92
92
(-)a/src/mobility/model/rectangle.cc (-13 / +14 lines)
 Lines 17-33    Link Here 
17
 *
17
 *
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
 */
19
 */
20
#include "rectangle.h"
20
21
#include <cmath>
22
#include <algorithm>
23
#include <sstream>
21
#include "ns3/vector.h"
24
#include "ns3/vector.h"
22
#include "ns3/assert.h"
25
#include "ns3/assert.h"
23
#include "ns3/fatal-error.h"
26
#include "ns3/fatal-error.h"
24
#include <cmath>
27
#include "rectangle-2d.h"
25
#include <algorithm>
26
#include <sstream> 
27
28
28
namespace ns3 {
29
namespace ns3 {
29
30
30
Rectangle::Rectangle (double _xMin, double _xMax,
31
Rectangle2d::Rectangle2d (double _xMin, double _xMax,
31
                      double _yMin, double _yMax)
32
                      double _yMin, double _yMax)
32
  : xMin (_xMin),
33
  : xMin (_xMin),
33
    xMax (_xMax),
34
    xMax (_xMax),
 Lines 36-42    Link Here 
36
{
37
{
37
}
38
}
38
39
39
Rectangle::Rectangle ()
40
Rectangle2d::Rectangle2d ()
40
  : xMin (0.0),
41
  : xMin (0.0),
41
    xMax (0.0),
42
    xMax (0.0),
42
    yMin (0.0),
43
    yMin (0.0),
 Lines 45-59    Link Here 
45
}
46
}
46
47
47
bool
48
bool
48
Rectangle::IsInside (const Vector &position) const
49
Rectangle2d::IsInside (const Vector &position) const
49
{
50
{
50
  return
51
  return
51
    position.x <= this->xMax && position.x >= this->xMin &&
52
    position.x <= this->xMax && position.x >= this->xMin &&
52
    position.y <= this->yMax && position.y >= this->yMin;
53
    position.y <= this->yMax && position.y >= this->yMin;
53
}
54
}
54
55
55
Rectangle::Side
56
Rectangle2d::Side
56
Rectangle::GetClosestSide (const Vector &position) const
57
Rectangle2d::GetClosestSide (const Vector &position) const
57
{
58
{
58
  double xMinDist = std::abs (position.x - this->xMin);
59
  double xMinDist = std::abs (position.x - this->xMin);
59
  double xMaxDist = std::abs (this->xMax - position.x);
60
  double xMaxDist = std::abs (this->xMax - position.x);
 Lines 86-92    Link Here 
86
}
87
}
87
88
88
Vector
89
Vector
89
Rectangle::CalculateIntersection (const Vector &current, const Vector &speed) const
90
Rectangle2d::CalculateIntersection (const Vector &current, const Vector &speed) const
90
{
91
{
91
  NS_ASSERT (IsInside (current));
92
  NS_ASSERT (IsInside (current));
92
  double xMaxY = current.y + (this->xMax - current.x) / speed.x * speed.y;
93
  double xMaxY = current.y + (this->xMax - current.x) / speed.x * speed.y;
 Lines 122-128    Link Here 
122
123
123
}
124
}
124
125
125
ATTRIBUTE_HELPER_CPP (Rectangle);
126
ATTRIBUTE_HELPER_CPP (Rectangle2d);
126
127
127
/**
128
/**
128
 * \brief Stream insertion operator.
129
 * \brief Stream insertion operator.
 Lines 132-138    Link Here 
132
 * \returns a reference to the stream
133
 * \returns a reference to the stream
133
 */
134
 */
134
std::ostream &
135
std::ostream &
135
operator << (std::ostream &os, const Rectangle &rectangle)
136
operator << (std::ostream &os, const Rectangle2d &rectangle)
136
{
137
{
137
  os << rectangle.xMin << "|" << rectangle.xMax << "|" << rectangle.yMin << "|" << rectangle.yMax;
138
  os << rectangle.xMin << "|" << rectangle.xMax << "|" << rectangle.yMin << "|" << rectangle.yMax;
138
  return os;
139
  return os;
 Lines 145-151    Link Here 
145
 * \returns a reference to the stream
146
 * \returns a reference to the stream
146
 */
147
 */
147
std::istream &
148
std::istream &
148
operator >> (std::istream &is, Rectangle &rectangle)
149
operator >> (std::istream &is, Rectangle2d &rectangle)
149
{
150
{
150
  char c1, c2, c3;
151
  char c1, c2, c3;
151
  is >> rectangle.xMin >> c1 >> rectangle.xMax >> c2 >> rectangle.yMin >> c3 >> rectangle.yMax;
152
  is >> rectangle.xMin >> c1 >> rectangle.xMax >> c2 >> rectangle.yMin >> c3 >> rectangle.yMax;
(-)a/src/mobility/model/rectangle.h (-9 / +9 lines)
 Lines 17-24    Link Here 
17
 *
17
 *
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
 */
19
 */
20
#ifndef RECTANGLE_H
20
#ifndef RECTANGLE_2D_H
21
#define RECTANGLE_H
21
#define RECTANGLE_2D_H
22
22
23
#include "ns3/attribute.h"
23
#include "ns3/attribute.h"
24
#include "ns3/attribute-helper.h"
24
#include "ns3/attribute-helper.h"
 Lines 31-37    Link Here 
31
 * \brief a 2d rectangle
31
 * \brief a 2d rectangle
32
 * \see attribute_Rectangle
32
 * \see attribute_Rectangle
33
 */
33
 */
34
class Rectangle
34
class Rectangle2d
35
{
35
{
36
public:
36
public:
37
  /**
37
  /**
 Lines 51-62    Link Here 
51
   *
51
   *
52
   * Create a rectangle.
52
   * Create a rectangle.
53
   */
53
   */
54
  Rectangle (double _xMin, double _xMax,
54
  Rectangle2d (double _xMin, double _xMax,
55
             double _yMin, double _yMax);
55
             double _yMin, double _yMax);
56
  /**
56
  /**
57
   * Create a zero-sized rectangle located at coordinates (0.0,0.0)
57
   * Create a zero-sized rectangle located at coordinates (0.0,0.0)
58
   */
58
   */
59
  Rectangle ();
59
  Rectangle2d ();
60
  /**
60
  /**
61
   * \param position the position to test.
61
   * \param position the position to test.
62
   * \return true if the input position is located within the rectangle, false otherwise.
62
   * \return true if the input position is located within the rectangle, false otherwise.
 Lines 91-101    Link Here 
91
  double yMax; //!< The y coordinate of the top bound of the rectangle
91
  double yMax; //!< The y coordinate of the top bound of the rectangle
92
};
92
};
93
93
94
std::ostream &operator << (std::ostream &os, const Rectangle &rectangle);
94
std::ostream &operator << (std::ostream &os, const Rectangle2d &rectangle);
95
std::istream &operator >> (std::istream &is, Rectangle &rectangle);
95
std::istream &operator >> (std::istream &is, Rectangle2d &rectangle);
96
96
97
ATTRIBUTE_HELPER_HEADER (Rectangle);
97
ATTRIBUTE_HELPER_HEADER (Rectangle2d);
98
98
99
} // namespace ns3
99
} // namespace ns3
100
100
101
#endif /* RECTANGLE_H */
101
#endif /* RECTANGLE_2D_H */
(-)a/src/mobility/test/mobility-trace-test-suite.cc (-2 / +2 lines)
 Lines 26-32    Link Here 
26
#include "ns3/uinteger.h"
26
#include "ns3/uinteger.h"
27
#include "ns3/string.h"
27
#include "ns3/string.h"
28
#include "ns3/simulator.h"
28
#include "ns3/simulator.h"
29
#include "ns3/rectangle.h"
29
#include "ns3/rectangle-2d.h"
30
#include "ns3/mobility-model.h"
30
#include "ns3/mobility-model.h"
31
#include "ns3/mobility-helper.h"
31
#include "ns3/mobility-helper.h"
32
#include "ns3/node-container.h"
32
#include "ns3/node-container.h"
 Lines 83-89    Link Here 
83
                             "Mode", StringValue ("Time"),
83
                             "Mode", StringValue ("Time"),
84
                             "Time", StringValue ("2s"),
84
                             "Time", StringValue ("2s"),
85
                             "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"),
85
                             "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"),
86
                             "Bounds", RectangleValue (Rectangle (0.0, 20.0, 0.0, 20.0)));
86
                             "Bounds", Rectangle2dValue (Rectangle2d (0.0, 20.0, 0.0, 20.0)));
87
  mobility.Install (sta);
87
  mobility.Install (sta);
88
  // Set mobility random number streams to fixed values
88
  // Set mobility random number streams to fixed values
89
  mobility.AssignStreams (sta, 0);
89
  mobility.AssignStreams (sta, 0);
(-)a/src/mobility/wscript (-2 / +2 lines)
 Lines 16-22    Link Here 
16
        'model/random-direction-2d-mobility-model.cc',
16
        'model/random-direction-2d-mobility-model.cc',
17
        'model/random-walk-2d-mobility-model.cc',
17
        'model/random-walk-2d-mobility-model.cc',
18
        'model/random-waypoint-mobility-model.cc',
18
        'model/random-waypoint-mobility-model.cc',
19
        'model/rectangle.cc',
19
        'model/rectangle-2d.cc',
20
        'model/steady-state-random-waypoint-mobility-model.cc',
20
        'model/steady-state-random-waypoint-mobility-model.cc',
21
        'model/waypoint.cc',
21
        'model/waypoint.cc',
22
        'model/waypoint-mobility-model.cc',
22
        'model/waypoint-mobility-model.cc',
 Lines 48-54    Link Here 
48
        'model/hierarchical-mobility-model.h',
48
        'model/hierarchical-mobility-model.h',
49
        'model/mobility-model.h',
49
        'model/mobility-model.h',
50
        'model/position-allocator.h',
50
        'model/position-allocator.h',
51
        'model/rectangle.h',
51
        'model/rectangle-2d.h',
52
        'model/random-direction-2d-mobility-model.h',
52
        'model/random-direction-2d-mobility-model.h',
53
        'model/random-walk-2d-mobility-model.h',
53
        'model/random-walk-2d-mobility-model.h',
54
        'model/random-waypoint-mobility-model.h',
54
        'model/random-waypoint-mobility-model.h',
(-)a/src/mpi/examples/third-distributed.cc (-1 / +1 lines)
 Lines 181-187    Link Here 
181
                                 "LayoutType", StringValue ("RowFirst"));
181
                                 "LayoutType", StringValue ("RowFirst"));
182
182
183
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
183
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
184
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
184
                             "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -50, 50)));
185
  mobility.Install (wifiStaNodes);
185
  mobility.Install (wifiStaNodes);
186
186
187
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
187
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
(-)a/src/netanim/examples/wireless-animation.cc (-1 / +1 lines)
 Lines 107-113    Link Here 
107
                                 "GridWidth", UintegerValue (5),
107
                                 "GridWidth", UintegerValue (5),
108
                                 "LayoutType", StringValue ("RowFirst"));
108
                                 "LayoutType", StringValue ("RowFirst"));
109
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
109
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
110
                             "Bounds", RectangleValue (Rectangle (-50, 50, -25, 50)));
110
                             "Bounds", Rectangle2dValue (Rectangle2d (-50, 50, -25, 50)));
111
  mobility.Install (wifiStaNodes);
111
  mobility.Install (wifiStaNodes);
112
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
112
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
113
  mobility.Install (wifiApNode);
113
  mobility.Install (wifiApNode);
(-)a/src/netanim/model/animation-interface.h (-2 / +2 lines)
 Lines 40-46    Link Here 
40
#include "ns3/lte-ue-net-device.h"
40
#include "ns3/lte-ue-net-device.h"
41
#include "ns3/lte-enb-net-device.h"
41
#include "ns3/lte-enb-net-device.h"
42
#include "ns3/uan-phy-gen.h"
42
#include "ns3/uan-phy-gen.h"
43
#include "ns3/rectangle.h"
43
#include "ns3/rectangle-2d.h"
44
#include "ns3/ipv4.h"
44
#include "ns3/ipv4.h"
45
#include "ns3/ipv4-l3-protocol.h"
45
#include "ns3/ipv4-l3-protocol.h"
46
46
 Lines 631-637    Link Here 
631
  Time m_wifiMacCountersPollInterval; ///< wifi MAC counters poll interval
631
  Time m_wifiMacCountersPollInterval; ///< wifi MAC counters poll interval
632
  Time m_wifiPhyCountersStopTime; ///< wifi Phy counters stop time
632
  Time m_wifiPhyCountersStopTime; ///< wifi Phy counters stop time
633
  Time m_wifiPhyCountersPollInterval; ///< wifi Phy counters poll interval
633
  Time m_wifiPhyCountersPollInterval; ///< wifi Phy counters poll interval
634
  static Rectangle * userBoundary; ///< user boundary
634
  static Rectangle2d * userBoundary; ///< user boundary
635
  bool m_trackPackets; ///< track packets
635
  bool m_trackPackets; ///< track packets
636
636
637
  // Counter ID
637
  // Counter ID

Return to bug 2918