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

(-)a/src/mobility/model/position-allocator.cc (-5 / +46 lines)
 Lines 114-119   GridPositionAllocator::GetTypeId (void) Link Here 
114
                   DoubleValue (0.0),
114
                   DoubleValue (0.0),
115
                   MakeDoubleAccessor (&GridPositionAllocator::m_yMin),
115
                   MakeDoubleAccessor (&GridPositionAllocator::m_yMin),
116
                   MakeDoubleChecker<double> ())
116
                   MakeDoubleChecker<double> ())
117
    .AddAttribute ("Z",
118
                   "The z coordinate of all the positions allocated.",
119
                   DoubleValue (0.0),
120
                   MakeDoubleAccessor (&GridPositionAllocator::m_z),
121
                   MakeDoubleChecker<double> ())
117
    .AddAttribute ("DeltaX", "The x space between objects.",
122
    .AddAttribute ("DeltaX", "The x space between objects.",
118
                   DoubleValue (1.0),
123
                   DoubleValue (1.0),
119
                   MakeDoubleAccessor (&GridPositionAllocator::m_deltaX),
124
                   MakeDoubleAccessor (&GridPositionAllocator::m_deltaX),
 Lines 146-151   GridPositionAllocator::SetMinY (double yMin) Link Here 
146
  m_yMin = yMin;
151
  m_yMin = yMin;
147
}
152
}
148
void
153
void
154
GridPositionAllocator::SetZ (double z)
155
{
156
  m_z = z;
157
}
158
void
149
GridPositionAllocator::SetDeltaX (double deltaX)
159
GridPositionAllocator::SetDeltaX (double deltaX)
150
{
160
{
151
  m_deltaX = deltaX;
161
  m_deltaX = deltaX;
 Lines 212-218   GridPositionAllocator::GetNext (void) const Link Here 
212
      break;
222
      break;
213
    }
223
    }
214
  m_current++;
224
  m_current++;
215
  return Vector (x, y, 0.0);
225
  return Vector (x, y, m_z);
216
}
226
}
217
227
218
int64_t
228
int64_t
 Lines 239-245   RandomRectanglePositionAllocator::GetTypeId (void) Link Here 
239
                   "A random variable which represents the y coordinate of a position in a random rectangle.",
249
                   "A random variable which represents the y coordinate of a position in a random rectangle.",
240
                   StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
250
                   StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1.0]"),
241
                   MakePointerAccessor (&RandomRectanglePositionAllocator::m_y),
251
                   MakePointerAccessor (&RandomRectanglePositionAllocator::m_y),
242
                   MakePointerChecker<RandomVariableStream> ());
252
                   MakePointerChecker<RandomVariableStream> ())
253
    .AddAttribute ("Z",
254
                   "The z coordinate of all the positions allocated.",
255
                   DoubleValue (0.0),
256
                   MakeDoubleAccessor (&RandomRectanglePositionAllocator::m_z),
257
                   MakeDoubleChecker<double> ())
258
    ;
243
  return tid;
259
  return tid;
244
}
260
}
245
261
 Lines 260-272   RandomRectanglePositionAllocator::SetY (Ptr<RandomVariableStream> y) Link Here 
260
{
276
{
261
  m_y = y;
277
  m_y = y;
262
}
278
}
279
void
280
RandomRectanglePositionAllocator::SetZ (double z)
281
{
282
  m_z = z;
283
}
263
284
264
Vector
285
Vector
265
RandomRectanglePositionAllocator::GetNext (void) const
286
RandomRectanglePositionAllocator::GetNext (void) const
266
{
287
{
267
  double x = m_x->GetValue ();
288
  double x = m_x->GetValue ();
268
  double y = m_y->GetValue ();
289
  double y = m_y->GetValue ();
269
  return Vector (x, y, 0.0);
290
  return Vector (x, y, m_z);
270
}
291
}
271
292
272
int64_t
293
int64_t
 Lines 374-379   RandomDiscPositionAllocator::GetTypeId (void) Link Here 
374
                   DoubleValue (0.0),
395
                   DoubleValue (0.0),
375
                   MakeDoubleAccessor (&RandomDiscPositionAllocator::m_y),
396
                   MakeDoubleAccessor (&RandomDiscPositionAllocator::m_y),
376
                   MakeDoubleChecker<double> ())
397
                   MakeDoubleChecker<double> ())
398
    .AddAttribute ("Z",
399
                   "The z coordinate of all the positions in the disc.",
400
                   DoubleValue (0.0),
401
                   MakeDoubleAccessor (&RandomDiscPositionAllocator::m_z),
402
                   MakeDoubleChecker<double> ())
