Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.6

0.11.6 / src / tool_blend_curve.luc

## Blend Curve (Alias's): a curve between two curves or edges, at the ends
## nearest each other, G0 to G4 at each end (G4: blend curves only), degree
## 5 on the spans the ends need; its tangent and curvature handles drag in
## the viewport (edit_cad_curves.luc). The node keeps its ends by name (a
## blend on edges follows them as the body changes); an Edit CAD step
## blends the two curves picked, or waits for them (a double-click on a
## surface: a temporary isoparm).
from tool_record import Tool, ToolEntry, Pick, Invocation
from geometry_data import GeometryData
from parameter_rows import Parameter
from edit_types import curve_level, edge_level
import parameter_rows
import pick_kinds
import edit_cad_curves
import cad_curve_nodes
import cad_cook

pub func entry() -> ToolEntry:
    return ToolEntry(edit_cad_curves.blend_verb, edit_cad_curves.blend_verb, "blend-curve", "Curves", [cad_cook.context], [cad_cook.edit_kind], made)

func made() -> Tool:
    return entry().tool("Modify", "Curves", "A curve blending two curves or edges, G0 to G4 at each end", picks(), rows(), cook,
                        numbers = edit_cad_curves.blend_numbers(), handles = true, waits = waits)

## A step's two curves (the selection when it is two, else their words as
## they are clicked); a node's ends.
func picks() -> list[Pick]:
    return [Pick("Curves", [curve_level], kind = pick_kinds.words, slot = pick_kinds.nowhere, step = 0, most = 2, grouped = true),
            Pick("From curve", [curve_level, edge_level], kind = pick_kinds.curve_or_edge, slot = 0, step = pick_kinds.nowhere,
                 doc = "The curve or edge the blend leaves, at its end nearest the other (an edge when the input has no curves)."),
            Pick("To curve", [curve_level, edge_level], kind = pick_kinds.curve_or_edge, slot = 1, step = pick_kinds.nowhere, doc = "The curve or edge the blend meets.")]

func waits(values: list[float], texts: list[str], wired: bool) -> str:
    return cad_curve_nodes.waits_for(edit_cad_curves.blend_verb, values, texts)

func cook(call: Invocation, data: GeometryData, tag: str) -> GeometryData!:
    if call.node:
        return cad_curve_nodes.evaluate(call.verb, call.numbers, call.texts, data, tag)
    return edit_cad_curves.cook(call, data, tag)

func rows() -> list[Parameter]:
    return edit_cad_curves.blend_rows() + [parameter_rows.entry("Name", cad_curve_nodes.name_text, "The curve's name in the model (empty: Curve and a number).")]