Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

elements.keep

Keep the elements a per-element value says to, and drop the rest: every element whose keep is not 0 stays, with every column it carries. Keeping points drops each face that used a dropped point; keeping faces keeps their corners and every point. What remains stands in its order, on the device, and a count on the device says how many, so no frame waits to find out: it is core.select with device on, so the result holds the elements the geometry is allocated for and counts the kept ones there, and a drained copy holds the kept ones alone. A keep field reading the geometry's own attributes (g.field.position(), g.element.P) reads this geometry's.

Built from core.select with points = "all"; a constant keep stands once on every element.

Inputs

  • geometry (Geometry). What is thinned. The columns of every class come through with the elements they belong to.
  • keep (Field | Float). Per element of class: not 0 keeps it. A comparison turns any value into this. A value of the geometry's own attributes is read from the geometry: g.field.position({ geometry = geometry }) or g.attribute.read({ geometry = geometry, name = "..." }).
  • class (one of point, primitive). Default "point". Which elements are kept or dropped.

Outputs

  • geometry: the kept elements with every column they carry and the links renumbered.

Example

local grid = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } })
local high = g.elements.keep({ geometry = grid, keep = g.compare(g.field.position({ geometry = grid }).x, "gt", 0) })

The three points at x = 1 stay; every triangle used a dropped point, so none stays.