Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.8

0.11.8 / src / blend_ops.luc

## Surfacing Stage 6's blends between surfaces on a CAD result (docs/
## research/SURFACING-ALIAS-PLASTICITY.md §4.1, §6.7, §7.1), shared by
## Edit CAD's steps (edit_cad_build.luc) and the CAD network's nodes
## (their tool_<name>.luc), each luce-cad's CadSurfaceBlend:
##   Blend Surface (Alias's Freeform Blend, and Profile Blend with profile
##     curves): between two sides, each a chain of edges, curves or
##     isoparms, G0 to G3 each with its Shape, Proportional Crown, Flow
##     Control and each side's range;
##   Surface Fillet (Alias's; Parasolid's face-face blend): a rolling ball
##     between two face sets, G0 Chamfer, G1 Circular, G2 or G3 Curvature,
##     by radius or chord, each set's side flipped, the faces trimmed back
##     to its contacts (Automatic), carrying them (Curves on surface) or
##     not (Off);
##   Tube (Alias's Tubular Offset): a circular tube along a curve, its
##     axis moved off it along the face's normal and across.
##   Fill (Stage 7, fill_ops.luc): the variational fill of a hole.
##   Bridge Fillet (Stage 8; Alias's, Parasolid's three-face blend): a
##     circular blend tangent to two side sets and a center set, its radius
##     whatever touches all three, the sides trimmed back and the center
##     consumed (Automatic);
##   Corner (Stage 8; Alias's Ball Corner and Corner Blend): the hole where
##     three or four blends meet, found from the blends picked, filled as
##     Fill fills it, G1 (Corner blend: four sides as one untrimmed patch).
## They take picks as the builders do (build_ops.luc's words, temporary
## isoparms by a double-click; the fillet's sets as faces), wait while they
## need more, publish their picks' lines and Blend Surface's side labels,
## and Blend Surface and Surface Fillet run Alias's Continuity Check.
from luce_cad.surfacing import CadSurfaceBlend, CadSurfaceEdit, CadSurfaceFill
from luce_cad.modeling import CadModeling
from luce_3d.graphics import Vector3
from geometry_data import GeometryData
from parameter_rows import Parameter, number, toggle, menu
import build_ops
import fill_ops
from luce_ui import ui
from luce_cad.model import CadTolerances

pub let blend_verb = "Blend Surface"
pub let fillet_verb = "Surface Fillet"
pub let tube_verb = "Tube"

pub let fill_verb = "Fill Surface"
pub let bridge_verb = "Bridge Fillet"
pub let corner_verb = "Corner"

pub func verbs() -> list[str]:
    return [blend_verb, fillet_verb, tube_verb, fill_verb, bridge_verb, corner_verb]

## The texts (build_ops.luc's curves and rails, then one more): the first
## side (Blend Surface), the first set (Surface Fillet) or the curve
## (Tube); the second side or set; the profiles.
pub let first_text = 0
pub let second_text = 1
pub let profiles_text = 2

# -- Slots.

## Blend Surface: each side's continuity and Shape, the shapes locked,
## Proportional Crown, Flow Control, Modify Range and the ranges (side 1
## from and to, side 2 from and to), the labels and the check.
pub let side_slot = 0
pub let shape_slot = 2
pub let lock_slot = 4
pub let crown_slot = 5
pub let flow_slot = 6
pub let range_on_slot = 7
pub let range_slot = 8
pub let blend_labels_slot = 12
pub let blend_check_slot = 13
## Blend Surface's Interior Edge Align and Explicit Control (16 to 20).
pub let interior_slot = 14
pub let blend_explicit_slot = 16

## Surface Fillet: the section, Radius or Chord, the size, each set's side
## flipped, the trim, the Form Factor and the check.
pub let section_slot = 0
pub let construction_slot = 1
pub let size_slot = 2
pub let flip_slot = 3
pub let trim_slot = 5
pub let form_slot = 6
pub let fillet_check_slot = 7
## Surface Fillet's Bias Factor, Knee Ratio, Curvature, and Variable
## (on, the middle size and the end size).
pub let bias_slot = 8
pub let knee_slot = 9
pub let curvature_slot = 10
pub let variable_slot = 11

## Bridge Fillet: the first radius tried, each side set flipped, the trim
## and the check.
pub let bridge_size_slot = 0
pub let bridge_flip_slot = 1
pub let bridge_trim_slot = 3
pub let bridge_check_slot = 4
## Corner: its type (Ball corner, Corner blend), the continuity, the check
## and the conflicts shown.
pub let corner_type_slot = 0
pub let corner_continuity_slot = 1
pub let corner_check_slot = 2
pub let corner_conflicts_slot = 3
## Corner's Center adjust (Alias's Ball Corner): the patch's middle moved
## along its normal by this share of the hole's size (0: as Fill makes it).
pub let corner_center_slot = 4

## Tube: the radius, the normal and tangent offsets, Flip.
pub let radius_slot = 0
pub let normal_slot = 1
pub let tangent_slot = 2
pub let tube_flip_slot = 3
## Tube's variable radius (on, middle, end) and trim.
pub let tube_variable_slot = 4
pub let tube_trim_slot = 7

# -- Rows.

## The rows of `verb` (the node's and the step's alike).
pub func rows(verb: str) -> list[Parameter]:
    if verb == fill_verb:
        return fill_ops.rows()
    if verb == blend_verb:
        let result: list[Parameter] = []
        for k in 0..<2:
            result.append(menu(f"Side {k + 1} continuity", side_slot + k, build_ops.order_cycle, 1.0, f"Alias's Side {k + 1}: G0 (position), G1 (tangent), G2 (curvature) or G3 to the surface side {k + 1} lies on; a free curve's side is G0. Its label on the model cycles it."))
        for k in 0..<2:
            let shape = number(f"Side {k + 1} shape", shape_slot + k, 1.0, 0.05, 5.0, 0.05, f"Alias's Side {k + 1} Shape: above 1 the blend hugs the corner (longer tangents), below 1 it is rounder.")
            if k == 1:
                shape.hide_when = "{ lock_shapes != 0 }"
            result.append(shape)
        result.append(toggle("Lock shapes", lock_slot, 1.0, "Alias's Lock Shape Controls: side 2's Shape follows side 1's."))
        result.append(number("Proportional crown", crown_slot, 0.0, -0.25, 0.25, 0.01, "Alias's Proportional Crown: the middle raised (or lowered) by this much of the gap between the sides, along the normal of the gap and side 1."))
        result.append(menu("Flow control", flow_slot, "Connect ends|Free|Edge align", 0.0, "Alias's Flow Control: the sides' ends joined to each other (Connect ends), each section square to side 1 (Free), or the sides matched by their own parameters so the isoparms leave them as their surfaces' do (Edge align)."))
        result.append(toggle("Modify range", range_on_slot, 0.0, "Alias's Modify Range: blend only a stretch of each side."))
        let ends = [("Side 1 from", 0.0), ("Side 1 to", 1.0), ("Side 2 from", 0.0), ("Side 2 to", 1.0)]
        for k in 0..<4:
            let (label, initial) = ends[k]
            let row = number(label, range_slot + k, initial, 0.0, 1.0, 0.01, "The stretch's end, a fraction of the side's length.")
            row.hide_when = "{ modify_range == 0 }"
            result.append(row)
        result.extend([toggle("Boundary labels", blend_labels_slot, 1.0, "Each side's continuity at its middle; a click cycles it."),
                       toggle("Continuity check", blend_check_slot, 1.0, "Alias's Continuity Check: the blend's edges against the surfaces its sides lie on, drawn as the Check node's."),
                       toggle("Interior edge align", interior_slot, 0.0, "Alias's Interior Edge Align (Profile Blend): the blend's isoparms run along each profile from side to side (side 2 matched through the profiles' ends).")])
        result.extend(build_ops.explicit_rows(blend_explicit_slot))
        return result
    if verb == fillet_verb:
        let size = number("Radius", size_slot, 1.0, 0.000001, 100000.0, 0.1, "The rolling ball's radius (Chord: the distance between the contacts).", soft = 20.0)
        size.length = true
        let form = number("Form factor", form_slot, 1.0, 0.1, 2.0, 0.05, "Alias's Form Factor (G2 and G3): the section's arms, below 1 sharper, above rounder.")
        form.hide_when = "{ section < 2 } { section == 5 }"
        let bias = number("Bias factor", bias_slot, 0.0, -1.0, 1.0, 0.05, "Alias's Bias Factor: the peak radius pushed toward set 1 (negative) or set 2 (positive).")
        bias.hide_when = "{ section != 4 }"
        let knee = number("Knee ratio", knee_slot, 0.0, 0.0, 10.0, 0.05, "Alias's Knee Ratio (Lead): the peak radius over the tangent offset (0: the ball's circle).")
        knee.hide_when = "{ section != 5 }"
        let curvature = menu("Curvature", curvature_slot, "Both|Side 1|Side 2|None", 0.0, "Alias's Curvature: the sets whose curvature the section matches (G2, G3, Bias); the other it meets tangent only.")
        curvature.hide_when = "{ section < 2 } { section == 5 }"
        let middle = number("Middle size", variable_slot + 1, 0.0, 0.0, 100000.0, 0.1, "The radius (or chord) halfway along (0: none, straight from start to end).", soft = 20.0)
        middle.length = true
        middle.hide_when = "{ variable == 0 }"
        let last = number("End size", variable_slot + 2, 1.0, 0.000001, 100000.0, 0.1, "The radius (or chord) at the end.", soft = 20.0)
        last.length = true
        last.hide_when = "{ variable == 0 }"
        return [menu("Section", section_slot, "G0 chamfer|G1 circular|G2 curvature|G3 curvature|Bias|Lead", 1.0, "Alias's Section Type: a chamfer between the contacts, the ball's circle, a curvature-continuous section (G2, or G3 also matching the curvature's rate), Bias (the peak pushed toward a set) or Lead (a conic by its Knee Ratio)."),
                menu("Construction", construction_slot, "Radius|Chord", 0.0, "Alias's Construction: the ball's radius, or the chord between the contacts held constant."),
                size,
                toggle("Flip set 1", flip_slot, 0.0, "The ball rolls on the other side of the first set's faces (Alias's arrow)."),
                toggle("Flip set 2", flip_slot + 1, 0.0, "The other side of the second set's faces."),
                menu("Trim", trim_slot, "Automatic|Curves on surface|Off", 0.0, "Alias's Trim Type: the faces trimmed back to the contacts, the contacts left on them as curves, or the faces as they are."),
                form, bias, knee, curvature,
                toggle("Variable", variable_slot, 0.0, "Alias's Variable Fillets: the radius (or chord) from its size at the start through a middle size to an end size, eased between."),
                middle, last,
                toggle("Continuity check", fillet_check_slot, 1.0, "The fillet's edges against the faces it rolls on, drawn as the Check node's.")]
    if verb == tube_verb:
        let radius = number("Radius", radius_slot, 0.25, 0.000001, 100000.0, 0.05, "The tube's radius.", soft = 10.0)
        radius.length = true
        let normal = number("Normal offset", normal_slot, 0.0, -100000.0, 100000.0, 0.05, "Alias's Normal offset: the tube's axis moved off the curve along the face's normal (off a face: the curve's frame's up).", soft = 10.0)
        normal.length = true
        let across = number("Tangent offset", tangent_slot, 0.0, -100000.0, 100000.0, 0.05, "Alias's Tangent offset: the axis moved across the curve, in the face.", soft = 10.0)
        across.length = true
        let middle = number("Middle radius", tube_variable_slot + 1, 0.0, 0.0, 100000.0, 0.05, "The radius halfway along (0: none).", soft = 10.0)
        middle.length = true
        middle.hide_when = "{ variable == 0 }"
        let last = number("End radius", tube_variable_slot + 2, 0.25, 0.000001, 100000.0, 0.05, "The radius at the curve's end.", soft = 10.0)
        last.length = true
        last.hide_when = "{ variable == 0 }"
        return [radius, normal, across, toggle("Flip", tube_flip_slot, 0.0, "Alias's Flip: the normal offset the other way (a groove for a bump)."),
                toggle("Variable", tube_variable_slot, 0.0, "Alias's variable radius: from the radius at the start through a middle radius to an end radius, eased between."), middle, last,
                menu("Trim", tube_trim_slot, "Off|Curves on surface|Inside", 0.0, "Alias's Tubular Offset trims (a curve on a face): where the tube meets the face as curves on it, or the face's strip under the tube taken away.")]
    if verb == bridge_verb:
        let size = number("Radius estimate", bridge_size_slot, 0.5, 0.000001, 100000.0, 0.1, "Where the ball starts: the bridge's radius is the one touching all three sets, found from this.", soft = 20.0)
        size.length = true
        return [size,
                toggle("Flip set 1", bridge_flip_slot, 0.0, "The ball rolls on the other side of the first set's faces."),
                toggle("Flip set 2", bridge_flip_slot + 1, 0.0, "The other side of the second set's faces."),
                menu("Trim", bridge_trim_slot, "Automatic|Curves on surface|Off", 0.0, "Automatic: the side sets trimmed back to the contacts and the center set consumed (Parasolid's three-face blend); Curves on surface: the contacts left as curves; Off: the faces as they are."),
                toggle("Continuity check", bridge_check_slot, 1.0, "The bridge's edges against the side sets, drawn as the Check node's.")]
    if verb == corner_verb:
        return [menu("Type", corner_type_slot, "Ball corner|Corner blend", 0.0, "Alias's Ball Corner (one trimmed patch over the corner's hole) or Corner Blend (four sides as one untrimmed patch, Quad), each G1 to the blends meeting there."),
                menu("Continuity", corner_continuity_slot, "Type's|G0|G1|G2", 0.0, "The patch's continuity to every blend (Type's: G1)."),
                toggle("Continuity check", corner_check_slot, 1.0, "The patch's edges against the blends, drawn as the Check node's."),
                toggle("Show conflicts", corner_conflicts_slot, 1.0, "Where the blends' demands disagree, drawn red (Fill's)."),
                number("Center adjust", corner_center_slot, 0.0, -1.0, 1.0, 0.05, "Alias's Center Adjust: the patch's middle moved out (more) or in (less) along its normal, a share of the hole's size; 0 as the fill makes it.", slider = true)]
    let none_shown: list[Parameter] = []
    return none_shown

## What `verb` waits for ("" when it has what it needs).
pub func waits_for(verb: str, t: list[str]) -> str:
    if verb == fill_verb:
        return fill_ops.waits_for(t)
    let first = build_ops.items(t[first_text]).length
    let second = build_ops.items(t[second_text]).length
    if verb == blend_verb:
        if first == 0:
            return "Pick the first side: edges, curves or isoparms (a chain in order), then Enter"
        if second == 0:
            return "Pick the second side, then Enter"
        return ""
    if verb == fillet_verb:
        if first == 0:
            return "Pick the first set's faces, then Enter"
        if second == 0:
            return "Pick the second set's faces, then Enter"
        return ""
    if verb == bridge_verb:
        if first == 0:
            return "Pick the first side set's faces, then Enter"
        if second == 0:
            return "Pick the second side set's faces, then Enter"
        if build_ops.items(t[profiles_text] if t.length > profiles_text else "").length == 0:
            return "Pick the center set's faces (the wall the bridge consumes), then Enter"
        return ""
    if verb == corner_verb and first == 0:
        return "Pick the blends (faces) meeting at the corner, three or four, then Enter"
    if verb == tube_verb and first == 0:
        return "Pick the curve the tube runs along (a curve, an edge, or double-click a surface for an isoparm)"
    return ""

## A new blend's values: its rows' starting values.
pub func starting(verb: str) -> list[float]:
    return build_ops.starting_of(rows(verb))

## Whether `verb` takes a second list (its prompt goes on to it at Enter;
## Fill's guides may be none).
pub func two_lists(verb: str) -> bool:
    return verb == blend_verb or verb == fillet_verb or verb == fill_verb or verb == bridge_verb

## Whether `verb` takes faces (the Faces level) rather than curves.
pub func takes_faces(verb: str) -> bool:
    return verb == fillet_verb or verb == bridge_verb or verb == corner_verb

## Picks as face words ("face <name>": a node keeps names alone).
func face_words(picks: list[str]) -> list[str]:
    let found: list[str] = []
    for w in picks:
        found.append(w if w.starts_with("face ") else "face " + w)
    return found

## The face names of face words ("face <name>").
func face_names(words: list[str]) -> str:
    let names: list[str] = []
    for w in words:
        let name = w[5..].trim() if w.starts_with("face ") else w.trim()
        if name != "" and not (name in names):
            names.append(name)
    return names.join(";")

## A point in the middle of face `name` of `data`, or none.
func face_middle(data: GeometryData, name: str) -> Vector3?!:
    for model in data.models():
        for f in 0..<model.face_count():
            if model.face_name(f) == name:
                let found = CadModeling.face_point(model, name)
                return found.point if found.found else none
    return none

# -- The cook.

## Blend `verb` on `data` by values `v` and texts `t`; `name` names the
## sheet it makes.
pub func build(verb: str, data: GeometryData, v: list[float], t: list[str], name: str, tolerances: CadTolerances) -> GeometryData!:
    if verb == fill_verb:
        return fill_ops.build(data, v, t, name, tolerances)
    let texts = [t[first_text], t[second_text], t[profiles_text] if t.length > profiles_text else ""]
    let first = build_ops.items(texts[first_text])
    let second = build_ops.items(texts[second_text])
    let waiting = waits_for(verb, texts)
    if waiting != "":
        return labelled(data.passed(waiting), data, verb, v, first, second)
    var made: CadSurfaceEdit? = none
    var report = ""
    if verb == blend_verb:
        let side1 = build_ops.resolve_isoparms(data, first, false).join("+")
        let side2 = build_ops.resolve_isoparms(data, second, false).join("+")
        let profiles = build_ops.resolve_isoparms(data, build_ops.items(texts[profiles_text]), false).join(";")
        let shape2 = v[shape_slot] if v[lock_slot] != 0.0 else v[shape_slot + 1]
        let ranges = [0.0, 1.0, 0.0, 1.0]
        if v[range_on_slot] != 0.0:
            for k in 0..<4:
                ranges[k] = v[range_slot + k]
        let e = blend_explicit_slot
        made = CadSurfaceBlend.blend(data.geometry, side1, side2, continuity = [int(v[side_slot]), int(v[side_slot + 1])], shape = [v[shape_slot], shape2],
                                     crown = v[crown_slot], flow = int(v[flow_slot]), range = ranges, profiles = profiles, name = name, interior = v[interior_slot] != 0.0,
                                     explicit = v[e] != 0.0, degree_u = int(v[e + 1]), spans_u = int(v[e + 2]), degree_v = int(v[e + 3]), spans_v = int(v[e + 4]), tolerances = tolerances)
        report = f"G{int(v[side_slot])} to G{int(v[side_slot + 1])}" + (f" through {build_ops.items(texts[profiles_text]).length} profiles" if profiles != "" else "")
    elif verb == fillet_verb:
        let sections = ["G0 chamfer", "G1 circular", "G2 curvature", "G3 curvature", "Bias", "Lead"]
        made = CadSurfaceBlend.fillet(data.geometry, face_names(first), face_names(second), v[size_slot], section = int(v[section_slot]), chordal = int(v[construction_slot]) == 1,
                                      flips = [v[flip_slot] != 0.0, v[flip_slot + 1] != 0.0], trim = int(v[trim_slot]), form = v[form_slot], name = name,
                                      bias = v[bias_slot], knee = v[knee_slot], curvature = int(v[curvature_slot]), variable = law(v, size_slot, variable_slot), tolerances = tolerances)
        report = f"{sections[int(v[section_slot])]} {"chord" if int(v[construction_slot]) == 1 else "radius"} {v[size_slot]}"
    elif verb == tube_verb:
        let along = build_ops.resolve_isoparms(data, first, false)
        made = CadSurfaceBlend.tube(data.geometry, along[0], v[radius_slot], tangent_offset = v[tangent_slot], normal_offset = v[normal_slot], flip = v[tube_flip_slot] != 0.0, name = name,
                                    variable = law(v, radius_slot, tube_variable_slot), trim = int(v[tube_trim_slot]), tolerances = tolerances)
        report = f"radius {v[radius_slot]}"
    elif verb == bridge_verb:
        let center = build_ops.items(texts[profiles_text])
        made = CadSurfaceBlend.bridge(data.geometry, face_names(first), face_names(second), face_names(center), v[bridge_size_slot],
                                      flips = [v[bridge_flip_slot] != 0.0, v[bridge_flip_slot + 1] != 0.0], trim = int(v[bridge_trim_slot]), name = name, tolerances = tolerances)
        report = f"bridge of {first.length + second.length + center.length} faces"
    elif verb == corner_verb:
        return corner(data, v, first, name, tolerances)
    let edit = made else error(ui.invalid, f"{verb} is not a blend")
    let result = GeometryData(geometry = edit.geometry())
    result.report = report
    if verb == blend_verb and v[blend_check_slot] != 0.0:
        var level = 0
        for k in 0..<2:
            if int(v[side_slot + k]) > level:
                level = int(v[side_slot + k])
        build_ops.checked(result, name, first + second, level if level > 0 else 1)
    if verb == bridge_verb and v[bridge_check_slot] != 0.0 and int(v[bridge_trim_slot]) == 0:
        build_ops.checked(result, name, first + second, 1)
    if verb == fillet_verb and v[fillet_check_slot] != 0.0 and int(v[trim_slot]) == 0:
        let orders = [0, 1, 2, 3, 3, 1]
        build_ops.checked(result, name, first + second, orders[int(v[section_slot])] if int(v[section_slot]) > 0 else 1)
    return labelled(result, data, verb, v, first, second)

