org.jcae.mesh.amibe.ds
Class TriangleVH

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

public class TriangleVH
extends Triangle

A triangular element of the mesh. Instances of this class carry up all topological information required for adjacency relations. Their vertices are contained in a Vertex array, and by convention the local number of an edge is the index of its opposite vertex. A TriangleVH instance has a pointer to its three neighbours through its edges, and knows the local number of opposite edges in their respective triangles. It also stores as a byte array attributes of its three edges.

As local numbers are integers between 0 and 2, a packed representation is wanted to save space. They can be stored within 6 bits, edge 0 is stored in the two least significant bits, edge 1 in next two and edge 2 in next two, so adjPos=(localNumberSymEdge0<<0)+(localNumberSymEdge1<<2)+(localNumberSymEdge2<<4).

[Image showing adjacency symmetric edges]

Vertices data are colored in black, edges in red and triangles in blue. Triangle a contains these members:

There are two special cases:

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jcae.mesh.amibe.ds.Triangle
Triangle.List
 
Field Summary
 
Fields inherited from class org.jcae.mesh.amibe.ds.Triangle
readable, traits, traitsBuilder, vertex, writable
 
Constructor Summary
TriangleVH(TriangleTraitsBuilder ttb)
          Constructor.
 
Method Summary
 void clearAttributes(int attr)
          Resets attributes for all edges of this triangle.
 void copy(Triangle that)
           
 VirtualHalfEdge getAbstractHalfEdge()
          Gets a VirtualHalfEdge instance bound to this triangle.
 VirtualHalfEdge getAbstractHalfEdge(AbstractHalfEdge that)
          Gets a VirtualHalfEdge instance bound to this triangle.
 TriangleVH getAdj(int num)
          Returns the adjacent TriangleVH through an edge.
 int getAdjLocalNumber(int num)
          Gets local number of a symmetric edge.
 int getEdgeAttributes(int num)
          Gets attributes of edge num.
 boolean hasAttributes(int attr)
          Checks if some attributes of this triangle are set.
 void setAdj(int num, TriangleVH link)
          Sets TriangleVH adjacent to an edge.
 void setAdjLocalNumber(int num, int pos)
          Sets local number of a symmetric edge.
 void setAttributes(int attr)
          Sets attributes for all edges of this triangle.
 void setEdgeAttributes(int num, int attr)
          Sets attributes of edge num.
 java.lang.String toString()
           
 
Methods inherited from class org.jcae.mesh.amibe.ds.Triangle
getGroupId, isReadable, isWritable, setGroupId, setReadable, setWritable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TriangleVH

public TriangleVH(TriangleTraitsBuilder ttb)
Constructor.

Method Detail

copy

public final void copy(Triangle that)
Overrides:
copy in class Triangle

getAbstractHalfEdge

public VirtualHalfEdge getAbstractHalfEdge()
Gets a VirtualHalfEdge instance bound to this triangle. This method allocates a new VirtualHalfEdge instance and binds it to this triangle.

Overrides:
getAbstractHalfEdge in class Triangle
Returns:
a new VirtualHalfEdge instance bound to this triangle

getAbstractHalfEdge

public VirtualHalfEdge getAbstractHalfEdge(AbstractHalfEdge that)
Gets a VirtualHalfEdge instance bound to this triangle. If argument is null, this method behaves as if no argument was passed. Otherwise, argument is an existing VirtualHalfEdge instance which is bound to this triangle and returned.

Overrides:
getAbstractHalfEdge in class Triangle
Parameters:
that - either null or an existing VirtualHalfEdge instance which is modified
Returns:
a VirtualHalfEdge instance bound to this triangle

getAdj

public TriangleVH getAdj(int num)
Returns the adjacent TriangleVH through an edge.

Parameters:
num - the local number of this edge.
Returns:
the adjacent TriangleVH

setAdj

public void setAdj(int num,
                   TriangleVH link)
Sets TriangleVH adjacent to an edge.

Parameters:
num - the local number of this edge
link - adjacent TriangleVH

getAdjLocalNumber

public int getAdjLocalNumber(int num)
Gets local number of a symmetric edge.

Parameters:
num - edge local number
Returns:
local number of this symmetric edge

setAdjLocalNumber

public void setAdjLocalNumber(int num,
                              int pos)
Sets local number of a symmetric edge.

Parameters:
num - edge local number
pos - local number of symmetric edge

getEdgeAttributes

public int getEdgeAttributes(int num)
Gets attributes of edge num.

Parameters:
num - local edge number
Returns:
attributes of this edge

setEdgeAttributes

public void setEdgeAttributes(int num,
                              int attr)
Sets attributes of edge num.

Parameters:
num - local edge number
attr - attributes to set on this edge

setAttributes

public void setAttributes(int attr)
Sets attributes for all edges of this triangle.

Overrides:
setAttributes in class Triangle
Parameters:
attr - attributes to set on edges

clearAttributes

public void clearAttributes(int attr)
Resets attributes for all edges of this triangle.

Overrides:
clearAttributes in class Triangle
Parameters:
attr - attributes to reset on edges

hasAttributes

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

Overrides:
hasAttributes in class Triangle
Parameters:
attr - attributes to check
Returns:
true if any edge of this triangle has one of these attributes set, false otherwise

toString

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