de.javagl.simplemesh.utils
Class MeshPrimitivesArrays

java.lang.Object
  extended by de.javagl.simplemesh.utils.MeshPrimitivesArrays

public class MeshPrimitivesArrays
extends java.lang.Object

Utility methods for computing primitive type arrays containing information from mesh primitives.


Method Summary
static int computeMaxVertexFaces(int[] vertexFaceCounters)
          Computes the maximum number of faces a vertex belongs to (i.e. simply the maximum of the given array)
static int[] computeVertexFaceIndices(java.lang.Iterable<? extends Face> faces, int numVertices, int maxVertexFaces)
          Computes for each vertex the indices of all faces that it belongs to
static int[] createEdgeVertexIndices(java.util.Collection<? extends Edge> edges)
          Create an array containing the vertex indices of the given set of edges.
static int[] createFaceVertexIndices(java.util.Collection<? extends Face> faces)
          Create an array containing the vertex indices of the given set of faces.
static int[] createVertexFaceCounters(java.lang.Iterable<? extends Face> faces, int numVertices)
          Computes an array containing for each vertex the number of faces that it belongs to
static float[] createVerticesArray(java.util.Collection<? extends Vertex> vertices, int stride)
          Creates an array containing the coordinates of the given vertices, with the given stride.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createVerticesArray

public static float[] createVerticesArray(java.util.Collection<? extends Vertex> vertices,
                                          int stride)
Creates an array containing the coordinates of the given vertices, with the given stride.

Parameters:
vertices - The vertices
stride - The stride
Returns:
The array containing the vertex coordinates

createEdgeVertexIndices

public static int[] createEdgeVertexIndices(java.util.Collection<? extends Edge> edges)
Create an array containing the vertex indices of the given set of edges. Two consecutive entries of the resulting array will contain the indices of the vertices of an edge.

Parameters:
edges - The edges
Returns:
The vertex indices

createFaceVertexIndices

public static int[] createFaceVertexIndices(java.util.Collection<? extends Face> faces)
Create an array containing the vertex indices of the given set of faces. It is assumed that the faces are triangles. Three consecutive entries of the resulting array will contain the indices of the vertices of a face.

Parameters:
faces - The faces
Returns:
The vertex indices

createVertexFaceCounters

public static int[] createVertexFaceCounters(java.lang.Iterable<? extends Face> faces,
                                             int numVertices)
Computes an array containing for each vertex the number of faces that it belongs to

Parameters:
faces - The faces
numVertices - The number of vertices
Returns:
The vertex face counters

computeMaxVertexFaces

public static int computeMaxVertexFaces(int[] vertexFaceCounters)
Computes the maximum number of faces a vertex belongs to (i.e. simply the maximum of the given array)

Parameters:
vertexFaceCounters - The vertex face counters
Returns:
The maximum of the given array

computeVertexFaceIndices

public static int[] computeVertexFaceIndices(java.lang.Iterable<? extends Face> faces,
                                             int numVertices,
                                             int maxVertexFaces)
Computes for each vertex the indices of all faces that it belongs to

Parameters:
faces - The faces
numVertices - The number of vertices
maxVertexFaces - The maximum number of faces that a vertex belongs to
Returns:
The vertex face indices:
 vertexFaceIndices[vertexIndex*maxVertexFaces+0] = faceIndex0 
 vertexFaceIndices[vertexIndex*maxVertexFaces+1] = faceIndex1 
 ...
 vertexFaceIndices[vertexIndex*maxVertexFaces+N] = faceIndexN
 
 where 
 vertexIndex = 0...numVertices-1 
 N = maxVertexFaces-1