org.jcae.mesh.amibe.ds
Class VirtualHalfEdge

java.lang.Object
  extended by org.jcae.mesh.amibe.ds.AbstractHalfEdge
      extended by org.jcae.mesh.amibe.ds.VirtualHalfEdge
Direct Known Subclasses:
VirtualHalfEdge2D

public class VirtualHalfEdge
extends AbstractHalfEdge

A handle to abstract half-edge instances. When triangles are instances of TriangleVH class, adjacency relations are contained within triangles. This VirtualHalfEdge class is a handle to an edge, it has a link to a triangle and contains a local number. When a VirtualHalfEdge instance is traversing the mesh, its reference is not modified, but its instance variables are updated. In order to prevent object allocations, we try to reuse VirtualHalfEdge objects as much as we can.


Field Summary
protected  int attributes
          Attributes of this edge.
protected  int localNumber
          Local number of this edge in this triangle.
protected  TriangleVH tri
          Triangle connected to this edge.
 
Fields inherited from class org.jcae.mesh.amibe.ds.AbstractHalfEdge
BOUNDARY, int3, MARKED, NONMANIFOLD, OUTER, QUAD, SWAPPED, traits, traitsBuilder
 
Constructor Summary
VirtualHalfEdge()
          Sole constructor.
VirtualHalfEdge(Triangle t, int o)
          Creates an object to handle data about a triangle.
 
Method Summary
 Vertex apex()
          Returns apex of this edge.
 double area()
          Returns the area of triangle bound to this edge.
 void bind(TriangleVH t)
          Sets triangle tied to this object, and resets localNumber.
 void bind(TriangleVH t, int l)
          Sets the triangle tied to this object, and the localNumber.
protected  boolean canCollapse(Vertex n)
          Checks whether an edge can be contracted.
 boolean checkNewRingNormals(double[] newpt)
          Checks that triangles are not inverted if origin vertex is moved.
 double checkSwap3D(double minCos)
          Checks the dihedral angle of an edge.
 double checkSwap3D(double minCos, double maxLength)
           
 void clearAttributes(int attr)
          Resets attributes of this edge.
protected  VirtualHalfEdge collapse(Mesh m, Vertex v)
          Contracts an edge.
 double computeNormal3D()
          Computes the normal of this triangle.
 double computeNormal3DT()
          Computes the normal of an edge, in the triangle plane.
protected static void copyOTri(VirtualHalfEdge src, VirtualHalfEdge dest)
          Copies a VirtualHalfEdge instance into another VirtualHalfEdge instance.
 Vertex destination()
          Returns end vertex of this edge.
 java.util.Iterator<AbstractHalfEdge> fanIterator()
          Returns an iterator over triangle fans connected to this edge.
 int getLocalNumber()
          Returns edge local number.
 double[] getTempVector()
          Returns the temporary array TempD.
 Triangle getTri()
          Returns triangle tied to this edge.
 void glue(AbstractHalfEdge sym)
          Sets adjacency relations between two triangles.
 boolean hasAttributes(int attr)
          Checks if some attributes of this edge are set.
 boolean hasSymmetricEdge()
          Tells whether edge is connected to a symmetric edge.
 boolean isMutable()
          Checks whether an edge can be modified.
 VirtualHalfEdge next()
          Moves counterclockwise to following edge.
 VirtualHalfEdge next(AbstractHalfEdge that)
          Moves counterclockwise to following edge.
 VirtualHalfEdge nextOrigin()
          Moves counterclockwise to the following edge which has the same origin.
 VirtualHalfEdge nextOrigin(AbstractHalfEdge that)
          Moves counterclockwise to the following edge which has the same origin.
 VirtualHalfEdge nextOriginLoop()
          Moves counterclockwise to the following edge which has the same origin.
protected static void nextOTri(VirtualHalfEdge o, VirtualHalfEdge that)
          Copies a VirtualHalfEdge instance and move it counterclockwise to following edge.
 Vertex origin()
          Returns start vertex of this edge.
 VirtualHalfEdge prev()
          Moves counterclockwise to previous edge.
 VirtualHalfEdge prev(AbstractHalfEdge that)
          Moves counterclockwise to previous edge.
