A Comparsion of Mesh Thicken / Offset Sripts

Hello

I have tested different aproaches of how to thicken a mesh with variable distances. This is a conclusion of what I have found so far. Feel free to comment, contribute and share your experience. I am aiming to minimize computational time due to an online application. (also, I can’t share the original mesh due to NDA, so at least a placeholder with the same params is used)

Source mesh with colour that represents variable thicken data:

Desired thickened mesh:

1) Pufferfish Mesh Offset
An attempt to variable offset the mesh stuck my Rhino so I guess that it’s for uniform offset only. The result is satisfying but way too slow - 11 seconds.

2) Weaverbird Mesh Thicken
Wb Mesh Thicken is cool and fast (600ms), but only works for one side. So I tested Wb Offset Mesh instead. The rest is about stitching naked edges. This part consumes a lot of time as I did it “rough”.

3) My own approach
Moving vertices using normals multiplied by variable distance. C# script finds start and end points and create a quad face of a mesh. Stitching should work way faster if there was a better way to get start / endpoint out of a line. More on that below. Estimated time of my approach is 500ms.

    DataTree <Mesh> meshes = new DataTree<Mesh>();

    for (int i = 0; i < L1.BranchCount; i++)
    {
      GH_Path path = new GH_Path(i);

      for (int j = 0; j < L1.Branch(i).Count; j++)
      {
        Rhino.Geometry.Mesh mesh = new Rhino.Geometry.Mesh();
        mesh.Vertices.Add(L1.Branch(i)[j].From);
        mesh.Vertices.Add(L1.Branch(i)[j].To);
        mesh.Vertices.Add(L2.Branch(i)[j].To);
        mesh.Vertices.Add(L2.Branch(i)[j].From);

        mesh.Faces.AddFace(0, 1, 2, 3);
        meshes.Add(mesh, path);
      }
    }

    M = meshes;

Off topic note:

Also, this is interesting. I assumed that it should be faster to get endpoints from “line” geometry type than from “curve”. But obviously it’s the opposite. The component returns “line” and it takes 144ms to get endpoints. Converting the type to “curve” takes 121ms with additional 16ms extracting endpoints. So it’s the same in both cases and it’s interesting to me. Is there a way how to get endpoints that fast just from line without the conversion?

PetrVacek_VariableMeshThickening.gh (2.8 MB)

I am looking forward to your remarks, experience and ideas.

1 Like

There’s also the native Mesh.Offset function. I’ve used it quite a bit for fast/simple mesh thickening. It has several overloads that might be relevant to your research here:

https://developer.rhino3d.com/api/RhinoCommon/html/Overload_Rhino_Geometry_Mesh_Offset.htm

2 Likes

Pufferfish is using this method, so if it took 11 seconds for his case then I’m not sure, I’ve noticed it be very fast sometimes and very slow others.

@PetrVacek about wondering if it is variable, you can always check required input structures, for Pufferfish case offset is item (one value), where as Wb is list (multiple values). Pufferfish is not variable because it is using the Rhinocommon method which is not variable.

TBH I am VDBing (shelling) everything these days because rarely do offsets result well in tight conditions and self intersections unless the geometry is very tame in its curvature and nooks and crannies.

2 Likes