use of mcib3d.geom.Object3DSurface in project mcib3d-core by mcib3d.
the class Mesh method computeConvexHull3D.
public ArrayList<Point3f> computeConvexHull3D() {
QuickHull3D hull = new QuickHull3D();
System.out.println("Computing 3d convex hull...");
Object3DSurface o = new Object3DSurface(vertices);
ArrayList<Voxel3D> pointsList = o.getContours();
Point3d[] points = new Point3d[pointsList.size()];
for (int ve = 0; ve < points.length; ve++) {
points[ve] = new Point3d(pointsList.get(ve).getX(), pointsList.get(ve).getY(), pointsList.get(ve).getZ());
}
System.out.println("done 1st for");
hull.build(points);
hull.triangulate();
ArrayList<Point3f> convex = new ArrayList<Point3f>();
int[][] faceIndices = hull.getFaces();
Point3d[] verticesHull = hull.getVertices();
for (int k = 0; k < faceIndices.length; k++) {
for (int ve = 0; ve < 3; ve++) {
Point3d point = verticesHull[faceIndices[k][ve]];
convex.add(new Point3f((float) point.x, (float) point.y, (float) point.z));
}
}
return convex;
}
Aggregations