GOAT (Geometrical optics application tool) 0.1
Loading...
Searching...
No Matches
GOAT::raytracing::Octree< T > Class Template Reference

This template class is used for internal purposes and represents an octree. More...

#include <octree.h>

Public Member Functions

void createChilds ()
 Creates the childs of the Octree and calculates the bounding boxes.
void createTree (int maxRecursions=1, int rek=0)
 Prepare the tree with recursion depth maxRecursions.
void delAllChilds ()
 Delete all children of the Octree.
void delChild (int i)
 Delete the i-th child of the Octree.
void delElements ()
 Deletes all elements.
 Octree ()
 Octree (const Octree &O)
void setBoundingBox (maths::Vector< double > MP, maths::Vector< double > d)
 Set the bounding box of the Octree The bounding box is a circumscribing cuboid with center MP and the side lengths described by the components of d.
void setRecursiondepth (int max_recursions)
void trimOctree ()
 Trims the tree, i.e. removing all empty childs.
void trimOctree (int rek)
 ~Octree ()

Public Attributes

Box BBox
std::vector< std::unique_ptr< Octree< T > > > child
std::vector< T > Element
bool isLeaf
 Sign wether the Octree is a leaf or not.
int MAX_RECURSIONS
size_t nChilds
size_t nElements
Octree< T > * parent

Detailed Description

template<class T>
class GOAT::raytracing::Octree< T >

This template class is used for internal purposes and represents an octree.

This class is mainly used together with the surface class. When searching the intersection point of a ray with a surface described by a large number of triangles, one has to test the ray against all triangles. This is often very time consuming. Therefore we used an octree algorithm. In this case the object is circumscribed by a box. In a first step, the intersection between the ray and this box is tested. If the ray hits this bounding box, the box is subdivided into 8 sub-boxes (therefore the name octree). The next task is to find the sub-box with the nearest intersection point. Then, this box is one again subdivided in another 8 boxes. This procedure is repeated several times (according to the number MAX_RECURSIONS). Then, only the triangles on the last sub-box are tested against the ray. Depending on the total number of triangles on the surface, this procedure can safe a lot of time. The Octree class is used to store the triangles in a tree-like structure, so the triangles within one box can be easily found. Since this class is a template, in principal it can be used for different purposes. The Octree structure is recursive. That means each Octree is a part of the whole tree. It contains up to 8 children (it can have less then 8, if some of the boxes are empty) and one parent Octree. The last Octree, i.e. an Octree with no children, is called a leaf.

Definition at line 27 of file octree.h.

Constructor & Destructor Documentation

◆ Octree() [1/2]

template<class T>
GOAT::raytracing::Octree< T >::Octree ( )
inline

Definition at line 31 of file octree.h.

◆ Octree() [2/2]

template<class T>
GOAT::raytracing::Octree< T >::Octree ( const Octree< T > & O)

Definition at line 72 of file octree.h.

◆ ~Octree()

template<class T>
GOAT::raytracing::Octree< T >::~Octree ( )
inline

Definition at line 44 of file octree.h.

Member Function Documentation

◆ createChilds()

template<class T>
void GOAT::raytracing::Octree< T >::createChilds ( )

Creates the childs of the Octree and calculates the bounding boxes.

Definition at line 153 of file octree.h.

◆ createTree()

template<class T>
void GOAT::raytracing::Octree< T >::createTree ( int maxRecursions = 1,
int rek = 0 )

Prepare the tree with recursion depth maxRecursions.

Definition at line 187 of file octree.h.

◆ delAllChilds()

template<class T>
void GOAT::raytracing::Octree< T >::delAllChilds ( )

Delete all children of the Octree.

Definition at line 142 of file octree.h.

◆ delChild()

template<class T>
void GOAT::raytracing::Octree< T >::delChild ( int i)

Delete the i-th child of the Octree.

Definition at line 148 of file octree.h.

◆ delElements()

template<class T>
void GOAT::raytracing::Octree< T >::delElements ( )

Deletes all elements.

Definition at line 90 of file octree.h.

◆ setBoundingBox()

template<class T>
void GOAT::raytracing::Octree< T >::setBoundingBox ( maths::Vector< double > MP,
maths::Vector< double > d )

Set the bounding box of the Octree The bounding box is a circumscribing cuboid with center MP and the side lengths described by the components of d.

Parameters
MPCenter of the bounding box
dVector, where each component is the corresponding side length

Definition at line 202 of file octree.h.

◆ setRecursiondepth()

template<class T>
void GOAT::raytracing::Octree< T >::setRecursiondepth ( int max_recursions)

Definition at line 207 of file octree.h.

◆ trimOctree() [1/2]

template<class T>
void GOAT::raytracing::Octree< T >::trimOctree ( )

Trims the tree, i.e. removing all empty childs.

Definition at line 98 of file octree.h.

◆ trimOctree() [2/2]

template<class T>
void GOAT::raytracing::Octree< T >::trimOctree ( int rek)

Definition at line 104 of file octree.h.

Member Data Documentation

◆ BBox

template<class T>
Box GOAT::raytracing::Octree< T >::BBox

Definition at line 69 of file octree.h.

◆ child

template<class T>
std::vector<std::unique_ptr<Octree<T> > > GOAT::raytracing::Octree< T >::child

Definition at line 65 of file octree.h.

◆ Element

template<class T>
std::vector<T> GOAT::raytracing::Octree< T >::Element

Definition at line 66 of file octree.h.

◆ isLeaf

template<class T>
bool GOAT::raytracing::Octree< T >::isLeaf

Sign wether the Octree is a leaf or not.

Definition at line 30 of file octree.h.

◆ MAX_RECURSIONS

template<class T>
int GOAT::raytracing::Octree< T >::MAX_RECURSIONS

Definition at line 68 of file octree.h.

◆ nChilds

template<class T>
size_t GOAT::raytracing::Octree< T >::nChilds

Definition at line 67 of file octree.h.

◆ nElements

template<class T>
size_t GOAT::raytracing::Octree< T >::nElements

Definition at line 67 of file octree.h.

◆ parent

template<class T>
Octree<T>* GOAT::raytracing::Octree< T >::parent

Definition at line 63 of file octree.h.


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