protected static void prevOTri(VirtualHalfEdge o, VirtualHalfEdge that)
          Copies a VirtualHalfEdge instance and move it counterclockwise to previous edge.
protected  void pullAttributes()
           
protected  void pushAttributes()
           
 void setApex(Vertex v)
          Sets apex of this edge.
 void setAttributes(int attr)
          Sets attributes of this edge.
 void setDestination(Vertex v)
          Sets end vertex of this edge.
 void setOrigin(Vertex v)
          Sets start vertex of this edge.
protected  VirtualHalfEdge split(Mesh m, Vertex v)
          Splits an edge.
protected  VirtualHalfEdge swap()
          Swaps an edge.
 VirtualHalfEdge sym()
          Moves to symmetric edge.
 VirtualHalfEdge sym(AbstractHalfEdge that)
          Moves to symmetric edge.
protected static void symOTri(VirtualHalfEdge o, VirtualHalfEdge that)
          Copies a VirtualHalfEdge instance and move to its symmetric edge.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tri

protected TriangleVH tri
Triangle connected to this edge.


localNumber

protected int localNumber
Local number of this edge in this triangle.


attributes

protected int attributes
Attributes of this edge.

Constructor Detail

VirtualHalfEdge

public VirtualHalfEdge()
Sole constructor.


VirtualHalfEdge

public VirtualHalfEdge(Triangle t,
                       int o)
Creates an object to handle data about a triangle.

Parameters:
t - geometrical triangle
o - a number between 0 and 2 determining an edge
Method Detail

getTri

public final Triangle getTri()
Returns triangle tied to this edge.

Specified by:
getTri in class AbstractHalfEdge
Returns:
triangle tied to this edge

getLocalNumber

public final int getLocalNumber()
Returns edge local number.

Specified by:
getLocalNumber in class AbstractHalfEdge
Returns:
edge local number

bind

public final void bind(TriangleVH t)
Sets triangle tied to this object, and resets localNumber.

Parameters:
t - triangle tied to this object

bind

public final void bind(TriangleVH t,
                       int l)
Sets the triangle tied to this object, and the localNumber.

Parameters:
t - triangle tied to this object
l - local number

hasAttributes

public final boolean hasAttributes(int attr)
Checks if some attributes of this edge are set.

Specified by:
hasAttributes in class AbstractHalfEdge
Parameters:
attr - attributes to check
Returns:
true if this VirtualHalfEdge has one of these attributes set, false otherwise

setAttributes

public final void setAttributes(int attr)
Sets attributes of this edge.

Specified by:
setAttributes in class AbstractHalfEdge
Parameters:
attr - attributes of this edge

clearAttributes

public final void clearAttributes(int attr)
Resets attributes of this edge.

Specified by:
clearAttributes in class AbstractHalfEdge
Parameters:
attr - attributes of this edge to clear out

pushAttributes

protected final void pushAttributes()

pullAttributes

protected final void pullAttributes()

isMutable

public final boolean isMutable()
Checks whether an edge can be modified.

Returns:
false if edge is a boundary or outside the mesh, true otherwise.

sym

public final VirtualHalfEdge sym()
Moves to symmetric edge.

Specified by:
sym in class AbstractHalfEdge
Returns:
current instance after its transformation

sym

public final VirtualHalfEdge sym(AbstractHalfEdge that)
Moves to symmetric edge. Make that instance be a copy of current instance, move it to its symmetric edge and return this instance. Current instance is not modified.

Specified by:
sym in class AbstractHalfEdge
Parameters:
that - instance where transformed edge is stored
Returns:
argument after its transformation

next

public final VirtualHalfEdge next()
Moves counterclockwise to following edge.

Specified by:
next in class AbstractHalfEdge
Returns:
current instance after its transformation

next

public final VirtualHalfEdge next(AbstractHalfEdge that)
Moves counterclockwise to following edge. Make that instance be a copy of current instance, move it counterclockwise to next edge and return this instance. Current instance is not modified.

