author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sat, 04 Jul 2009 08:15:48 +0200 | |
changeset 4654 | 2eaebe77d66b |
parent 3226 | 8c191779d1c2 |
permissions | -rw-r--r-- |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 INRIA |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#include "rectangle.h" |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
21 |
#include "vector.h" |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#include "ns3/assert.h" |
2388
073c864796ec
add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
23 |
#include "ns3/fatal-error.h" |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include <cmath> |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
#include <algorithm> |
2391
588a4d8324b7
fix Value support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2388
diff
changeset
|
26 |
#include <sstream> |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
|
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
namespace ns3 { |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
Rectangle::Rectangle (double _xMin, double _xMax, |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
double _yMin, double _yMax) |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
: xMin (_xMin), |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
xMax (_xMax), |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
yMin (_yMin), |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
yMax (_yMax) |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
{} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
|
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
Rectangle::Rectangle () |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
: xMin (0.0), |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
xMax (0.0), |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
yMin (0.0), |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
yMax (0.0) |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
{} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
|
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
bool |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
46 |
Rectangle::IsInside (const Vector &position) const |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
{ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
return |
1653
040b0e2c0473
Use this-> to access member variables of Rectangle, for clarity.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1642
diff
changeset
|
49 |
position.x <= this->xMax && position.x >= this->xMin && |
040b0e2c0473
Use this-> to access member variables of Rectangle, for clarity.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1642
diff
changeset
|
50 |
position.y <= this->yMax && position.y >= this->yMin; |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
|
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
Rectangle::Side |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
54 |
Rectangle::GetClosestSide (const Vector &position) const |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
55 |
{ |
1653
040b0e2c0473
Use this-> to access member variables of Rectangle, for clarity.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1642
diff
changeset
|
56 |
double xMinDist = std::abs (position.x - this->xMin); |
040b0e2c0473
Use this-> to access member variables of Rectangle, for clarity.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1642
diff
changeset
|
57 |
double xMaxDist = std::abs (this->xMax - position.x); |
040b0e2c0473
Use this-> to access member variables of Rectangle, for clarity.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1642
diff
changeset
|
58 |
double yMinDist = std::abs (position.y - this->yMin); |
040b0e2c0473
Use this-> to access member variables of Rectangle, for clarity.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1642
diff
changeset
|
59 |
double yMaxDist = std::abs (this->yMax - position.y); |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
60 |
double minX = std::min (xMinDist, xMaxDist); |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
61 |
double minY = std::min (yMinDist, yMaxDist); |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
if (minX < minY) |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
63 |
{ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
if (xMinDist < xMaxDist) |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
{ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
return LEFT; |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
68 |
else |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
69 |
{ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
70 |
return RIGHT; |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
72 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
73 |
else |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
74 |
{ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
75 |
if (yMinDist < yMaxDist) |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
76 |
{ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
77 |
return BOTTOM; |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
79 |
else |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
{ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
81 |
return TOP; |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
82 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
83 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
84 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
85 |
|
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
86 |
Vector |
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
87 |
Rectangle::CalculateIntersection (const Vector ¤t, const Vector &speed) const |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
88 |
{ |
3226
8c191779d1c2
doxygen a couple of missing functions. Add acouple of more comments to existing mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2582
diff
changeset
|
89 |
NS_ASSERT (IsInside (current)); |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
90 |
double xMaxY = current.y + (this->xMax - current.x) / speed.x * speed.y; |
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
91 |
double xMinY = current.y + (this->xMin - current.x) / speed.x * speed.y; |
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
92 |
double yMaxX = current.x + (this->yMax - current.y) / speed.y * speed.x; |
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
93 |
double yMinX = current.x + (this->yMin - current.y) / speed.y * speed.x; |
1654
c51f82e8ffb1
Minor code readability improvements.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1653
diff
changeset
|
94 |
bool xMaxYOk = (xMaxY <= this->yMax && xMaxY >= this->yMin); |
c51f82e8ffb1
Minor code readability improvements.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1653
diff
changeset
|
95 |
bool xMinYOk = (xMinY <= this->yMax && xMinY >= this->yMin); |
c51f82e8ffb1
Minor code readability improvements.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1653
diff
changeset
|
96 |
bool yMaxXOk = (yMaxX <= this->xMax && yMaxX >= this->xMin); |
c51f82e8ffb1
Minor code readability improvements.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1653
diff
changeset
|
97 |
bool yMinXOk = (yMinX <= this->xMax && yMinX >= this->xMin); |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
98 |
if (xMaxYOk && speed.x >= 0) |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
99 |
{ |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
100 |
return Vector (this->xMax, xMaxY, 0.0); |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
101 |
} |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
102 |
else if (xMinYOk && speed.x <= 0) |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
103 |
{ |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
104 |
return Vector (this->xMin, xMinY, 0.0); |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
105 |
} |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
106 |
else if (yMaxXOk && speed.y >= 0) |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
107 |
{ |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
108 |
return Vector (yMaxX, this->yMax, 0.0); |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
109 |
} |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
110 |
else if (yMinXOk && speed.y <= 0) |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
111 |
{ |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
112 |
return Vector (yMinX, this->yMin, 0.0); |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
113 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
114 |
else |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
115 |
{ |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
116 |
NS_ASSERT (false); |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
117 |
// quiet compiler |
1817
8b0520433350
replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1654
diff
changeset
|
118 |
return Vector (0.0, 0.0, 0.0); |
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
119 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
120 |
|
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
121 |
} |
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
122 |
|
2582
3e28107b870f
rename old VALUE leftovers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2422
diff
changeset
|
123 |
ATTRIBUTE_HELPER_CPP (Rectangle); |
2388
073c864796ec
add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
124 |
|
2409
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
125 |
std::ostream & |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
126 |
operator << (std::ostream &os, const Rectangle &rectangle) |
2388
073c864796ec
add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
127 |
{ |
2409
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
128 |
os << rectangle.xMin << "|" << rectangle.xMax << "|" << rectangle.yMin << "|" << rectangle.yMax; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
129 |
return os; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
130 |
} |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
131 |
std::istream & |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
132 |
operator >> (std::istream &is, Rectangle &rectangle) |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
133 |
{ |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
134 |
char c1, c2, c3; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
135 |
is >> rectangle.xMin >> c1 >> rectangle.xMax >> c2 >> rectangle.yMin >> c3 >> rectangle.yMax; |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
136 |
if (c1 != '|' || |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
137 |
c2 != '|' || |
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
138 |
c3 != '|') |
2388
073c864796ec
add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
139 |
{ |
2409
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
140 |
is.setstate (std::ios_base::failbit); |
2388
073c864796ec
add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
141 |
} |
2409
8744ec60e8e6
convert RandomVariable, Rectangle, Vector, and Time to the new Class Helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2391
diff
changeset
|
142 |
return is; |
2388
073c864796ec
add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
143 |
} |
073c864796ec
add Value support to Rectangle
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1817
diff
changeset
|
144 |
|
968
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
145 |
|
70d02500c9d5
mobility models
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
146 |
} // namespace ns3 |