Builtin Library
README.md
attribute.accumulate
Fold a column over the elements that carry it: running, where each element holds the sum, mean, least or greatest of every element up to and including itself, or total, where each element holds its whole group's. by splits the elements into groups by a whole number, each folded on its own; without it the class is one group. A running cost along a path, each island's total area, the highest point of each cluster.
Inputs
geometry(Geometry). What carries the column. A copy comes out with the folded values underas.by(Field | Float, optional). The group each element is in, a whole number. Elements of a group are folded in the order they stand. Left empty, every element is in one group.name(String). Default"". The column folded. A name the class does not carry is refused.class(one of point, vertex, primitive). Default"point". Which elements are folded.op(one of sum, mean, min, max). Default"sum". How the values fold: added up, averaged, the least or the greatest.mode(one of running, total). Default"running". "running" gives each element the fold of its group up to itself; "total" gives each element its whole group's.as(String). Default"". The name the folded values are written under. Left empty it isname.
Outputs
geometry: the geometry with the folded values written underas(orname) onclass, of the column's type.
Example
local grid = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } })
local numbered = g.attribute.number({ geometry = grid, class = "point", name = "n" })
local summed = g.attribute.accumulate({ geometry = numbered, name = "n", op = "sum", mode = "running", as = "total" })
total holds 0, 1, 3, 6, 10, 15, 21, 28, 36 on the nine points.