Space Comps
 All Classes Files Functions Variables
Public Member Functions | List of all members
Octree Class Reference

The Octree data structure used in OctreeAlgorithm. More...

#include <octree.h>

Public Member Functions

 Octree (int levelIn, double nwfXIn, double nwfYIn, double nwfZIn, double sebXIn, double sebYIn, double sebZIn)
 Constructs a Octree object. More...
 
void clear ()
 Clears the Octree. More...
 
void split ()
 Splits the Octree into 8 octants. More...
 
int getIndex (Particle *particle)
 Gets the index of a given Particle within a Octree. More...
 
void insertToTree (Particle *particle)
 Inserts a given Particle into a Octree. More...
 
std::vector< Particle * > * getPossibleColliders (std::vector< Particle * > *colliders, Particle *particle)
 Returns a vector of Particles that may be colliding with a given Particle. More...
 

Detailed Description

The Octree data structure used in OctreeAlgorithm.

A Octree represents a cubic section of space defined in the X,Y,Z coordinate system.

Constructor & Destructor Documentation

Octree::Octree ( int  levelIn,
double  nwfXIn,
double  nwfYIn,
double  nwfZIn,
double  sebXIn,
double  sebYIn,
double  sebZIn 
)

Constructs a Octree object.

Constructs a Octree object based on the given parameters.

Parameters
levelInthe level of the Octree object within the larger tree. The head of the tree is 0 and increases with each subsequent tree.
nwXInthe X coordinate of the upper left corner of the space represented by this level of the tree.
nwYInthe Y coordinate of the upper left corner of the space represented by this level of the tree.
nwZInthe Z coordinate of the upper left corner of the space represented by this level of the tree.
seXInthe X coordinate of the bottom right corner of the space represented by this level of the tree.
seYInthe Y coordinate of the bottom right corner of the space represented by this level of the tree.
seZInthe Z coordinate of the bottom right corner of the space represented by this level of the tree.

Member Function Documentation

void Octree::clear ( )

Clears the Octree.

Clears the Octree by recursively clearing nodeParticles at each level of the tree.

int Octree::getIndex ( Particle particle)

Gets the index of a given Particle within a Octree.

Gets the index of a given Particle within a Octree. An index of -1 means the Particle cannot fit completely within any of the 8 nodes. An index of 0, 1, 2, 3, 4, 5, 6, or 7 means the particle fits completely within the cooresponding node.

Parameters
particlepointer to the Particle to get an index of.
Returns
index of a given Particle.
std::vector< Particle * > * Octree::getPossibleColliders ( std::vector< Particle * > *  colliders,
Particle particle 
)

Returns a vector of Particles that may be colliding with a given Particle.

Returns a pointer to the vector of pointers to Particles that may be colliding with a given Particle.

Parameters
colliderspointer to the vector of Particles that may be colliding with a given Particle.
ppointer to the given Particle to check against.
Returns
pointer to a vector of pointers to Particles.
void Octree::insertToTree ( Particle particle)

Inserts a given Particle into a Octree.

Inserts a given Particle into a Octree. If the Particle is inserted into a level of the Octree that has more Particles than is allowed by MAX_PARTICLES_PER_LEVEL, Split() will be called on the node.

Parameters
particlepointer to the Particle to insert into a Octree.
void Octree::split ( )

Splits the Octree into 8 octants.

Splits the Octree into 8 octants and creates a new Octree for each octant.


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