CreateConvexHull3D method returns an incorrect mesh.
Attached GH file with sample Python script including the point set that results in an faulty hull mesh. The resulting hull from the pointset should be octahedral. Note the one face with overlapping geometry.
I would be interested in a fix to the function or in a way to post process the mesh output to fix the hull.
incorrect hull.gh (6.8 KB)
Python script:
import Rhino.Geometry as rg
import System
from System.Collections.Generic import List
import clr
Constants
TOLERANCE = 1e-6
ANGLE_TOLERANCE = 0.01
Minimal Convex Hull Function
def create_convex_hull(points):
if len(points) < 4:
print(“Insufficient points for a convex hull.”)
return None
net_points = List[rg.Point3d](points)
hull_facets_ref = clr.Reference[System.Array[System.Array[int]]]()
hull_mesh = rg.Mesh.CreateConvexHull3D(net_points, hull_facets_ref, TOLERANCE, ANGLE_TOLERANCE)
if hull_mesh:
print("Convex hull mesh created.")
return hull_mesh
else:
print("Convex hull generation failed.")
return None
points = points
hull_mesh = create_convex_hull(points)
if hull_mesh:
print(f"Hull mesh vertices: {hull_mesh.Vertices.Count}“)
print(f"Hull mesh faces: {hull_mesh.Faces.Count}”)