org.jcae.mesh.amibe.ds
Class Vertex

java.lang.Object
  extended by org.jcae.mesh.amibe.ds.Vertex
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
FakeNonReadVertex, Vertex2D

public class Vertex
extends java.lang.Object
implements java.io.Serializable

Vertex of a mesh. When meshing a CAD surface, a vertex has two parameters and a metrics in its tangent plane is computed so that a unit mesh in this metrics comply with user constraints. When the underlying surface is defined by the 3D mesh itself, a vertex has three parameters and the surface is locally interpolated by a quadrics computed from vertex neighbours.

There is a special vertex, Mesh.outerVertex, which represents a vertex at infinite. It is used to create exterior triangles.

Each vertex has a pointer to an incident Triangle, which allows to find any other incident VirtualHalfEdge or Triangle. For non-manifold vertices, this link points to a Triangle [] array, which can be used to retrieve all incident triangles through their adjacency relations.

See Also:
Serialized Form

Field Summary
protected  int label
           
protected  java.lang.Object link
           
protected  double[] param
          2D or 3D coordinates.
protected  int ref1d
           
protected  Traits traits
           
protected  VertexTraitsBuilder traitsBuilder
           
 
Constructor Summary
protected Vertex(VertexTraitsBuilder vtb)
          Constructor.
  Vertex(VertexTraitsBuilder vtb, double x, double y, double z)
          Create a Vertex for a 3D mesh.
 
Method Summary
 double angle3D(Vertex n1, Vertex n2)
          Returns the angle at which a segment is seen.
 void copy(Vertex that)
          Copy all attributes from another Vertex.
 boolean discreteCurvatureDirections(double[] normal, double[] t1, double[] t2)
          Compute the discrete local frame at this vertex.
 double discreteCurvatures(double[] meanNormal)
          Returns the discrete Gaussian curvature and the mean normal.
 boolean discreteProject(Vertex pt)
          Project a point on the approximated surface.
 double distance3D(Vertex end)
          Returns the distance in 3D space.
 AbstractHalfEdge getIncidentAbstractHalfEdge(Triangle t, AbstractHalfEdge ot)
           
 int getLabel()
          Get node label.
 java.lang.Object getLink()
          Get a finite element containing this Vertex.
 double[] getLocalQuadric(Matrix3D P)
           
 Matrix3D getMatrix3DLocalFrame()
           
 java.util.Collection<Vertex> getNeighboursNodes()
          Get the list of adjacent vertices.
 int getRef()
          Gets 1D reference of this node.
 double[] getUV()
          Gets coordinates of this vertex.
 boolean isManifold()
          Tells whether this vertex is manifold.
 boolean isMutable()
          Check whether this vertex can be modified.
 boolean isReadable()
           
 boolean isWritable()
           
 void moveTo(double x, double y, double z)
          Sets 3D coordinates of this vertex.
 void outer3D(Vertex n1, Vertex n2, double[] work1, double[] work2, double[] ret)
          Returns the outer product of two vectors.
 void projectQuadric(double[] origin, Matrix3D P, double[] q)
           
 void setLabel(int l)
          Set node label.
 void setLink(java.lang.Object o)
          Set link to a finite element containing this Vertex.
 void setLinkFan(java.util.Collection<Triangle> triangles)
          Set link to an array of Triangles.
 void setReadable(boolean r)
           
 void setRef(int l)
          Sets 1D reference of this node.
 void setWritable(boolean w)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

traitsBuilder

protected final VertexTraitsBuilder traitsBuilder

traits

protected final Traits traits

param

protected final double[] param
2D or 3D coordinates.


ref1d

protected int ref1d

link

protected java.lang.Object link

label

protected int label
Constructor Detail

Vertex

protected Vertex(VertexTraitsBuilder vtb)
Constructor.


Vertex

public Vertex(VertexTraitsBuilder vtb,
              double x,
              double y,
              double z)
Create a Vertex for a 3D mesh.

Parameters:
vtb - traits builder
x - first coordinate.
y - second coordinate.
z - third coordinate.
Method Detail

copy

public void copy(Vertex that)
Copy all attributes from another Vertex.

Parameters:
that - the Vertex to be copied.

getRef

public int getRef()
Gets 1D reference of this node. Reference is positive for node of free edges, zero for internal points, and positive for nodes of group borders.

Returns:
1D reference of this node

setRef

public void setRef(int l)
Sets 1D reference of this node.

Parameters:
l - 1D reference of this node

getUV

public double[] getUV()
Gets coordinates of this vertex.

Returns:
coordinates of this vertex

moveTo

public void moveTo(double x,
                   double y,
                   double z)
Sets 3D coordinates of this vertex.

Parameters:
x - first coordinate of the new position
y - second coordinate of the new position
z - third coordinate of the new position

