Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-geocore

Source of release 0.7.3

0.7.3 / src / kernel.lucb

## The geocore_kernel export: what Base kernels in other packages build on.
## Luce code never imports it: these take spans and pointers. Sections:
## attributes and bits, meshes, groups and selections, geometry sets, verbs
## and subdivision, curves, fields, the geometry codec, and polygon
## triangulation.
import core.attributes
import core.bits
import core.float3
import core.idset
import core.limits
import core.paths
import core.strings
import geometries.polygon
import geometries.triangulation.display_triangulation
import geometries.triangulation.face_scratch
import geometries.triangulation.polygon_triangulation
import geometry_set
import groups
import verbs
import set_verbs
import subdivision
import curves
import fields
import geometry_files
import code

# mark: Attributes and bits

## Element domains: point, corner, face, detail, edge.
pub type Domain = attributes.Domain
## An attribute's scalar type.
pub type DataType = attributes.DataType
## How operations treat an attribute's values (generic, position, normal, …).
pub type Role = attributes.Role
## One named attribute: its domain, type, width and shared column.
pub type Attribute = attributes.Attribute
## The attributes of one mesh, cloud or curves; (name, domain) is unique.
pub type AttributeStore = attributes.AttributeStore
## f32 positions and normals, as columns store them.
pub type Float3 = float3.Float3
## A read-only bit set over a domain's elements.
pub type Bits = bits.Bits
## Bits being built, published by `finish`.
pub type BitsBuilder = bits.BitsBuilder
## The number of set bits in a word.
pub let popcount = bits.popcount
## The index of the lowest set bit of a nonzero word.
pub let trailing_zeros = bits.trailing_zeros
## Interns strings for a text attribute and publishes their table.
pub type TableBuilder = strings.TableBuilder
## Which `path` values a Blast or export keeps (glob patterns).
pub type PathFilter = paths.PathFilter
## Column block ids already counted (memory footprints).
pub type IdSet = idset.IdSet

## A text attribute of `elements` whose element i is string `values[i]` of
## `texts` (-1: "").
pub func text_attribute(name: str, domain: Domain, elements: usize, texts: const TableBuilder*, values: const i32[]) -> Attribute!:
    var table = try texts.finish()
    defer table.release()
    return try Attribute.text(name, domain, elements, table, values)

# mark: Meshes

## Assembly from columns an importer filled (luce-usd, luce-fbx): a mesh
## taking its columns, its attributes put on afterwards. Meshes past the
## size limits are refused.
pub let assembled = polygon.assembled
## Add or replace an attribute of a mesh being built.
pub let put_attribute = polygon.put_attribute
## At most 8M points: a mesh's size limits.
pub let max_points = limits.max_points
## At most 8M faces.
pub let max_faces = limits.max_faces
## At most 32M corners.
pub let max_corners = limits.max_corners
## An error when a mesh of these sizes would pass the limits.
pub let check_mesh_size = limits.check_mesh_size
## A new owner sharing every column of a mesh.
pub let mesh_share = polygon.mesh_share
## Release one owner of a mesh.
pub let mesh_dispose = polygon.mesh_dispose
## Adopt heap mesh storage as a Luce-visible mesh.
pub let mesh_adopt = polygon.mesh_adopt
## A mesh over `source`'s topology with new positions of which `moved`
## changed (normals around them refreshed; caches update in part).
pub let moved_storage = polygon.moved_storage
## A precise mesh's f64 points; empty otherwise.
pub let precise_span = polygon.precise_span
## One mesh of a concatenation and its placement.
pub type MeshPart = polygon.MeshPart
## Every part's points, faces and attributes, placed, in one mesh.
pub let concatenated = polygon.concatenated

# mark: Groups and selections

