public class BoundingBoxTraversal extends SceneGraphVisitor
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:
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.Sphere
have build-in bounding boxes
which are transformed and union-ed with B
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 and Description |
---|
BoundingBoxTraversal() |
Modifier and Type | Method and Description |
---|---|
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) |
public void setInitialMatrix(double[] initialMatrix)
initialTransformation
- The initialTransformation to setpublic void traverse(SceneGraphComponent root)
root
- public void visit(SceneGraphComponent c)
visit
in class SceneGraphVisitor
public void visit(Transformation t)
visit
in class SceneGraphVisitor
public void visit(Geometry g)
visit
in class SceneGraphVisitor
public void visit(ClippingPlane p)
visit
in class SceneGraphVisitor
public void visit(Cylinder c)
visit
in class SceneGraphVisitor
public void visit(PointSet p)
visit
in class SceneGraphVisitor
public void visit(Sphere s)
visit
in class SceneGraphVisitor
public double getXmax()
public double getXmin()
public double getYmax()
public double getYmin()
public double getZmax()
public double getZmin()
public double[] getBoundingBoxCenter(double[] c)
public Rectangle3D getBoundingBox()
Rectangle3D
public static Rectangle3D getBoundingBox(double[] initialMatrix, SceneGraphComponent sgc)