Node Class Reference

#include <Node.h>

Collaboration diagram for Node:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Node ()
 Node (const std::vector< Primitive * > primitives)
 ~Node ()
Nodeleft () const
Noderight () const
void setLeftRight (Node *newleft, Node *newright)
Axis splitAxis () const
void setSplitAxis (Axis splitaxis)
float splitPlane () const
void setSplitPlane (float plane)
void add (Primitive *primitive)
Primitiveprimitive (unsigned int index) const
void clear_primitives ()
unsigned int primitives_count () const
bool isLeafNode () const
bool leafIntersect (Ray &ray, float min, float max) const
void nearFar (const Ray &r, Node *&near, Node *&far) const
float distanceToSplitPlane (const Ray &ray) const

Private Attributes

Axis mSplitAxis
 Splitting axis.
float mSplitPlane
 Splitting plane position.
NodemLeft
 Left child node.
NodemRight
 Right child node.
std::vector< Primitive * > mPrimitives
 Primitives within this node.

Detailed Description

Subclass representing a node in the tree

Author:
Alex Busenius

Definition at line 19 of file Node.h.


Constructor & Destructor Documentation

Node::Node (  )  [inline]

Construct empty leaf node

Definition at line 24 of file Node.h.

Node::Node ( const std::vector< Primitive * >  primitives  )  [inline]

Construct a node with given primitives

Parameters:
primitives Primitives list

Definition at line 37 of file Node.h.

Node::~Node (  )  [inline]

Release used memory

Definition at line 48 of file Node.h.

References mLeft, and mRight.


Member Function Documentation

Node* Node::left (  )  const [inline]

Get left child

Definition at line 56 of file Node.h.

References mLeft.

Referenced by SimpleKDTree::buildTree(), SAHKDTree::buildTree(), and SAHKDTree::classifyAndSplice().

Node* Node::right (  )  const [inline]

Get right child

Definition at line 63 of file Node.h.

References mRight.

Referenced by SimpleKDTree::buildTree(), SAHKDTree::buildTree(), and SAHKDTree::classifyAndSplice().

void Node::setLeftRight ( Node newleft,
Node newright 
) [inline]

Set both children

Parameters:
newleft New left child, must be not NULL
newright New right child, must be not NULL

Definition at line 73 of file Node.h.

References mLeft, and mRight.

Referenced by SimpleKDTree::buildTree(), and SAHKDTree::buildTree().

Axis Node::splitAxis (  )  const [inline]

Get Splitting axis

Definition at line 84 of file Node.h.

References mSplitAxis.

Referenced by SimpleKDTree::buildTree(), and SimpleKDTree::setBestSplit().

void Node::setSplitAxis ( Axis  splitaxis  )  [inline]

Set splitting axis

Definition at line 91 of file Node.h.

References mSplitAxis.

Referenced by SimpleKDTree::buildTree(), SAHKDTree::buildTree(), and SimpleKDTree::setBestSplit().

float Node::splitPlane (  )  const [inline]

Get splitting plane location

Definition at line 98 of file Node.h.

References mSplitPlane.

Referenced by SimpleKDTree::buildTree().

void Node::setSplitPlane ( float  plane  )  [inline]

Set splitting plane location

Definition at line 105 of file Node.h.

References mSplitPlane.

Referenced by SAHKDTree::buildTree(), and SimpleKDTree::setBestSplit().

void Node::add ( Primitive primitive  )  [inline]

Add a primitive to list

Parameters:
primitive New primitive to add

Definition at line 114 of file Node.h.

References mPrimitives, and primitive().

Referenced by SimpleKDTree::buildTree(), and SAHKDTree::classifyAndSplice().

Primitive* Node::primitive ( unsigned int  index  )  const [inline]

Get a primitive by index

Parameters:
index Primitive intex in the list
Returns:
Primitive

Definition at line 124 of file Node.h.

References mPrimitives.

Referenced by add(), SimpleKDTree::buildTree(), SAHKDTree::classifyAndSplice(), and SimpleKDTree::setBestSplit().

void Node::clear_primitives (  )  [inline]

Clear primitives list

Definition at line 131 of file Node.h.

References mPrimitives.

Referenced by SimpleKDTree::buildTree(), and SAHKDTree::buildTree().

unsigned int Node::primitives_count (  )  const [inline]

Get number of primitives in the list

Returns:
primitives number

Definition at line 140 of file Node.h.

References mPrimitives.

Referenced by SimpleKDTree::buildTree(), SAHKDTree::classifyAndSplice(), SAHKDTree::findBestPlane(), SimpleKDTree::setBestSplit(), SAHKDTree::terminate(), and KDTree::terminate().

bool Node::isLeafNode (  )  const [inline]

Check whenever the node is a leaf node

Definition at line 147 of file Node.h.

References mSplitAxis, and NO_AXIS.

Referenced by KDTree::intersect().

bool Node::leafIntersect ( Ray ray,
float  min,
float  max 
) const

Check if ray intersects any object in this node (leaf node). Store the intersection parameters (t and hit) in the ray structure

Parameters:
ray Ray to intersect with
min Nearest distance to bounding box
max Furthest distance to bounding box
Returns:
true if intersection is found

Definition at line 14 of file Node.cpp.

References EPSILON, mPrimitives, Ray::setHit(), and Ray::t().

Referenced by KDTree::intersect().

void Node::nearFar ( const Ray r,
Node *&  near,
Node *&  far 
) const [inline]

Sorts children nodes as near and far. Near child is the one which contains the ray origin

Parameters:
r Ray to test
near Node that will become the near one
far Node that will become the far one

Definition at line 169 of file Node.h.

References mLeft, mRight, mSplitAxis, mSplitPlane, and Ray::org().

Referenced by KDTree::intersect().

float Node::distanceToSplitPlane ( const Ray ray  )  const [inline]

Compute distance to the splitting plane

Parameters:
ray Ray to calculate distance for

Definition at line 187 of file Node.h.

References Ray::dir(), mSplitAxis, mSplitPlane, and Ray::org().

Referenced by KDTree::intersect().


Member Data Documentation

Axis Node::mSplitAxis [private]

Splitting axis.

Definition at line 194 of file Node.h.

Referenced by distanceToSplitPlane(), isLeafNode(), nearFar(), setSplitAxis(), and splitAxis().

float Node::mSplitPlane [private]

Splitting plane position.

Definition at line 197 of file Node.h.

Referenced by distanceToSplitPlane(), nearFar(), setSplitPlane(), and splitPlane().

Node* Node::mLeft [private]

Left child node.

Definition at line 200 of file Node.h.

Referenced by left(), nearFar(), setLeftRight(), and ~Node().

Node* Node::mRight [private]

Right child node.

Definition at line 203 of file Node.h.

Referenced by nearFar(), right(), setLeftRight(), and ~Node().

std::vector<Primitive *> Node::mPrimitives [private]

Primitives within this node.

Definition at line 206 of file Node.h.

Referenced by add(), clear_primitives(), leafIntersect(), primitive(), and primitives_count().


The documentation for this class was generated from the following files:
Generated on Fri Feb 1 00:02:20 2008 for Grayfall by  doxygen 1.5.1