Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-geocore

Source of release 0.7.8

0.7.8 / src / set_verbs / field_verbs.lucb

## Volume and SDF nodes: SDF primitives, booleans and modifiers (analytic
## programs), sampling into level sets (SDF, mesh, points), surfaces as
## meshes, and slices. Kernels live in luce_geocore.fields.

let center_doc: str = "Where the shape's center sits."
let voxel_doc: str = "Distance between voxels; smaller is finer and slower."
let band_doc: str = "Voxels of distance kept on each side of the surface."

## The input set with `sdf` (taken) in place of its SDF.
func with_sdf(input: const SetVerbInput*, sdf: Sdf*, output: SetVerbOutput*, keep_input: bool) -> !:
    let storage = (input.set.storage() if keep_input else empty_storage()) catch failure:
        release_sdf(sdf)
        error(failure.code, failure.message)
    storage.put(sdf_type(), (void*)sdf) catch failure:
        dispose_set(storage)
        error(failure.code, failure.message)
    output.set = storage

## The input set with `grid` (taken) as a volume, next to or instead of
## what `drop` names.
func with_grid(input: const SetVerbInput*, grid: SparseGrid*, output: SetVerbOutput*, drop: const ComponentType*?) -> !:
    let volume = new_volume() catch failure:
        release_grid(grid)
        error(failure.code, failure.message)
    add_grid(volume, grid) catch failure:
        release_volume(volume)
        error(failure.code, failure.message)
    let storage = input.set.storage() catch failure:
        release_volume(volume)
        error(failure.code, failure.message)
    storage.put(volume_type(), (void*)volume) catch failure:
        dispose_set(storage)
        error(failure.code, failure.message)
    if let kind = drop: storage.remove(kind)
    output.set = storage

# mark: Primitives

let sphere_parms: ParmSpec[2] = [
    ParmSpec("Radius", ParmKind.number, 1.0, 0.000001, 100000.0, 1, "", "Distance from the center to the surface.", 10.0),
    ParmSpec("Center", ParmKind.vector, 0.0, -100000.0, 100000.0, 3, "", center_doc)]

func sdf_sphere_verb() -> SetVerb:
    return SetVerb("SDF Sphere", "Volumes", "A sphere as a signed distance field", 0, false, false, sphere_parms, cook_sphere)

