Biggest closed curve / surface possible given a bunch of lines?

Hi, I have lots of bunches of separate lines which describe surfaces on a plane. Running the Join component doesn’t always give me the right result given the ‘internal’ lines. What would be the best approach to find the biggest closed curve / or which lines are ‘internal’? ‘Internal’ lines highlighted on the below screengrab.


Biggest Closed Curve.gh (22.9 KB)

Up.load.code

Done - thanks!

You use the Curve.CreateBooleanRegions method (which isn’t exposed in native Grasshopper):


240726_BiggestClosedCurve_00.gh (23.4 KB)

1 Like

Thanks! I’m new to the Python stuff - is it simply a case of placing a Python node and copying your script in the image?

I attached the Grasshopper file too, see below the image :slight_smile:

1 Like

The Python node displays as red - looks like I’m missing something?

Try running the Rhino SystemInfo command and pasting the results here.

Rhino 6 SR35 2021-8-10 (Rhino 6, 6.35.21222.17001, Git hash:master @ 073ac7b225c67348731c6597127b9410126c3139)
License type: Commercial, build 2021-08-10
License details: LAN Zoo Network Node

Windows 10.0.0 SR0.0 or greater (Physical RAM: 32Gb)
Machine name: LSI-WS-048

Computer platform: DESKTOP

Standard graphics configuration.
Primary display and OpenGL: NVIDIA Quadro RTX 4000 (NVidia) Memory: 8GB, Driver date: 4-26-2024 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 538.62
> Accelerated graphics device with 4 adapter port(s)
- Secondary monitor attached to adapter port #0
- Windows Main Display attached to adapter port #1

Secondary graphics devices.
Citrix Display Only Adapter (Citrix Systems Inc.) Memory: 0MB, Driver date: 3-14-2024 (M-D-Y).
> External USB display device with 8 adapter port(s)
- There are no monitors attached to this device!
Citrix Indirect Display Adapter (Citrix Systems Inc.) Memory: 0MB, Driver date: 2-27-2024 (M-D-Y).
> External USB display device with 8 adapter port(s)
- There are no monitors attached to this device!

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On

Anti-alias mode: 4x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 4-26-2024
Driver Version: 31.0.15.3862
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 8 GB

Rhino plugins
C:\Program Files\Rhino 6\Plug-ins\Commands.rhp “Commands” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 6\Plug-ins\RhinoRender.rhp “Rhino Render”
C:\Program Files\Rhino 6\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\rdk_ui.rhp “Renderer Development Kit UI”
C:\Program Files\Rhino 6\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 6\Plug-ins\IronPython\RhinoDLR_Python.rhp “IronPython” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\RhinoCycles.rhp “RhinoCycles” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\Grasshopper\GrasshopperPlugin.rhp “Grasshopper” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 6.35.21222.17001
C:\Program Files\Rhino 6\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 6\Plug-ins\Displacement.rhp “Displacement”

The Curve.CreateBooleanRegions was added in Rhino 7.0, so I’m afraid the GhPython script I posted won’t work with your current Rhino version :confused:

:frowning: Bummer - thanks anyway.

In place of that, the best approach I can think of is:

  • Pick a start point which only connects to two other points.
  • Find a line that connects
  • Repeat until you arrive back at the first point
  • Any point that has more than two connecting lines, Pick the first point in a clockwise manner

It’s not perfect logic as it depends on what point I pick as the start point - probably need to compare against picking anti-clockwise too, and go with the longer of the two lists.

I’m well aware that there may be some GH components which do most of this for me - but as I’m pretty new to it, I have no idea.

1 Like

if you are working with polylines only I think Clipper is the best in slot for Rhino 6 for this task (Food4Rhino states Clipper should work with Rhino 6)

Thanks, I’ve got Clipper installed. The only useful looking component is Polyline Boolean Union, but it doesn’t seem to get me much further, unless I’m missing something. It still requires the calculation of closed shapes beforehand, which is the step I’m stuck on…

Incidentally, I found another approach in another post - using Surface Split. Seems like it has some mileage…

you are right, I forgot the intermediate step of creating the different regions .___. which is quite a fundamental one :upside_down_face:

I don’t know if Heteroptera’s Geometric Cell component relies on Rhinocommon or has some internal methods to create regions from curves, I don’t have an R6 installation to give it a try… you can try by opening this file after installing Heteroptera from food4rhino (I see there’s a R6 compatible version) Heteroptera | Food4Rhino

you will also have to replace Clipper2 Union component with Clipper1 equivalent

Biggest Closed Curve_Re.gh (70.5 KB)

[edit] just a note on the method you describe and might work for this task
I think it might be a good solution, and I guess you don’t necessarily need to find already the regions with maximum extension/perimeter/area in the first step: you just need to be sure you have found all of them, then you could just region_boolean them together to find the ones with max extent?
which is sort of… your lines compose an undirected graph of nodes and edges, where edges are the lines and nodes are the line end points: for each node, find all the loops in the graph using each edge max 1 time…


but to keep things simpler, surface split should also work:


Biggest Closed Curve_SrfSplit.gh (26.3 KB)