BspTree Class Reference

Dynamic tree data structure capable to organize data by spacial properties. More...

#include <BspTree.h>

List of all members.

Public Member Functions

 BspTree ()
 Standard constructor.
 BspTree (const BspTree &source)
 Copy constructor.
 BspTree (struct Particle *object)
 Constructor for creting a new leaf.
 ~BspTree ()
 Destructor (if you want to free memory of content, call whipe() first).
void push_back (struct Particle *object)
 Adds a new object to the tree.
void del (struct Particle *object)
 Deletes a object from the tree.
void whipe ()
 Frees memory from all stored objects.
Uint32 size ()
 Returns the size of tree.
vector< struct Particle * > traverse (const Vector &vertex, const Vector &dir, const Uint32 &time) const
 Returns the content of the tree sorted by a given vertex and vector at a given time.
vector< struct Particle * > traverse (const Vector &vertex, const Vector &dir) const
 Returns the content of the tree sorted by a given vertex and vector.
vector< struct Particle * > traverse () const
 Returns the unsorted content of the tree.
const Vector getPlaneNormal () const
 Getter for plane normal.
void setPlaneNormal (const Vector &planeNormal)
 Setter for plane normal.
const GLfloat getPlaneDistance () const
 Getter for plane distance.
void setPlaneDistance (const GLfloat &planeDistance)
 Setter for plane distance.
const bool isLeaf () const
 Getter for leaf property.
void setLeaf (const bool &leaf)
 Setter for leaf property.
BspTreegetPosChild () const
 Getter for positive child.
void setPosChild (BspTree *posChild)
 Setter for positive child.
BspTreegetNegChild () const
 Getter for negative child.
void setNegChild (BspTree *negChild)
 Setter for negative child.
struct ParticlegetLeafContent () const
 Getter for leaf content.
void setLeafContent (struct Particle *content)
 Setter for leaf content.
const bool isVisited () const
 Getter for visited flag.
const bool isUnvisited () const
 Getter for visited flag.
void setVisited (const bool &visited)
 Setter for visited flag.
const GLfloat getMaxDistance () const
 Getter for maxDistance.
void setMaxDistance (const GLfloat &maxDistance)
 Setter for plane distance.

Private Member Functions

bool isOnPositiveSide (struct Particle *object)
 Checks if the object is on the plane or its positive side.
bool isOnPositiveSide (const Vector &vertex) const
 Checks if the vertex is on the plane or its positive side.
void resetVisited ()
 Resets all visited attributes.
void resetMaxDistance ()
 Resets all max distance attributes.
void calcMaxDistance (const Vector &vertex, const Vector &dir)
 Calculates all max distance attributes.
void calcMaxDistance (const Vector &vertex, const Vector &dir, const Uint32 &time)
 Calculates all max distance attributes for a given time.

Private Attributes

Vector planeNormal
 Plane normal for inner nodes.
GLfloat planeDistance
 Plane distance to origin for inner nodes.
BspTreeposChild
 The subtree in the direction (>=0) of the plane normal.
BspTreenegChild
 The subtree in the opposite direction (<0) relative to the plane normal.
bool leaf
 Indicates if the node is a leaf and has no children.
struct ParticleleafContent
 The content stored in a leaf.
bool visited
 Needed for traversal.
GLfloat maxDistance
 Needed for sorting.


Detailed Description

Dynamic tree data structure capable to organize data by spacial properties.

This implementation of a BSP-Tree enables sorting by position for any Animatable object. It is intended to replace the STD::List for all purposes that are related to 3-space operations.


Constructor & Destructor Documentation

BspTree::BspTree (  ) 

Standard constructor.

Creates a new BSP-Tree.

BspTree::BspTree ( const BspTree source  ) 

Copy constructor.

Creates a copy of the source BSP-Tree. Note: The content will not be dublicated.

Parameters:
source The original Tree to be cloned

BspTree::BspTree ( struct Particle object  ) 

Constructor for creting a new leaf.

Creates a new leaf with the provided content

Parameters:
object The content of the new leaf

BspTree::~BspTree (  ) 

Destructor (if you want to free memory of content, call whipe() first).

Note: The content will not be destroyed.


Member Function Documentation

bool BspTree::isOnPositiveSide ( struct Particle object  )  [private]

Checks if the object is on the plane or its positive side.

