INET Framework for OMNeT++/OMNEST
inet::physicalenvironment::GridObjectCache Class Reference

#include <GridObjectCache.h>

Inheritance diagram for inet::physicalenvironment::GridObjectCache:
inet::physicalenvironment::IObjectCache

Public Member Functions

 GridObjectCache ()
 
virtual ~GridObjectCache ()
 
virtual void visitObjects (const IVisitor *visitor, const LineSegment &lineSegment) const override
 Calls the visitor with at least all physical objects that intersect with the provided line segment. More...
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual bool insertObject (const IPhysicalObject *object)
 

Protected Attributes

Parameters
PhysicalEnvironmentphysicalEnvironment
 
Cache
SpatialGridgrid
 

Constructor & Destructor Documentation

inet::physicalenvironment::GridObjectCache::GridObjectCache ( )
27  :
28  physicalEnvironment(nullptr),
29  grid(nullptr)
30 {
31 }
PhysicalEnvironment * physicalEnvironment
Definition: GridObjectCache.h:36
SpatialGrid * grid
Definition: GridObjectCache.h:41
inet::physicalenvironment::GridObjectCache::~GridObjectCache ( )
virtual
34 {
35  delete grid;
36 }
SpatialGrid * grid
Definition: GridObjectCache.h:41

Member Function Documentation

void inet::physicalenvironment::GridObjectCache::initialize ( int  stage)
overrideprotectedvirtual
39 {
40  if (stage == INITSTAGE_LOCAL)
41  physicalEnvironment = getModuleFromPar<PhysicalEnvironment>(par("physicalEnvironmentModule"), this);
42  else if (stage == INITSTAGE_PHYSICAL_ENVIRONMENT_2) {
43  double cellSizeX = par("cellSizeX");
44  double cellSizeY = par("cellSizeY");
45  double cellSizeZ = par("cellSizeZ");
46  const Coord spaceMin = physicalEnvironment->getSpaceMin();
47  const Coord spaceMax = physicalEnvironment->getSpaceMax();
48  const Coord spaceSize = spaceMax - spaceMin;
49  if (std::isnan(cellSizeX))
50  cellSizeX = spaceSize.x / par("cellCountX").doubleValue();
51  if (std::isnan(cellSizeY))
52  cellSizeY = spaceSize.y / par("cellCountY").doubleValue();
53  if (std::isnan(cellSizeZ))
54  cellSizeZ = spaceSize.z / par("cellCountZ").doubleValue();
55  Coord voxelSizes(cellSizeX, cellSizeY, cellSizeZ);
56  grid = new SpatialGrid(voxelSizes, spaceMin, spaceMax);
57  for (int i = 0; i < physicalEnvironment->getNumObjects(); i++)
59  }
60 }
PhysicalEnvironment * physicalEnvironment
Definition: GridObjectCache.h:36
Additional physical environment initializations that depend on the previous stage.
Definition: InitStages.h:47
virtual bool insertObject(const IPhysicalObject *object)
Definition: GridObjectCache.cc:62
virtual const Coord & getSpaceMax() const override
Definition: PhysicalEnvironment.h:93
SpatialGrid * grid
Definition: GridObjectCache.h:41
virtual int getNumObjects() const override
Definition: PhysicalEnvironment.h:97
Local initializations.
Definition: InitStages.h:35
virtual const Coord & getSpaceMin() const override
Definition: PhysicalEnvironment.h:92
double x
Definition: Coord.h:49
virtual const PhysicalObject * getObject(int index) const override
Definition: PhysicalEnvironment.h:98
bool inet::physicalenvironment::GridObjectCache::insertObject ( const IPhysicalObject object)
protectedvirtual

Referenced by initialize().

63 {
64  Coord pos = object->getPosition();
65  Coord boundingBoxSize = object->getShape()->computeBoundingBoxSize();
66  // TODO: avoid dynamic cast
67  grid->insertObject(dynamic_cast<const cObject *>(object), pos, boundingBoxSize);
68  return true;
69 }
SpatialGrid * grid
Definition: GridObjectCache.h:41
bool insertObject(const cObject *object, const Coord &pos, const Coord &boundingBoxSize)
Definition: SpatialGrid.cc:22
virtual int inet::physicalenvironment::GridObjectCache::numInitStages ( ) const
inlineoverrideprotectedvirtual
45 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::physicalenvironment::GridObjectCache::visitObjects ( const IVisitor visitor,
const LineSegment lineSegment 
) const
overridevirtual

Calls the visitor with at least all physical objects that intersect with the provided line segment.

Implements inet::physicalenvironment::IObjectCache.

72 {
73  grid->lineSegmentQuery(lineSegment, visitor);
74 }
SpatialGrid * grid
Definition: GridObjectCache.h:41
void lineSegmentQuery(const LineSegment &lineSegment, const IVisitor *visitor) const
Definition: SpatialGrid.cc:107

Member Data Documentation

SpatialGrid* inet::physicalenvironment::GridObjectCache::grid
protected
PhysicalEnvironment* inet::physicalenvironment::GridObjectCache::physicalEnvironment
protected

Referenced by initialize().


The documentation for this class was generated from the following files: