maspack.geometry
Class Vertex3d

java.lang.Object
  extended by maspack.geometry.Feature
      extended by maspack.geometry.Vertex3d
All Implemented Interfaces:
java.lang.Cloneable, Boundable, Clonable
Direct Known Subclasses:
FemMeshVertex, MFreeVertex3d, PointMeshVertex, SubdivisionVertex3d

public class Vertex3d
extends Feature
implements Clonable, Boundable

Vertex for a 3D dimensional polyhedral object.


Field Summary
 Point3d myRenderPnt
           
 Point3d pnt
          3D point associated with this vertex.
 int uniqueIndex
           
 
Fields inherited from class maspack.geometry.Feature
CELL, EDGE, FACE, FACET, HALF_EDGE, TYPE_MASK, UNKNOWN, VERTEX_2D, VERTEX_3D, VISITED
 
Constructor Summary
Vertex3d()
          Creates a new Vertex3d with a point initialized to (0,0,0) and an index value of -1.
Vertex3d(double x, double y, double z)
          Creates a new Vertex3d with a specified point and index value.
Vertex3d(double x, double y, double z, int idx)
          Creates a new Vertex3d with a specified point and index value.
Vertex3d(int idx)
          Creates a new Vertex3d with point initialized to (0,0,0) and a specified index value.
Vertex3d(Point3d pnt)
          Creates a new Vertex3d with a specified point and an index value of -1.
Vertex3d(Point3d pnt, int idx)
          Creates a new Vertex3d with a specified point and index value.
 
Method Summary
 void addIncidentHalfEdge(HalfEdge he)
          Adds a half-edge to the list of half-edges incident onto this vertex.
 Vertex3d clone()
           
 boolean computeAngleWeightedNormal(Vector3d nrm)
          Computes a normal for this vertex by averaging the cross products of all the incident half edges.
 void computeCentroid(Vector3d centroid)
          Computed the centroid of this element.
 double computeCovariance(Matrix3d C)
          Computes the covariance of the element, assuming a uniform density of one.
 boolean computeNormal(Vector3d nrm)
          Computes a normal for this vertex by taking the average of all the associated face normals.
 boolean computeRenderNormal(Vector3d nrm)
           
 Vertex3d copy()
           
 HalfEdge firstIncidentHalfEdge()
          Returns the first incident half-edge listed for this vertex, or null if there are no incident half-edges.
 java.awt.Color getColor()
          Returns the color of this vertex, or null if no color has been set.
 float[] getColorArray()
           
 java.util.Iterator<HalfEdge> getIncidentHalfEdges()
          Returns an iterator for all the half-edges which are incident onto this vertex.
 int getIndex()
          Returns the index value associated with this vertex.
 MeshBase getMesh()
           
 Point3d getPoint(int idx)
          Returns the idx-th point associated with this element.
 Point3d getPosition()
           
 Point3d getWorldPoint()
          Returns the point value of this vertex in world coordinates.
 void getWorldPoint(Point3d pnt)
          Returns the point value of this vertex in world coordinates.
 Vertex3d interpolate(double s, Vertex3d vb)
           
 int numIncidentHalfEdges()
          Returns the number of half-edges which are incident onto this vertex.
 int numPoints()
          Returns the number of points associated with this element, if any, or zero otherwise.
 boolean removeIncidentHalfEdge(HalfEdge hedge)
          Removes a half-edge from the list of half-edges incident onto this vertex.
 void saveRenderInfo()
           
 void setColor(java.awt.Color color)
          Sets a color for this vertex, or removes the color if null is specified.
 void setColor(java.awt.Color color, float alpha)
           
 void setColor(double r, double g, double b)
           
 void setColor(double r, double g, double b, double a)
           
 void setColor(float r, float g, float b)
           
 void setColor(float r, float g, float b, float a)
           
 void setColorHSV(double h, double s, double b)
          Sets the vertex color based on hue, saturation, and value (brightness).
 void setColorHSV(double h, double s, double b, double a)
          Sets the vertex color based on hue, saturation, and value (brightness).
 void setIndex(int idx)
          Sets the index value for this vertex.
 void setMesh(MeshBase mesh)
           
 void setPosition(Point3d pos)
           
 void updateBounds(Point3d min, Point3d max)
          Updates the axis-aligned bounds of this element.
 
