The SKIRT project
advanced radiative transfer for astrophysics
Public Member Functions | List of all members
OctTreeNode Class Reference

#include <OctTreeNode.hpp>

Inheritance diagram for OctTreeNode:
Inheritance graph
[legend]

Public Member Functions

void addNeighbors () override
 
TreeNodechild (Vec r) override
 
void createChildren (int id) override
 
 TreeNode (const Box &extent)
 
 TreeNode (TreeNode *parent, int id, const Box &extent)
 
- Public Member Functions inherited from TreeNode
 TreeNode (const Box &extent)
 
 TreeNode (TreeNode *parent, int id, const Box &extent)
 
virtual ~TreeNode ()
 
void addNeighbor (Wall wall, TreeNode *node)
 
virtual void addNeighbors ()=0
 
virtual TreeNodechild (Vec r)=0
 
const vector< TreeNode * > & children () const
 
virtual void createChildren (int id)=0
 
void deleteNeighbor (Wall wall, TreeNode *node)
 
int id () const
 
bool isChildless () const
 
TreeNodeleafChild (Vec r)
 
int level () const
 
const TreeNodeneighbor (Wall wall, Vec r) const
 
const vector< TreeNode * > & neighbors (Wall wall) const
 
TreeNodeparent ()
 
void sortNeighbors ()
 
void subdivide (vector< TreeNode * > &nodev)
 
- Public Member Functions inherited from Box
 Box ()
 
 Box (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
 
 Box (Vec rmin, Vec rmax)
 
void cellIndices (int &i, int &j, int &k, Vec r, int nx, int ny, int nz) const
 
Vec center () const
 
bool contains (const Box &box) const
 
bool contains (double x, double y, double z) const
 
bool contains (Vec r) const
 
double diagonal () const
 
const Boxextent () const
 
void extent (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const
 
Vec fracPos (double xfrac, double yfrac, double zfrac) const
 
Vec fracPos (int xd, int yd, int zd, int xn, int yn, int zn) const
 
bool intersects (const Box &box) const
 
bool intersects (Vec r, const Vec k, double &smin, double &smax) const
 
bool intersects (Vec rc, double r) const
 
Vec rmax () const
 
Vec rmin () const
 
double volume () const
 
Vec widths () const
 
double xmax () const
 
double xmin () const
 
double xwidth () const
 
double ymax () const
 
double ymin () const
 
double ywidth () const
 
double zmax () const
 
double zmin () const
 
double zwidth () const
 

Additional Inherited Members

- Public Types inherited from TreeNode
enum  Wall {
  BACK , FRONT , LEFT , RIGHT ,
  BOTTOM , TOP
}
 
- Static Public Member Functions inherited from TreeNode
static void makeNeighbors (Wall wall1, TreeNode *node1, TreeNode *node2)
 
- Protected Member Functions inherited from TreeNode
void addChild (TreeNode *child)
 
TreeNodechildAt (int l)
 
- Protected Member Functions inherited from Box
void setExtent (const Box &extent)
 
void setExtent (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
 

Detailed Description

OctTreeNode is a TreeNode subclass that represents nodes in an octtree, where each subsequent level subdivides a node into eight equal portions (i.e. using a regular geometric subdivision scheme).

Member Function Documentation

◆ addNeighbors()

void OctTreeNode::addNeighbors ( )
overridevirtual

This function adds the relevant neighbors to a node with children (the function does nothing if the node doesn't have any children). It considers internal neighbors (each of the 8 children has 3 neighbors among its siblings) as well as the neighbors of the parent node (i.e. this node). These external neighbors are distributed among the children depending on the geometry; note that a particular external neighbor may be neighbor to multiple children.

Implements TreeNode.

◆ child()

TreeNode * OctTreeNode::child ( Vec  r)
overridevirtual

This function returns a pointer to the node's child that contains the specified point. More accurately, it returns the child corresponding to the octant that contains the specified point relative to the node's central division point. If the specified point is inside the node, then it will also be inside the returned child. This function crashes if the node is childless.

Implements TreeNode.

◆ createChildren()

void OctTreeNode::createChildren ( int  id)
overridevirtual

This function creates eight new equally sized subnodes subdividing the node at the geometric center, and adds these new nodes as its own child nodes. The children are assigned consecutive integer identifiers, starting with the identifier specified as an argument to this function. A node does NOT take ownership of its children, so the caller is responsible for deleting the child nodes when they are no longer needed. Invoking this function on a node that already has children results in undefined behavior.

Implements TreeNode.

◆ TreeNode() [1/2]

TreeNode::TreeNode ( const Box extent)

This constructor creates a new octtree node with the specified parent node, identifier, and spatial extent. The constructor sets the level of the new node to be one higher than the level of the parent. If the pointer to the parent is null, the level of the new node is zero.

◆ TreeNode() [2/2]

TreeNode::TreeNode ( TreeNode parent,
int  id,
const Box extent 
)

This constructor creates a new octtree node with the specified parent node, identifier, and spatial extent. The constructor sets the level of the new node to be one higher than the level of the parent. If the pointer to the parent is null, the level of the new node is zero.


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