## The bits of group attribute `index` of a mesh.
pub let group_bits = polygon.group_bits
## A snapshot of a mesh with a group holding given bits.
pub let with_group_bits = polygon.with_group_bits
## Edge bits as (low, high) point pairs, which survive topology changes.
pub let edge_pairs = polygon.edge_pairs
## Set the bits of the edges named by point pairs.
pub let edge_bits_from_pairs = polygon.edge_bits_from_pairs
## What group evaluation noticed without failing (numbers naming nothing).
pub type GroupReport = groups.GroupReport
## A selection: bits over one domain, guarded by a topology hash.
pub type Selection = groups.Selection
## The bits a group expression names on a domain, evaluated or cached.
pub let group_bits_of = groups.group_bits
## Drop every cached group (tests with allocation trackers).
pub let clear_group_cache = groups.clear_group_cache
## The bits of a selection.
pub let selection_bits = groups.selection_bits
## A selection over bits a Base kernel made (a knife stroke's faces).
pub let adopt_selection = groups.adopt_selection

# mark: Geometry sets

## A geometry set: one component per family, plus detail attributes.
pub type GeometrySet = geometry_set.GeometrySet
## A component family's operations (share, close, bounds, placement, …).
pub type ComponentType = geometry_set.ComponentType
## One family's data in a set.
pub type Component = geometry_set.Component
## Where a component or instance is placed.
pub type Placement = geometry_set.Placement
## A heap set holding nothing yet.
pub let empty_set = geometry_set.empty_storage
## Adopt heap set storage as a Luce-visible set.
pub let adopt_set = geometry_set.adopt_set
## Release heap set storage.
pub let dispose_set = geometry_set.dispose_set
## The mesh of a set, borrowed while the set lives.
pub let set_mesh = geometry_set.set_mesh
## The detail attributes of a set.
pub let set_detail = geometry_set.set_detail
## Put an attribute (taken) among a set's detail attributes.
pub let set_put_detail = geometry_set.set_put_detail
## Append text to a byte buffer (component labels).
pub let append_text = geometry_set.append_text
## Append a whole number in decimal to a byte buffer.
pub let append_number = geometry_set.append_number

## The mesh family. The built-in families are functions: taking a global's
## address in a global initializer does not compile through the C backend.
pub func mesh_component() -> const ComponentType*:
    return &geometry_set.mesh_component

## The point cloud family.
pub func points_component() -> const ComponentType*:
    return &geometry_set.points_component

## The instances family.
pub func instances_component() -> const ComponentType*:
    return &geometry_set.instances_component

## Points without faces.
pub type PointCloud = geometry_set.PointCloud
## A cloud's positions, relative to its origin.
pub let cloud_positions = geometry_set.cloud_positions
## The origin a cloud's positions are measured from.
pub let cloud_origin = geometry_set.cloud_origin
## A cloud's point attributes.
pub let cloud_store = geometry_set.cloud_store
## The change id of a cloud's positions.
pub let cloud_positions_id = geometry_set.cloud_positions_id
## A set's point cloud, splats or plain points.
pub let set_cloud = geometry_set.set_cloud
## A heap cloud owning given columns.
pub let cloud_assembled = geometry_set.cloud_assembled
## A cloud sharing another's positions with new point attributes (taken).
pub let cloud_with_store = geometry_set.cloud_with_store
## A set's point cloud when it is a Gaussian splat cloud (luce_geocore.splats
## has the conventions and math).
pub let set_splats = geometry_set.set_splats
## A set with its splat cloud in the raw 3DGS PLY names, for writers (the
## inverse of Bake GSplats; GeometrySet.unbaked_splats in Luce).
pub let unbaked_set = geometry_set.unbaked_set
## Placed copies of prototype sets.
pub type Instances = geometry_set.Instances
## A new, empty instances component.
pub let new_instances = geometry_set.new_instances
## Cameras and lights with their paths.
pub type SceneObjects = geometry_set.SceneObjects
## Every camera and light of a set and its instances, placed.
pub let scene_flattened = geometry_set.scene_flattened
## Materials with their paths, shaders and parameters.
pub type Materials = geometry_set.Materials
## One material parameter's value: up to four numbers, or a texture file.
pub type MaterialParameter = geometry_set.MaterialParameter
## Every material of a set and its instances, each prototype once.
pub let materials_flattened = geometry_set.materials_flattened

# mark: Verbs and subdivision

