org.jcae.mesh.amibe.ds
Class HalfEdge

java.lang.Object
  extended by org.jcae.mesh.amibe.ds.AbstractHalfEdge
      extended by org.jcae.mesh.amibe.ds.HalfEdge
All Implemented Interfaces:
java.io.Serializable

public class HalfEdge
extends AbstractHalfEdge
implements java.io.Serializable

Half-edge data structure. This is a straightforward implementation of AbstractHalfEdge, an half-edge is represented by a local number (between 0 and 2) and a triangle. It has a link to the next edge in the same triangle, and to its symmetric edge.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jcae.mesh.amibe.ds.AbstractHalfEdge
BOUNDARY, int3, MARKED, NONMANIFOLD, OUTER, QUAD, SWAPPED, traits, traitsBuilder
 
Constructor Summary
HalfEdge(HalfEdgeTraitsBuilder htb, TriangleHE tri, byte localNumber, byte attributes)
           
 
Method Summary
 Vertex apex()
          Returns apex of this edge.
 double area()
          Returns the area of triangle bound to this edge.
protected  boolean canCollapse(Vertex v)
          Checks whether an edge can be contracted into a given vertex.
 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  HalfEdge collapse(Mesh m, Vertex v)
          Contracts an edge.
 void copy(HalfEdge that)
           
 Vertex destination()
          Returns end vertex of this edge.
 java.util.Iterator<AbstractHalfEdge> fanIterator()
          Returns an iterator over triangle fans connected to this edge.
 int getAttributes()
           
 int getLocalNumber()
          Returns edge local number.
 Triangle getTri()
          Returns triangle tied to this edge.
 void glue(AbstractHalfEdge e)
          Sets the edge tied to this object.
 boolean hasAttributes(int attr)
          Checks if some attributes of this edge are set.
 boolean hasSymmetricEdge()
          Tells whether edge is connected to a symmetric edge.
 HalfEdge next()
          Moves counterclockwise to following edge.
 AbstractHalfEdge next(AbstractHalfEdge that)
          Moves counterclockwise to following edge.
 HalfEdge nextApexLoop()
          Moves counterclockwise to the following edge which has the same apex.
 HalfEdge nextOrigin()
          Moves counterclockwise to the following edge which has the same origin.
 AbstractHalfEdge nextOrigin(AbstractHalfEdge that)
          Moves counterclockwise to the following edge which has the same origin.
 HalfEdge nextOriginLoop()
          Moves counterclockwise to the following edge which has the same origin.
 HalfEdge notOriented()
           
 Vertex origin()
          Returns start vertex of this edge.
 HalfEdge prev()
          Moves counterclockwise to previous edge.
 AbstractHalfEdge prev(AbstractHalfEdge that)
          Moves counterclockwise to previous edge.
 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 setNext(HalfEdge e)
          Sets next link.
 void setOrigin(Vertex v)
          Sets start vertex of this edge.
protected  HalfEdge split(Mesh m, Vertex v)
          Splits an edge.
protected  HalfEdge swap()
          Swaps an edge.
 HalfEdge sym()
          Moves to symmetric edge.
 AbstractHalfEdge sym(AbstractHalfEdge that)
          Moves to symmetric edge.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HalfEdge

public HalfEdge(HalfEdgeTraitsBuilder htb,
                TriangleHE tri,
                byte localNumber,
                byte attributes)
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

getAttributes

public final int getAttributes()

glue

public final void glue(AbstractHalfEdge e)
Sets the edge tied to this object.

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

notOriented

public final HalfEdge notOriented()

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.

sym

public final HalfEdge sym()
Moves to symmetric edge.

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

sym

public final AbstractHalfEdge 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 HalfEdge next()
Moves counterclockwise to following edge.

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

next

public final AbstractHalfEdge 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 HalfEdge prev()
Moves counterclockwise to previous edge.

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

prev

public final AbstractHalfEdge 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 HalfEdge 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 AbstractHalfEdge 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

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

setNext

public final void setNext(HalfEdge e)
Sets next link.


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 HalfEdge 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

origin

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

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

destination

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

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

apex

public final Vertex apex()
Returns apex of this edge.

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

nextOriginLoop

public final HalfEdge 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.

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

nextApexLoop

public final HalfEdge nextApexLoop()
Moves counterclockwise to the following edge which has the same apex. If a boundary is reached, loop backward until another boundary is found and start again from there.


checkSwap3D

public final double checkSwap3D(double minCos)
Checks the dihedral angle of an edge. Warning: this method uses temp[0], temp[1], temp[2] and temp[3] temporary arrays.

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

checkSwap3D

public final double checkSwap3D(double minCos,
                                double maxLength)

swap

protected final HalfEdge 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)

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 temp[0], temp[1] and temp[2] temporary arrays.

canCollapse

protected final boolean canCollapse(Vertex v)
Checks whether an edge can be contracted into a given vertex.

Specified by:
canCollapse in class AbstractHalfEdge
Parameters:
v - the resulting vertex
Returns:
true if this edge can be contracted into the single vertex n, false otherwise
See Also:
Mesh.canCollapseEdge(org.jcae.mesh.amibe.ds.AbstractHalfEdge, org.jcae.mesh.amibe.ds.Vertex)

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 temp[0], temp[1], temp[2] and temp[3] temporary arrays.

collapse

protected final HalfEdge 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 HalfEdge split(Mesh m,
                               Vertex v)
Splits an edge. This is the opposite of collapse(org.jcae.mesh.amibe.ds.Mesh, org.jcae.mesh.amibe.ds.Vertex).

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

copy

public final void copy(HalfEdge that)