KDTree Class Reference

#include <KDTree.h>

Inherited by SAHKDTree, and SimpleKDTree.

Inheritance diagram for KDTree:

Inheritance graph
[legend]
Collaboration diagram for KDTree:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::vector< Primitive * > PrimitiveList
 Primitive list.

Public Member Functions

 KDTree (unsigned int min_primitives, unsigned int max_depth)
virtual ~KDTree ()
virtual bool intersect (Ray &ray) const
virtual void buildTree (const PrimitiveList &list, const Box &bbox)
void setConstraints (unsigned int min_primitives, unsigned int max_depth)
unsigned int minPrimitives () const
unsigned int maxDepth () const

Protected Member Functions

virtual bool intersect (const Node *node, Ray &ray, float min, float max) const
virtual bool terminate (const Node *current, float dummy, unsigned int depth) const

Protected Attributes

Box mBoundingBox
 bounding box of the whole tree
NodemRootNode
 Root node of the tree.
unsigned int mMinPrimitives
 Maximal number of primitives in a leaf node.
unsigned int mMaxDepth
 Tree depth which should be reached.

Detailed Description

Abstract base class for all KD-Trees

Author:
Alex Busenius

Definition at line 21 of file KDTree.h.


Member Typedef Documentation

typedef std::vector<Primitive *> KDTree::PrimitiveList

Primitive list.

Definition at line 25 of file KDTree.h.


Constructor & Destructor Documentation

KDTree::KDTree ( unsigned int  min_primitives,
unsigned int  max_depth 
) [inline]

Constructor

Parameters:
min_primitives Minimal number of primitives in one node
max_depth Maximal tree depth

Definition at line 33 of file KDTree.h.

KDTree::~KDTree (  )  [virtual]

Cleanup used memory

Definition at line 9 of file KDTree.cpp.

References mRootNode.


Member Function Documentation

bool KDTree::intersect ( Ray ray  )  const [virtual]

Intersect a ray with the kdtree. Store corresponding intersection information if the ray structure (t, hit)

Parameters:
ray The ray to intersect with, intersection point is stored here
Returns:
true if intersection is found.

Definition at line 21 of file KDTree.cpp.

References EPSILON, Box::intersect(), mBoundingBox, and mRootNode.

Referenced by OBJObject::doIntersect(), and intersect().

void KDTree::buildTree ( const PrimitiveList list,
const Box bbox 
) [virtual]

Build the kd-tree from the given primitive list.

Parameters:
list List of all primitives
bbox Overall bounding box

Definition at line 97 of file KDTree.cpp.

References LOG, mBoundingBox, and mRootNode.

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

void KDTree::setConstraints ( unsigned int  min_primitives,
unsigned int  max_depth 
) [inline]

Set build tree termination constraints. These numbers declares the minimal possible number of primitives in a leaf node and maximal tree depth

Parameters:
min_primitives Minimal number of primitives in one node
max_depth Maximal tree depth

Definition at line 68 of file KDTree.h.

References mMaxDepth, and mMinPrimitives.

unsigned int KDTree::minPrimitives (  )  const [inline]

Get minimal primitives number

Definition at line 77 of file KDTree.h.

References mMinPrimitives.

unsigned int KDTree::maxDepth (  )  const [inline]

Get maximal tree depth

Definition at line 84 of file KDTree.h.

References mMaxDepth.

bool KDTree::intersect ( const Node node,
Ray ray,
float  min,
float  max 
) const [protected, virtual]

Recursive method to look for the intersection

Parameters:
node Current node
ray The ray to intersect with
min Distance to the near intersection point with the bounding box
max Distance to the far intersection point with the bounding box
Returns:
true if intersection is found

Definition at line 46 of file KDTree.cpp.

References Node::distanceToSplitPlane(), intersect(), Node::isLeafNode(), Node::leafIntersect(), and Node::nearFar().

bool KDTree::terminate ( const Node current,
float  dummy,
unsigned int  depth 
) const [protected, virtual]

Determine if building tree should terminate on the current node. Default implementation do only subdivide current node if primitive number is still over the minimum and node deep is not too large

Parameters:
current Current node
dummy Dummy param
depth Depth of the current node
Returns:
true if current node should become leaf node

Reimplemented in SAHKDTree.

Definition at line 122 of file KDTree.cpp.

References mMaxDepth, mMinPrimitives, and Node::primitives_count().

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


Member Data Documentation

Box KDTree::mBoundingBox [protected]

bounding box of the whole tree

Definition at line 91 of file KDTree.h.

Referenced by buildTree(), and intersect().

Node* KDTree::mRootNode [protected]

Root node of the tree.

Definition at line 94 of file KDTree.h.

Referenced by SimpleKDTree::buildTree(), SAHKDTree::buildTree(), buildTree(), intersect(), and ~KDTree().

unsigned int KDTree::mMinPrimitives [protected]

Maximal number of primitives in a leaf node.

Definition at line 97 of file KDTree.h.

Referenced by minPrimitives(), setConstraints(), and terminate().

unsigned int KDTree::mMaxDepth [protected]

Tree depth which should be reached.

Definition at line 100 of file KDTree.h.

Referenced by maxDepth(), setConstraints(), and terminate().


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