KDTree::KDNode Class Reference


Detailed Description

The internal node structur of the KDTree.

Each interior node provides three pieces of information:

Definition at line 111 of file KDTree.h.


Private Member Functions

 KDNode ()
 The constructor of the KDNode.
 ~KDNode ()
 The Destructor of the KDNode.
bool isLeafNode () const
bool leafIntersect (Ray &ray, float min, float max)
 Checks if the ray intersects any object in this node (leaf node).
void getNearFar (const Ray &r, KDNode *&near, KDNode *&far)
 Returns the children nodes sorted as near and far.
float distanceToSplitPlane (const Ray &ray) const
 Computes the distance to the splitting plane.

Private Attributes

Axis _splitAxis
 Which of the x, y or z axes was split at this node.
float _splitPlane
 The position of the splitting plane along the axis.
KDNode_left
 A pointer to the left child of that node.
KDNode_right
 A pointer to the right child of that node.
std::vector< Primitive * > _primitives
 The primitives that overlap.

Friends

class KDTree

Constructor & Destructor Documentation

KDTree::KDNode::KDNode (  )  [private]

The constructor of the KDNode.

Definition at line 10 of file KDTree.cpp.

References _left, _right, _splitAxis, _splitPlane, and KDTree::NO_AXIS.

KDTree::KDNode::~KDNode (  )  [private]

The Destructor of the KDNode.

Definition at line 18 of file KDTree.cpp.

References _left, and _right.


Member Function Documentation

bool KDTree::KDNode::isLeafNode (  )  const [inline, private]

Definition at line 163 of file KDTree.h.

References _splitAxis, and KDTree::NO_AXIS.

Referenced by KDTree::Intersect().

bool KDTree::KDNode::leafIntersect ( Ray ray,
float  min,
float  max 
) [private]

Checks if the ray intersects any object in this node (leaf node).

Parameters:
ray The tay to intersect with.
min The minimal t-value.
max The maximal t-value.
Return values:
True iff an intersection is found.
Checks if the ray intersects any object in this node. Returns true if an intersection is found and stores the intersection parameters (t,hit) in the ray.

Definition at line 24 of file KDTree.cpp.

References _primitives, Epsilon, Ray::hit, KDTree::Intersect(), and Ray::t.

Referenced by KDTree::Intersect().

void KDTree::KDNode::getNearFar ( const Ray r,
KDNode *&  near,
KDNode *&  far 
) [inline, private]

Returns the children nodes sorted as near and far.

Parameters:
r The ray that intersects that Node.
near The near child is returned in this parameter.
far The far child is returned in this parameter.
Return the children nodes sorted as near and far. Near child is the one which contains the origin of the ray.

Definition at line 188 of file KDTree.h.

References _left, _right, _splitAxis, _splitPlane, and Ray::org.

Referenced by KDTree::Intersect().

float KDTree::KDNode::distanceToSplitPlane ( const Ray ray  )  const [inline, private]

Computes the distance to the splitting plane.

Return values:
The distance from the ray to the splittingplane (scaled by the direction-vector of the ray).

Definition at line 206 of file KDTree.h.

References _splitAxis, _splitPlane, Ray::dir, and Ray::org.

Referenced by KDTree::Intersect().


Friends And Related Function Documentation

friend class KDTree [friend]

Definition at line 113 of file KDTree.h.


Field Documentation

Axis KDTree::KDNode::_splitAxis [private]

Which of the x, y or z axes was split at this node.

Definition at line 120 of file KDTree.h.

Referenced by KDTree::BuildTree(), distanceToSplitPlane(), getNearFar(), isLeafNode(), and KDNode().

float KDTree::KDNode::_splitPlane [private]

The position of the splitting plane along the axis.

Definition at line 126 of file KDTree.h.

Referenced by KDTree::BuildTree(), distanceToSplitPlane(), getNearFar(), and KDNode().

KDNode * KDTree::KDNode::_left [private]

A pointer to the left child of that node.

Definition at line 132 of file KDTree.h.

Referenced by KDTree::BuildTree(), getNearFar(), KDNode(), and ~KDNode().

KDNode * KDTree::KDNode::_right [private]

A pointer to the right child of that node.

Definition at line 138 of file KDTree.h.

Referenced by KDTree::BuildTree(), getNearFar(), KDNode(), and ~KDNode().

std::vector< Primitive * > KDTree::KDNode::_primitives [private]

The primitives that overlap.

Definition at line 144 of file KDTree.h.

Referenced by KDTree::BuildTree(), leafIntersect(), and KDTree::retrySplit().


The documentation for this class was generated from the following files:
Generated on Thu Jan 31 21:48:54 2008 for RayTracer by  doxygen 1.5.4