func cook_sphere(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let p = input.parms
    try with_sdf(input, try primitive_sdf(SdfOp.sphere, [p.at(1), p.at(2), p.at(3), p.at(0)]), output, false)

let box_parms: ParmSpec[3] = [
    ParmSpec("Size", ParmKind.vector, 1.0, 0.000001, 100000.0, 3, "", "Width, height and depth."),
    ParmSpec("Rounding", ParmKind.number, 0.0, 0.0, 100000.0, 1, "", "Radius of the rounded edges.", 1.0),
    ParmSpec("Center", ParmKind.vector, 0.0, -100000.0, 100000.0, 3, "", center_doc)]

func sdf_box_verb() -> SetVerb:
    return SetVerb("SDF Box", "Volumes", "A box with rounded edges as a signed distance field", 0, false, false, box_parms, cook_box)

func cook_box(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let p = input.parms
    let rounding = math.min(p.at(3), 0.5 * math.min(p.at(0), math.min(p.at(1), p.at(2))))
    try with_sdf(input, try primitive_sdf(SdfOp.rounded_box, [p.at(4), p.at(5), p.at(6), p.at(0) * 0.5, p.at(1) * 0.5, p.at(2) * 0.5, rounding]), output, false)

let torus_parms: ParmSpec[3] = [
    ParmSpec("Major radius", ParmKind.number, 1.0, 0.000001, 100000.0, 1, "", "Distance from the center to the middle of the tube.", 10.0),
    ParmSpec("Minor radius", ParmKind.number, 0.25, 0.000001, 100000.0, 1, "", "Radius of the tube.", 2.0),
    ParmSpec("Center", ParmKind.vector, 0.0, -100000.0, 100000.0, 3, "", center_doc)]

func sdf_torus_verb() -> SetVerb:
    return SetVerb("SDF Torus", "Volumes", "A torus around Y as a signed distance field", 0, false, false, torus_parms, cook_torus)

func cook_torus(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let p = input.parms
    try with_sdf(input, try primitive_sdf(SdfOp.torus, [p.at(2), p.at(3), p.at(4), p.at(0), p.at(1)]), output, false)

let capsule_parms: ParmSpec[3] = [
    ParmSpec("Radius", ParmKind.number, 0.25, 0.000001, 100000.0, 1, "", "Radius of the capsule.", 2.0),
    ParmSpec("Height", ParmKind.number, 1.0, 0.0, 100000.0, 1, "", "Length of the straight part along Y.", 10.0),
    ParmSpec("Center", ParmKind.vector, 0.0, -100000.0, 100000.0, 3, "", center_doc)]

func sdf_capsule_verb() -> SetVerb:
    return SetVerb("SDF Capsule", "Volumes", "A capsule along Y as a signed distance field", 0, false, false, capsule_parms, cook_capsule)

func cook_capsule(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let p = input.parms
    try with_sdf(input, try primitive_sdf(SdfOp.capsule, [p.at(2), p.at(3), p.at(4), p.at(1) * 0.5, p.at(0)]), output, false)

let cylinder_parms: ParmSpec[3] = [
    ParmSpec("Radius", ParmKind.number, 0.5, 0.000001, 100000.0, 1, "", "Radius of the cylinder.", 2.0),
    ParmSpec("Height", ParmKind.number, 1.0, 0.000001, 100000.0, 1, "", "Length along Y.", 10.0),
    ParmSpec("Center", ParmKind.vector, 0.0, -100000.0, 100000.0, 3, "", center_doc)]

func sdf_cylinder_verb() -> SetVerb:
    return SetVerb("SDF Cylinder", "Volumes", "A capped cylinder along Y as a signed distance field", 0, false, false, cylinder_parms, cook_cylinder)

func cook_cylinder(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let p = input.parms
    try with_sdf(input, try primitive_sdf(SdfOp.cylinder, [p.at(2), p.at(3), p.at(4), p.at(0), p.at(1) * 0.5]), output, false)

# mark: Combining

let boolean_parms: ParmSpec[2] = [
    ParmSpec("Operation", ParmKind.menu, 0.0, 0.0, 2.0, 1, "Union|Subtract|Intersect", "Both shapes, the first without the second, or where they overlap."),
    ParmSpec("Smoothness", ParmKind.number, 0.0, 0.0, 100000.0, 1, "", "Blend width of the seam; 0 is a sharp edge.", 1.0)]

func sdf_boolean_verb() -> SetVerb:
    return SetVerb("SDF Boolean", "Volumes", "Combine two SDFs: union, subtract or intersect, sharp or smooth", 2, true, false, boolean_parms, cook_boolean)

func cook_boolean(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let second = input.second else error(errors.invalid, "connect the second SDF")
    let first_field = set_sdf(input.set)
    let second_field = set_sdf(second)
    if first_field == none or second_field == none:
        output.warning = "Both inputs need an SDF; the first passes through"
        return
    let a = first_field else return
    let b = second_field else return
    let p = input.parms
    let smooth = p.at(1) > 0.0
    var op = SdfOp.unite
    if p.at(0) == 1.0: op = SdfOp.smooth_subtract if smooth else SdfOp.subtract
    elif p.at(0) == 2.0: op = SdfOp.smooth_intersect if smooth else SdfOp.intersect
    elif smooth: op = SdfOp.smooth_unite
    try with_sdf(input, try combined_sdf(a, b, op, p.at(1)), output, true)

let modify_parms: ParmSpec[2] = [
    ParmSpec("Mode", ParmKind.menu, 0.0, 0.0, 1.0, 1, "Round|Shell", "Grow the surface outward (negative: inward), or keep only a shell around it."),
    ParmSpec("Amount", ParmKind.number, 0.05, -100000.0, 100000.0, 1, "", "How far the surface moves, or half the shell's thickness.", 1.0)]

func sdf_modify_verb() -> SetVerb:
    return SetVerb("SDF Modify", "Volumes", "Round an SDF's surface outward or hollow it into a shell", 1, false, false, modify_parms, cook_modify)

func cook_modify(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let found = set_sdf(input.set)
    if found == none: output.warning = "The input has no SDF; it passes through"
    let a = found else return
    let p = input.parms
    try with_sdf(input, try modified_sdf(a, SdfOp.shell if p.at(0) == 1.0 else SdfOp.round, math.abs(p.at(1)) if p.at(0) == 1.0 else p.at(1)), output, true)

# mark: Level sets

let sample_parms: ParmSpec[3] = [
    ParmSpec("Voxel size", ParmKind.number, 0.05, 0.000001, 100000.0, 1, "", voxel_doc, 1.0),
    ParmSpec("Band", ParmKind.number, 3.0, 1.0, 64.0, 1, "", band_doc, 8.0),
    ParmSpec("Keep input", ParmKind.toggle, 0.0, 0.0, 1.0, 1, "", "Keep what the volume was made from beside it.")]

func sdf_to_volume_verb() -> SetVerb:
    return SetVerb("SDF to Volume", "Volumes", "Sample an SDF into a narrow-band level set volume", 1, false, false, sample_parms, cook_sdf_to_volume)

func cook_sdf_to_volume(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let found = set_sdf(input.set)
    if found == none: output.warning = "The input has no SDF; it passes through"
    let sdf = found else return
    let p = input.parms
    try with_grid(input, try sampled_sdf(sdf, p.at(0), p.at(1), "surface"), output, sdf_type() if p.at(2) == 0.0 else none)

func mesh_to_sdf_verb() -> SetVerb:
    return SetVerb("Mesh to SDF", "Volumes", "The signed distance of a closed mesh as a level set volume", 1, false, false, sample_parms, cook_mesh_to_sdf)

func cook_mesh_to_sdf(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let found = set_mesh(input.set)
    if found == none: output.warning = "The input has no mesh; it passes through"
    let mesh = found else return
    let p = input.parms
    try with_grid(input, try mesh_level_set(mesh, p.at(0), p.at(1), "surface"), output, mesh_type_component() if p.at(2) == 0.0 else none)

let points_parms: ParmSpec[4] = [
    ParmSpec("Radius", ParmKind.number, 0.1, 0.000001, 100000.0, 1, "", "Radius of the sphere around each point.", 1.0),
    ParmSpec("Voxel size", ParmKind.number, 0.02, 0.000001, 100000.0, 1, "", voxel_doc, 1.0),
    ParmSpec("Band", ParmKind.number, 3.0, 1.0, 64.0, 1, "", band_doc, 8.0),
    ParmSpec("Keep input", ParmKind.toggle, 0.0, 0.0, 1.0, 1, "", "Keep the points beside the volume.")]

func volume_from_points_verb() -> SetVerb:
    return SetVerb("Volume from Points", "Volumes", "A level set of spheres around the input's points (mesh, cloud and curve points)", 1, false, false, points_parms, cook_volume_from_points)

func cook_volume_from_points(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    var points = Growing[Vector3]()
    defer points.close()
    if let mesh = set_mesh(input.set):
        let origin = mesh.position_origin()
        for p in mesh.point_span(): try points.push(p.vector().add(origin))
    if let data = input.set.find(&points_component):
        let cloud = (const PointCloud*)data
        let origin = cloud_origin(cloud)
        for p in cloud_positions(cloud): try points.push(p.vector().add(origin))
    if let found = set_curves(input.set):
        for at in 0..<found.point_count(): try points.push(found.point(at))
    if points.count == 0:
        output.warning = "The input has no points; it passes through"
        return
    let p = input.parms
    let grid = try points_level_set(points.view(), p.at(0), p.at(1), p.at(2), "surface")
    let storage = (input.set.storage() if p.at(3) != 0.0 else empty_storage()) catch failure:
        release_grid(grid)
        error(failure.code, failure.message)
    errdefer dispose_set(storage)
    let volume = new_volume() catch failure:
        release_grid(grid)
        error(failure.code, failure.message)
    add_grid(volume, grid) catch failure:
        release_volume(volume)
        error(failure.code, failure.message)
    try storage.put(volume_type(), (void*)volume)
    output.set = storage

# mark: Meshes and slices

let convert_parms: ParmSpec[4] = [
    ParmSpec("Voxel size", ParmKind.number, 0.0, 0.0, 100000.0, 1, "", "Sampling of SDFs; 0 is 1/256 of the longest side.", 1.0),
    ParmSpec("Isovalue", ParmKind.number, 0.0, -100000.0, 100000.0, 1, "", "The value the surface follows: a distance for level sets, a density for fog.", 1.0),
    ParmSpec("Exact", ParmKind.toggle, 1.0, 0.0, 1.0, 1, "", "Move an SDF's surface points onto its exact surface."),
    ParmSpec("Keep input", ParmKind.toggle, 0.0, 0.0, 1.0, 1, "", "Keep the SDF and volume beside the mesh.")]

func convert_to_mesh_verb() -> SetVerb:
    return SetVerb("Convert to Mesh", "Volumes", "The surface of the input's SDF and volume grids as a mesh (surface nets)", 1, false, false, convert_parms, cook_convert)

func cook_convert(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let p = input.parms
    var parts = Growing[Mesh*]()
    defer:
        for part in parts.view(): mesh_dispose(part)
        parts.close()
    if let sdf = set_sdf(input.set):
        var voxel = p.at(0)
        if voxel <= 0.0:
            let box = sdf.bounds()
            let size = box.maximum.subtract(box.minimum)
            voxel = math.max(size.x, math.max(size.y, size.z)) / 256.0
        let grid = try sampled_sdf(sdf, voxel, 2.0, "surface")
        defer release_grid(grid)
        try push_mesh(&parts, try surface_mesh(grid, p.at(1), sdf if p.at(2) != 0.0 else none))
    if let volume = set_volume(input.set):
        for index in 0..<volume.grid_count():
            try push_mesh(&parts, try surface_mesh(volume.grid(index), p.at(1), none))
    if parts.count == 0:
        output.warning = "The input has no SDF or volume; it passes through"
        return
    var pieces = Growing[MeshPart]()
    defer pieces.close()
    for part in parts.view(): try pieces.push(MeshPart(part, Matrix4()))
    let joined = try concatenated(pieces.view())
    defer joined.release()
    let storage = try input.set.storage()
    errdefer dispose_set(storage)
    if p.at(3) == 0.0:
        storage.remove(sdf_type())
        storage.remove(volume_type())
    output.set = try with_added_mesh(storage, try mesh_share(joined.value()), false)
    dispose_set(storage)

let slice_parms: ParmSpec[4] = [
    ParmSpec("Axis", ParmKind.menu, 1.0, 0.0, 2.0, 1, "X|Y|Z", "The axis the slice plane faces."),
    ParmSpec("Position", ParmKind.number, 0.5, 0.0, 1.0, 1, "", "Where the plane cuts, across the field's bounds (0..1).", 1.0),
    ParmSpec("Resolution", ParmKind.integer, 128.0, 1.0, 4096.0, 1, "", "Quads along the plane's longer side.", 512.0),
    ParmSpec("Keep input", ParmKind.toggle, 1.0, 0.0, 1.0, 1, "", "Keep the field beside its slice.")]

func volume_slice_verb() -> SetVerb:
    return SetVerb("Volume Slice", "Volumes", "A colored plane through an SDF or volume: blue inside, orange outside, contour bands", 1, false, false, slice_parms, cook_slice)

func cook_slice(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    if set_sdf(input.set) == none and set_volume(input.set) == none:
        output.warning = "The input has no SDF or volume; it passes through"
        return
    let p = input.parms
    let mesh = try slice_mesh(input.set, (i64)p.at(0), p.at(1), (i64)p.at(2))
    if p.at(3) != 0.0:
        output.set = try with_added_mesh(input.set, mesh, false)
        return
    let storage = empty_storage() catch failure:
        mesh_dispose(mesh)
        error(failure.code, failure.message)
    storage.put(&mesh_component, (void*)mesh) catch failure:
        dispose_set(storage)
        error(failure.code, failure.message)
    output.set = storage

func mesh_type_component() -> const ComponentType*:
    return &mesh_component

# mark: Volumes from scratch

let volume_parms: ParmSpec[7] = [
    ParmSpec("Class", ParmKind.menu, 0.0, 0.0, 1.0, 1, "Fog|Level set", "Fog holds densities; a level set signed distances, negative inside."),
    ParmSpec("Center", ParmKind.vector, 0.0, -100000.0, 100000.0, 3, "", "The box's center."),
    ParmSpec("Size", ParmKind.vector, 2.0, 0.000001, 100000.0, 3, "", "The box's width, height and depth."),
    ParmSpec("Voxel size", ParmKind.number, 0.05, 0.000001, 100000.0, 1, "", voxel_doc, 1.0),
    ParmSpec("Background", ParmKind.number, 0.0, -100000.0, 100000.0, 1, "", "The value everywhere outside the voxels.", 1.0),
    ParmSpec("Initial value", ParmKind.number, 0.0, -100000.0, 100000.0, 1, "", "The value every voxel starts with.", 1.0),
    ParmSpec("Dense", ParmKind.toggle, 1.0, 0.0, 1.0, 1, "", "Every voxel of the box active; off, the grid starts with none.")]

let volume_rows: TextRow[1] = [
    TextRow("Name", "The grid's name: empty is density for fog, surface for a level set. A grid of that name in the input is replaced.")]

func volume_verb() -> SetVerb:
    return SetVerb("Volume", "Volumes", "A grid of voxels over a box, by name, to fill with a Voxels Code node", 1, false, false, volume_parms, cook_volume, volume_rows)

## The grid joins the input's volume, replacing a grid of its name (the Name
## row: "density" for fog, "surface" for a level set when empty).
func cook_volume(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let p = input.parms
    let level_set = p.at(0) != 0.0
    var name = input.text(0)
    if name.length == 0: name = "surface" if level_set else "density"
    let center = Vector3(p.at(1), p.at(2), p.at(3))
    let half = Vector3(p.at(4) * 0.5, p.at(5) * 0.5, p.at(6) * 0.5)
    let grid = try box_grid(name, GridClass.level_set if level_set else GridClass.fog, center.subtract(half), center.add(half), p.at(7), (f32)p.at(8), (f32)p.at(9), p.at(10) != 0.0)
    try with_added_grid(input, grid, output)

## The input set with `grid` (taken) added to its volume, in place of a grid of its name.
func with_added_grid(input: const SetVerbInput*, grid: SparseGrid*, output: SetVerbOutput*) -> !:
    let volume = new_volume() catch failure:
        release_grid(grid)
        error(failure.code, failure.message)
    var others: usize = 0
    if let existing = set_volume(input.set): others = existing.grid_count()
    var placed = false
    for at in 0..<others:
        let existing = set_volume(input.set) else break
        let other = existing.grid(at)
        let taken = grid if other.name() == grid.name() else share_grid((SparseGrid*)other)
        if taken == grid: placed = true
        add_grid(volume, taken) catch failure:
            if not placed: release_grid(grid)
            release_volume(volume)
            error(failure.code, failure.message)
    if not placed:
        add_grid(volume, grid) catch failure:
            release_volume(volume)
            error(failure.code, failure.message)
    let storage = input.set.storage() catch failure:
        release_volume(volume)
        error(failure.code, failure.message)
    storage.put(volume_type(), (void*)volume) catch failure:
        dispose_set(storage)
        error(failure.code, failure.message)
    output.set = storage

# mark: Volume Visualization

## A flame's colors along the emission range: dark red, deep orange, orange,
## then pale yellow (luce-std ramp numbers, linear between points).
let flame_ramp: str = "1,3,4,0,0.2,0.01,0,1,0.35,1,0.18,0.01,1,0.7,1,0.55,0.08,1,1,1,0.85,0.4,1"

let look_rows: TextRow[5] = [
    TextRow("Group", "The grids the look goes on, by name: names and globs apart by spaces (smoke*), #2 the third grid. Empty: every grid."),
    TextRow("Density field", "The grid whose values show as the density, as Houdini's density field; it is not drawn as smoke itself. Empty: each grid shows its own."),
    TextRow("Emission field", "The grid whose values emit light (heat, temperature); it is not drawn as smoke itself. Empty: no emission."),
    TextRow("Emission color ramp", "With Emission ramp on, the emitted color along the emission range: its left end at Emission min, its right at Emission max.", true, flame_ramp),
    TextRow("Emission color field", "The grid whose values pick the emitted color along the emission range (temperature, while the emission field gives the strength); it is not drawn as smoke itself. Empty: the emission field picks it.")]

let look_parms: ParmSpec[9] = [
    ParmSpec("Density scale", ParmKind.number, 1.0, 0.0, 1000000.0, 1, "", "Multiplies every density: how thick the smoke looks.", 10.0),
    ParmSpec("Smoke color", ParmKind.vector, 1.0, 0.0, 1.0, 3, "", "The color light scatters off the smoke with."),
    ParmSpec("Shadow scale", ParmKind.number, 1.0, 0.0, 100.0, 1, "", "Multiplies the smoke's shadowing of itself: 0 lit throughout.", 4.0),
    ParmSpec("Emission scale", ParmKind.number, 0.0, 0.0, 1000000.0, 1, "", "Light emitted per unit at an emission field value of 1; where the field is 0 or below, none.", 10.0),
    ParmSpec("Emission color", ParmKind.vector, 1.0, 0.0, 1.0, 3, "", "The color of the emitted light, without the ramp."),
    ParmSpec("Emission ramp", ParmKind.toggle, 0.0, 0.0, 1.0, 1, "", "Color the emission by the emission color ramp along the emission range (Houdini's Emission Color Ramp); off, the emission color throughout."),
    ParmSpec("Emission min", ParmKind.number, 0.0, -1000000.0, 1000000.0, 1, "", "The value at the ramp's left end (of the emission color field, else the emission field); values below it take that end.", 1.0),
    ParmSpec("Emission max", ParmKind.number, 1.0, -1000000.0, 1000000.0, 1, "", "The value at the ramp's right end; values above it take that end.", 1.0),
    ParmSpec("Step", ParmKind.number, 1.0, 0.25, 8.0, 1, "", "The viewport's ray-marching step, in voxels: smaller is finer and slower.")]

func volume_visualization_verb() -> SetVerb:
    return SetVerb("Volume Visualization", "Volumes", "How the viewport draws fog grids: density, smoke color, shadows, emission and its color ramp", 1, false, false, look_parms, cook_visualization, look_rows)

## The input with the look on the grids of the Group row, as Houdini's volvis_*
## primitive attributes: each such grid becomes one sharing its voxels with the
## new look; the others are shared as they are.
func cook_visualization(input: const SetVerbInput*, output: SetVerbOutput*) -> !:
    let p = input.parms
    var look = VolumeLook(density = p.at(0), smoke = Vector3(p.at(1), p.at(2), p.at(3)), shadow = p.at(4), emission = p.at(5),
                          emission_color = Vector3(p.at(6), p.at(7), p.at(8)), emission_low = p.at(10), emission_high = p.at(11), step = p.at(12))
    try look.set_density_field(input.text(1))
    try look.set_emission_field(input.text(2))
    try look.set_emission_color_field(input.text(4))
    if p.at(9) != 0.0:
        var numbers = try ramp_numbers(input.text(3) if input.text(3).length > 0 else flame_ramp)
        defer numbers.close()
        try look.set_emission_ramp(numbers.view())
    if set_volume(input.set) == none:
        output.warning = "The input has no volume; the look waits for one"
        return
    let source = set_volume(input.set) else return
    let volume = try new_volume()
    errdefer release_volume(volume)
    var styled: usize = 0
    for at in 0..<source.grid_count():
        let grid = source.grid(at)
        if grid_in_group(input.text(0), grid, at):
            try add_grid(volume, try restyled(grid, &look))
            styled += 1
        else:
            try add_grid(volume, share_grid((SparseGrid*)grid))
    let storage = try input.set.storage()
    errdefer dispose_set(storage)
    try storage.put(volume_type(), (void*)volume)
    output.set = storage
    if styled == 0: output.warning = "The group names no grid of the input"

## A ramp row's text, numbers comma apart, as numbers.
func ramp_numbers(text: str) -> Growing[f64]!:
    var numbers = Growing[f64]()
    errdefer numbers.close()
    var start: usize = 0
    while start <= text.length:
        var end = start
        while end < text.length and text.bytes[end] != ',': end += 1
        let piece = strings.trim((str)text.bytes[start..<end])
        if piece.length > 0:
            let value = strings.parse_f64(piece) catch failure:
                error(errors.invalid, "a ramp's text is numbers apart by commas")
            try numbers.push(value)
        start = end + 1
    return numbers