public class TetMesh
extends java.lang.Object
implements java.io.Serializable
Each tet in the mesh references four nodes. Depending on the context, these four nodes are labelled as 0, 1, 2, and 3, or A, B, C, D. The nodes are ordered such that 1, 2, and 3 (or B, C, and D) are in counter-clockwise (CCW) order as viewed from node 0 (or A). Here is a picture:
2(C)
*
/|\
/ | \
0(A)*---|---* 3(D)
\ | /
\ | /
\|/
*
1(B)
Each tet has up to four neighbors (nabors), corresponding to the four
faces of the tet. Tets on the convex hull of the mesh have one or more
null nabors. Each nabor is labelled by the node opposite its face. For
example, the tet nabor 0 (or A) is opposite the node 0 (or A).
Faces and edges of each tet are enumerated as follows. The four oriented faces of each tet are ABC|D, BDC|A, CDA|B, and DBA|C, where the fourth node in each group is referenced by the tet, but not the face, and is left of the plane defined by the first three nodes. Likewise, the six directed edges of each tet are AB|CD, AC|DB, AD|BC, BC|AD, BD|CA, and CD|AB, where the third and fourth nodes in each group are referenced by the tet, but not the edge, and the fourth node is left of the plane defined by the first three nodes.
Nodes are constructed with float coordinates that are stored internally as perturbed doubles. This perturbation minimizes the likelihood that four or more nodes are exactly co-planar, or that five or more nodes lie exactly on the circumsphere of any tet in the mesh. Only the least significant bits of the double coordinates are altered, so that casting the perturbed doubles to floats always yields the float coordinates with which nodes are constructed.
A tet mesh is serializable. When written to an object output stream, a tet mesh writes its nodes and tets so that any references to them from serialized objects not in the mesh will remain valid.
While mesh nodes and tets are serializable alone, most of their state is serialized only when the entire mesh is serialized.
Listeners to a tet mesh are not serialized. When a tet mesh is read from an object input stream, it will have no listeners.
Modifier and Type | Class and Description |
---|---|
static class |
TetMesh.Edge
A directed edge.
|
static interface |
TetMesh.EdgeIterator
Type-safe iterator for edges.
|
static class |
TetMesh.EdgeList
A dynamically growing list of edges.
|
static class |
TetMesh.Face
An oriented triangular face.
|
static interface |
TetMesh.FaceIterator
Type-safe iterator for faces.
|
static class |
TetMesh.FaceList
A dynamically growing list of faces.
|
static class |
TetMesh.Node
A node, which may be added or removed from the mesh.
|
static interface |
TetMesh.NodeIterator
A type-safe iterator for nodes.
|
static class |
TetMesh.NodeList
A dynamically growing list of nodes.
|
static interface |
TetMesh.NodeListener
Implemented to monitor the addition and removal of nodes in the mesh.
|
static interface |
TetMesh.NodePropertyMap
Implemented by maps that associate property values with mesh nodes.
|
static class |
TetMesh.NodeStepList
A dynamically growing list of nodes and steps.
|
static class |
TetMesh.PointLocation
The location of a point relative to the mesh.
|
static class |
TetMesh.Tet
One tetrahedron (tet) in the mesh.
|
static interface |
TetMesh.TetIterator
A type-safe iterator for tets.
|
static class |
TetMesh.TetList
A dynamically growing list of tets.
|
static interface |
TetMesh.TetListener
Implemented to monitor the addition and removal of tets in the mesh.
|
Constructor and Description |
---|
TetMesh()
Constructs an empty mesh.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addNode(TetMesh.Node node)
Adds a node to the mesh, if the mesh does not already contain
a node with the same (x,y,z) coordinates.
|
void |
addNodeListener(TetMesh.NodeListener nl)
Adds the specified node listener.
|
void |
addTetListener(TetMesh.TetListener tl)
Adds the specified tet listener.
|
void |
clearNodeMarks()
Clears all node marks, so that no node is marked.
|
void |
clearTetMarks()
Clears all tet marks, so that no tet is marked.
|
int |
countNodes()
Returns the number of nodes in the mesh.
|
int |
countTets()
Returns the number of tets in the mesh.
|
void |
disableOuterBox()
Disables outer box testing, without altering the outer box.
|
void |
enableOuterBox()
Enables outer box testing.
|
TetMesh.Edge |
findEdge(TetMesh.Node na,
TetMesh.Node nb)
Finds an edge of a tet in the mesh that references the specified nodes.
|
TetMesh.Face |
findFace(TetMesh.Node na,
TetMesh.Node nb,
TetMesh.Node nc)
Finds a face of a tet in the mesh that references the specified nodes.
|
TetMesh.Node |
findNodeNearest(float x,
float y,
float z)
Finds the node nearest to the point with specified coordinates.
|
TetMesh.Node |
findNodeNearestSlow(float x,
float y,
float z)
Finds the node nearest to the point with specified coordinates.
|
TetMesh.Tet |
findTet(TetMesh.Node node)
Returns a tet that references the specified node.
|
TetMesh.Tet |
findTet(TetMesh.Node na,
TetMesh.Node nb)
Returns a tet that references the specified nodes.
|
TetMesh.Tet |
findTet(TetMesh.Node na,
TetMesh.Node nb,
TetMesh.Node nc)
Returns a tet that references the specified nodes.
|
TetMesh.Tet |
findTet(TetMesh.Node na,
TetMesh.Node nb,
TetMesh.Node nc,
TetMesh.Node nd)
Returns a tet that references the specified nodes.
|
TetMesh.Tet |
findTetInPlane(double a,
double b,
double c,
double d)
Finds a tet that intersects the specified plane a*x+b*y+c*z+d = 0.
|
TetMesh.Edge[] |
getEdgeNabors(TetMesh.Node node)
Gets an array of edge nabors of the specified node.
|
void |
getEdgeNabors(TetMesh.Node node,
TetMesh.EdgeList nabors)
Appends the edge nabors of the specified node to the specified list.
|
TetMesh.EdgeIterator |
getEdges()
Gets an iterator for all edges in the mesh.
|
TetMesh.Face[] |
getFaceNabors(TetMesh.Edge edge)
Gets an array of face nabors of the specified edge.
|
void |
getFaceNabors(TetMesh.Edge edge,
TetMesh.FaceList nabors)
Appends the face nabors of the specified edge to the specified list.
|
TetMesh.FaceIterator |
getFacesOnHull()
Gets an iterator for all faces on the hull of the mesh.
|
TetMesh.Node[] |
getNodeNabors(TetMesh.Node node)
Gets an array of node nabors of the specified node.
|
TetMesh.NodeStepList |
getNodeNabors(TetMesh.Node node,
int stepMax)
Finds all node nabors that are within the specified maximum
number of steps of the specified node.
|
void |
getNodeNabors(TetMesh.Node node,
TetMesh.NodeList nabors)
Appends the node nabors of the specified node to the specified list.
|
TetMesh.NodePropertyMap |
getNodePropertyMap(java.lang.String name)
Gets the node property map with the specified name.
|
java.lang.String[] |
getNodePropertyMapNames()
Returns the names of the node property maps.
|
TetMesh.NodeIterator |
getNodes()
Gets an iterator for all nodes in the mesh.
|
TetMesh.NodeIterator |
getNodesNearestPlane(double a,
double b,
double c,
double d)
Gets an iterator for all nodes in the mesh that are nearest to a plane.
|
TetMesh.Tet[] |
getTetNabors(TetMesh.Edge edge)
Gets an array of tet nabors of the specified edge.
|
void |
getTetNabors(TetMesh.Edge edge,
TetMesh.TetList nabors)
Appends the tet nabors of the specified edge to the specified list.
|
TetMesh.Tet[] |
getTetNabors(TetMesh.Face face)
Gets an array of tet nabors of the specified face.
|
void |
getTetNabors(TetMesh.Face face,
TetMesh.TetList nabors)
Appends the tet nabors of the specified face to the specified list.
|
TetMesh.Tet[] |
getTetNabors(TetMesh.Node node)
Gets an array of tet nabors of the specified node.
|
void |
getTetNabors(TetMesh.Node node,
TetMesh.TetList nabors)
Appends the tet nabors of the specified node to the specified list.
|
TetMesh.TetIterator |
getTets()
Gets an iterator for all tets in the mesh.
|
TetMesh.TetIterator |
getTetsInPlane(double a,
double b,
double c,
double d)
Gets an iterator for all tets in the mesh that intersect a plane.
|
long |
getVersion()
Gets the version number for the mesh.
|
boolean |
hasNodePropertyMap(java.lang.String name)
Determines whether this mesh has a node property map with specified name.
|
protected void |
init()
Initialization for use in constructers and serialization (readObject).
|
boolean |
isInner(TetMesh.Edge edge)
Determines whether the specified edge is an inner edge.
|
boolean |
isInner(TetMesh.Face face)
Determines whether the specified face is an inner face.
|
boolean |
isInner(TetMesh.Node node)
Determines whether the specified node is an inner node.
|
boolean |
isInner(TetMesh.Tet tet)
Determines whether the specified tet is an inner tet.
|
boolean |
isMarked(TetMesh.Node node)
Determines whether the specified node is marked (red).
|
boolean |
isMarked(TetMesh.Tet tet)
Determines whether the specified tet is marked (red).
|
boolean |
isMarkedBlue(TetMesh.Node node)
Determines whether the specified node is marked blue.
|
boolean |
isMarkedBlue(TetMesh.Tet tet)
Determines whether the specified tet is marked blue.
|
boolean |
isMarkedRed(TetMesh.Node node)
Determines whether the specified node is marked red.
|
boolean |
isMarkedRed(TetMesh.Tet tet)
Determines whether the specified tet is marked red.
|
boolean |
isOuter(TetMesh.Edge edge)
Determines whether the specified edge is an outer edge.
|
boolean |
isOuter(TetMesh.Face face)
Determines whether the specified face is an outer face.
|
boolean |
isOuter(TetMesh.Node node)
Determines whether the specified node is an outer node.
|
boolean |
isOuter(TetMesh.Tet tet)
Determines whether the specified tet is an outer tet.
|
TetMesh.PointLocation |
locatePoint(float x,
float y,
float z)
Locates a point with specified coordinates.
|
void |
mark(TetMesh.Node node)
Marks the specified node (red).
|
void |
mark(TetMesh.Tet tet)
Marks the specified tet (red).
|
void |
markBlue(TetMesh.Node node)
Marks the specified node blue.
|
void |
markBlue(TetMesh.Tet tet)
Marks the specified tet blue.
|
void |
markRed(TetMesh.Node node)
Marks the specified node red.
|
void |
markRed(TetMesh.Tet tet)
Marks the specified tet red.
|
boolean |
moveNode(TetMesh.Node node,
float x,
float y,
float z)
Moves a node in the mesh to the specified (x,y,z) coordinates.
|
boolean |
removeNode(TetMesh.Node node)
Removes a node from the mesh, if the node is in the mesh.
|
void |
removeNodeListener(TetMesh.NodeListener nl)
Removes the specified node listener.
|
void |
removeTetListener(TetMesh.TetListener tl)
Removes the specified tet listener.
|
void |
setOuterBox(float xmin,
float ymin,
float zmin,
float xmax,
float ymax,
float zmax)
Sets and enables the outer box for this mesh.
|
void |
unmark(TetMesh.Node node)
Unmarks the specified node.
|
void |
unmark(TetMesh.Tet tet)
Unmarks the specified tet.
|
void |
validate()
Validates the internal consistency of the mesh.
|
public int countNodes()
public int countTets()
public long getVersion()
public boolean addNode(TetMesh.Node node)
node
- the node to add.public boolean removeNode(TetMesh.Node node)
node
- the node to remove.public boolean moveNode(TetMesh.Node node, float x, float y, float z)
node
- a node in the mesh.x
- the x coordinate of the moved node.y
- the y coordinate of the moved node.z
- the z coordinate of the moved node.public TetMesh.Node findNodeNearest(float x, float y, float z)
x
- the x coordinate.y
- the y coordinate.z
- the z coordinate.public TetMesh.Edge findEdge(TetMesh.Node na, TetMesh.Node nb)
na
- a node.nb
- a node.public TetMesh.Face findFace(TetMesh.Node na, TetMesh.Node nb, TetMesh.Node nc)
na
- a node.nb
- a node.nc
- a node.public TetMesh.Tet findTet(TetMesh.Node node)
node
- the node.public TetMesh.Tet findTet(TetMesh.Node na, TetMesh.Node nb)
na
- a node.nb
- a node.public TetMesh.Tet findTet(TetMesh.Node na, TetMesh.Node nb, TetMesh.Node nc)
na
- a node.nb
- a node.nc
- a node.public TetMesh.Tet findTet(TetMesh.Node na, TetMesh.Node nb, TetMesh.Node nc, TetMesh.Node nd)
na
- a node.nb
- a node.nc
- a node.nd
- a node.public TetMesh.PointLocation locatePoint(float x, float y, float z)
x
- the x coordinate.y
- the y coordinate.z
- the z coordinate.TetMesh.PointLocation
.public TetMesh.NodeIterator getNodes()
public TetMesh.TetIterator getTets()
public TetMesh.EdgeIterator getEdges()
public TetMesh.TetIterator getTetsInPlane(double a, double b, double c, double d)
a
- the coefficient a in the equation for the plane.b
- the coefficient b in the equation for the plane.c
- the coefficient c in the equation for the plane.d
- the coefficient d in the equation for the plane.public TetMesh.NodeIterator getNodesNearestPlane(double a, double b, double c, double d)
Nodes nearest the plane are those with Voronoi polyhedra that intersect the plane. In other words, a node is nearest the plane if there exists some point in the plane that is nearer to that node than to all other nodes in the mesh.
a
- the coefficient a in the equation for the plane.b
- the coefficient b in the equation for the plane.c
- the coefficient c in the equation for the plane.d
- the coefficient d in the equation for the plane.public TetMesh.Tet findTetInPlane(double a, double b, double c, double d)
a
- the coefficient a in the equation for the plane.b
- the coefficient b in the equation for the plane.c
- the coefficient c in the equation for the plane.d
- the coefficient d in the equation for the plane.public TetMesh.FaceIterator getFacesOnHull()
public TetMesh.Node[] getNodeNabors(TetMesh.Node node)
node
- the node for which to get nabors.public void getNodeNabors(TetMesh.Node node, TetMesh.NodeList nabors)
node
- the node for which to get nabors.nabors
- the list to which nabors are appended.public TetMesh.NodeStepList getNodeNabors(TetMesh.Node node, int stepMax)
node
- the node for which to get nabors.stepMax
- the maximum number of steps; must not exceed 256.public TetMesh.Tet[] getTetNabors(TetMesh.Node node)
node
- the node for which to get nabors.public void getTetNabors(TetMesh.Node node, TetMesh.TetList nabors)
node
- the node for which to get nabors.nabors
- the list to which nabors are appended.public TetMesh.Tet[] getTetNabors(TetMesh.Edge edge)
edge
- the edge for which to get nabors.public void getTetNabors(TetMesh.Edge edge, TetMesh.TetList nabors)
edge
- the edge for which to get nabors.nabors
- the list to which nabors are appended.public TetMesh.Tet[] getTetNabors(TetMesh.Face face)
face
- the face for which to get nabors.public void getTetNabors(TetMesh.Face face, TetMesh.TetList nabors)
face
- the face for which to get nabors.nabors
- the list to which nabors are appended.public TetMesh.Edge[] getEdgeNabors(TetMesh.Node node)
node
- the node for which to get nabors.public void getEdgeNabors(TetMesh.Node node, TetMesh.EdgeList nabors)
node
- the node for which to get nabors.nabors
- the list to which nabors are appended.public TetMesh.Face[] getFaceNabors(TetMesh.Edge edge)
edge
- the edge for which to get nabors.public void getFaceNabors(TetMesh.Edge edge, TetMesh.FaceList nabors)
edge
- the edge for which to get nabors.nabors
- the list to which nabors are appended.public void setOuterBox(float xmin, float ymin, float zmin, float xmax, float ymax, float zmax)
The outer box is typically set to be slightly larger than the bounding box of the convex hull of the mesh, so that outer tets lie near the convex hull. These outer tets tend to have poor quality, and are often ignored in iterations over tets.
xmin
- minimum x coordinate of box.ymin
- minimum y coordinate of box.zmin
- minimum z coordinate of box.xmax
- maximum x coordinate of box.ymax
- maximum y coordinate of box.zmax
- maximum z coordinate of box.public void enableOuterBox()
public void disableOuterBox()
public boolean isInner(TetMesh.Node node)
public boolean isOuter(TetMesh.Node node)
public boolean isInner(TetMesh.Tet tet)
public boolean isOuter(TetMesh.Tet tet)
public boolean isInner(TetMesh.Edge edge)
public boolean isOuter(TetMesh.Edge edge)
public boolean isInner(TetMesh.Face face)
public boolean isOuter(TetMesh.Face face)
public final void mark(TetMesh.Node node)
node
- the node to mark (red).public final void markRed(TetMesh.Node node)
node
- the node to mark red.public final void markBlue(TetMesh.Node node)
node
- the node to mark blue.public final void unmark(TetMesh.Node node)
node
- the node to unmark.public final boolean isMarked(TetMesh.Node node)
node
- the node.public final boolean isMarkedRed(TetMesh.Node node)
node
- the node.public final boolean isMarkedBlue(TetMesh.Node node)
node
- the node.public void clearNodeMarks()
public final void mark(TetMesh.Tet tet)
tet
- the tet to mark (red).public final void markRed(TetMesh.Tet tet)
tet
- the tet to mark red.public final void markBlue(TetMesh.Tet tet)
tet
- the tet to mark blue.public final void unmark(TetMesh.Tet tet)
tet
- the tet to unmark.public final boolean isMarked(TetMesh.Tet tet)
tet
- the tet.public final boolean isMarkedRed(TetMesh.Tet tet)
tet
- the tet.public final boolean isMarkedBlue(TetMesh.Tet tet)
tet
- the tet.public void clearTetMarks()
public TetMesh.NodePropertyMap getNodePropertyMap(java.lang.String name)
name
- the property map name.public boolean hasNodePropertyMap(java.lang.String name)
name
- the property map name.public java.lang.String[] getNodePropertyMapNames()
getNodePropertyMap(String)
public void addNodeListener(TetMesh.NodeListener nl)
nl
- the node listener.public void removeNodeListener(TetMesh.NodeListener nl)
nl
- the node listener.public void addTetListener(TetMesh.TetListener tl)
tl
- the tet listener.public void removeTetListener(TetMesh.TetListener tl)
tl
- the tet listener.public void validate()
java.lang.RuntimeException
- if the mesh is invalid.protected void init()
public TetMesh.Node findNodeNearestSlow(float x, float y, float z)