Specified by:
next in class AbstractHalfEdge
Parameters:
that - instance where transformed edge is stored
Returns:
argument after its transformation

prev

public final VirtualHalfEdge prev()
Moves counterclockwise to previous edge.

Specified by:
prev in class AbstractHalfEdge
Returns:
current instance after its transformation

prev

public final VirtualHalfEdge prev(AbstractHalfEdge that)
Moves counterclockwise to previous edge. Make that instance be a copy of current instance, move it counterclockwise to previous edge and return this instance. Current instance is not modified.

Specified by:
prev in class AbstractHalfEdge
Parameters:
that - instance where transformed edge is stored
Returns:
argument after its transformation

nextOrigin

public final VirtualHalfEdge nextOrigin()
Moves counterclockwise to the following edge which has the same origin.

Specified by:
nextOrigin in class AbstractHalfEdge
Returns:
current instance after its transformation

nextOrigin

public final VirtualHalfEdge nextOrigin(AbstractHalfEdge that)
Moves counterclockwise to the following edge which has the same origin. Make that instance be a copy of current instance, move it counterclockwise to the following edge which has the same origin and return this instance. Current instance is not modified.

Specified by:
nextOrigin in class AbstractHalfEdge
Parameters:
that - instance where transformed edge is stored
Returns:
argument after its transformation

nextOriginLoop

public final VirtualHalfEdge nextOriginLoop()
Moves counterclockwise to the following edge which has the same origin. If a boundary is reached, loop backward until another boundary is found and start again from there. Note: outer triangles are taken into account in this loop, because this is sometimes needed, as in VirtualHalfEdge2D.removeDegenerated(). They have to be explicitly filtered out by testing hasAttributes(OUTER).

Specified by:
nextOriginLoop in class AbstractHalfEdge
Returns:
current instance after its transformation

copyOTri

protected static final void copyOTri(VirtualHalfEdge src,
                                     VirtualHalfEdge dest)
Copies a VirtualHalfEdge instance into another VirtualHalfEdge instance.

Parameters:
src - VirtualHalfEdge being duplicated
dest - already allocated VirtualHalfEdge where data are copied

symOTri

protected static final void symOTri(VirtualHalfEdge o,
                                    VirtualHalfEdge that)
Copies a VirtualHalfEdge instance and move to its symmetric edge.

Parameters:
o - source VirtualHalfEdge
that - already allocated VirtualHalfEdge where data are copied

nextOTri

protected static final void nextOTri(VirtualHalfEdge o,
                                     VirtualHalfEdge that)
Copies a VirtualHalfEdge instance and move it counterclockwise to following edge.

Parameters:
o - source VirtualHalfEdge
that - already allocated VirtualHalfEdge where data are copied

prevOTri

protected static final void prevOTri(VirtualHalfEdge o,
                                     VirtualHalfEdge that)
Copies a VirtualHalfEdge instance and move it counterclockwise to previous edge.

Parameters:
o - source VirtualHalfEdge
that - already allocated VirtualHalfEdge where data are copied

origin

public Vertex origin()
Returns start vertex of this edge.

Specified by:
origin in class AbstractHalfEdge
Returns:
start vertex of this edge

destination

public Vertex destination()
Returns end vertex of this edge.

Specified by:
destination in class AbstractHalfEdge
Returns:
end vertex of this edge

apex

public Vertex apex()
Returns apex of this edge.

Specified by:
apex in class AbstractHalfEdge
Returns:
apex of this edge

setOrigin

public final void setOrigin(Vertex v)
Sets start vertex of this edge.

Parameters:
v - start vertex of this edge

setDestination

public final void setDestination(Vertex v)
Sets end vertex of this edge.

Parameters:
v - end vertex of this edge

setApex

public final void setApex(Vertex v)
Sets apex of this edge.

Parameters:
v - apex of this edge

glue

public final void glue(AbstractHalfEdge sym)
Sets adjacency relations between two triangles.

Specified by:
glue in class AbstractHalfEdge
Parameters:
sym - the edge tied to this object

hasSymmetricEdge

public final boolean hasSymmetricEdge()
Tells whether edge is connected to a symmetric edge.

