Class AbstractDrawable3DObject
- java.lang.Object
-
- org.scilab.forge.scirenderer.implementation.g2d.motor.AbstractDrawable3DObject
-
- Direct Known Subclasses:
ConvexObject
public abstract class AbstractDrawable3DObject extends java.lang.Object
- Author:
- Calixte DENIZET
-
-
Field Summary
Fields Modifier and Type Field Description protected BoundingBox
bbox
protected java.awt.Color[]
colors
protected java.lang.Boolean
degenerated
protected java.lang.Boolean
is2d
protected boolean
marked
protected boolean
marked2
protected Vector3d
normal
protected double
nv0v1
protected int
precedence
static double
PRECISION
protected Vector3d
v0
protected Vector3d
v0v1
protected Vector3d
v1
protected Vector3d[]
vertices
protected java.lang.Double
zindex
-
Constructor Summary
Constructors Constructor Description AbstractDrawable3DObject(Vector3d[] vertices, java.awt.Color[] colors)
Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
draw(java.awt.Graphics2D g2d)
Draw this object on a Graphics2D objectprotected static java.awt.Color
getColorsBarycenter(java.awt.Color c1, java.awt.Color c2, double w1, double w2)
Vector3d
getNormal()
Get the normal vector.int
getPrecedence()
Get the precedence of this object, i.e.protected java.awt.geom.Path2D
getProjectedContour()
Get the projected contour (i.e.protected java.awt.geom.Path2D
getProjectedPolyLine()
Get the projected polyline of this objectVector3d
getProvidedNormal()
Get the normal vector.boolean
is2D()
Determinates if this object is 2D in looking at the z coordinates (when all the drawn objects are 2D, we can avoid the projection)int
isBehind(Vector3d v, double a)
static boolean
isBehind(Vector3d M, Vector3d v, double a)
protected boolean
isDegenerate()
protected static boolean
isEqual(double d1, double d2)
protected static boolean
isGreaterOrEqual(double d1, double d2)
protected static boolean
isLowerOrEqual(double d1, double d2)
static boolean
isMonochromatic(java.awt.Color[] colors)
Test if an array of colors contains only one color or notprotected boolean
isNanOrInf()
static boolean
isNanOrInf(Vector3d v)
protected static boolean
isNegativeOrNull(double d)
protected static boolean
isNull(double d)
protected boolean
isPlanar()
Determinates if the object is contained into a planeprotected static boolean
isPositiveOrNull(double d)
protected static double[]
minmax2D(AbstractDrawable3DObject o, double x, double y)
Get min-max of the projections of the vertices of o on vprotected static double[]
minmax3D(AbstractDrawable3DObject o, Vector3d v)
Get min-max of the projections of the vertices of o on vstatic void
resetDefaultPrecedence()
Reset the default precedenceprotected void
setNormal()
Set the normal vectorvoid
setPrecedence(int precedence)
Set the precedence of this object.
-
-
-
Field Detail
-
PRECISION
public static final double PRECISION
- See Also:
- Constant Field Values
-
vertices
protected final Vector3d[] vertices
-
colors
protected final java.awt.Color[] colors
-
precedence
protected int precedence
-
is2d
protected java.lang.Boolean is2d
-
zindex
protected java.lang.Double zindex
-
v0
protected Vector3d v0
-
v1
protected Vector3d v1
-
v0v1
protected Vector3d v0v1
-
nv0v1
protected double nv0v1
-
normal
protected Vector3d normal
-
bbox
protected BoundingBox bbox
-
marked
protected boolean marked
-
marked2
protected boolean marked2
-
degenerated
protected java.lang.Boolean degenerated
-
-
Constructor Detail
-
AbstractDrawable3DObject
public AbstractDrawable3DObject(Vector3d[] vertices, java.awt.Color[] colors) throws InvalidPolygonException
Default constructor- Parameters:
vertices
- the vertices- Throws:
InvalidPolygonException
-
-
Method Detail
-
isMonochromatic
public static boolean isMonochromatic(java.awt.Color[] colors)
Test if an array of colors contains only one color or not- Parameters:
colors
- the colors array- Returns:
- true if the array is monochromatic
-
draw
public abstract void draw(java.awt.Graphics2D g2d)
Draw this object on a Graphics2D object- Parameters:
g2d
- the Graphics2d object where to draw
-
resetDefaultPrecedence
public static void resetDefaultPrecedence()
Reset the default precedence
-
setPrecedence
public void setPrecedence(int precedence)
Set the precedence of this object.- Parameters:
precedence
- the precedence of this object
-
getPrecedence
public int getPrecedence()
Get the precedence of this object, i.e. its position in the list of the draw objects. The first object has a precedence of 0, the second has a precedence of 1, ...- Parameters:
the
- precedence
-
is2D
public boolean is2D()
Determinates if this object is 2D in looking at the z coordinates (when all the drawn objects are 2D, we can avoid the projection)
-
getProvidedNormal
public Vector3d getProvidedNormal()
Get the normal vector. If no normal vector has been set then it is calculated in using the cross product of the first two vectors.- Returns:
- the normal vector.
-
getNormal
public Vector3d getNormal()
Get the normal vector. If no normal vector has been set then it is calculated in using the cross product of the first two vectors.- Returns:
- the normal vector.
-
setNormal
protected void setNormal()
Set the normal vector
-
isPlanar
protected boolean isPlanar()
Determinates if the object is contained into a plane- Returns:
- true if the object is planar
-
isBehind
public int isBehind(Vector3d v, double a)
-
getProjectedPolyLine
protected java.awt.geom.Path2D getProjectedPolyLine()
Get the projected polyline of this object- Returns:
- a path 2D
-
getProjectedContour
protected java.awt.geom.Path2D getProjectedContour()
Get the projected contour (i.e. a closed polyline) of this object- Returns:
- a path 2D
-
isNull
protected static final boolean isNull(double d)
- Parameters:
d
- a number- Returns:
- true if d is near zero
-
isPositiveOrNull
protected static final boolean isPositiveOrNull(double d)
- Parameters:
d
- a number- Returns:
- true if d is greater than zero
-
isNegativeOrNull
protected static final boolean isNegativeOrNull(double d)
- Parameters:
d
- a number- Returns:
- true if d is greater than zero
-
isGreaterOrEqual
protected static final boolean isGreaterOrEqual(double d1, double d2)
- Parameters:
d1
- a numberd2
- a number- Returns:
- true if d1 is greater than d2
-
isLowerOrEqual
protected static final boolean isLowerOrEqual(double d1, double d2)
- Parameters:
d1
- a numberd2
- a number- Returns:
- true if d1 is lower than d2
-
isEqual
protected static final boolean isEqual(double d1, double d2)
- Parameters:
d1
- a numberd2
- a number- Returns:
- true if d1 is equal to d2
-
minmax3D
protected static final double[] minmax3D(AbstractDrawable3DObject o, Vector3d v)
Get min-max of the projections of the vertices of o on v- Parameters:
o
- an objectv
- a vector- Returns:
- an array of size 2 containing min-max.
-
minmax2D
protected static final double[] minmax2D(AbstractDrawable3DObject o, double x, double y)
Get min-max of the projections of the vertices of o on v- Parameters:
o
- an objectv
- a vector- Returns:
- an array of size 2 containing min-max.
-
getColorsBarycenter
protected static final java.awt.Color getColorsBarycenter(java.awt.Color c1, java.awt.Color c2, double w1, double w2)
-
isDegenerate
protected boolean isDegenerate()
- Returns:
- true if there are two vertices which are indentical
-
isNanOrInf
protected boolean isNanOrInf()
-
isNanOrInf
public static final boolean isNanOrInf(Vector3d v)
-
-