## Per-point soft weights of a selection (the Edit viewport's falloff tint).
pub let selection_weights = verbs.selection_weights
## Transform Components' numbers as matrices, for editors moving whole things.
pub type ComponentTransform = verbs.ComponentTransform
## What a set verb made: its set (taken by the caller) and its report.
pub type SetVerbOutput = set_verbs.SetVerbOutput
## Run a set verb, for Base callers and tests.
pub let run_set_verb = set_verbs.run_set_verb
## The set verb called `name`, if any.
pub let find_set_verb = set_verbs.find_set_verb
## A subdivided mesh's display mesh (limit surface, cached), or none.
pub let subdivided_display = subdivision.subdivided_display

# mark: Curves

## Poly, Bezier, NURBS and Catmull-Rom curves sharing one point column.
pub type Curves = curves.Curves
## Curves built point by point and curve by curve.
pub type CurvesBuilder = curves.CurvesBuilder
## Poly, Bezier, NURBS or Catmull-Rom.
pub type CurveType = curves.CurveType
## Where a NURBS curve's knots come from.
pub type KnotMode = curves.KnotMode
## How one curve evaluates.
pub type CurveSettings = curves.CurveSettings
## A Curves owning given columns.
pub let curves_assembled = curves.curves_assembled
## The curves family.
pub let curves_type = curves.curves_type
## A set's curves, borrowed while the set lives.
pub let set_curves = curves.set_curves
## A copy of a set with other curves (taken).
pub let with_curves = curves.with_curves
## Heap storage sharing every column of curves.
pub let curves_share = curves.curves_share
## Release heap curves storage.
pub let curves_dispose = curves.curves_dispose
## The curves whose bits are set, every attribute carried.
pub let curves_subset = curves.curves_subset
## The origin curve positions are measured from.
pub let curves_origin = curves.curves_origin
## An f32 x3 point attribute (handles) as Float3s.
pub let curve_float3_span = curves.float3_span
## The point weights `w`, when they are f32.
pub let curve_weight_span = curves.weight_span
## Every curve's custom knots, back to back.
pub let curves_knots = curves.curves_knots
## Where each curve's custom knots start.
pub let curves_knot_offsets = curves.curves_knot_offsets
## Where each curve's evaluated points start.
pub let evaluated_offsets = curves.evaluated_offsets
## Evaluated points, relative to the curves' origin.
pub let evaluated_positions = curves.evaluated_positions
## Tangents, normals and arc lengths of the evaluated points.
pub let evaluated_frames = curves.evaluated_frames
## The evaluated points' change id.
pub let evaluated_id = curves.evaluated_id
## The group language on curves.
pub let curve_group_bits = curves.curve_group_bits
## A line of evenly spaced points.
pub let line_curves = curves.line_curves
## An arc or circle of curves.
pub let arc_curves = curves.arc_curves
## A spiral around Y.
pub let spiral_curves = curves.spiral_curves
## A sketch's plane (the set's detail attributes), for kernels that read
## sketches exactly (luce-cad's profiles).
pub type SketchPlane = curves.SketchPlane
## The sketch plane of a set (the ground when unset).
pub let sketch_plane_of = curves.sketch_plane_of

# mark: Fields