Methods inherited from class maspack.geometry.Feature
checkFlag, clearFlag, clearVisited, getType, getTypeName, isVisited, setFlag, setVisited, voronoiCheck
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pnt

public Point3d pnt
3D point associated with this vertex.


myRenderPnt

public Point3d myRenderPnt

uniqueIndex

public int uniqueIndex
Constructor Detail

Vertex3d

public Vertex3d()
Creates a new Vertex3d with a point initialized to (0,0,0) and an index value of -1.


Vertex3d

public Vertex3d(int idx)
Creates a new Vertex3d with point initialized to (0,0,0) and a specified index value.

Parameters:
idx - desired index value

Vertex3d

public Vertex3d(Point3d pnt,
                int idx)
Creates a new Vertex3d with a specified point and index value. The pnt field is set to refer directly to the supplied point.

Parameters:
pnt - point to use for the pnt field
idx - desired index value

Vertex3d

public Vertex3d(double x,
                double y,
                double z)
Creates a new Vertex3d with a specified point and index value.

Parameters:
x - vertex x coordinate
y - vertex y coordinate
z - vertex z coordinate

Vertex3d

public Vertex3d(double x,
                double y,
                double z,
                int idx)
Creates a new Vertex3d with a specified point and index value.

Parameters:
x - vertex x coordinate
y - vertex y coordinate
z - vertex z coordinate
idx - desired index value

Vertex3d

public Vertex3d(Point3d pnt)
Creates a new Vertex3d with a specified point and an index value of -1. The pnt field is set to refer directly to the supplied point.

Parameters:
pnt - point to use for the pnt field
Method Detail

getIncidentHalfEdges

public java.util.Iterator<HalfEdge> getIncidentHalfEdges()
Returns an iterator for all the half-edges which are incident onto this vertex. The iterator will return objects of type HalfEdge.

Returns:
iterator over incident half-edges

numIncidentHalfEdges

public int numIncidentHalfEdges()
Returns the number of half-edges which are incident onto this vertex.

Returns:
number of incident half-edges

computeNormal

public boolean computeNormal(Vector3d nrm)
Computes a normal for this vertex by taking the average of all the associated face normals.

Parameters:
nrm - returns the computed normal
Returns:
false if no faces normals are found

computeAngleWeightedNormal

public boolean computeAngleWeightedNormal(Vector3d nrm)
Computes a normal for this vertex by averaging the cross products of all the incident half edges.

Parameters:
nrm - returns the computed normal
Returns:
false if no incident halt edges are present

computeRenderNormal

public boolean computeRenderNormal(Vector3d nrm)

addIncidentHalfEdge

public void addIncidentHalfEdge(HalfEdge he)
Adds a half-edge to the list of half-edges incident onto this vertex.

Parameters:
he - HalfEdgeNode containing the half edge in question

removeIncidentHalfEdge

public boolean removeIncidentHalfEdge(HalfEdge hedge)
Removes a half-edge from the list of half-edges incident onto this vertex.

Parameters:
hedge - half-edge to remove
Returns:
true if the half-edge was present; false otherwise

firstIncidentHalfEdge

public HalfEdge firstIncidentHalfEdge()
Returns the first incident half-edge listed for this vertex, or null if there are no incident half-edges.

Returns:
first incident half-edge

getIndex

public int getIndex()
Returns the index value associated with this vertex.

Returns:
index value

setIndex

public void setIndex(int idx)
Sets the index value for this vertex.

Parameters:
idx - new index value

setColor

public void setColor(java.awt.Color color)
Sets a color for this vertex, or removes the color if null is specified.

Parameters:
color - color to set for this vertex.

setColor

