AggregPacking
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
octree::OctreeNode< T > Class Template Reference

Class representing octree node. More...

#include <octree.hpp>

Public Member Functions

 ~OctreeNode ()
 Destructor.
 
bool operator== (const OctreeNode &other)
 Equality operator, intended for Python.
 
bool operator!= (const OctreeNode &other)
 Inequality operator, intended for Python.
 
double getX ()
 Getter for x coordinate.
 
double getY ()
 Getter for y coordinate.
 
double getZ ()
 Getter for z coordinate.
 
double getSize ()
 Getter for size.
 
int getLevel ()
 Getter for level.
 
int getNumber ()
 Getter for number.
 
const vector< T > & getData () const
 Getter for data (by const reference)
 
vector< T > & getData ()
 Getter for data (by non-const reference)
 
const OctreeNode ** getChildren () const
 Getter for children (by const pointer to pointer)
 
vector< OctreeNode * > * py_getChildren ()
 Getter for children (as a vector, intended for Python)
 
OctreeNodegetParent ()
 Getter for parent (by pointer)
 
const OctreeNodegetParent () const
 Getter for parent (by const pointer)
 
bool isRoot () const
 Returns if receiver is root or not.
 
bool isLeaf () const
 Returns if receiver is leaf or not.
 
void addData (const T &data)
 Adds data to receiver or its children. Determines x,y,z and size from given data.
 
void addData (const T &data, double x, double y, double z, double size)
 Adds data to receiver or its children. x,y,z and size are given.
 
bool containsEntireBox (double x, double y, double z, double size) const
 Returns if receiver contains entirely given box or not. More...
 
bool containsEntireBox (const T &o) const
 Returns if receiver contains entirely axis aligned box made around given object.
 
int getChildrenIntersectingBox (double x, double y, double z, double size) const
 Returns children intersecting given box. More...
 
int getChildrenIntersectingBox (const T &o) const
 Returns children of receiver receiver intersecting axis aligned box made around given object.
 
vector< OctreeNode * > * py_getChildrenIntersectingBox (double x, double y, double z, double size) const
 Returns vector of children intersecting box, intended for Python.
 
vector< OctreeNode * > * py_getChildrenIntersectingBox (const T &o) const
 Returns vector of children intersecting box, intended for Python.
 
OctreeNodegetRoot ()
 Getter for root (by pointer)
 
const OctreeNodegetRoot () const
 Getter for root (by const pointer)
 
OctreeNodenext () const
 Returns next node. More...
 
void getPotentialNeighbors (vector< T > &answer, double x, double y, double z, double size) const
 returns vector of objects from receiver and its children More...
 
void getPotentialNeighbors (vector< T > &answer, const T &o) const
 returns vector of objects from receiver, its neighbors and their children More...
 
vector< T > * py_getPotentialNeighbors (double x, double y, double z, double size) const
 Returns new vector of potential neighbors, intended for Python.
 
vector< T > * py_getPotentialNeighbors (const T &o) const
 Returns new vector of potential neighbors, intended for Python.
 

Static Public Member Functions

static bool bitFlag2bool (int flag, int index)
 Auxiliary function to extract indexed value from bitmask flag. More...
 

Private Member Functions

 OctreeNode (double x, double y, double z, OctreeNode &parent, int number)
 Constructor, used by a parent node. More...
 
 OctreeNode (double x, double y, double z, double size)
 Constructor to create root node. More...
 
void divide (int depth)
 Divides receiver until defined depth. More...
 

Private Attributes

double x
 x coordinate
 
double y
 y coordinate
 
double z
 z coordinate
 
OctreeNode ** children
 Child nodes.
 
vector< T > data
 Vector of data belonging to the node.
 
OctreeNodeparent
 Parent node.
 
int level
 level of the node
 
double size
 Dimension of the node.
 
int number
 Number of the node.
 

Friends

void Octree (double x, double y, double z, double size)
 Friend to enable Octree build.
 

Detailed Description

template<class T>
class octree::OctreeNode< T >

Class representing octree node.

Constructor & Destructor Documentation

template<class T >
octree::OctreeNode< T >::OctreeNode ( double  x,
double  y,
double  z,
OctreeNode< T > &  parent,
int  number 
)
private

Constructor, used by a parent node.

Parameters
xx coordinate
yy coordinate
zz coordinate
parentparent node
numbernumber of the node
template<class T >
octree::OctreeNode< T >::OctreeNode ( double  x,
double  y,
double  z,
double  size 
)
private

Constructor to create root node.

Parameters
xx coordinate
yy coordinate
zz coordinate
sizesize of the node

Member Function Documentation

template<class T>
static bool octree::OctreeNode< T >::bitFlag2bool ( int  flag,
int  index 
)
inlinestatic

Auxiliary function to extract indexed value from bitmask flag.

Parameters
flagbitmask flag
indexindex to check
template<class T >
bool octree::OctreeNode< T >::containsEntireBox ( double  x,
double  y,
double  z,
double  size 
) const

Returns if receiver contains entirely given box or not.

Parameters
xx coordinate of box center
yy coordinate of box center
zz coordinate of box center
sizesize fo the box
template<class T >
void octree::OctreeNode< T >::divide ( int  depth)
private

Divides receiver until defined depth.

Parameters
depthdefined depth (number of levels) of the division
template<class T >
int octree::OctreeNode< T >::getChildrenIntersectingBox ( double  x,
double  y,
double  z,
double  size 
) const

Returns children intersecting given box.

Parameters
xx coordinate of box center
yy coordinate of box center
zz coordinate of box center
sizesize fo the box
Returns
bitmask. For example 0b00100101, means that 1st, 3rd and 6th children intersects box, the others not
template<class T>
void octree::OctreeNode< T >::getPotentialNeighbors ( vector< T > &  answer,
double  x,
double  y,
double  z,
double  size 
) const

returns vector of objects from receiver and its children

Parameters
answerresulting vetor of objects, potential neighbors
xx coordinate of given object
yy coordinate of given object
zz coordinate of given object
sizesize of given object
template<class T>
void octree::OctreeNode< T >::getPotentialNeighbors ( vector< T > &  answer,
const T &  o 
) const
inline

returns vector of objects from receiver, its neighbors and their children

Parameters
answerresulting vetor of objects, potential neighbors
ogiven object
template<class T >
OctreeNode< T > * octree::OctreeNode< T >::next ( ) const

Returns next node.

In this order:

  • if receiver has children, return its first child
  • if receiver is root and has no children, return nullptr
  • if receiver is not the last child of its parent, return its next sibling
  • find receiver's ancestor, which is not the last child of its parent. If such ancestor is root, return nullptr. Else return next sibling of this ancestor

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