org.openmali.spatial.quadtree
Class QuadCell<T extends SpatialNode>

java.lang.Object
  extended by org.openmali.spatial.bodies.Body
      extended by org.openmali.spatial.bodies.Box
          extended by org.openmali.spatial.quadtree.QuadCell<T>
All Implemented Interfaces:
java.io.Serializable, BodyInterface

public class QuadCell<T extends SpatialNode>
extends Box

This is a non-standard implementation of an QuadTree's cell. 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).

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.openmali.spatial.bodies.Box
lower, upper
 
Fields inherited from class org.openmali.spatial.bodies.Body
centerX, centerY, centerZ, distComputed, maxCenterDist, maxCenterDistSquared
 
Constructor Summary
  QuadCell(int level, float centerX, float centerY, float centerZ, PlaneIndicator plane, float size, float height)
           
  QuadCell(int level, float centerX, float centerY, float centerZ, PlaneIndicator plane, float size, float height, boolean useExtendedCells)
           
  QuadCell(int level, float centerX, float centerY, float centerZ, PlaneIndicator plane, float width, float depth, float height)
           
protected QuadCell(int level, float centerX, float centerY, float centerZ, PlaneIndicator plane, float width, float depth, float height, boolean useExtendedCells)
           
 
Method Summary
 void clear()
          Removes all nodes from this cell and also removes all child cells.
 void dump()
           
protected  QuadCell<T> findChildCell(Bounds bounds, BoundsType type, int minNodesBeforeSplit, int maxLevelForExtendedCells, boolean ignoreReinserting)
           
protected  QuadCell<T> findChildCell(Bounds bounds, int minNodesBeforeSplit, int maxLevelForExtendedCells)
           
protected  QuadCell<T> findChildCell(T node, int minNodesBeforeSplit, int maxLevelForExtendedCells)
           
 QuadCell<T> getCellHBack()
           
 QuadCell<T> getCellHFront()
           
 QuadCell<T> getCellHLeft()
           
 QuadCell<T> getCellHRight()
           
 QuadCell<T> getCellQuBackLeft()
           
 QuadCell<T> getCellQuBackRight()
           
 QuadCell<T> getCellQuFrontLeft()
           
 QuadCell<T> getCellQuFrontRight()
           
 float getDepth()
           
 float getHalfDepth()
           
 float getHalfWidth()
           
 float getHeight()
           
 int getLevel()
           
 T getNode(int index)
           
 int getNumNodes()
           
 PlaneIndicator getPlane()
           
 AxisIndicator getUpAxis()
           
 float getWidth()
           
 boolean hasChildCells()
           
 int insertNode(T node, int minNodesBeforeSplit, int maxLevelForExtendedCells)
          Inserts a node into this QuadCell or a child (or child of a child, etc.).
 boolean removeNode(T node)
          Removes a node from this cell (or a child, etc.).
 boolean usesExtendedCells()
           
 
Methods inherited from class org.openmali.spatial.bodies.Box
calcCenter, combine_, combine_, combine, combine, combine, combine, combine, contains, contains, getLower, getLower, getLowerX, getLowerY, getLowerZ, getSize, getSize, getUpper, getUpper, getUpperX, getUpperY, getUpperZ, getXSpan, getYSpan, getZSpan, onBoundsChanged, set, set, setCenter, setLower, setLower, setLowerX, setLowerY, setLowerZ, setSize, setSize, setUpper, setUpper, setUpperX, setUpperY, setUpperZ, toString
 
Methods inherited from class org.openmali.spatial.bodies.Body
getCenter, getCenterX, getCenterY, getCenterZ, getMaxCenterDistance, getMaxCenterDistanceSquared, setCenter, setMaxCenterDistanceSquared
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QuadCell

protected QuadCell(int level,
                   float centerX,
                   float centerY,
                   float centerZ,
                   PlaneIndicator plane,
                   float width,
                   float depth,
                   float height,
                   boolean useExtendedCells)

QuadCell

public QuadCell(int level,
                float centerX,
                float centerY,
                float centerZ,
                PlaneIndicator plane,
                float width,
                float depth,
                float height)

QuadCell

public QuadCell(int level,
                float centerX,
                float centerY,
                float centerZ,
                PlaneIndicator plane,
                float size,
                float height,
                boolean useExtendedCells)

QuadCell

public QuadCell(int level,
                float centerX,
                float centerY,
                float centerZ,
                PlaneIndicator plane,
                float size,
                float height)
Method Detail

getPlane

public final PlaneIndicator getPlane()

getUpAxis

public final AxisIndicator getUpAxis()

usesExtendedCells

public final boolean usesExtendedCells()
Returns:
true, if extended cells are potentially used. This doesn't necessarily mean, that extended cells are currently in use.

getLevel

public final int getLevel()
Returns:
this QuadCell's level in the QuadTree (root-cell has 0).

getWidth

public final float getWidth()
Returns:
the width of this QuadCell.

getDepth

public final float getDepth()
Returns:
the depth of this QuadCell.

getHeight

public final float getHeight()
Returns:
the height of this QuadCell.

getHalfWidth

public final float getHalfWidth()
Returns:
the half width of this QuadCell.

getHalfDepth

public final float getHalfDepth()
Returns:
the half depth of this QuadCell.

getCellQuFrontLeft

public final QuadCell<T> getCellQuFrontLeft()

getCellQuFrontRight

public final QuadCell<T> getCellQuFrontRight()

getCellQuBackLeft

public final QuadCell<T> getCellQuBackLeft()

getCellQuBackRight

public final QuadCell<T> getCellQuBackRight()

getNumNodes

public final int getNumNodes()

getCellHLeft

public final QuadCell<T> getCellHLeft()

getCellHRight

public final QuadCell<T> getCellHRight()

getCellHBack

public final QuadCell<T> getCellHBack()

getCellHFront

public final QuadCell<T> getCellHFront()

getNode

public final T getNode(int index)
Parameters:
index -
Returns:
one node, that is stored in this QuadCell.

hasChildCells

public final boolean hasChildCells()
Returns:
true, if this QuadCell currently has child QuadCells. This also includes extended cells!

findChildCell

protected QuadCell<T> findChildCell(Bounds bounds,
                                    BoundsType type,
                                    int minNodesBeforeSplit,
                                    int maxLevelForExtendedCells,
                                    boolean ignoreReinserting)

findChildCell

protected QuadCell<T> findChildCell(Bounds bounds,
                                    int minNodesBeforeSplit,
                                    int maxLevelForExtendedCells)

findChildCell

protected QuadCell<T> findChildCell(T node,
                                    int minNodesBeforeSplit,
                                    int maxLevelForExtendedCells)

insertNode

public int insertNode(T node,
                      int minNodesBeforeSplit,
                      int maxLevelForExtendedCells)
Inserts a node into this QuadCell or a child (or child of a child, etc.).

Parameters:
node -
minNodesBeforeSplit -
maxLevelForExtendedCells -
Returns:
the chosen cell's level.

removeNode

public boolean removeNode(T node)
Removes a node from this cell (or a child, etc.).

Parameters:
node -
Returns:
true, if the node was contained in this cell (or a child, etc.).

clear

public void clear()
Removes all nodes from this cell and also removes all child cells.


dump

public void dump()