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

#include <BvhObjectCache.h>

Inheritance diagram for inet::physicalenvironment::BvhObjectCache:
inet::physicalenvironment::IObjectCache

Protected Attributes

Parameters
ModuleRefByPar< PhysicalEnvironmentphysicalEnvironment
 
unsigned int leafCapacity
 
const char * axisOrder
 

Cache

BvhTreebvhTree
 
std::vector< const IPhysicalObject * > objects
 
virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual bool insertObject (const IPhysicalObject *object)
 
 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...
 

Additional Inherited Members

Constructor & Destructor Documentation

◆ BvhObjectCache()

inet::physicalenvironment::BvhObjectCache::BvhObjectCache ( )
18  :
19  leafCapacity(0),
20  axisOrder(nullptr),
21  bvhTree(nullptr)
22 {
23 }

◆ ~BvhObjectCache()

inet::physicalenvironment::BvhObjectCache::~BvhObjectCache ( )
virtual
26 {
27  delete bvhTree;
28 }

Member Function Documentation

◆ initialize()

void inet::physicalenvironment::BvhObjectCache::initialize ( int  stage)
overrideprotectedvirtual
31 {
32  if (stage == INITSTAGE_LOCAL) {
33  physicalEnvironment.reference(this, "physicalEnvironmentModule", true);
34  leafCapacity = par("leafCapacity");
35  axisOrder = par("axisOrder");
36  }
37  else if (stage == INITSTAGE_PHYSICAL_OBJECT_CACHE) {
38  for (int i = 0; i < physicalEnvironment->getNumObjects(); i++)
39  insertObject(physicalEnvironment->getObject(i));
40  }
41 }

◆ insertObject()

bool inet::physicalenvironment::BvhObjectCache::insertObject ( const IPhysicalObject object)
protectedvirtual
44 {
45  if (bvhTree) {
46  delete bvhTree;
47  bvhTree = nullptr;
48  }
49  objects.push_back(object);
50  return true;
51 }

Referenced by initialize().

◆ numInitStages()

virtual int inet::physicalenvironment::BvhObjectCache::numInitStages ( ) const
inlineoverrideprotectedvirtual
39 { return NUM_INIT_STAGES; }

◆ visitObjects()

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.

54 {
55  if (!bvhTree)
56 #ifdef _OPENMP
57 #pragma omp critical
58 #endif
59  bvhTree = new BvhTree(physicalEnvironment->getSpaceMin(), physicalEnvironment->getSpaceMax(), objects, 0, objects.size() - 1, BvhTree::Axis(axisOrder), leafCapacity);
60  bvhTree->lineSegmentQuery(lineSegment, visitor);
61 }

Member Data Documentation

◆ axisOrder

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

Referenced by initialize(), and visitObjects().

◆ bvhTree

BvhTree* inet::physicalenvironment::BvhObjectCache::bvhTree
mutableprotected

◆ leafCapacity

unsigned int inet::physicalenvironment::BvhObjectCache::leafCapacity
protected

Referenced by initialize(), and visitObjects().

◆ objects

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

Referenced by insertObject(), and visitObjects().

◆ physicalEnvironment

ModuleRefByPar<PhysicalEnvironment> inet::physicalenvironment::BvhObjectCache::physicalEnvironment
protected

Referenced by initialize(), and visitObjects().


The documentation for this class was generated from the following files:
inet::physicalenvironment::BvhObjectCache::bvhTree
BvhTree * bvhTree
Definition: BvhObjectCache.h:34
inet::physicalenvironment::BvhObjectCache::insertObject
virtual bool insertObject(const IPhysicalObject *object)
Definition: BvhObjectCache.cc:43
inet::physicalenvironment::BvhObjectCache::objects
std::vector< const IPhysicalObject * > objects
Definition: BvhObjectCache.h:35
inet::INITSTAGE_PHYSICAL_OBJECT_CACHE
INET_API InitStage INITSTAGE_PHYSICAL_OBJECT_CACHE
Initialization of the cache of physical objects present in the physical environment.
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::physicalenvironment::BvhObjectCache::leafCapacity
unsigned int leafCapacity
Definition: BvhObjectCache.h:28
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::physicalenvironment::BvhObjectCache::axisOrder
const char * axisOrder
Definition: BvhObjectCache.h:29
inet::physicalenvironment::BvhObjectCache::physicalEnvironment
ModuleRefByPar< PhysicalEnvironment > physicalEnvironment
Definition: BvhObjectCache.h:27
inet::BvhTree::lineSegmentQuery
void lineSegmentQuery(const LineSegment &lineSegment, const IVisitor *visitor) const
Definition: BvhTree.cc:99