org.openmali.spatial.octree
Class OcCell<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.octree.OcCell<T>
All Implemented Interfaces:
java.io.Serializable, BodyInterface

public class OcCell<T extends SpatialNode>
extends Box

This is a non-standard implementation of an OcTree'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
  OcCell(int level, float centerX, float centerY, float centerZ, float size)
           
  OcCell(int level, float centerX, float centerY, float centerZ, float size, boolean useExtendedCells)
           
  OcCell(int level, float centerX, float centerY, float centerZ, float sizeX, float sizeY, float sizeZ)
           
protected OcCell(int level, float centerX, float centerY, float centerZ, float sizeX, float sizeY, float sizeZ, boolean useExtendedCells)
           
 
Method Summary
 void clear()
          Removes all nodes from this cell and also removes all child cells.
 void dump()
           
protected  OcCell<T> findChildCell(Bounds bounds, BoundsType type, int minNodesBeforeSplit, int maxLevelForExtendedCells, boolean ignoreReinserting)
           
protected  OcCell<T> findChildCell(Bounds bounds, int minNodesBeforeSplit, int maxLevelForExtendedCells)
           
protected  OcCell<T> findChildCell(T node, int minNodesBeforeSplit, int maxLevelForExtendedCells)
           
 OcCell<T> getCellHBack()
           
 OcCell<T> getCellHFront()
           
 OcCell<T> getCellHLeft()
           
 OcCell<T> getCellHLower()
           
 OcCell<T> getCellHRight()
           
 OcCell<T> getCellHUpper()
           
 OcCell<T> getCellOcLowerBackLeft()
           
 OcCell<T> getCellOcLowerBackRight()
           
 OcCell<T> getCellOcLowerFrontLeft()
           
 OcCell<T> getCellOcLowerFrontRight()
           
 OcCell<T> getCellOcUpperBackLeft()
           
 OcCell<T> getCellOcUpperBackRight()
           
 OcCell<T> getCellOcUpperFrontLeft()
           
 OcCell<T> getCellOcUpperFrontRight()
           
 OcCell<T> getCellQuBackLeft()
           
 OcCell<T> getCellQuBackRight()
           
 OcCell<T> getCellQuFrontLeft()
           
 OcCell<T> getCellQuFrontRight()
           
 OcCell<T> getCellQuLowerBack()
           
 OcCell<T> getCellQuLowerFront()
           
 OcCell<T> getCellQuLowerLeft()
           
 OcCell<T> getCellQuLowerRight()
           
 OcCell<T> getCellQuUpperBack()
           
 OcCell<T> getCellQuUpperFront()
           
 OcCell<T> getCellQuUpperLeft()
           
 OcCell<T> getCellQuUpperRight()
           
 float getHalfSizeX()
           
 float getHalfSizeY()
           
 float getHalfSizeZ()
           
 int getLevel()
           
 T getNode(int index)
           
 int getNumNodes()
           
 float getSizeX()
           
 float getSizeY()
           
 float getSizeZ()
           
 boolean hasChildCells()
           
 int insertNode(T node, int minNodesBeforeSplit, int maxLevelForExtendedCells)
          Inserts a node into this OcCell 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

OcCell

protected OcCell(int level,
                 float centerX,
                 float centerY,
                 float centerZ,
                 float sizeX,
                 float sizeY,
                 float sizeZ,
                 boolean useExtendedCells)

OcCell

public OcCell(int level,
              float centerX,
              float centerY,
              float centerZ,
              float sizeX,
              float sizeY,
              float sizeZ)

OcCell

public OcCell(int level,
              float centerX,
              float centerY,
              float centerZ,
              float size,
              boolean useExtendedCells)

OcCell

public OcCell(int level,
              float centerX,
              float centerY,
              float centerZ,
              float size)
Method Detail

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 OcCell's level in the OcTree (root-cell has 0).

getSizeX

public final float getSizeX()
Returns:
the x-size of this OcCell.

getSizeY

public final float getSizeY()
Returns:
the y-size of this OcCell.

getSizeZ

public final float getSizeZ()
Returns:
the z-size of this OcCell.

getHalfSizeX

public final float getHalfSizeX()
Returns:
the half x-size of this OcCell.

getHalfSizeY

public final float getHalfSizeY()
Returns:
the half y-size of this OcCell.

getHalfSizeZ

public final float getHalfSizeZ()
Returns:
the half z-size of this OcCell.

getCellOcUpperFrontLeft

public final OcCell<T> getCellOcUpperFrontLeft()

getCellOcUpperFrontRight

public final OcCell<T> getCellOcUpperFrontRight()

getCellOcUpperBackLeft

public final OcCell<T> getCellOcUpperBackLeft()

getCellOcUpperBackRight

public final OcCell<T> getCellOcUpperBackRight()

getCellOcLowerFrontLeft

public final OcCell<T> getCellOcLowerFrontLeft()

getCellOcLowerFrontRight

public final OcCell<T> getCellOcLowerFrontRight()

getCellOcLowerBackLeft

public final OcCell<T> getCellOcLowerBackLeft()

getCellOcLowerBackRight

public final OcCell<T> getCellOcLowerBackRight()

getNumNodes

public final int getNumNodes()

getCellQuUpperBack

public final OcCell<T> getCellQuUpperBack()

getCellQuUpperFront

public final OcCell<T> getCellQuUpperFront()

getCellQuUpperLeft

public final OcCell<T> getCellQuUpperLeft()

getCellQuUpperRight

public final OcCell<T> getCellQuUpperRight()

getCellQuLowerBack

public final OcCell<T> getCellQuLowerBack()

getCellQuLowerFront

public final OcCell<T> getCellQuLowerFront()

getCellQuLowerLeft

public final OcCell<T> getCellQuLowerLeft()

getCellQuLowerRight

public final OcCell<T> getCellQuLowerRight()

getCellQuBackLeft

public final OcCell<T> getCellQuBackLeft()

getCellQuBackRight

public final OcCell<T> getCellQuBackRight()

getCellQuFrontLeft

public final OcCell<T> getCellQuFrontLeft()

getCellQuFrontRight

public final OcCell<T> getCellQuFrontRight()

getCellHUpper

public final OcCell<T> getCellHUpper()

getCellHLower

public final OcCell<T> getCellHLower()

getCellHLeft

public final OcCell<T> getCellHLeft()

getCellHRight

public final OcCell<T> getCellHRight()

getCellHBack

public final OcCell<T> getCellHBack()

getCellHFront

public final OcCell<T> getCellHFront()

getNode

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

hasChildCells

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

findChildCell

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

findChildCell

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

findChildCell

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

insertNode

public int insertNode(T node,
                      int minNodesBeforeSplit,
                      int maxLevelForExtendedCells)
Inserts a node into this OcCell 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()