org.openmali.spatial.octree
Class OcTree<T extends SpatialNode>

java.lang.Object
  extended by org.openmali.spatial.octree.OcTree<T>

public class OcTree<T extends SpatialNode>
extends java.lang.Object

This is a non-standard OcTree implementation. It provides the possibility to use extended cells. These extended cells are cells, that don't cover an octant of the parent cell, but a half (one of six) or a quadrant (one of twelve).


Constructor Summary
OcTree(float centerX, float centerY, float centerZ, float size, boolean useExtendedCells)
           
OcTree(float centerX, float centerY, float centerZ, float sizeX, float sizeY, float sizeZ, boolean useExtendedCells)
           
OcTree(Tuple3f center, float size, boolean useExtendedCells)
           
OcTree(Tuple3f center, float sizeX, float sizeY, float sizeZ, boolean useExtendedCells)
           
 
Method Summary
 void clear()
          Removes all nodes from this OcTree.
 void dump()
          Dumps the whole OcTree to System.out.
 float getCenterX()
           
 float getCenterY()
           
 float getCenterZ()
           
 int getMaxLevel()
           
 int getMaxLevelForExtendedCells()
           
 int getMinNodesBeforeSplit()
           
 OcCell<T> getRootCell()
           
 float getSizeX()
           
 float getSizeY()
           
 float getSizeZ()
           
 int insertNode(T node)
          Inserts a node into the OcTree.
 void removeNode(T node)
          Removes the node from the OcTree (from its container cell).
 void setMaxLevelForExtendedCells(int maxLevelForExtendedCells)
          Sets the maximum number of nodes, that can be inserted into a cell before it is splitted into extended cells.
 void setMinNodesBeforeSplit(int minNodesBeforeSplit)
          Sets the minimum number of nodes, that must be inserted into a cell to make the cell be splitted.
 void updateNodePosition(T node)
          This method must be called after a node's position or size has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OcTree

public OcTree(float centerX,
              float centerY,
              float centerZ,
              float sizeX,
              float sizeY,
              float sizeZ,
              boolean useExtendedCells)

OcTree

public OcTree(Tuple3f center,
              float sizeX,
              float sizeY,
              float sizeZ,
              boolean useExtendedCells)

OcTree

public OcTree(float centerX,
              float centerY,
              float centerZ,
              float size,
              boolean useExtendedCells)

OcTree

public OcTree(Tuple3f center,
              float size,
              boolean useExtendedCells)
Method Detail

getRootCell

public final OcCell<T> getRootCell()
Returns:
the OcTree's root OcCell.

getMaxLevel

public final int getMaxLevel()
Returns:
the maximum currently used level of cells in this OcTree.

getCenterX

public final float getCenterX()
Returns:
the x-center of this OcTree (or of the root cell).

getCenterY

public final float getCenterY()
Returns:
the y-center of this OcTree (or of the root cell).

getCenterZ

public final float getCenterZ()
Returns:
the z-center of this OcTree (or of the root cell).

getSizeX

public final float getSizeX()
Returns:
the x-size of this OcTree (or of the root cell).

getSizeY

public final float getSizeY()
Returns:
the y-size of this OcTree (or of the root cell).

getSizeZ

public final float getSizeZ()
Returns:
the z-size of this OcTree (or of the root cell).

setMinNodesBeforeSplit

public void setMinNodesBeforeSplit(int minNodesBeforeSplit)
Sets the minimum number of nodes, that must be inserted into a cell to make the cell be splitted.

Parameters:
minNodesBeforeSplit -

getMinNodesBeforeSplit

public final int getMinNodesBeforeSplit()
Returns:
the minimum number of nodes, that must be inserted into a cell to make the cell be splitted.

setMaxLevelForExtendedCells

public void setMaxLevelForExtendedCells(int maxLevelForExtendedCells)
Sets the maximum number of nodes, that can be inserted into a cell before it is splitted into extended cells.

Parameters:
maxLevelForExtendedCells -

getMaxLevelForExtendedCells

public final int getMaxLevelForExtendedCells()
Returns:
the maximum number of nodes, that can be inserted into a cell before it is splitted into extended cells.

insertNode

public final int insertNode(T node)
Inserts a node into the OcTree. This first searches the OcCell to insert and then places the node into the cell.

Parameters:
node -
Returns:
the level of the OcCell, the node has been inserted to.

removeNode

public final void removeNode(T node)
Removes the node from the OcTree (from its container cell).

Parameters:
node -

clear

public final void clear()
Removes all nodes from this OcTree.


updateNodePosition

public final void updateNodePosition(T node)
This method must be called after a node's position or size has changed. You don't need to call this method, if you exactly know, that the modification won't affect the node's placement in the tree.

Parameters:
node -

dump

public void dump()
Dumps the whole OcTree to System.out.