Specified by:
hasSymmetricEdge in class AbstractHalfEdge
Returns:
true if edge has a symmetric edge, false otherwise.

computeNormal3DT

public double computeNormal3DT()
Computes the normal of an edge, in the triangle plane. This vector is not normalized, it has the same length as this edge. The result is stored in the tempD temporary array.

Returns:
triangle area Warning: this method uses tempD, tempD1 and tempD2 temporary arrays.
See Also:
getTempVector()

computeNormal3D

public double computeNormal3D()
Computes the normal of this triangle. The result is stored in the tempD temporary array.

Returns:
triangle area Warning: this method uses tempD, tempD1 and tempD2 temporary arrays.
See Also:
getTempVector()

area

public double area()
Returns the area of triangle bound to this edge.

Specified by:
area in class AbstractHalfEdge
Returns:
triangle area Warning: this method uses tempD, tempD1 and tempD2 temporary arrays.

getTempVector

public double[] getTempVector()
Returns the temporary array TempD.


checkSwap3D

public final double checkSwap3D(double minCos)
Checks the dihedral angle of an edge.

Parameters:
minCos - if the dot product of the normals to adjacent triangles is lower than monCos, then -1.0 is returned.
Returns:
the minimum quality of the two trianglles generated by swapping this edge.

checkSwap3D

public final double checkSwap3D(double minCos,
                                double maxLength)

swap

protected final VirtualHalfEdge swap()
Swaps an edge.

Specified by:
swap in class AbstractHalfEdge
Returns:
swapped edge, origin and apical vertices are the same as in original edge
Throws:
java.lang.IllegalArgumentException - if edge is on a boundary or belongs to an outer triangle.
See Also:
Mesh.edgeSwap(org.jcae.mesh.amibe.ds.AbstractHalfEdge)

checkNewRingNormals

public final boolean checkNewRingNormals(double[] newpt)
Checks that triangles are not inverted if origin vertex is moved.

Specified by:
checkNewRingNormals in class AbstractHalfEdge
Parameters:
newpt - the new position to be checked
Returns:
false if the new position produces an inverted triangle, true otherwise. Warning: this method uses work[0] and work[1] temporary arrays.

canCollapse

protected final boolean canCollapse(Vertex n)
Checks whether an edge can be contracted.

Specified by:
canCollapse in class AbstractHalfEdge
Parameters:
n - the resulting vertex
Returns:
true if this edge can be contracted into the single vertex n, false otherwise
See Also:
Warning: this method uses work[0], work[1] and work[2] temporary arrays.

collapse

protected final VirtualHalfEdge collapse(Mesh m,
                                         Vertex v)
Contracts an edge.

Specified by:
collapse in class AbstractHalfEdge
Parameters:
m - mesh
v - the resulting vertex
Returns:
edge starting from n and with the same apex
Throws:
java.lang.IllegalArgumentException - if edge belongs to an outer triangle, because there would be no valid return value. User must then run this method against symmetric edge, this is not done automatically.
See Also:
Mesh.edgeCollapse(org.jcae.mesh.amibe.ds.AbstractHalfEdge, org.jcae.mesh.amibe.ds.Vertex)

split

protected final VirtualHalfEdge split(Mesh m,
                                      Vertex v)
Splits an edge. This is the opposite of collapse.

Specified by:
split in class AbstractHalfEdge
Parameters:
m - mesh
v - vertex being inserted
Returns:
edge starting from origin and pointing to n
See Also:
Mesh.vertexSplit(org.jcae.mesh.amibe.ds.AbstractHalfEdge, org.jcae.mesh.amibe.ds.Vertex)

fanIterator

public final java.util.Iterator<AbstractHalfEdge> fanIterator()
Returns an iterator over triangle fans connected to this edge. If edge is manifold, this iterator contains a single value, which is this edge. But if it is non-manifold and bound to n triangles, this iterator returns successively the n edges contained in these triangles and connected to the same endpoints.

Specified by:
fanIterator in class AbstractHalfEdge
Returns:
iterator over triangle fans connected to this edge

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object