Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

attribute.promote

Move a named attribute from one class of elements to another: point, vertex, primitive, detail or edge, folding the values that meet with sum, mean, min or max. Answers the geometry with the attribute written on the target class.

Built from the gather, scatter and reduce kernels and core.owner; only the route from to to names cooks:

  • point to vertex: gather at vertex.pt.
  • vertex to point: scatter fold at vertex.pt.
  • vertex to primitive: reduce over each primitive's run, segments = primitive.count.
  • primitive to vertex: gather at the vertex's owner.
  • point to primitive and primitive to point: through the vertices.
  • detail to a class, the edge class included: gather of the one value; a class to detail, the edge class included: reduce of the whole column (segments = 0).
  • point to edge: the fold of the two end points over core.edges.
  • edge to point: the edge class's column scattered to both end points of every edge and folded there; a point no edge reaches holds 0.
  • primitive to edge: the values of the primitives along each edge of core.edges folded onto it: one primitive for an open edge, two for an inner one.
  • edge to primitive: the values of the edges around each primitive (core.adjacency with face_edges) folded onto it by a segmented reduce.

The same class is the attribute unchanged. A route that does not exist refuses the build by name.

Inputs

  • geometry (Geometry). The geometry holding the attribute.
  • name (String). Default "". The attribute to promote.
  • from (one of point, vertex, primitive, detail, edge). Default "point". The class the attribute lives on.
  • to (one of point, vertex, primitive, detail, edge). The class the attribute is moved to; every caller states it.
  • op (one of sum, mean, min, max). Default "mean". How values that meet on one element combine: added up, averaged, the least or the greatest.
  • as (String). Default "". The name written on the target class; empty keeps name.

Outputs

  • geometry: the geometry with the promoted column written on the target class under as (or name).

Example

local grid = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } })
local centred = g.attribute.promote({ geometry = grid, name = "P", from = "point", to = "primitive", op = "mean", as = "center" })

Each of the grid's primitives holds the mean of its corner positions under center.