dymokomi/luced-3d
Source of release 0.11.6
## Curve: a free curve added to the input, through typed points or with
## them as control points, from a body's edge (Duplicate Curve, kept by the
## edge's reference), a face's isoparm, or on a face (points in its chart
## coordinates). A node of a CAD network (cad_curve_nodes.luc).
from tool_record import Tool, ToolEntry, Pick, Invocation
from geometry_data import GeometryData
from edit_types import edge_level, face_level
import pick_kinds
import cad_curve_nodes
import cad_cook
pub func entry() -> ToolEntry:
return ToolEntry(cad_curve_nodes.curve_kind, cad_curve_nodes.curve_kind, "pen-tool", "Curves", [cad_cook.context], [], made)
func made() -> Tool:
return entry().tool("Create", "Curves", "A free curve: through points, by control points, from an edge, an isoparm, or on a face", picks(),
cad_curve_nodes.fields(cad_curve_nodes.curve_kind), cook, waits = waits)
## The edge it is (From edge), or the face it lies on (Isoparm, On face).
func picks() -> list[Pick]:
return [Pick("Edge", [edge_level], kind = pick_kinds.edge, slot = cad_curve_nodes.source_text, hide_when = "{ type != 2 }", needed = from_edge,
doc = "From edge: the body's edge the curve is, kept by its reference."),
Pick("Face", [face_level], kind = pick_kinds.face, slot = cad_curve_nodes.source_text, hide_when = "{ type < 3 }", needed = on_face,
doc = "Isoparm and On face: the face, kept by its name.")]
func from_edge(values: list[float], texts: list[str], wired: bool) -> bool:
return int(values[cad_curve_nodes.type_slot]) == cad_curve_nodes.edge_type
func on_face(values: list[float], texts: list[str], wired: bool) -> bool:
return int(values[cad_curve_nodes.type_slot]) >= cad_curve_nodes.isoparm_type
func waits(values: list[float], texts: list[str], wired: bool) -> str:
return cad_curve_nodes.waits_for(cad_curve_nodes.curve_kind, values, texts)
func cook(call: Invocation, data: GeometryData, tag: str) -> GeometryData!:
return cad_curve_nodes.evaluate(call.verb, call.numbers, call.texts, data, tag)