de.jreality.geometry
Class BoundingBoxTraversal

java.lang.Object
  extended by de.jreality.scene.SceneGraphVisitor
      extended by de.jreality.geometry.BoundingBoxTraversal

public class BoundingBoxTraversal
extends SceneGraphVisitor

This class traverses a scene graph starting from the given "root" scene graph component and calculates the 3D bounding box.

At any point of the traversal, there is a current transformation representing the transformation from the root. Call this M. It can be initialized to a value using setInitialMatrix(double[]). For the following, let the current state of the bounding box during the traversal be denoted by B.

Only instances of Geometry currently contribute to the bounding box. They can do this in three ways:

One can obtain the bounding box using the methods getXmin(), etc, or all at once using getBoundingBox(). * @author Tim Hoffmann, Charles Gunn


Constructor Summary
BoundingBoxTraversal()
           
 
Method Summary
 Rectangle3D getBoundingBox()
          Convert result into Rectangle3D instance (see Rectangle3D
static Rectangle3D getBoundingBox(double[] initialMatrix, SceneGraphComponent sgc)
           
 double[] getBoundingBoxCenter(double[] c)
           
 double getXmax()
           
 double getXmin()
           
 double getYmax()
           
 double getYmin()
           
 double getZmax()
           
 double getZmin()
           
 void setInitialMatrix(double[] initialMatrix)
          Sets the initialTransformation.
 void traverse(SceneGraphComponent root)
          This starts the traversal of a SceneGraph starting form root.
 void visit(ClippingPlane p)
           
 void visit(Cylinder c)
           
 void visit(Geometry g)
           
 void visit(PointSet p)
           
 void visit(SceneGraphComponent c)
           
 void visit(Sphere s)
           
 void visit(Transformation t)
           
 
Methods inherited from class de.jreality.scene.SceneGraphVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundingBoxTraversal

public BoundingBoxTraversal()
Method Detail

setInitialMatrix

public void setInitialMatrix(double[] initialMatrix)
Sets the initialTransformation.

Parameters:
initialTransformation - The initialTransformation to set

traverse

public void traverse(SceneGraphComponent root)
This starts the traversal of a SceneGraph starting form root.

Parameters:
root -

visit

public void visit(SceneGraphComponent c)
Overrides:
visit in class SceneGraphVisitor

visit

public void visit(Transformation t)
Overrides:
visit in class SceneGraphVisitor

visit

public void visit(Geometry g)
Overrides:
visit in class SceneGraphVisitor

visit

public void visit(ClippingPlane p)
Overrides:
visit in class SceneGraphVisitor

visit

public void visit(Cylinder c)
Overrides:
visit in class SceneGraphVisitor

visit

public void visit(PointSet p)
Overrides:
visit in class SceneGraphVisitor

visit

public void visit(Sphere s)
Overrides:
visit in class SceneGraphVisitor

getXmax

public double getXmax()
Returns:
Returns the xmax.

getXmin

public double getXmin()
Returns:
Returns the xmin.

getYmax

public double getYmax()
Returns:
Returns the ymax.

getYmin

public double getYmin()
Returns:
Returns the ymin.

getZmax

public double getZmax()
Returns:
Returns the zmax.

getZmin

public double getZmin()
Returns:
Returns the zmin.

getBoundingBoxCenter

public double[] getBoundingBoxCenter(double[] c)

getBoundingBox

public Rectangle3D getBoundingBox()
Convert result into Rectangle3D instance (see Rectangle3D


getBoundingBox

public static Rectangle3D getBoundingBox(double[] initialMatrix,
                                         SceneGraphComponent sgc)