## A sparse voxel grid of 8x8x8 leaves.
pub type SparseGrid = fields.SparseGrid
## What a grid holds: a level set or a density.
pub type GridClass = fields.GridClass
## Trilinear samples of a grid, with a one-leaf cache.
pub type GridSampler = fields.GridSampler
## The leaf key (Morton code) of leaf coordinates.
pub let leaf_key = fields.leaf_key
## The leaf coordinates of a leaf key.
pub let key_leaf = fields.key_leaf
## Share a heap grid (one more user), and release one.
pub let share_grid = fields.share_grid
pub let release_grid = fields.release_grid
## A grid built from a list of leaves filled in parallel.
pub let grid_of_leaves = fields.grid_of_leaves
## A volume: named grids in a set.
pub type Volume = fields.Volume
## The volume family.
pub let volume_type = fields.volume_type
## A set's volume, borrowed while the set lives.
pub let set_volume = fields.set_volume
## How a fog grid looks in a viewport (Volume Visualization), carried by
## each grid.
pub type VolumeLook = fields.VolumeLook
## A grid with another look, sharing its voxels.
pub let restyled = fields.restyled
## One fog drawing of a volume: the grid whose look it takes, its density
## grid and its emission field.
pub type FogShow = fields.FogShow
## Fog drawing `index` of a volume, and how many it makes.
pub let fog_show = fields.fog_show
pub let fog_show_count = fields.fog_show_count
## A new volume of no grids.
pub let new_volume = fields.new_volume
## Add a grid (taken) to a volume being built.
pub let add_grid = fields.add_grid
## Release a heap volume.
pub let release_volume = fields.release_volume
## An SDF program: primitives, booleans, modifiers and placement.
pub type Sdf = fields.Sdf
## An SDF program's operations.
pub type SdfOp = fields.SdfOp
## The SDF family.
pub let sdf_type = fields.sdf_type
## A set's SDF, borrowed while the set lives.
pub let set_sdf = fields.set_sdf
## Release a heap SDF.
pub let release_sdf = fields.release_sdf
## A one-op program of a primitive.
pub let primitive_sdf = fields.primitive_sdf
## Two programs combined by a boolean, smoothly.
pub let combined_sdf = fields.combined_sdf
## A program rounded or shelled.
pub let modified_sdf = fields.modified_sdf
## A program placed by a matrix.
pub let placed_sdf = fields.placed_sdf
## A level set sampled from an SDF.
pub let sampled_sdf = fields.sampled_sdf
## The signed distance of a closed mesh as a level set.
pub let mesh_level_set = fields.mesh_level_set
## A union of spheres around points as a level set.
pub let points_level_set = fields.points_level_set
## The surface mesh where a grid crosses a value.
pub let surface_mesh = fields.surface_mesh
## An SDF's surface preview, built on first use and kept.
pub let sdf_preview = fields.sdf_preview

# mark: Geometry codec

## Where codecs write. Sets save and load as prism crates; other packages'
## families (luce-cad's B-rep) add encoders and decoders to the registry.
pub type GeometryWriter = geometry_files.GeometryWriter
## Where codecs read: the crate being loaded.
pub type GeometryReader = geometry_files.GeometryReader
## A property's name, dtype, shape and size.
pub type PropertyHeader = geometry_files.PropertyHeader
## Reads a crate element by element.
pub type CrateReader = geometry_files.CrateReader
## Register a family's encoder and decoder.
pub let register_codec = geometry_files.register_codec
## Write a set under an element path.
pub let encode_set = geometry_files.encode_set
## Save a set to a file as a prism crate.
pub let save_geometry = geometry_files.save_geometry
## Load a geometry crate as a new set.
pub let load_geometry = geometry_files.load_geometry
## The key a geometry file was saved with.
pub let geometry_key = geometry_files.geometry_key
## 32-bit integers, a prism wire dtype for codecs' columns.
pub let dtype_int32 = geometry_files.dtype_int32
## Raw bytes.
pub let dtype_uint8 = geometry_files.dtype_uint8
## 64-bit floats.
pub let dtype_float64 = geometry_files.dtype_float64

# mark: Polygon triangulation

## Display triangulation of one polygon of any size: `output` gets the
## 3 * (count - 2) corner indices of corners start..<start + count, wound
## about the unit `normal` (zero: a fan). Only running out of memory fails.
pub let triangulate_polygon = polygon_triangulation.triangulate
## Check display triangles of one polygon as Mesh construction does.
pub let validate_polygon_display = display_triangulation.validate
## For tests: faces of more than `limit` corners take the heap path (see
## face_scratch); set it before any work starts.
pub let set_small_faces = face_scratch.set_small_faces

# mark: The Code node

## Run a Code snippet over a set on `threads` workers (0: every core); see `Code.run`.
pub let run_code = code.run_code
## How many snippets were checked and lowered (program cache misses).
pub let code_compiles = code.code_compiles