RhinoCommon ConvexHull -?

I know this has been asked in the past and it appears that currently there is still no native RhinoCommon method for this. So I guess the only possibility is importing the GH node?

Are there any plans to port that or QuickHull to RhinoCommon soon?

1 Like

Hi @Helvetosaur,

An option might be to use RhinoPolyhedra, which exposes a QuickHull solver.

import clr
import sys
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
from System import Array

# Note, this path may vary
sys.path.append('%APPDATA%/McNeel/Rhinoceros?6.0?Plug-ins/Rhino Polyhedra (666ae572-a6c5-44b5-b668-6b503d56c199)/6.0.6844.19198')
clr.AddReference('PolyhedraCommon.dll')
import PolyhedraCommon

points = rs.GetPointCoordinates("Select points")

arr = Array[Rhino.Geometry.Point3d](points)
polylines = PolyhedraCommon.Geometry.WatermanPolyhedron.CalculateConvexHull(arr)
mesh = PolyhedraCommon.PolyhedraUtils.MeshFromClosedPolylines(polylines, sc.doc.ModelAbsoluteTolerance)
sc.doc.Objects.AddMesh(mesh)
sc.doc.Views.Redraw()

– Dale

4 Likes

Anything happening on this or is it still necessary to get this function via GH or RhinoPolyhedra?

1 Like

Hi @Helvetosaur,

RhinoCommon doesn’t have a convex hull calculation method, nor does the Rhino SDK.

– Dale

Hi @dale,

Quite old topic, but why not include the QuickHull calculation inside RhinoCommon? This is quite an handy feature :slight_smile:

1 Like

Hi @jeffoulet,

I believe something is in the works already.

https://mcneel.myjetbrains.com/youtrack/issue/RH-68446

RhinoPolyhedra uses a three dimensional implementation of Quickhull, as described in Barber, Dobkin, and Huhdanpaa, The Quickhull Algorithm for Convex Hulls (ACM Transactions on Mathematical Software, Vol. 22, No. 4, December 1996). I don’t know what algorithm GH2 has implemented.

– Dale

2 Likes

Hi @dale,

Thanks for your feedback, this is a great news! :slight_smile:

It’s probably worth mentioning MIConvexHull here as well, which is C# and open source:

1 Like

Thanks! Didn’t know this project.

MIConvexHull is also available as a NuGet package.

– Dale

1 Like

I have found Mesh.CreateConvexHull3D in the docs, but I’m not sure why the documentation says that this feature is available since Rhino 8.5 when Rhinos latest release is only 8.1? Is there a way to access the Mesh.CreateConvexHull3D function yet?

I’m referring the to following docs:
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.mesh/createconvexhull3d

Rhino’s current release is 8.16…

1 Like

True, I got confused because it feels like 8.16 < 8.5 because I’m used to reading decimals not versions.

I’m still confused because Mesh.CreateConvexHull3D is not available in 8.16, but according to the docs it should be? Any idea why its not showing up for me?

It is there


convex hull R8.gh (6.3 KB)

4 Likes

It shows up in the grasshopper C# script node, but it does not show up in visual studio. Why might this be?

It is a static method
so access it using the type not instance e.g. Mesh.CreateConvexHull3D instead of mesh.CreateConvexHull3D

Im aware.

Visual studio is telling me:
error CS0117: ‘Mesh’ does not contain a definition for ‘CreateConvexHull3D’

My code looks like:

Mesh convexHull = Mesh.CreateConvexHull3D(points, out int[] _, 0.01, 0.01);

The LSP is telling me the function does not exist. The compiler is telling me the function does not exist. But the docs are telling me that the function does exist.

Any idea what the issue is?

I’m guessing that I need to update the SDK, I suppose I’ll look into that.

I didn’t realize that my sdk had a different version than my Rhino Installation. Updating my sdk fixed the issue. Sorry for wasting your time.

Thanks for the continued interest in the 3d convex hull. I used the algorithm from the famous Computational Geometry book.

1 Like