Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

core.adjacency (procNode)

Answer a neighbour relation over a geometry as a table of offsets and items: the points around a point, the primitives that use a point, the vertices that stand on a point, the primitives across an edge, the edges and points of a primitive, and the rest of nine relations.

Relations (<owner>_<listed>): point_points, point_faces, point_vertices, point_edges, face_points, face_edges, face_faces, edge_points, edge_faces. Built from core.owner, core.edges, the expand kernel (a side or an end per edge; the two faces of each edge that has two are laid out over the live total of those pairs, which one read-back states), sort of the owner keys, scatter for each owner's count, scan for the offsets and gather. Outputs: offsets (where each owner's list starts in items), counts (the length of each list) and items. The relation's owners are numbered as its first word says: points, primitives or edges.

Inputs

  • geometry (Geometry). The geometry whose neighbours are listed.
  • relation (one of point_points, point_faces, point_vertices, point_edges, face_points, face_edges, face_faces, edge_points, edge_faces). Default "point_points". Which relation: the owner's kind, then the listed kind. "point_faces" lists, for each point, the primitives that use it, and "point_vertices" the vertices that stand on it, in the same order: the k-th vertex of a point belongs to its k-th primitive.

Outputs

  • offsets: where each owner's list starts in items.
  • counts: the length of each owner's list.
  • items: the listed elements, owner after owner.

Example

local grid = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } })
local around = g.core.adjacency({ geometry = grid, relation = "point_faces" })

around.counts holds how many primitives use each of the nine points, around.offsets where each point's list starts in around.items.