Nori

KDTree Class Reference

Specializes GenericKDTree to a three-dimensional tree that can be used to intersect rays against triangles meshes. More...

#include <kdtree.h>

Inheritance diagram for KDTree:
GenericKDTree< BoundingBox3f, SurfaceAreaHeuristic3, KDTree > KDTreeBase< BoundingBox3f >

List of all members.

Public Member Functions

 KDTree ()
 Create a new and empty kd-tree.
virtual ~KDTree ()
 Release all memory.
void addMesh (Mesh *mesh)
 Register a triangle mesh for inclusion in the kd-tree.
void build ()
 Build the kd-tree.
bool rayIntersect (const Ray3f &ray, Intersection &its, bool shadowRay=false) const
 Intersect a ray against all triangle meshes registered with the kd-tree.
SizeType getPrimitiveCount () const
 Return the total number of internally represented triangles.
SizeType getMeshCount () const
 Return the total number of meshes registered with the kd-tree.
MeshgetMesh (IndexType idx)
 Return one of the registered meshes.
const MeshgetMesh (IndexType idx) const
 Return one of the registered meshes (const version)
const BoundingBox3fgetBoundingBox () const
 Return a (slightly enlarged) axis-aligned bounding box containing all primitives.
BoundingBox3f getBoundingBox (IndexType index) const
BoundingBox3f getClippedBoundingBox (IndexType index, const BoundingBox3f &clip) const
 Returns the axis-aligned bounding box of a triangle after it has clipped to the extents of another given bounding box.

Protected Types

typedef GenericKDTree
< BoundingBox3f,
SurfaceAreaHeuristic3, KDTree
Parent
typedef Parent::SizeType SizeType
 Size number format.
typedef Parent::IndexType IndexType
 Index number format (max 2^32 prims)
typedef Parent::KDNode KDNode

Protected Member Functions

IndexType findMesh (IndexType &idx) const
 Compute the mesh and triangle indices corresponding to a primitive index used by the underlying generic kd-tree implementation.

Detailed Description

Specializes GenericKDTree to a three-dimensional tree that can be used to intersect rays against triangles meshes.

The internal tree construction algorithm generates a surface area heuristic (SAH) kd-tree using the "perfect splits" optimization.

This class also implements an robust adapted version of the optimized ray traversal algorithm (TA^B_{rec}), which is explained in Vlastimil Havran's PhD thesis "Heuristic Ray Shooting Algorithms".

Author:
Wenzel Jakob

Definition at line 42 of file kdtree.h.


Member Typedef Documentation

typedef Parent::IndexType KDTree::IndexType [protected]

Index number format (max 2^32 prims)

Reimplemented from GenericKDTree< BoundingBox3f, SurfaceAreaHeuristic3, KDTree >.

Definition at line 46 of file kdtree.h.

typedef Parent::KDNode KDTree::KDNode [protected]

Reimplemented from GenericKDTree< BoundingBox3f, SurfaceAreaHeuristic3, KDTree >.

Definition at line 47 of file kdtree.h.

typedef Parent::SizeType KDTree::SizeType [protected]

Size number format.

Reimplemented from GenericKDTree< BoundingBox3f, SurfaceAreaHeuristic3, KDTree >.

Definition at line 45 of file kdtree.h.


Constructor & Destructor Documentation

KDTree::KDTree ( )

Create a new and empty kd-tree.

virtual KDTree::~KDTree ( ) [virtual]

Release all memory.


Member Function Documentation

void KDTree::addMesh ( Mesh mesh)

Register a triangle mesh for inclusion in the kd-tree.

This function can only be used before build() is called

void KDTree::build ( )

Build the kd-tree.

IndexType KDTree::findMesh ( IndexType idx) const [inline, protected]

Compute the mesh and triangle indices corresponding to a primitive index used by the underlying generic kd-tree implementation.

Definition at line 126 of file kdtree.h.

const BoundingBox3f& KDTree::getBoundingBox ( ) const [inline]

Return a (slightly enlarged) axis-aligned bounding box containing all primitives.

Reimplemented from KDTreeBase< BoundingBox3f >.

Definition at line 101 of file kdtree.h.

BoundingBox3f KDTree::getBoundingBox ( IndexType  index) const [inline]

Definition at line 106 of file kdtree.h.

BoundingBox3f KDTree::getClippedBoundingBox ( IndexType  index,
const BoundingBox3f clip 
) const [inline]

Returns the axis-aligned bounding box of a triangle after it has clipped to the extents of another given bounding box.

See Mesh::getClippedBoundingBox() for details

Definition at line 117 of file kdtree.h.

const Mesh* KDTree::getMesh ( IndexType  idx) const [inline]

Return one of the registered meshes (const version)

Definition at line 98 of file kdtree.h.

Mesh* KDTree::getMesh ( IndexType  idx) [inline]

Return one of the registered meshes.

Definition at line 95 of file kdtree.h.

SizeType KDTree::getMeshCount ( ) const [inline]

Return the total number of meshes registered with the kd-tree.

Definition at line 92 of file kdtree.h.

SizeType KDTree::getPrimitiveCount ( ) const [inline]

Return the total number of internally represented triangles.

Definition at line 89 of file kdtree.h.

bool KDTree::rayIntersect ( const Ray3f ray,
Intersection its,
bool  shadowRay = false 
) const

Intersect a ray against all triangle meshes registered with the kd-tree.

Detailed information about the intersection, if any, will be stored in the provided Intersection data record.

The shadowRay parameter specifies whether this detailed information is really needed. When set to true, the function just checks whether or not there is occlusion, but without providing any more detail (i.e. its will not be filled with contents). This is usually much faster.

Returns:
true If an intersection was found

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines