Help with Delaunay Mesh problem

Hi there,

I’ve got a specific problem I’m trying to solve; perhaps there’s a solution out there.

When making a topography like this

I Often want to add a path on top of that which can be assigned a material etc.

However, I need this overlay mesh path to be made of the same faces as the topography.

In the top view above, you can see two paths which make a hole.

If I do split mesh, it absolutely doesn’t work. I want to rebuild the path mesh using the following 3 parts.

The outer curve/s
The inner Curve/s
and the Extracted and trimmed edges from the mesh below

In a similar way to how hatch, or planarsrf is able to do boolean operations, is it possible to rebuild this mesh using these three parts, the Delaunay component, and not fill in the hole?

Best,
Jeremy

1 Like

Does it have to be a mesh? Could you work with surfaces instead?

1 Like

I think i see green lines in your path that are not yet part of your mesh, so you would need to make sure they are created with the rest of the mesh. For this check out this tutorial: https://www.youtube.com/watch?v=auTzooRfyYI

For cutting the mesh with lines, check out this discussion:

Not sure which exact file you can best use there, but i have a working C# or Python script somewhere.

1 Like

Hi Martin, thanks for your reply.
Ideally, it must be a mesh. I am working with landscapes which are around 220 hectares, and simple joined meshes with many many faces seems to be the only way to work. The mesh on top is purely for albedo. The other option is to project a high resolution image onto the mesh for colour, but that is problematic as well.
If this were rendered in Unreal Engine, it might be able to reduce the mesh dynamically to what’s in the view.
I digress, the colour albedo path needs to be projected perfectly on the landscape mesh; hence using the same edges as what’s underneath. If I create a new mesh based purely on the path, and no the underlying landscape, the edges dont match. When I project that flat path to the underlying landscape, parts intersect and become ugly/unpure.

-Jeremy

Hi Calcman, thanks for your reply.

I’m not sure I understand your comment. The green lines were gathered in this manner. First, I made the underlying landscape mesh. Second, i extracted the edges of the whole of the landscape mesh. Third, I trimmed all those curves with the boundary of that path hatch. That’s how I got those green lines.

Due to the nature of the workflow to generate the landscape, the path and other landscape elements which form the mesh are not formed separately and joined; they are formed as one mesh from the start.

The addition of colour is purely for communication on that 3d mesh. I need to have distinct colour for different landscape elements that can seamlessly ‘sit’ on the underlying landscape mesh. Not sure if it’s possible or not.

I will check out the links you provided.

Best,
Jeremy

Ok, that makes it easier. If you can find exactly the outlines / naked edges of your shape, you should be able to cut out the path using the following Python script.

"""
Split mesh (M) at polyline (PL)
Author: Anders Holden Deleuran
"""

import Rhino as rc

# Weld mesh
M.Weld(rc.RhinoMath.ToRadians(180))

# Get topological edges midpoints
teMids = rc.Collections.Point3dList()
for i in range(M.TopologyEdges.Count):
    teMids.Add(M.TopologyEdges.EdgeLine(i).PointAt(0.5))

# Get topological edges to unweld
teUnweld = []
for polyline in PL:
    segments = polyline.GetSegments()
    print len(segments)
    for segment in segments:
        teUnweld.append(teMids.ClosestIndex(segment.PointAt(0.5)))

# Unweld mesh and explode it 
M.UnweldEdge(teUnweld,True)
M = M.ExplodeAtUnweldedEdges()

But i imagine you can also just find the faces you want to delete from your mesh using their centroids and your path shape connected to a Inside Shape component or sth. If you upload your file with all geometry internalized i can see if i can help you further.

Hi Calcman,
just wondering how to use the script you posted? I tried saving it as a python file and running it, but it shows:

-Jeremy

Hi @jdelavaulx,

You need to make an input called M and PL on the grasshopper component and then feed the mesh to cut into M and the path boundary Polyline into the PL input.

Hi Michael, thanks for your help.

I’m not familiar with this process of working wit PY files in gh.
Am I on the right track?

Best,
Jeremy

Almost there i presume, you probably just need to right click on M and PL and set the Type hint to Mesh and Polyline respectively.

Thanks for sharing @jdelavaulx,

You are getting a None Type error because you have nothing connected/plugged into your script component inputs so the script is saying “hey sorry I can’t weld something that is nothing”

Typically components have logic inside them to bypass this error and say “no input found in M” or something like “please provide a mesh”

But this is a leaner script and doesn’t have robust error handling in that way which is fine.

You should now just reference your mesh in Grasshopper and plug the wire from that Mesh into your M input of the script component. Likewise, plug the polyline boundary into your PL input.

See how the original linked post has the mesh node connecting to the M input and the “Curve” node connecting into the PL input?

That should work, let us know if you still get an error in your script,

Thanks!

Hi Michael, thanks for your help

I’m using Rhino 7, and get this message with mesh and polyline plugged into the inputs.

I’ve attached the file with internalised data.
Mesh test split 2.3dm (237.9 KB)
Test.gh (135.5 KB)

-Jeremy

Hi @jdelavaulx ,

Right click on your M input and under Type Hints of choose Mesh from the drop down

1 Like

Hi Michael,

Having set the type hint to Mesh, and the Crv container to polyline, I still get this error:

I apologise if these are basic rookie errors… It’s a bit of a foreign world to me.

-Jeremy

Hi Calcman, thanks for your message.

I was able to get the script to work, but the mesh seemed not to rebuild according to the trimmed curves defined by the input curves.


I’m trying to use the trimmed edges of the mesh to generate a new mesh limited to the bounds of the curve, but without mesh in the area indicated by the red x in the image below

Do you think that it’s possible?
231230_SplitMeshAtPolyline_00.gh (137.3 KB)
Mesh test split 2.3dm (391.5 KB)

-Jeremy

Hi @jdelavaulx ,
This reminds me of this thread:

Below is a version which uses curves as input instead of the meshes from the previous thread. Note, the outer boundary needs to be the first curve in the list.
20240914_SplitMeshAtPolyline_BW.gh (10.8 KB)

-Brian

2 Likes

Brian Washburn, I cannot thank you enough… it seems to work as envisioned.

Don’t know where you learned about how to do all this coding to achieve the goal, but it’s impressive.

Is the best way to manage the curve list order by using the ‘manage curve collection’ in the right click menu on the Crv container?

Also, Is there a way in which this script can work in Rhino 7 as well as 8? Or perhaps it’s only possible thanks to 8’s new features…

Best,
Jeremy

@jdelavaulx ,
The same features work in RH7, so I just copied the text of the script over in the RH7 definition below.
20240915_SplitMeshAtPolylineRH7_BW.gh (7.9 KB)

I’ve also sorted the curves based on area to make sure the outer boundary is first.

All that I’ve learned about C# coding is by just doing. There has been a lot of trial and error and I still see myself as a hack, but this forum (for RH specific code) and StackOverflow (for the basics) have served as some fantastic resources with plenty of great examples to learn from. With AI, I expect my path would have been different.

-Brian

1 Like

Thank you again. The script is very helpful :slight_smile:

Cheers,
Jeremy