Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

core.islands (procNode)

Label every primitive with the connected island it belongs to. With connectivity "point", primitives that share a point are in the same island; with "edge", only primitives that share an edge are. Answers the island of each primitive and the number of islands.

Built from core.edges, jump in label mode folded until no label changes (g:fold with stop = "changed"), gather, scatter and compact. With "point", every point takes the smallest point number of the points joined to it by an edge, and a primitive's island is the label of its first point; with "edge", every primitive takes the smallest primitive number of the primitives joined to it across an edge. The labels are renumbered 0 to count - 1 in ascending order. Outputs islands (one number per primitive) and count.

Inputs

  • geometry (Geometry). The geometry whose primitives are labelled.
  • connectivity (one of point, edge). Default "point". What joins two primitives: a shared point, or a shared edge.

Outputs

  • islands: the island number of each primitive.
  • count: how many islands.

Example

local grid = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } })
local apart = g.core.concat({ geometries = { grid, g.mesh.box({}) } })
local islands = g.core.islands({ geometry = apart })

The grid is one island and each face of the box is one more: islands.count is 7.