377
  ;
403
  ;
378
  return tid;
404
  return tid;
379
}
405
}
 Lines 405-410   RandomDiscPositionAllocator::SetY (double y) Link Here 
405
{
431
{
406
  m_y = y;
432
  m_y = y;
407
}
433
}
434
void
435
RandomDiscPositionAllocator::SetZ (double z)
436
{
437
  m_z = z;
438
}
408
Vector
439
Vector
409
RandomDiscPositionAllocator::GetNext (void) const
440
RandomDiscPositionAllocator::GetNext (void) const
410
{
441
{
 Lines 413-419   RandomDiscPositionAllocator::GetNext (void) const Link Here 
413
  double x = m_x + std::cos (theta) * rho;
444
  double x = m_x + std::cos (theta) * rho;
414
  double y = m_y + std::sin (theta) * rho;
445
  double y = m_y + std::sin (theta) * rho;
415
  NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y);
446
  NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y);
416
  return Vector (x, y, 0.0);
447
  return Vector (x, y, m_z);
417
}
448
}
418
449
419
int64_t
450
int64_t
 Lines 450-455   UniformDiscPositionAllocator::GetTypeId (void) Link Here 
450
                   DoubleValue (0.0),
481
                   DoubleValue (0.0),
451
                   MakeDoubleAccessor (&UniformDiscPositionAllocator::m_y),
482
                   MakeDoubleAccessor (&UniformDiscPositionAllocator::m_y),
452
                   MakeDoubleChecker<double> ())
483
                   MakeDoubleChecker<double> ())
484
    .AddAttribute ("Z",
485
                   "The z coordinate of all the positions in the disc.",
486
                   DoubleValue (0.0),
487
                   MakeDoubleAccessor (&UniformDiscPositionAllocator::m_z),
488
                   MakeDoubleChecker<double> ())
453
  ;
489
  ;
454
  return tid;
490
  return tid;
455
}
491
}
 Lines 477-482   UniformDiscPositionAllocator::SetY (double y) Link Here 
477
{
513
{
478
  m_y = y;
514
  m_y = y;
479
}
515
}
516
void
517
UniformDiscPositionAllocator::SetZ (double z)
518
{
519
  m_z = z;
520
}
480
Vector
521
Vector
481
UniformDiscPositionAllocator::GetNext (void) const
522
UniformDiscPositionAllocator::GetNext (void) const
482
{
523
{
 Lines 491-497   UniformDiscPositionAllocator::GetNext (void) const Link Here 
491
  x += m_x;
532
  x += m_x;
492
  y += m_y;
533
  y += m_y;
493
  NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y);
534
  NS_LOG_DEBUG ("Disc position x=" << x << ", y=" << y);
494
  return Vector (x, y, 0.0);
535
  return Vector (x, y, m_z);
495
}
536
}
496
537
497
int64_t
538
int64_t
(-)a/src/mobility/model/position-allocator.h (-1 / +22 lines)
 Lines 140-145   public: Link Here 
140
   */
140
   */
141
  void SetMinY (double yMin);
141
  void SetMinY (double yMin);
142
  /**
142
  /**
143
   * \param z   the Z coordinate of all the positions allocated 
144
   */
145
  void SetZ (double z);
146
  /**
143
   * \param deltaX the x interval between two x-consecutive positions.
147
   * \param deltaX the x interval between two x-consecutive positions.
144
   */
148
   */
145
  void SetDeltaX (double deltaX);
149
  void SetDeltaX (double deltaX);
 Lines 190-195   private: Link Here 
190
  enum LayoutType m_layoutType;  //!< currently selected layout type
194
  enum LayoutType m_layoutType;  //!< currently selected layout type
191
  double m_xMin; //!< minimum boundary on x positions
195
  double m_xMin; //!< minimum boundary on x positions
192
  double m_yMin; //!< minimum boundary on y positions
196
  double m_yMin; //!< minimum boundary on y positions
197
  double m_z; //!< z coordinate of all the positions generated
193
  uint32_t m_n;  //!< number of positions to allocate on each row or column
198
  uint32_t m_n;  //!< number of positions to allocate on each row or column
194
  double m_deltaX; //!< x interval between two consecutive x positions
199
  double m_deltaX; //!< x interval between two consecutive x positions
195
  double m_deltaY; //!< y interval between two consecutive y positions
