de.jreality.geometry

Class 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:

j
• When an instance of PointSet is found, M is applied to it vertices, and B is set to the union of the bounding box of these points is union-ed with B.
• Instances of build-in geometries such as Sphere have build-in bounding boxes which are transformed and union-ed with B
• If an instance of Geometry has a geometry attribute with key GeometryUtility.BOUNDING_BOX then this value is expected to be an instance of Rectangle3D and is union-ed with B. This overrides the first option given above.

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

• 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 -
• 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