public void setColor(java.awt.Color color,
                     float alpha)

setColor

public void setColor(float r,
                     float g,
                     float b)

setColor

public void setColor(float r,
                     float g,
                     float b,
                     float a)

setColor

public void setColor(double r,
                     double g,
                     double b)

setColor

public void setColor(double r,
                     double g,
                     double b,
                     double a)

setColorHSV

public void setColorHSV(double h,
                        double s,
                        double b)
Sets the vertex color based on hue, saturation, and value (brightness).

Parameters:
h - hue (in the range 0-1)
s - saturation (in the range 0-1)
b - brightness (in the range 0-1)

setColorHSV

public void setColorHSV(double h,
                        double s,
                        double b,
                        double a)
Sets the vertex color based on hue, saturation, and value (brightness).

Parameters:
h - hue (in the range 0-1)
s - saturation (in the range 0-1)
b - brightness (in the range 0-1)
a - alpha (in the range of 0-1)

getColor

public java.awt.Color getColor()
Returns the color of this vertex, or null if no color has been set.

Returns:
color for this vertex

getColorArray

public float[] getColorArray()

saveRenderInfo

public void saveRenderInfo()

getWorldPoint

public Point3d getWorldPoint()
Returns the point value of this vertex in world coordinates. The returned value should not be modified.

Returns:
point value in world coordinates

getWorldPoint

public void getWorldPoint(Point3d pnt)
Returns the point value of this vertex in world coordinates. The returned value should not be modified.


getMesh

public MeshBase getMesh()

setMesh

public void setMesh(MeshBase mesh)

interpolate

public Vertex3d interpolate(double s,
                            Vertex3d vb)

getPosition

public Point3d getPosition()

setPosition

public void setPosition(Point3d pos)

copy

public Vertex3d copy()

clone

public Vertex3d clone()
Specified by:
clone in interface Clonable
Overrides:
clone in class java.lang.Object

numPoints

public int numPoints()
Description copied from interface: Boundable
Returns the number of points associated with this element, if any, or zero otherwise. If the element has points, then it's spatial extent is assumed to be enclosed within their convex hull. At present, elements that do not have points cannot be enclosed within oriented bounding box (OBB) trees.

Specified by:
numPoints in interface Boundable
Returns:
number of points associated with this element

getPoint

public Point3d getPoint(int idx)
Description copied from interface: Boundable
Returns the idx-th point associated with this element.

Specified by:
getPoint in interface Boundable
Parameters:
idx - index of the point (must be on the range 0 to Boundable.numPoints()).
Returns:
idx-th point associated with this element. Must not be modified.

updateBounds

public void updateBounds(Point3d min,
                         Point3d max)
Description copied from interface: Boundable
Updates the axis-aligned bounds of this element. The value in min and max should be decreased or increased, respectively, so that all spatial points associated with this element lie within the axis-aligned box defined by min and max.

Specified by:
updateBounds in interface Boundable
Parameters:
min - minimum values to be updated
max - maximum values to be updated

computeCentroid

public void computeCentroid(Vector3d centroid)
Description copied from interface: Boundable
Computed the centroid of this element.

Specified by:
computeCentroid in interface Boundable
Parameters:
centroid - returns the computed centroid value.

computeCovariance

public double computeCovariance(Matrix3d C)
Description copied from interface: Boundable
Computes the covariance of the element, assuming a uniform density of one. The covariance is defined as
 int_V \rho x x^T dV,
 
where \rho is the density, x is any spatial point within the element, and the integral is evaluated over the element's spatial extent. The method returns the element's spatial size, which for elements of dimension 3, 2, 1, or 0 will be a volume, area, length, or discrete value.

Implementation of this method is optional, with non-implementation indicated by having the method return -1. Non-implementation may prevent the element from being enclosed within certain types of oriented bounding box (OBB) constructions.

Specified by:
computeCovariance in interface Boundable
Parameters:
C - returns the covariance
Returns:
spatial size of the element, or -1 if this method is not implemented.