distance3D

public double distance3D(Vertex end)
Returns the distance in 3D space.

Parameters:
end - the node to which distance is computed.
Returns:
the distance to end.

angle3D

public double angle3D(Vertex n1,
                      Vertex n2)
Returns the angle at which a segment is seen.

Parameters:
n1 - first node
n2 - second node
Returns:
the angle at which the segment is seen.

outer3D

public void outer3D(Vertex n1,
                    Vertex n2,
                    double[] work1,
                    double[] work2,
                    double[] ret)
Returns the outer product of two vectors. This method computes the outer product of two vectors starting from the current vertex.

Parameters:
n1 - end point of the first vector
n2 - end point of the second vector
work1 - double[3] temporary array
work2 - double[3] temporary array
ret - array which will store the outer product of the two vectors

getLabel

public int getLabel()
Get node label.

Returns:
node label.

setLabel

public void setLabel(int l)
Set node label.

Parameters:
l - node label.

getLink

public java.lang.Object getLink()
Get a finite element containing this Vertex.

Returns:
a Triangle instance for manifold vertices, and a Triangle [] array otherwise.

setLink

public void setLink(java.lang.Object o)
Set link to a finite element containing this Vertex.

Parameters:
o - object linked to this Vertex.

getIncidentAbstractHalfEdge

public AbstractHalfEdge getIncidentAbstractHalfEdge(Triangle t,
                                                    AbstractHalfEdge ot)

setLinkFan

public void setLinkFan(java.util.Collection<Triangle> triangles)
Set link to an array of Triangles. This routine eliminates duplicates to keep only one Triangle by fan.

Parameters:
triangles - initial set of adjacent triangles.

setReadable

public void setReadable(boolean r)

setWritable

public void setWritable(boolean w)

isReadable

public boolean isReadable()

isWritable

public boolean isWritable()

isManifold

public final boolean isManifold()
Tells whether this vertex is manifold.

Returns:
true if vertex is manifold, false otherwise

getNeighboursNodes

public java.util.Collection<Vertex> getNeighboursNodes()
Get the list of adjacent vertices. Note: this method works also with non-manifold meshes.

Returns:
the list of adjacent vertices.

isMutable

public boolean isMutable()
Check whether this vertex can be modified.

Returns:
true if this vertex can be modified, false.

discreteCurvatures

public double discreteCurvatures(double[] meanNormal)
Returns the discrete Gaussian curvature and the mean normal. These discrete operators are described in "Discrete Differential-Geometry Operators for Triangulated 2-Manifolds", Mark Meyer, Mathieu Desbrun, Peter Schröder, and Alan H. Barr. http://www.cs.caltech.edu/~mmeyer/Publications/diffGeomOps.pdf http://www.cs.caltech.edu/~mmeyer/Publications/diffGeomOps.pdf Note: on a sphere, the Gaussian curvature is very accurate, but not the mean curvature. Guoliang Xu suggests improvements in his papers http://lsec.cc.ac.cn/~xuguo/xuguo3.htm


discreteCurvatureDirections

public boolean discreteCurvatureDirections(double[] normal,
                                           double[] t1,
                                           double[] t2)
Compute the discrete local frame at this vertex. These discrete operators are described in "Discrete Differential-Geometry Operators for Triangulated 2-Manifolds", Mark Meyer, Mathieu Desbrun, Peter Schröder, and Alan H. Barr. http://www.cs.caltech.edu/~mmeyer/Publications/diffGeomOps.pdf


discreteProject

public boolean discreteProject(Vertex pt)
Project a point on the approximated surface. This algorithm is described by Pascal J. Frey in About Surface Remeshing. The idea if to approximate locally the surface by a quadric F(x,y) = a x^2 + b xy + c y^2 - z. To that end, the local frame at the current vertex is computed. The (x,y) coordinates of neighbour vertices are computed in that frame, and we search for the quadric which fits best for all neighbour vertices (in a least squares sense). The vertex is then projected onto this quadric. Note1: Several improvements exist in the litterature, see eg. this paper by Anshuman Razdan and MyungSoo Bae for a survey of several methods. Note2: According to Pascal J. Frey, the key point is to have reliable input. We can have good approximation of quadrics if the normal to the surface is accurate, and normal to the surface can be approximated accurately if the quadric is precise. So we should certainly read normals from a file if they are available.

Parameters:
pt - point to project on the approximated surface.
Returns:
true if projection has been performed successfully, false otherwise.

projectQuadric

public void projectQuadric(double[] origin,
                           Matrix3D P,
                           double[] q)

getMatrix3DLocalFrame

public Matrix3D getMatrix3DLocalFrame()

getLocalQuadric

public double[] getLocalQuadric(Matrix3D P)

toString

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