## Corner on `data` by values `v` from the blends `picked` (face words):
## the hole whose open edges those faces bound the most of (each open edge
## of a picked face tried as Fill's one edge of a hole), filled by Fill
## at the continuity asked (G1 by default) on every side; Center adjust
## moves its middle along its normal (Alias's Ball Corner).
func corner(data: GeometryData, v: list[float], picked: list[str], name: str, tolerances: CadTolerances) -> GeometryData!:
    let names = face_names(picked).split(";")
    var best = ""
    var best_count = 0
    for model in data.models():
        for f in 0..<model.face_count():
            if not (model.face_name(f) in names):
                continue
            for use in 0..<model.face_edge_count(f):
                let p = model.face_edge_point(f, use, 0.5)
                let loop = CadSurfaceFill.hole(data.geometry, f"edge {model.face_name(f)} {p.x} {p.y} {p.z}") catch failure:
                    continue
                var count = 0
                for n in names:
                    if loop.contains(f"edge {n} "):
                        count += 1
                if count > best_count:
                    best = loop
                    best_count = count
    if best_count < 2:
        error(ui.invalid, "Corner: the blends picked bound no hole together (pick the faces round the corner's gap)")
    let loop_words = best.split(";")
    let code = int(v[corner_continuity_slot])
    let ball = int(v[corner_type_slot]) == 0
    let continuity = 2 if code == 0 else code
    let values = fill_ops.starting_values()
    values[fill_ops.continuity_slot] = float(continuity)
    values[fill_ops.quad_slot] = 1.0 if not ball and loop_words.length == 4 else 0.0
    values[fill_ops.check_slot] = v[corner_check_slot]
    values[fill_ops.conflicts_slot] = v[corner_conflicts_slot]
    values[fill_ops.labels_slot] = 0.0
    var made = fill_ops.build(data, values, [best, ""], name, tolerances)
    let adjust = v[corner_center_slot] if corner_center_slot < v.length else 0.0
    if adjust != 0.0:
        # Center adjust: the fill made again through its middle moved along
        # its normal (an interior point, Fill's), a share of the hole's size
        # (its boundary points' mean distance from that middle).
        let models = made.models()
        let sheet = models[models.length - 1]
        let at = CadModeling.face_point(sheet, sheet.face_name(0))
        var reach = 0.0
        for word in loop_words:
            let parts = word.trim().split(" ")
            if parts.length >= 5:
                reach += Vector3(float(parts[parts.length - 3]), float(parts[parts.length - 2]), float(parts[parts.length - 1])).subtract(at.point).length()
        reach = reach / float(loop_words.length)
        let moved = at.point.add(at.normal.multiply_scalar(adjust * reach))
        made = fill_ops.build(data, values, [best, f"isoparm_at {moved.x} {moved.y} {moved.z}"], name, tolerances)
    made.report = ("Ball corner" if ball else "Corner blend") + f" of {loop_words.length} sides; " + made.report
    return made

## A variable size's law from values `v`: (fraction, size) pairs, the
## start the row at `size`, the middle (when more than 0) and end the rows
## after `at` (its toggle); a constant when off.
func law(v: list[float], size: int, at: int) -> list[float]:
    if v[at] == 0.0:
        return [0.0, 0.0]
    let found = [0.0, v[size]]
    if v[at + 1] > 0.0:
        found.extend([0.5, v[at + 1]])
    found.extend([1.0, v[at + 2]])
    return found

## `result` with Blend Surface's side labels (its continuity rows),
## Surface Fillet's set labels (a click flips the side the ball rolls on:
## Alias's arrows) and every blend's picks' lines as state lines.
func labelled(result: GeometryData, data: GeometryData, verb: str, v: list[float], first: list[str], second: list[str]) -> GeometryData!:
    let lines: list[str] = []
    if verb == blend_verb and v[blend_labels_slot] != 0.0:
        for (k, side) in [(0, first), (1, second)]:
            if side.length > 0 and not side[0].starts_with("isoparm_at"):
                lines.append(build_ops.label_line(build_ops.middle_of(data, side[0]), side_slot + k, 4, build_ops.order_cycle.split("|")[int(v[side_slot + k])]))
    if verb == fillet_verb:
        for (k, faces) in [(0, first), (1, second)]:
            if faces.length == 0:
                continue
            let at = face_middle(data, face_names([faces[0]]))
            if let p = at:
                lines.append(build_ops.label_line(p, flip_slot + k, 2, f"Set {k + 1}" + (" flipped" if v[flip_slot + k] != 0.0 else "")))
    lines.extend(build_ops.pick_lines(data, face_words(first + second) if takes_faces(verb) else first + second))
    if lines.length > 0:
        result.sketch_state = (result.sketch_state + "\n" if result.sketch_state != "" else "") + lines.join("\n")
    return result