Class ConvexHull3D
java.lang.Object
jaba.convexHull3d.ConvexHull3D
This class constructs the convex hull for 3-classes model.
We use the algorithm presented in Computational Geometry in C 2th
edition by Joseph O'Rourke.
The original algorithm is coded in C language and uses global variables. In
order to make the concept of global variables available in Java, we adopt the
Singleton pattern for the class ConvexHull3D.
In order to make the code as much as possible similar to the original one we
have implemented double linked lists in the C way (next and prev pointer
inside the item). Exploiting the protected visibility for the pointer next
and prev, we use this approach only inside this package. The result (a list
of faces of the convex hull) is converted in a ArrayList before return.
Unless for the aforementioned exceptions the code is as the original version,
so for further information consult Computational Geometry in C 2th ed.
by Joseph O'Rourke (Cambridge University Press).
- Author:
- Sebastiano Spicuglia 19:42 09/05/2011
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds the @p edge to the global list of edgesprotected voidAdds the @p face to the global list of facesprotected voidAdds the @p vertex to the global list of verticesbuildHull(HashSet<HullVertex> stations, boolean autoProject) Builds the convex hull for the @stations set.
-
Constructor Details
-
ConvexHull3D
public ConvexHull3D()Creates a new ConvexHull3D object
-
-
Method Details
-
buildHull
public ArrayList<HullFace> buildHull(HashSet<HullVertex> stations, boolean autoProject) throws AllPointsCoplanarExceptions, AllPointsCollinearException Builds the convex hull for the @stations set. It returns the faces (divided into triangles) of the convex hull.- Parameters:
stations- the set of verticesautoProject- if it is true the method explodes the @stations set, adding to it the projection on the planes xy, yz, zx of all points in the @stations set.- Returns:
- It returns the faces (divided into triangles) of the convex hull.
- Throws:
AllPointsCoplanarExceptionsAllPointsCollinearException
-
addEdge
Adds the @p edge to the global list of edges- Parameters:
p- the edge you want to add
-
addFace
Adds the @p face to the global list of faces- Parameters:
p- the face you want to add
-
addVertex
Adds the @p vertex to the global list of vertices- Parameters:
p- the vertex you want to add
-