Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

points.count_neighbors (procNode)

Count each point's occupied lattice neighbours, from an integer grid-coordinate attribute, into an Int attribute: the shell, erosion, flood and tiling primitive. Use it on voxel-like points to find the surface (fewer than 6 face neighbours), the interior, or the cells a tile set must match.

The coordinates are rounded to cells and laid in as positions of a fresh point set; every cell's neighbours at lattice distance 1 (the 6 faces) or up to the cube's corner at 1.732 (the 26 cells) fall inside a search radius of 1.01 or 1.74, so core.neighbours counts them. The tally is written to the original points, which keep everything they carried. Points without the attribute are an error naming it.

Built from: core.points, core.neighbours, vector.floor, math.*.

Inputs

  • points (Geometry). The cloud whose lattice occupancy is counted. Each point is read as one cell of an integer grid through attribute.
  • attribute (String, default "voxel"). Name of the attribute holding each point's grid coordinate; its three components are rounded to whole numbers to give the cell the point occupies.
  • output (String, default "neighbors"). Name the tally is written under, as an Int attribute on every point.
  • diagonal (Bool, default false). false counts the 6 cells sharing a face with the point's cell; true counts all 26 cells of the surrounding cube.

Outputs

  • points (Geometry). The points, with the tally under output.
local cells = g.points.box({ countX = 3, countY = 3, countZ = 3 })
cells.point.voxel = cells.point.P
local counted = g.points.count_neighbors({ points = cells })