# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Attributes

# vl::ActorKdTree Class Reference

ActorKdTree class extends the ActorTreeAbstract class implementing a space partitioning scheme based on a Kd-Tree. More...

`#include <ActorKdTree.hpp>`

Inheritance diagram for vl::ActorKdTree:

List of all members.

## Public Member Functions

| ActorKdTree ()
virtual int | childrenCount () const
| Returns the number of child nodes of an ActorTreeAbstract node.
virtual ActorTreeAbstract * | child (int i)
| Returns the i-th child node of an ActorTreeAbstract node.
virtual const ActorTreeAbstract * | child (int i) const
| Returns the i-th child node of an ActorTreeAbstract node.
void | buildKdTree (ActorCollection &actors, int max_depth=100, float minimum_volume=0)
| Builds a ActorKdTree with the given list of Actor[s].
void | rebuildKdTree (int max_depth=100, float minimum_volume=0)
| Builds a ActorKdTree with the Actor[s] contained in the tree.
const Plane & | plane () const
| Returns the splitting plane used to divide its two child nodes.
ActorKdTree * | childN ()
| Returns the child node that lies in the negative space defined by the splitting plane.
const ActorKdTree * | childN () const
| Returns the child node that lies in the negative space defined by the splitting plane.
ActorKdTree * | childP ()
| Returns the child node that lies in the positive space defined by the splitting plane.
const ActorKdTree * | childP () const
| Returns the child node that lies in the positive space defined by the splitting plane.
ActorKdTree * | insertActor (Actor *actor)
| Inserts an Actor in the ActorKdTree node hierarchy.
ref< ActorKdTree > | kdtreeFromNonLeafyActors (int max_depth=100, float minimum_volume=0)
| Removes the Actor[s] in the internal nodes of the ActorKdTree and uses them to create a new ActorKdTree.
void | harvestNonLeafActors (ActorCollection &actors)
| Removes the Actor[s] in the internal nodes of the ActorKdTree and appends them in the given ActorCollection.

## Protected Attributes

Plane | mPlane
ref< ActorKdTree > | mChildN
ref< ActorKdTree > | mChildP

## Detailed Description

ActorKdTree class extends the ActorTreeAbstract class implementing a space partitioning scheme based on a Kd-Tree.

Note:
  When building the Kd-Tree, Visualization Library considers the Actors' LOD level 0.

See also:
  - ActorTree
  - SceneManager
  - SceneManagerActorKdTree
  - SceneManagerActorTree
  - Actor

Definition at line 57 of file ActorKdTree.hpp.

## Constructor & Destructor Documentation

vl::ActorKdTree::ActorKdTree | ( | ) | `[inline]`

Definition at line 62 of file ActorKdTree.hpp.

References VL_DEBUG_SET_OBJECT_NAME.

Referenced by kdtreeFromNonLeafyActors().

## Member Function Documentation

int ActorKdTree::childrenCount | ( | ) | const`[virtual]`

Returns the number of child nodes of an ActorTreeAbstract node.

Implements vl::ActorTreeAbstract.

Definition at line 286 of file ActorKdTree.cpp.

References mChildN, and mChildP.

ActorTreeAbstract * ActorKdTree::child | ( | int | i ) | `[virtual]`

Returns the i-th child node of an ActorTreeAbstract node.

Implements vl::ActorTreeAbstract.

Definition at line 297 of file ActorKdTree.cpp.

References vl::Log::error(), vl::ref< T >::get(), mChildN, mChildP, and NULL.

const ActorTreeAbstract * ActorKdTree::child | ( | int | i ) | const`[virtual]`

Returns the i-th child node of an ActorTreeAbstract node.

Implements vl::ActorTreeAbstract.

Definition at line 311 of file ActorKdTree.cpp.

References vl::Log::error(), vl::ref< T >::get(), mChildN, mChildP, and NULL.

void ActorKdTree::buildKdTree | ( | ActorCollection & | actors,
|  | int | max_depth = `100`,
|  | float | minimum_volume = `0`
| ) |  |

Builds a ActorKdTree with the given list of Actor[s].

The ActorKdTree generation routine will try to minimize the ActorKdTree depth. Note that this function is relatively quick, but is not for free. Consider that using a Core 2 Duo @2.0GHz you can process around 22.000 objects/sec.

Note:
  This method calls prepareActors() before computing the KdTree.

Definition at line 104 of file ActorKdTree.cpp.

References vl::ActorTreeAbstract::prepareActors().

Referenced by vl::Terrain::init(), and rebuildKdTree().

void ActorKdTree::rebuildKdTree | ( | int | max_depth = `100`,
|  | float | minimum_volume = `0`
| ) |  |

Builds a ActorKdTree with the Actor[s] contained in the tree.

Note:
  This method calls prepareActors() before computing the KdTree.

Definition at line 111 of file ActorKdTree.cpp.

References buildKdTree(), and vl::ActorTreeAbstract::extractActors().

const Plane& vl::ActorKdTree::plane | ( | ) | const`[inline]`

Returns the splitting plane used to divide its two child nodes.

Definition at line 84 of file ActorKdTree.hpp.

ActorKdTree* vl::ActorKdTree::childN | ( | ) | `[inline]`

Returns the child node that lies in the negative space defined by the splitting plane.

Definition at line 87 of file ActorKdTree.hpp.

Referenced by harvestNonLeafActors(), and insertActor().

const ActorKdTree* vl::ActorKdTree::childN | ( | ) | const`[inline]`

Returns the child node that lies in the negative space defined by the splitting plane.

Definition at line 89 of file ActorKdTree.hpp.

ActorKdTree* vl::ActorKdTree::childP | ( | ) | `[inline]`

Returns the child node that lies in the positive space defined by the splitting plane.

Definition at line 92 of file ActorKdTree.hpp.

Referenced by harvestNonLeafActors(), and insertActor().

const ActorKdTree* vl::ActorKdTree::childP | ( | ) | const`[inline]`

Returns the child node that lies in the positive space defined by the splitting plane.

Definition at line 94 of file ActorKdTree.hpp.

ActorKdTree * ActorKdTree::insertActor | ( | Actor * | actor ) |

Inserts an Actor in the ActorKdTree node hierarchy.

Note that the Actor is likely to be inserted in a node whose bounding volume does not surround the Actor's bounding volume. For this reason after you inserted one or more Actor[s] in the ActorKdTree you should call computeAABB() on the root node of the ActorKdTree. Inserting and removing Actor[s] is an expensive operation and produces an ActorKdTree that is less balanced than the one you would get by recompiling the whole ActorKdTree from scratch.

Returns:
  The ActorKdTree node in which the Actor has been inserted.

See also:
  ActorTree::eraseActor()

Definition at line 269 of file ActorKdTree.cpp.

References vl::ActorTreeAbstract::actors(), childN(), childP(), vl::Plane::classify(), insertActor(), mPlane, vl::Collection< T >::push_back(), and VL_CHECK.

Referenced by insertActor().

ref< ActorKdTree > ActorKdTree::kdtreeFromNonLeafyActors | ( | int | max_depth = `100`,
|  | float | minimum_volume = `0`
| ) |  |

Removes the Actor[s] in the internal nodes of the ActorKdTree and uses them to create a new ActorKdTree.

Definition at line 70 of file ActorKdTree.cpp.

References ActorKdTree(), and harvestNonLeafActors().

void ActorKdTree::harvestNonLeafActors | ( | ActorCollection & | actors ) |

Removes the Actor[s] in the internal nodes of the ActorKdTree and appends them in the given ActorCollection.

Definition at line 79 of file ActorKdTree.cpp.

References vl::ActorTreeAbstract::actors(), childN(), childP(), vl::Collection< T >::clear(), harvestNonLeafActors(), mChildN, mChildP, vl::Collection< T >::push_back(), vl::Collection< T >::size(), and VL_CHECK.

Referenced by harvestNonLeafActors(), and kdtreeFromNonLeafyActors().

## Member Data Documentation

Plane vl::ActorKdTree::mPlane`[protected]`

Definition at line 149 of file ActorKdTree.hpp.

Referenced by insertActor().

ref<ActorKdTree> vl::ActorKdTree::mChildN`[protected]`

Definition at line 150 of file ActorKdTree.hpp.

Referenced by child(), childrenCount(), and harvestNonLeafActors().

ref<ActorKdTree> vl::ActorKdTree::mChildP`[protected]`

Definition at line 151 of file ActorKdTree.hpp.

Referenced by child(), childrenCount(), and harvestNonLeafActors().

The documentation for this class was generated from the following files:

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/ActorKdTree.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/ActorKdTree.cpp

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:44:20.
Permission is granted to use this page to write and publish articles regarding Visualization Library.