Parameters:
object The object to be checked
Returns:
True if the origin of the object is on the plane or its positive side and else otherwise.

bool BspTree::isOnPositiveSide ( const Vector vertex  )  const [private]

Checks if the vertex is on the plane or its positive side.

Parameters:
object The object to be checked
Returns:
True if the origin of the object is on the plane or its positive side and else otherwise.

void BspTree::resetVisited (  )  [private]

Resets all visited attributes.

Resets all visited Attributes in this Tree for traversal.

void BspTree::resetMaxDistance (  )  [private]

Resets all max distance attributes.

Resets all maxDistance Attributes in this Tree for traversal.

void BspTree::calcMaxDistance ( const Vector vertex,
const Vector dir 
) [private]

Calculates all max distance attributes.

Claculates all maxDistance Attributes in this Tree for traversal.

void BspTree::calcMaxDistance ( const Vector vertex,
const Vector dir,
const Uint32 &  time 
) [private]

Calculates all max distance attributes for a given time.

void BspTree::push_back ( struct Particle object  ) 

Adds a new object to the tree.

void BspTree::del ( struct Particle object  ) 

Deletes a object from the tree.

void BspTree::whipe (  ) 

Frees memory from all stored objects.

Collapses the tree and frees the memory of all stored content. Only this node as root will survive.

Uint32 BspTree::size (  ) 

Returns the size of tree.

vector< struct Particle * > BspTree::traverse ( const Vector vertex,
const Vector dir,
const Uint32 &  time 
) const

Returns the content of the tree sorted by a given vertex and vector at a given time.

Returns:
A list with all the struct Particles stored in the tree. The content is ordered by distance from the given vertex for the given time.

vector< struct Particle * > BspTree::traverse ( const Vector vertex,
const Vector dir 
) const

Returns the content of the tree sorted by a given vertex and vector.

Returns:
A list with all the struct Particles stored in the tree. The content is ordered by distance from the given vertex.

vector< struct Particle * > BspTree::traverse (  )  const

Returns the unsorted content of the tree.

Returns:
A list with all the struct Particles stored in the tree. The content is orderd by the generic structure of the tree.

const Vector BspTree::getPlaneNormal (  )  const

Getter for plane normal.

void BspTree::setPlaneNormal ( const Vector planeNormal  ) 

Setter for plane normal.

const GLfloat BspTree::getPlaneDistance (  )  const

Getter for plane distance.

void BspTree::setPlaneDistance ( const GLfloat &  planeDistance  ) 

Setter for plane distance.

const bool BspTree::isLeaf (  )  const

Getter for leaf property.

void BspTree::setLeaf ( const bool &  leaf  ) 

Setter for leaf property.

BspTree * BspTree::getPosChild (  )  const

Getter for positive child.

void BspTree::setPosChild ( BspTree posChild  ) 

Setter for positive child.

BspTree * BspTree::getNegChild (  )  const

Getter for negative child.

void BspTree::setNegChild ( BspTree negChild  ) 

Setter for negative child.

struct Particle * BspTree::getLeafContent (  )  const [read]

Getter for leaf content.

void BspTree::setLeafContent ( struct Particle content  ) 

Setter for leaf content.

const bool BspTree::isVisited (  )  const

Getter for visited flag.

const bool BspTree::isUnvisited (  )  const

Getter for visited flag.

void BspTree::setVisited ( const bool &  visited  ) 

Setter for visited flag.

const GLfloat BspTree::getMaxDistance (  )  const

Getter for maxDistance.

Getter for max distance.

void BspTree::setMaxDistance ( const GLfloat &  maxDistance  ) 

Setter for plane distance.

Setter for max distance.


Member Data Documentation

Plane normal for inner nodes.

GLfloat BspTree::planeDistance [private]

Plane distance to origin for inner nodes.

The subtree in the direction (>=0) of the plane normal.

The subtree in the opposite direction (<0) relative to the plane normal.

bool BspTree::leaf [private]

Indicates if the node is a leaf and has no children.

struct Particle* BspTree::leafContent [read, private]

The content stored in a leaf.

bool BspTree::visited [private]

Needed for traversal.

GLfloat BspTree::maxDistance [private]

Needed for sorting.


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

Generated on Mon Jul 7 13:30:33 2008 for Firefly by  doxygen 1.5.6