use of com.github.quickhull3d.Point3d in project mcib3d-core by mcib3d.
the class Object3DSurface method computeConvexHull3D.
public ArrayList<Point3f> computeConvexHull3D() {
QuickHull3D hull = new QuickHull3D();
ArrayList<Voxel3D> pointsList = this.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());
}
hull.build(points);
hull.triangulate();
ArrayList<Point3f> convex = new ArrayList<Point3f>();
int[][] faceIndices = hull.getFaces();
Point3d[] verticesHull = hull.getVertices();
for (int ve = 0; ve < verticesHull.length; ve++) {
for (int k = 0; k < faceIndices[ve].length; k++) {
Point3d point = verticesHull[faceIndices[ve][k]];
convex.add(new Point3f((float) point.x, (float) point.y, (float) point.z));
}
}
for (int[] faceIndice : faceIndices) {
for (int ve = 0; ve < 3; ve++) {
Point3d point = verticesHull[faceIndice[ve]];
convex.add(new Point3f((float) point.x, (float) point.y, (float) point.z));
}
}
return convex;
}
use of com.github.quickhull3d.Point3d 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