The SKIRT project
advanced radiative transfer for astrophysics
BinTreeNode Class Reference

#include <BinTreeNode.hpp>

Inheritance diagram for BinTreeNode:

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)
const vector< TreeNode * > & children () const
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
void extend (const Box &box)
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

BinTreeNode is a TreeNode subclass that represents nodes in a binary tree, where each subsequent level subdivides a node into two equal portions along one of the coordinate planes. The class implements an alternating subdivision scheme, i.e. the nodes are alternatively divided perpendicular to each of the three coordinate axes when descending the tree.

Member Function Documentation

◆ addNeighbors()

void BinTreeNode::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 among the children 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 * BinTreeNode::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 half-space that contains the specified point relative to the node's central division plane. If the specified point is inside the node, then it will also be inside the returned child. Invoking this function on a childless node results in undefined behavior.

Implements TreeNode.

◆ createChildren()

void BinTreeNode::createChildren ( int id)
overridevirtual

This function creates two new nodes subdividing the node at its geometric center along a plane perpendicular to one of the coordinate axes, depending on the node's level in the tree. The splitting direction is selected as the modulo of the node's level, with (0=x, 1=y, 2=z), so that the nodes are alternatively divided along each of the axes when descending the tree.

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 binary tree 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 binary tree 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: