# Draw outline around points

Hi there!

I am trying to create a curve/polyline outline around a set of points (the blue line in the screenshot)

I have attempted to do this by using Delaunay edges which draws lines between each of the points but I can not seem to get an outline around all of it.

Thank you!

draw line around points.gh (227.0 KB)

This (general case) is a concave hull task (not convex). Given a planar pts List a concave hull is this:

But if you can optain the right mesh out of your collection (this could be quite tricky mind) then the naked edges (i.e. mesh face edges that are connected to a single face) are the segments of the polyline that you are after: use the join Curves component on them (or use the MShadow against a suitable plane).

Plus if your collection is exactly as shown (i.e portions of a rectangular grid) then you can get what you want by excluding faces (on a Delauney mesh) that have edges greater than the diagonal length OR using other ways without a mesh â€¦ but Iâ€™m not sure how to achieve this without code (but that is a personal opinion).

Anyway: see attached that is the fastest way to cut the mustard - via a del mesh - on that matter â€¦ but is pure C# code (the bad news).

Note: you are responsible for entering the right L - the diagonal distance (if not > bananas on sight).

Note: this works on rectangular grids.

2 Likes

~49K points!

draw_line_around_points_2019Nov25a.gh (236.1 KB)

Boundary surface is faster than I expected but misses the tiny â€śholesâ€ť and flips the normal direction on two of the surfaces.

2 Likes

Thank you, I will have a look at both of them!

What if you explode the rectangles, make mid points and cull(all) duplicate pointsâ€¦?
Maybe fasterâ€¦ will tryâ€¦

Edit:

draw_line_around_points_2019Nov25a_V2.gh (236.5 KB)
Surprisingly, CullPt is really slow. Made a pseudo â€śCullPtâ€ť funcion and removed duplicated segmentsâ€¦ it is somewhat faster overallâ€¦

Still RUnion is working really fast, incredible!

Added the purple group to move nested curves (â€śregionsâ€ť) to the same branch as their parent so that Boundary surface works correctly to show the holes.

Also converted all the polylines to NURBS curves to smooth the edges.

draw_line_around_points_2019Nov25b.gh (253.8 KB)

I integrated your optimization into this file, @maje90. It appears to yield identical results as RUnion and is certainly faster. Unfortunately, two of the four holes disappear when I use it!? I canâ€™t see why but left it disabled for now.

This works 10-15% faster (does the Del mesh inside C#) plus it can - as an option - advise you upon the L value to use.

On an I9 or some Ryzen 9 expect ~300 milliseconds for 50K points (a bit pathetic but anyway).

NOTE: As always it works only against a rectangular collection (for the general case youâ€™ll need a proper Concave Hull C#). Does NOT make a check on planarity (for speed) and a check of a Plane fitted to points (for speed).