dymokomi/luced-3d
Source of release 0.11.9
0.11.9 / src / tool_trim_convert.luc
## Trim Convert (Alias's): a trimmed face made an untrimmed surface of its
## own degrees and spans (surface_ops.luc). The node keeps its face by
## name; an Edit CAD step converts the one face picked.
from tool_record import Tool, ToolEntry, Pick, Invocation
from geometry_data import GeometryData
from parameter_rows import Parameter, whole, toggle
from edit_types import face_level, patch_level
import pick_kinds
import edit_cad_surfaces
import surface_ops
import cad_cook
from luce_ui import ui
pub func entry() -> ToolEntry:
return ToolEntry(edit_cad_surfaces.convert_verb, edit_cad_surfaces.convert_verb, "trim-convert", "Surfaces", [cad_cook.context], [cad_cook.edit_kind], made)
func made() -> Tool:
return entry().tool("Modify", "Surface Edit", "Make a trimmed face a surface of its own, untrimmed", [Pick("Face", [face_level, patch_level], kind = pick_kinds.face, slot = 0, doc = "The face, kept by its name.")],
rows(), cook, waits = waits)
func waits(values: list[float], texts: list[str], wired: bool) -> str:
return "Pick the face" if texts[0].trim() == "" else ""
func cook(call: Invocation, data: GeometryData, tag: str) -> GeometryData!:
var face = call.text(0).trim()
if call.node:
let waiting = waits(call.numbers, call.texts, false)
if waiting != "":
return data.passed(waiting)
else:
let faces = edit_cad_surfaces.step_faces(call, data)
if faces.length > 1:
error(ui.invalid, f"{call.verb} works on one face: pick one")
face = faces[0]
let v = call.numbers
return surface_ops.convert(data, face, int(v[edit_cad_surfaces.degree_u_slot]), int(v[edit_cad_surfaces.degree_v_slot]), int(v[edit_cad_surfaces.spans_u_slot]),
int(v[edit_cad_surfaces.spans_v_slot]), v[edit_cad_surfaces.swap_slot] != 0.0, v[edit_cad_surfaces.keep_slot] != 0.0)
func rows() -> list[Parameter]:
return [whole("Degree U", edit_cad_surfaces.degree_u_slot, 5.0, 1.0, 11.0, "The new surface's degree across its first pair of sides."),
whole("Degree V", edit_cad_surfaces.degree_v_slot, 5.0, 1.0, 11.0, "Its degree across the other pair."),
whole("Spans U", edit_cad_surfaces.spans_u_slot, 4.0, 1.0, 64.0, "Its spans along u."),
whole("Spans V", edit_cad_surfaces.spans_v_slot, 4.0, 1.0, 64.0, "Its spans along v."),
toggle("Switch U/V", edit_cad_surfaces.swap_slot, 0.0, "Exchange the new surface's u and v."),
toggle("Keep originals", edit_cad_surfaces.keep_slot, 0.0, "Keep the trimmed face as a body of its own beside the converted one.")]