de.grogra.vecmath.geom
Class OctreeUnion

java.lang.Object
  extended by de.grogra.vecmath.geom.VolumeBase
      extended by de.grogra.vecmath.geom.CompoundVolume
          extended by de.grogra.vecmath.geom.UnionBase
              extended by de.grogra.vecmath.geom.OctreeUnion
All Implemented Interfaces:
Volume

public class OctreeUnion
extends UnionBase

An OctreeUnion behaves like a SimpleUnion, but has a better performance due to the intersection acceleration by an octree. After all component volumes have been added to the union, initialize(int, int, de.grogra.vecmath.geom.CellIterator) has to be invoked in order to construct the octree.

Author:
Michael Tauer, Ole Kniemeyer

Field Summary
 
Fields inherited from class de.grogra.vecmath.geom.CompoundVolume
volumes
 
Constructor Summary
OctreeUnion()
           
 
Method Summary
 void addInfiniteVolume(Volume v)
           
 boolean computeIntersections(Line line, int which, IntersectionList list, Intersection excludeStart, Intersection excludeEnd)
          Computes intersections between the boundary surface of this object and the specified line.
 void getExtent(Tuple3d min, Tuple3d max, Variables temp)
          Computes the extent of this volume, i.e., an axis-aligned bounding box between min and max.
 Octree getOctree()
           
 void initialize(int maxDepth, int minObjects, CellIterator iterator)
          Initializes the octree.
 
Methods inherited from class de.grogra.vecmath.geom.UnionBase
contains
 
Methods inherited from class de.grogra.vecmath.geom.CompoundVolume
boxContainsBoundary, computeNormal, computeTangents, computeUV
 
Methods inherited from class de.grogra.vecmath.geom.VolumeBase
addConvexIntersections, getId, operator$and, operator$com, operator$or, operator$sub, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OctreeUnion

public OctreeUnion()
Method Detail

addInfiniteVolume

public void addInfiniteVolume(Volume v)

computeIntersections

public boolean computeIntersections(Line line,
                                    int which,
                                    IntersectionList list,
                                    Intersection excludeStart,
                                    Intersection excludeEnd)
Description copied from interface: Volume
Computes intersections between the boundary surface of this object and the specified line. The intersections are added to list in ascending order of distance (i.e., of Intersection.parameter), where the parameter has to lie between line.start and line.end. Implementations of this method must not clear or modify the existing intersections in list.

The parameter which has to be one of Intersection.ALL, Intersection.CLOSEST, Intersection.ANY. It determines if all intersections have to be added to the list, only the closest (minimal value of Intersection.parameter), or an arbitrary of the set of all intersections. Only in case of ALL, the return value of this method is precise.

If specific intersection points should be excluded from the list of computed intersections, they have to be specified in excludeStart and excludeEnd. The intersection point of excludeStart has to be the starting point of line, the intersection point of excludeEnd has to be the end point of line. The exclusion of intersections is a useful feature for ray-tracing, e.g., when a ray is re-emitted at an intersection point in another direction.

Parameters:
line - a line
which - one of Intersection.ALL, Intersection.CLOSEST, Intersection.ANY, this determines which intersections have to be added to list
list - the intersections are added to this list
excludeStart - intersection at start point which shall be excluded, or null
excludeEnd - intersection at end point which shall be excluded, or null
Returns:
true iff the beginning of the line lies within the volume (i.e., if the line starts within the volume or enters the volume at the starting point); however note that the returned value is valid only if which == Intersection.ALL

getExtent

public void getExtent(Tuple3d min,
                      Tuple3d max,
                      Variables temp)
Description copied from interface: Volume
Computes the extent of this volume, i.e., an axis-aligned bounding box between min and max.

Specified by:
getExtent in interface Volume
Overrides:
getExtent in class UnionBase
Parameters:
min - minimum coordinates of bounding box are placed in here
max - maximum coordinates of bounding box are placed in here
temp - has to be provided by the invoker, may be used in implementations

getOctree

public Octree getOctree()

initialize

public void initialize(int maxDepth,
                       int minObjects,
                       CellIterator iterator)
Initializes the octree. This method has to be invoked after all volumes have been added to this union, but before any of the other methods are invoked.

Parameters:
maxDepth - maximum allowed depth of octree
minObjects - minimum volumes per cell. Only cells having more than minObjects volumes are checked for subdivision
iterator - the cell iterator to use