200
  double m_deltaY; //!< y interval between two consecutive y positions
 Lines 220-231   public: Link Here 
220
   * \param y pointer to a RandomVariableStream object
225
   * \param y pointer to a RandomVariableStream object
221
   */
226
   */
222
  void SetY (Ptr<RandomVariableStream> y);
227
  void SetY (Ptr<RandomVariableStream> y);
228
  /** 
229
   * \param z   the Z coordinate of all the positions allocated 
230
   */
231
  void SetZ (double z);
223
232
224
  virtual Vector GetNext (void) const;
233
  virtual Vector GetNext (void) const;
225
  virtual int64_t AssignStreams (int64_t stream);
234
  virtual int64_t AssignStreams (int64_t stream);
226
private:
235
private:
227
  Ptr<RandomVariableStream> m_x; //!< pointer to x's random variable stream
236
  Ptr<RandomVariableStream> m_x; //!< pointer to x's random variable stream
228
  Ptr<RandomVariableStream> m_y; //!< pointer to y's random variable stream
237
  Ptr<RandomVariableStream> m_y; //!< pointer to y's random variable stream
238
  double m_z; //!< z coordinate of all the positions generated
229
};
239
};
230
240
231
/**
241
/**
 Lines 301-306   public: Link Here 
301
   * \param y   the Y coordinate of the center of the disc 
311
   * \param y   the Y coordinate of the center of the disc 
302
   */
312
   */
303
  void SetY (double y);
313
  void SetY (double y);
314
  /** 
315
   * \param z   the Z coordinate of all the positions allocated 
316
   */
317
  void SetZ (double z);
304
318
305
  virtual Vector GetNext (void) const;
319
  virtual Vector GetNext (void) const;
306
  virtual int64_t AssignStreams (int64_t stream);
320
  virtual int64_t AssignStreams (int64_t stream);
 Lines 309-314   private: Link Here 
309
  Ptr<RandomVariableStream> m_rho; //!< pointer to rho's random variable stream
323
  Ptr<RandomVariableStream> m_rho; //!< pointer to rho's random variable stream
310
  double m_x; //!< x coordinate of center of disc
324
  double m_x; //!< x coordinate of center of disc
311
  double m_y; //!< y coordinate of center of disc
325
  double m_y; //!< y coordinate of center of disc
326
  double m_z;  //!< z coordinate of the disc
312
};
327
};
313
328
314
329
 Lines 317-323   private: Link Here 
317
 * \brief Allocate the positions uniformely (with constant density) randomly within a disc.
332
 * \brief Allocate the positions uniformely (with constant density) randomly within a disc.
318
 *
333
 *
319
 * UniformDiscPositionAllocator allocates the positions randomly within a disc \f$ D \f$ lying on the
334
 * UniformDiscPositionAllocator allocates the positions randomly within a disc \f$ D \f$ lying on the
320
 * plane \f$ z=0 \f$ and having center at coordinates \f$ (x,y,0) \f$
335
 * plane \f$ z\f$ and having center at coordinates \f$ (x,y,z) \f$
321
 * and radius \f$ \rho \f$. The random positions are chosen such that,
336
 * and radius \f$ \rho \f$. The random positions are chosen such that,
322
 * for any subset \f$ S \subset D \f$, the expected value of the
337
 * for any subset \f$ S \subset D \f$, the expected value of the
323
 * fraction of points which fall into \f$ S \subset D \f$ corresponds
338
 * fraction of points which fall into \f$ S \subset D \f$ corresponds
 Lines 355-360   public: Link Here 
355
   */
370
   */
356
  void SetY (double y);
371
  void SetY (double y);
357
372
373
  /** 
374
   * \param z   the Z coordinate of all the positions allocated 
375
   */
376
  void SetZ (double z);
377
358
  virtual Vector GetNext (void) const;
378
  virtual Vector GetNext (void) const;
359
  virtual int64_t AssignStreams (int64_t stream);
379
  virtual int64_t AssignStreams (int64_t stream);
360
private:
380
private:
 Lines 362-367   private: Link Here 
362
  double m_rho; //!< value of the radius of the disc
382
  double m_rho; //!< value of the radius of the disc
363
  double m_x;  //!< x coordinate of center of disc
383
  double m_x;  //!< x coordinate of center of disc
364
  double m_y;  //!< y coordinate of center of disc
384
  double m_y;  //!< y coordinate of center of disc
385
  double m_z;  //!< z coordinate of the disc
365
};
386
};
366
387
367
} // namespace ns3
388
} // namespace ns3

Return to bug 2860