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

#include <BVHObjectCache.h>

Inheritance diagram for inet::physicalenvironment::BVHObjectCache:
inet::physicalenvironment::IObjectCache

Public Member Functions

 BVHObjectCache ()
 
virtual ~BVHObjectCache ()
 
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
 
unsigned int leafCapacity
 
const char * axisOrder
 
Cache
BVHTreebvhTree
 
std::vector< const IPhysicalObject * > objects
 

Constructor & Destructor Documentation

inet::physicalenvironment::BVHObjectCache::BVHObjectCache ( )
27  :
28  physicalEnvironment(nullptr),
29  leafCapacity(0),
30  axisOrder(nullptr),
31  bvhTree(nullptr)
32 {
33 }
unsigned int leafCapacity
Definition: BVHObjectCache.h:37
const char * axisOrder
Definition: BVHObjectCache.h:38
BVHTree * bvhTree
Definition: BVHObjectCache.h:43
PhysicalEnvironment * physicalEnvironment
Definition: BVHObjectCache.h:36
inet::physicalenvironment::BVHObjectCache::~BVHObjectCache ( )
virtual
36 {
37  delete bvhTree;
38 }
BVHTree * bvhTree
Definition: BVHObjectCache.h:43

Member Function Documentation

void inet::physicalenvironment::BVHObjectCache::initialize ( int  stage)
overrideprotectedvirtual
41 {
42  if (stage == INITSTAGE_LOCAL)
43  {
44  physicalEnvironment = getModuleFromPar<PhysicalEnvironment>(par("physicalEnvironmentModule"), this);
45  leafCapacity = par("leafCapacity");
46  axisOrder = par("axisOrder");
47  }
48  else if (stage == INITSTAGE_PHYSICAL_ENVIRONMENT_2)
49  {
50  for (int i = 0; i < physicalEnvironment->getNumObjects(); i++)
52  }
53 }
Additional physical environment initializations that depend on the previous stage.
Definition: InitStages.h:47
unsigned int leafCapacity
Definition: BVHObjectCache.h:37
const char * axisOrder
Definition: BVHObjectCache.h:38
virtual bool insertObject(const IPhysicalObject *object)
Definition: BVHObjectCache.cc:55
virtual int getNumObjects() const override
Definition: PhysicalEnvironment.h:97
Local initializations.
Definition: InitStages.h:35
PhysicalEnvironment * physicalEnvironment
Definition: BVHObjectCache.h:36
virtual const PhysicalObject * getObject(int index) const override
Definition: PhysicalEnvironment.h:98
bool inet::physicalenvironment::BVHObjectCache::insertObject ( const IPhysicalObject object)
protectedvirtual

Referenced by initialize().

56 {
57  if (bvhTree) {
58  delete bvhTree;
59  bvhTree = nullptr;
60  }
61  objects.push_back(object);
62  return true;
63 }
std::vector< const IPhysicalObject * > objects
Definition: BVHObjectCache.h:44
BVHTree * bvhTree
Definition: BVHObjectCache.h:43
virtual int inet::physicalenvironment::BVHObjectCache::numInitStages ( ) const
inlineoverrideprotectedvirtual
48 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::physicalenvironment::BVHObjectCache::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.

66 {
67  if (!bvhTree)
68  bvhTree = new BVHTree(physicalEnvironment->getSpaceMin(), physicalEnvironment->getSpaceMax(), objects, 0, objects.size() - 1, BVHTree::Axis(axisOrder), leafCapacity);
69  bvhTree->lineSegmentQuery(lineSegment, visitor);
70 }
std::vector< const IPhysicalObject * > objects
Definition: BVHObjectCache.h:44
void lineSegmentQuery(const LineSegment &lineSegment, const IVisitor *visitor) const
Definition: BVHTree.cc:108
unsigned int leafCapacity
Definition: BVHObjectCache.h:37
const char * axisOrder
Definition: BVHObjectCache.h:38
virtual const Coord & getSpaceMax() const override
Definition: PhysicalEnvironment.h:93
virtual const Coord & getSpaceMin() const override
Definition: PhysicalEnvironment.h:92
BVHTree * bvhTree
Definition: BVHObjectCache.h:43
PhysicalEnvironment * physicalEnvironment
Definition: BVHObjectCache.h:36

Member Data Documentation

const char* inet::physicalenvironment::BVHObjectCache::axisOrder
protected

Referenced by initialize(), and visitObjects().

BVHTree* inet::physicalenvironment::BVHObjectCache::bvhTree
mutableprotected
unsigned int inet::physicalenvironment::BVHObjectCache::leafCapacity
protected

Referenced by initialize(), and visitObjects().

std::vector<const IPhysicalObject *> inet::physicalenvironment::BVHObjectCache::objects
mutableprotected

Referenced by insertObject(), and visitObjects().

PhysicalEnvironment* inet::physicalenvironment::BVHObjectCache::physicalEnvironment
protected

Referenced by initialize(), and visitObjects().


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