# Geometry nodes, how to select the boundaries of mesh islands?

is it possible to select only the outer boundaries of these meshes using geometry nodes?

blender 3.6+

If the method with the raycast from Markus von Broady does not work for you, you can also go the indirect way via splines:

Here I first capture with Capture Attribute the number of points to which each point is connected. This value will later help me to distinguish the inside edge from the outside edge, because only the inside curve has vertices that are connected to four (or more) points. Also, in the first step, I convert the outer edges of the mesh to curves so that I can process this geometry more easily. In doing so, the previously captured values in the point domain are preserved:

Then I capture the index in the spline domain, which I use as ID to accumulate the previously captured values per point. The value Total that the node Accumulate Field gives me is thus for all points within a spline always either $$0$$ if it is an outer edge, or greater/equal $$4$$ if the spline contains points that were previously connected with four or more points.

And with just this selection, you can then remove the spline that was the inside edge in the original mesh:

But in order to then be able to use these values in the original mesh, I "transfer" these values. To do this, I compare the positions of the points of the mesh with those of the still existing splines, and if the positions are the same, then it is the outer edge and thus the selection we are looking for. The node Extrude Mesh, however, processes the values in the edge domain, which is why this selection is finally transferred from the point domain to the edge domain with Evaluate Domain.

(Blender 3.6+)

Update:

An idea came up in the comments (thanks to @Pooya heydari) about detecting curves based on Mesh Island and Spline Length.

This is a terrific idea, and the solution for it could look like this:

After I have extracted the splines (as described above) I accumulate their lengths per Mesh Island, divide this value and simply compare which spline is longer/shorter. This way it should be possible to reliably (?) identify the outer (longer) spline.

(Blender 3.6+)

• Smart observation that inner corners are topologically different. I was thinking about a curve solution too but I didn't have an exact plan: add a big square-spline, Fill Curve, and Blender does the work of figuring out outer/inner for filling, something like that. It would still be overfitted to the specific OP's case though, so why bother. BTW, a boolean False/True converts to integer 0/1, so no need for the switch except if you're a fan of explicitness. Same goes for int > 0. Maybe I'll write 2 Q&As, on conversions and interpolations… Aug 20, 2023 at 15:02
• So you're not a fan of explicitness after all :D Aug 20, 2023 at 15:16
• @MarkusvonBroady Yes, I'm generally a fan of explicitness, but in this case you're absolutely right :D Well observed! Often artifacts remain in my node trees that I overlook when cleaning up, and sometimes something can still be optimized. Thanks for your feedback! Aug 20, 2023 at 15:17
• I have an idea, is it possible to select the boundary edges based on each "mesh island" and it's "Spline Length" ? (select the longer spline ) because in some cases "vertex count" doesn't work. Aug 22, 2023 at 10:33
• @Pooyaheydari Oh yeah, that's a good idea to use the spline length for that! Well observed! ...give me a second, there's a solution. Aug 26, 2023 at 11:05

Very hard problem in general, but in your particular case you can raycast to see if you're on the inside - though you need to know which direction to raycast to… If the normals are pointing in a way as if you duplicated the floor, moved on top, merged and recalculated normals outside, then it's easy, so what I do below is extrude faces instead of edges to get the 'correct' normals. And similarly near the end I also flip the normals of the input geometry, anticipating some future problems if you don't:

• Thank u. I'll try it. Aug 20, 2023 at 21:06