dymokomi/luced-3d
Source of release 0.11.8
0.11.8 / tools / preview_surfacing.luc
## The captures of the surfacing plan's Stage 0, measuring
## (docs/research/SURFACING-ALIAS-PLASTICITY.md; preview_parity2.luc hands
## these scenes here):
## surf_check: a box's front top edge filleted 6 at G2, checked for G2:
## the fillet's contacts green with three ticks, the sharp edges red
## with one, combs on the fillet's end arcs, cross quills equal.
## surf_check_g1: the same fillet at G1, checked for G2: its contacts one
## order short (yellow, two ticks), the quills jumping from 0 to 1/r.
## surf_check_g3: a G3 fillet checked for G3, only its contacts picked
## (zebra shading shows it best: --mode 7).
## surf_combs: a cylinder and its rims' combs, uniform at 1/r.
## surf_deviation: the G2 filleted box against the box it was made from:
## green where they agree, blue where the fillet lies inside.
## surf_band: the G2 filleted box in Curvature (--mode 9) with a least
## radius of 8: the fillet's middle, tighter than 8, magenta.
## surf_draft: a frustum (radius 10 to 6) in Draft (--mode 10), pulled
## up with 3° asked for: its side (11.3°) and top green, its bottom red,
## and the shading menu open on Draft's rows.
## Stage 1, the CVs level (edit_cad_nets.luc), on an Edit CAD box whose top
## face was converted to a B-spline and rebuilt as 4 by 4 quintic spans:
## surf_cv_nuv: the middle CV dragged up in NUV with Rows falloff (two
## rows): the gizmo in the CV's frame, the hull's ghost under the
## moving net, the CV mode row lit on NUV and Rows.
## surf_cv_row: a hull row picked (a second click), the right-click menu
## open on it: the structure tools.
## surf_rebuild: Rebuild's tool bar (Explicit Control, multi-span
## quintic, G2 kept) and what it did.
## surf_insert: Insert Knot's tool bar, the new row of CVs.
## surf_convert: a cylinder's side converted (rational quadratic), its
## net at the CVs level.
## surf_insert_click: Insert Knot on the quintic top, the pointer over
## the surface: the green isoparm where a click puts the knot.
## Stage 2, curves (edit_cad_curves.luc, cad_curve_nodes.luc), beside an
## Edit CAD box: a CV curve, an EP curve and a curve on its top face.
## surf_curves: the three at the Curves level, two picked.
## surf_curve_menu: the right-click menu on the two: the curve tools.
## surf_blend: Blend Curve between them, G2 both ends, its tool bar.
## surf_blend_g4: the same at G4 both ends, at the CVs level: the
## blend's ten control points (five quintic spans).
## surf_curve_cvs: the curves' control points at the CVs level, the CV
## curve's last one picked with the gizmo.
## surf_blend_node: a CAD network's Blend Curve node between two of a
## box's top edges, its parameters.
## Stage 2's follow-ups:
## surf_blend_handles: the blend's handles close up: each end's tangent
## arrow and, at G2, its curvature arrow (drag to change them).
## surf_stretch: Stretch on the CV curve with a third handle mid-curve,
## pulled up: the handles on the curve.
## surf_isoparm: an isoparm picked by a double-click on a cylinder at the
## Curves level, selected.
## surf_curve_combs: a CAD network's Check node combing a curve.
## Stage 3, projection, trims and stitching (edit_cad_surfaces.luc,
## tool_<name>.luc), on an Edit CAD box with a curve above its top:
## surf_project: the curve projected onto the top (a curve on it).
## surf_trim_markers: Trim on the top, waiting: a region marker in each
## region, the crossings green (Show intersections).
## surf_trim_keep: a marker clicked: its region kept, the box opened.
## surf_divide: Divide: both regions faces of their own.
## surf_surface_menu: the right-click menu on the top face: the surface
## tools.
## surf_intersect: a cylinder through the box, the faces intersected:
## the curves on both.
## surf_stitch: a CAD network's box unstitched and stitched again,
## checked: every edge G0 across the stitched edges.
## surf_project_node: a CAD network's Curve, Project and Trim nodes: a
## region of the box's top kept, the Trim node's markers.
## Stage 4, Align, and Stage 3's follow-ups: preview_align.luc.
import tool_run
import preview_support
import preview_align
from luce_3d.graphics import Vector3
from luce_cad.cad_geometry import CadGeometry
from luce_cad.modeling import CadModeling
from app import Luce3D
from workspace import Workspace
import node_commands
import modeling_commands
import selection_commands
import edit_cad_nets
import edit_cad_curves
import cad_curve_nodes
import edit_cad_surfaces
import surface_ops
import placing_commands
import component_moves
from view_projection import project
from luce_ui.ui import Event
from luce_window.input import EventKind
import cad_blends
import cad_check
from luce_std import math
pub func scenes() -> list[str]:
return ["surf_check", "surf_check_g1", "surf_check_g3", "surf_combs", "surf_deviation", "surf_band", "surf_draft", "surf_cv_nuv", "surf_cv_row", "surf_rebuild", "surf_insert", "surf_convert",
"surf_insert_click", "surf_curves", "surf_curve_menu", "surf_blend", "surf_blend_g4", "surf_curve_cvs", "surf_blend_node",
"surf_blend_handles", "surf_stretch", "surf_isoparm", "surf_curve_combs", "surf_project", "surf_trim_markers", "surf_trim_keep", "surf_divide",
"surf_surface_menu", "surf_intersect", "surf_stitch", "surf_project_node"] + preview_align.scenes()
func look(editor: Luce3D, yaw: float, pitch: float, distance: float, target: Vector3) -> unit!:
let w = editor.workspace
w.view.yaw = yaw
w.view.pitch = pitch
w.view.distance = distance
w.view.target = target
w.view.update_camera()
## A new CAD node, entered and empty.
func cad(editor: Luce3D) -> unit!:
let w = editor.workspace
node_commands.delete_selected(w)
node_commands.add_node(w, "CAD", 40.0, 40.0)
node_commands.enter_group(w, w.network.selected)
## The references of node `id`'s first body's edges whose start and middle
## `keep` takes.
func references_where(w: Workspace, id: int, keep: func(Vector3, Vector3) -> bool) -> str!:
let model = CadGeometry.model(preview_support.cooked(w, id).geometry, 0)
let found: list[int] = []
for face in 0..<model.face_count():
for use in 0..<model.face_edge_count(face):
let edge = model.face_edge_id(face, use)
if keep(model.face_edge_point(face, use, 0.0), model.face_edge_point(face, use, 0.5)) and not (edge in found):
found.append(edge)
return CadModeling.edge_references(model, found)
## A 20 box (its id) with its front top edge filleted 6 at `continuity`
## (1 to 3) after it (the fillet's id).
func filleted_box(editor: Luce3D, continuity: int) -> (int, int)!:
let w = editor.workspace
cad(editor)
node_commands.add_node(w, "Solid Box", 40.0, 40.0)
let box = w.network.selected
let front_top = func (a: Vector3, b: Vector3) -> bool:
return a.y > 9.99 and b.y > 9.99 and a.z > 9.99 and b.z > 9.99
node_commands.add_node(w, "Fillet", 40.0, 140.0)
node_commands.set_text(w, 0, references_where(w, box, front_top))
node_commands.set_parameter(w, cad_blends.size_slot, 6.0)
node_commands.set_parameter(w, cad_blends.continuity_slot, float(continuity - 1))
return (box, w.network.selected)
## A Check node after the selected one, shown, asking for `level`.
func check(editor: Luce3D, level: int) -> int!:
let w = editor.workspace
node_commands.add_node(w, cad_check.kind_name, 40.0, 240.0)
node_commands.display_selected(w)
node_commands.set_parameter(w, cad_check.level_slot, float(level))
return w.network.selected
## An Edit CAD node with a `primitive`, its face whose center `pick` takes
## converted to a B-spline (the Edit node selected, the Faces level).
func converted(editor: Luce3D, primitive: str, pick: func(Vector3) -> bool) -> unit!:
let w = editor.workspace
cad(editor)
node_commands.add_node(w, "Edit CAD", 40.0, 40.0)
preview_support.settle(w)
modeling_commands.create(w, primitive)
preview_support.settle(w)
selection_commands.set_mode(w, 3)
pick_face(w, pick)
tool_run.run(w, edit_cad_nets.convert_verb)
## The face whose center `pick` takes (the highest such), picked.
func pick_face(w: Workspace, pick: func(Vector3) -> bool) -> unit!:
let mesh = preview_support.shown(w) else trap("no pick mesh")
var best = -1
for face in 0..<mesh.face_count():
if pick(mesh.face_center(face)) and (best < 0 or mesh.face_center(face).y > mesh.face_center(best).y):
best = face
selection_commands.choose_component(w, best, false)
## The CV at (u, v) of the shown cloud.
func cv_at(w: Workspace, u: int, v: int) -> int!:
let cloud = preview_support.shown(w) else trap("no cloud")
let us = cloud.find_attribute("cad_cv_u", 0)
let vs = cloud.find_attribute("cad_cv_v", 0)
for i in 0..<cloud.point_count():
if int(cloud.attribute_value(us, i)) == u and int(cloud.attribute_value(vs, i)) == v: return i
trap("no such CV")
## The box's top face converted and rebuilt (4 by 4 quintic spans, 9 by 9
## CVs), at the CVs level with its middle CV picked.
func quintic_top(editor: Luce3D) -> unit!:
let w = editor.workspace
w.display.hulls_visible = true
let top = func (c: Vector3) -> bool: return c.y > 0.99
converted(editor, "Box", top)
pick_face(w, top)
tool_run.run(w, edit_cad_nets.rebuild_verb)
selection_commands.set_mode(w, 1)
selection_commands.choose_component(w, cv_at(w, 4, 4), false)
# A frame the worker put off till it cooked happens first.
preview_support.settle(w)
look(editor, 0.7, 0.85, 5.2, Vector3(0.0, 0.9, 0.0))
## An Edit CAD box with three curves drawn beside and on it (surf_curves
## and the scenes after it), at the Curves level.
func three_curves(editor: Luce3D) -> unit!:
let w = editor.workspace
cad(editor)
node_commands.add_node(w, "Edit CAD", 40.0, 40.0)
preview_support.settle(w)
modeling_commands.create(w, "Box")
preview_support.settle(w)
draw(w, edit_cad_curves.cv_verb, [Vector3(1.6, -1.0, -0.6), Vector3(2.2, 0.2, -0.9), Vector3(2.6, 0.6, 0.2), Vector3(3.0, 1.4, 0.6), Vector3(3.6, 1.6, 1.4)])
draw(w, edit_cad_curves.ep_verb, [Vector3(-0.6, 1.8, 2.4), Vector3(0.6, 2.2, 2.6), Vector3(1.6, 1.6, 3.4), Vector3(2.4, 2.4, 4.0)])
draw(w, edit_cad_curves.surface_verb, [Vector3(-0.7, 1.0, -0.6), Vector3(-0.2, 1.0, 0.4), Vector3(0.3, 1.0, -0.3), Vector3(0.7, 1.0, 0.6)])
preview_support.settle(w)
selection_commands.set_mode(w, 6)
preview_support.settle(w)
## The curve scenes' camera (after their last command: a first result
## frames the view).
func curves_look(editor: Luce3D) -> unit!:
look(editor, 0.55, 0.42, 8.0, Vector3(1.4, 1.0, 1.6))
## Drawing tool `tool` through `points`, finished.
func draw(w: Workspace, tool: str, points: list[Vector3]) -> unit!:
modeling_commands.model(w, tool)
for p in points:
placing_commands.add_corner(w, p)
placing_commands.finish_placing(w)
preview_support.settle(w)
## The Curves level's pick edge of curve `index` (the shown pick mesh's).
func curve_edge(w: Workspace, index: int) -> int!:
let mesh = preview_support.shown(w) else trap("no curve pick mesh")
let owners = mesh.find_attribute("cad_curve", 4)
for edge in 0..<mesh.edge_count():
if int(mesh.attribute_value(owners, edge)) == index:
return edge
trap(f"no edge of curve {index}")
## Curves 0 and 1 picked.
func pick_two(w: Workspace) -> unit!:
selection_commands.choose_component(w, curve_edge(w, 0), false)
selection_commands.choose_component(w, curve_edge(w, 1), true)
preview_support.settle(w)
## An Edit CAD box with a curve above its top along x, projected onto the
## top (Stage 3's scenes), at the Curves level.
func projected_box(editor: Luce3D) -> unit!:
let w = editor.workspace
cad(editor)
node_commands.add_node(w, "Edit CAD", 40.0, 40.0)
preview_support.settle(w)
modeling_commands.create(w, "Box")
preview_support.settle(w)
draw(w, edit_cad_curves.cv_verb, [Vector3(-1.8, 2.2, 0.3), Vector3(-0.7, 2.2, -0.4), Vector3(0.4, 2.2, 0.6), Vector3(1.8, 2.2, -0.1)])
selection_commands.set_mode(w, 6)
preview_support.settle(w)
selection_commands.choose_component(w, curve_edge(w, 0), false)
tool_run.run(w, edit_cad_surfaces.project_verb)
preview_support.settle(w)
selection_commands.set_mode(w, 3)
preview_support.settle(w)
pick_face(w, func (c: Vector3) -> bool: return c.y > 0.99)
preview_support.settle(w)
## The top face picked and a Trim step on it, waiting for clicks.
func trimming(editor: Luce3D) -> unit!:
let w = editor.workspace
projected_box(editor)
selection_commands.set_mode(w, 3)
preview_support.settle(w)
pick_face(w, func (c: Vector3) -> bool: return c.y > 0.99)
tool_run.run(w, edit_cad_surfaces.trim_verb)
preview_support.settle(w)
## The Stage 3 scenes' camera.
func box_look(editor: Luce3D) -> unit!:
look(editor, 0.6, 0.62, 6.5, Vector3(0.0, 0.6, 0.0))
## Frame `frame` of scene `scene` (`last` is the frame captured).
pub func act(editor: Luce3D, scene: str, frame: int, last: int) -> unit!:
let w = editor.workspace
if scene in preview_align.scenes():
preview_align.act(editor, scene, frame, last)
return
if frame != last - 1:
return
if scene == "surf_insert_click":
# The pointer over the top, a third of the way along.
let area = editor.panels.view.layout().bounds()
let s = project(w, Vector3(-0.35, 1.0, 0.1), area.width, area.height)
editor.app.dispatch(Event(kind = EventKind.pointer_moved, x = area.x + s[0], y = area.y + s[1]))
elif scene == "surf_curve_menu":
let area = editor.panels.view.layout().bounds()
let s = project(w, Vector3(2.6, 0.6, 0.2), area.width, area.height)
editor.app.dispatch(Event(kind = EventKind.pointer_moved, x = area.x + s[0], y = area.y + s[1]))
editor.app.dispatch(Event(kind = EventKind.pointer_down, x = area.x + s[0], y = area.y + s[1], button = 1))
editor.app.dispatch(Event(kind = EventKind.pointer_up, x = area.x + s[0], y = area.y + s[1], button = 1))
elif scene == "surf_trim_keep":
# A click on the marker in front (+z): its region kept.
let node = w.selected() else trap("no Edit CAD node")
let markers = surface_ops.points_of(node.sketch_state, surface_ops.markers_head)
if markers.length < 2:
trap(f"no markers: {node.warning}")
let front = markers[0] if markers[0].z > markers[1].z else markers[1]
let area = editor.panels.view.layout().bounds()
let s = project(w, front, area.width, area.height)
for kind in [EventKind.pointer_moved, EventKind.pointer_down, EventKind.pointer_up]:
editor.app.dispatch(Event(kind = kind, x = area.x + s[0], y = area.y + s[1], button = 0))
preview_support.settle(w)
editor.panels.refresh()
elif scene == "surf_surface_menu":
let area = editor.panels.view.layout().bounds()
let s = project(w, Vector3(0.6, 1.0, 0.6), area.width, area.height)
editor.app.dispatch(Event(kind = EventKind.pointer_moved, x = area.x + s[0], y = area.y + s[1]))
editor.app.dispatch(Event(kind = EventKind.pointer_down, x = area.x + s[0], y = area.y + s[1], button = 1))
editor.app.dispatch(Event(kind = EventKind.pointer_up, x = area.x + s[0], y = area.y + s[1], button = 1))
elif scene == "surf_isoparm":
# A double-click on the side, as a user picks the isoparm there.
let area = editor.panels.view.layout().bounds()
let s = project(w, Vector3(math.sin(0.4), 0.3, math.cos(0.4)), area.width, area.height)
for _ in 0..<2:
for kind in [EventKind.pointer_moved, EventKind.pointer_down, EventKind.pointer_up]:
editor.app.dispatch(Event(kind = kind, x = area.x + s[0], y = area.y + s[1], button = 0))
preview_support.settle(w)
editor.panels.refresh()
elif scene == "surf_blend_handles":
# The pointer on the start's tangent handle: lit.
let area = editor.panels.view.layout().bounds()
let tip = editor.panels.view.arrow.tip(area.width, area.height, edit_cad_curves.start_tangent_slot) else trap("no blend handle")
editor.app.dispatch(Event(kind = EventKind.pointer_moved, x = area.x + tip[0], y = area.y + tip[1]))
elif scene == "surf_cv_nuv":
# Held mid-drag: the frame fixed at the press, the ghost kept.
let frame_axes = component_moves.cv_axes(w) else trap("no NUV frame")
w.ghost_hulls = w.batches.hull_batches.copy()
w.begin("Move gizmo")
w.cv_frame = frame_axes
component_moves.preview_move(w, frame_axes[0].multiply_scalar(0.6))
preview_support.settle(w)
editor.panels.refresh()
elif scene == "surf_cv_row":
let cloud = preview_support.shown(w) else trap("no cloud")
let middle = cv_at(w, 4, 4)
selection_commands.choose_component(w, middle, false, row = 0)
let p = cloud.point(middle)
let area = editor.panels.view.layout().bounds()
let s = project(w, Vector3(p.x, p.y, p.z), area.width, area.height)
editor.app.dispatch(Event(kind = EventKind.pointer_moved, x = area.x + s[0], y = area.y + s[1]))
editor.app.dispatch(Event(kind = EventKind.pointer_down, x = area.x + s[0], y = area.y + s[1], button = 1))
editor.app.dispatch(Event(kind = EventKind.pointer_up, x = area.x + s[0], y = area.y + s[1], button = 1))
## Scene `scene` before its first frame.
pub func setup(editor: Luce3D, scene: str) -> unit!:
let w = editor.workspace
if scene in preview_align.scenes():
preview_align.setup(editor, scene)
return
if scene == "surf_check":
_ = filleted_box(editor, 2)
_ = check(editor, 2)
look(editor, 0.62, 0.42, 58.0, Vector3(0.0, 4.0, 2.0))
elif scene == "surf_band":
_ = filleted_box(editor, 2)
node_commands.display_selected(w)
w.display.curvature_kind = 4
w.display.curvature_band_low = 8.0
look(editor, 0.62, 0.42, 58.0, Vector3(0.0, 4.0, 2.0))
elif scene == "surf_draft":
cad(editor)
node_commands.add_node(w, "Solid Cone", 40.0, 40.0)
node_commands.set_parameter(w, 2, 6.0)
node_commands.display_selected(w)
w.display.draft_axis = 1
w.display.draft_angle = 3.0
look(editor, 0.5, 0.25, 70.0, Vector3(0.0, 0.0, 0.0))
elif scene == "surf_check_g1":
_ = filleted_box(editor, 1)
_ = check(editor, 2)
look(editor, 0.62, 0.42, 58.0, Vector3(0.0, 4.0, 2.0))
elif scene == "surf_check_g3":
let (_, fillet) = filleted_box(editor, 3)
_ = check(editor, 3)
# The fillet's contacts: lengthwise, off the box's own edges.
let contacts = func (a: Vector3, b: Vector3) -> bool:
return math.abs(a.x - b.x) > 1.0 and a.y > 0.0 and a.z > 0.0 and not (a.y > 9.99 and a.z > 9.99)
node_commands.set_text(w, 0, references_where(w, fillet, contacts))
look(editor, 0.62, 0.42, 58.0, Vector3(0.0, 4.0, 2.0))
elif scene == "surf_combs":
cad(editor)
node_commands.add_node(w, "Solid Cylinder", 40.0, 40.0)
_ = check(editor, 2)
look(editor, 0.5, 0.5, 70.0, Vector3(0.0, 0.0, 0.0))
elif scene in ["surf_cv_nuv", "surf_cv_row"]:
quintic_top(editor)
node_commands.set_parameter(w, edit_cad_nets.move_mode_slot, 1.0)
if scene == "surf_cv_nuv":
node_commands.set_parameter(w, edit_cad_nets.falloff_kind_slot, 1.0)
modeling_commands.choose_tool(w, "Move")
editor.panels.refresh()
elif scene == "surf_rebuild":
quintic_top(editor)
selection_commands.set_mode(w, 1)
# The worker publishes the CV nets once it is asked with the CVs
# level on: ask again and wait for it before the capture.
w.rebuild()
preview_support.settle(w)
editor.panels.refresh()
elif scene == "surf_insert_click":
quintic_top(editor)
tool_run.run(w, edit_cad_nets.insert_verb)
preview_support.settle(w)
look(editor, 0.7, 0.85, 5.2, Vector3(0.0, 0.9, 0.0))
editor.panels.refresh()
elif scene in ["surf_curves", "surf_curve_menu"]:
three_curves(editor)
pick_two(w)
curves_look(editor)
editor.panels.refresh()
elif scene in ["surf_blend", "surf_blend_g4"]:
three_curves(editor)
pick_two(w)
tool_run.run(w, edit_cad_curves.blend_verb)
if scene == "surf_blend_g4":
modeling_commands.set_last_step(w, edit_cad_curves.start_g_slot, 4.0, 0.0, 4.0)
modeling_commands.set_last_step(w, edit_cad_curves.end_g_slot, 4.0, 0.0, 4.0)
w.display.hulls_visible = true
preview_support.settle(w)
selection_commands.set_mode(w, 1)
preview_support.settle(w)
curves_look(editor)
editor.panels.refresh()
elif scene == "surf_curve_cvs":
three_curves(editor)
w.display.hulls_visible = true
selection_commands.set_mode(w, 1)
let cloud = preview_support.shown(w) else trap("no cloud")
var last = -1
let owners = cloud.find_attribute("cad_cv_surface", 0)
let models = cloud.find_attribute("cad_cv_model", 0)
for i in 0..<cloud.point_count():
if int(cloud.attribute_value(models, i)) < 0 and int(cloud.attribute_value(owners, i)) == 0: last = i
selection_commands.choose_component(w, last, false)
modeling_commands.choose_tool(w, "Move")
preview_support.settle(w)
curves_look(editor)
editor.panels.refresh()
elif scene == "surf_blend_node":
cad(editor)
node_commands.add_node(w, "Solid Box", 40.0, 40.0)
let box = w.network.selected
node_commands.add_node(w, cad_curve_nodes.blend_kind, 40.0, 140.0)
let blend = w.network.selected
w.network.connect(box, blend, 0)
let along_x = func (a: Vector3, b: Vector3) -> bool: return math.abs(a.y - 10.0) < 1e-9 and math.abs(b.y - 10.0) < 1e-9 and math.abs(a.x - b.x) > 1.0
let references = references_where(w, box, along_x).split(";")
node_commands.set_text(w, 0, "edge " + references[0])
node_commands.set_text(w, 1, "edge " + references[1])
node_commands.display_selected(w)
preview_support.settle(w)
look(editor, 0.75, 0.55, 75.0, Vector3(0.0, 8.0, 0.0))
editor.panels.refresh()
elif scene == "surf_insert":
quintic_top(editor)
tool_run.run(w, edit_cad_nets.insert_verb)
modeling_commands.set_last_step(w, edit_cad_nets.fraction_slot, 0.3, 0.0, 1.0)
selection_commands.set_mode(w, 1)
editor.panels.refresh()
elif scene == "surf_convert":
converted(editor, "Cylinder", func (c: Vector3) -> bool: return math.hypot(c.x, c.z) > 0.95)
w.display.hulls_visible = true
selection_commands.set_mode(w, 1)
preview_support.settle(w)
look(editor, 0.7, 0.3, 7.5, Vector3(0.0, 1.0, 0.0))
editor.panels.refresh()
elif scene == "surf_blend_handles":
three_curves(editor)
pick_two(w)
tool_run.run(w, edit_cad_curves.blend_verb)
preview_support.settle(w)
look(editor, 0.9, 0.45, 4.0, Vector3(3.4, 1.4, 2.0))
editor.panels.refresh()
elif scene == "surf_stretch":
three_curves(editor)
selection_commands.choose_component(w, curve_edge(w, 0), false)
tool_run.run(w, edit_cad_curves.stretch_verb)
let node = w.selected() else trap("no Edit CAD node")
let numbers = edit_cad_curves.stretch_with(node.edits[-1].numbers, [0.0, 1.0, 0.5], [Vector3(), Vector3(), Vector3(0.0, 0.8, -0.4)])
w.perform("Stretch handle", func () -> unit!:
node.edits[-1] = node.edits[-1].with_numbers(numbers)
w.network.invalidate(node.id)
w.rebuild())
preview_support.settle(w)
curves_look(editor)
editor.panels.refresh()
elif scene == "surf_isoparm":
cad(editor)
node_commands.add_node(w, "Edit CAD", 40.0, 40.0)
preview_support.settle(w)
modeling_commands.create(w, "Cylinder")
preview_support.settle(w)
selection_commands.set_mode(w, 6)
preview_support.settle(w)
look(editor, 0.4, 0.35, 6.0, Vector3(0.0, 0.0, 0.0))
editor.panels.refresh()
elif scene == "surf_curve_combs":
cad(editor)
node_commands.add_node(w, "Solid Box", 40.0, 0.0)
for slot in 0..<3:
node_commands.set_parameter(w, slot, 4.0)
node_commands.add_node(w, "Curve", 40.0, 40.0)
node_commands.set_text(w, 0, "-10 12 0; -5 18 0; 0 14 0; 5 8 0; 10 15 0")
_ = check(editor, 2)
preview_support.settle(w)
look(editor, 0.0, 0.15, 34.0, Vector3(0.0, 11.0, 0.0))
editor.panels.refresh()
elif scene == "surf_project":
projected_box(editor)
selection_commands.set_mode(w, 6)
preview_support.settle(w)
box_look(editor)
editor.panels.refresh()
elif scene in ["surf_trim_markers", "surf_trim_keep", "surf_divide"]:
trimming(editor)
if scene == "surf_divide":
modeling_commands.set_last_step(w, edit_cad_surfaces.mode_slot, 2.0, 0.0, 2.0)
preview_support.settle(w)
selection_commands.set_mode(w, 3)
preview_support.settle(w)
pick_face(w, func (c: Vector3) -> bool: return c.y > 0.99)
preview_support.settle(w)
box_look(editor)
editor.panels.refresh()
elif scene == "surf_surface_menu":
projected_box(editor)
selection_commands.set_mode(w, 3)
preview_support.settle(w)
pick_face(w, func (c: Vector3) -> bool: return c.y > 0.99)
preview_support.settle(w)
box_look(editor)
editor.panels.refresh()
elif scene == "surf_intersect":
cad(editor)
node_commands.add_node(w, "Edit CAD", 40.0, 40.0)
preview_support.settle(w)
modeling_commands.create(w, "Box")
preview_support.settle(w)
modeling_commands.create(w, "Cylinder")
preview_support.settle(w)
component_moves.move_selection(w, Vector3(0.9, 0.0, 0.3))
preview_support.settle(w)
selection_commands.set_mode(w, 3)
preview_support.settle(w)
# The box's front (z = 1) clear of the cylinder, and the cylinder's side.
let mesh = preview_support.shown(w) else trap("no pick mesh")
let models = mesh.find_attribute("cad_model", 2)
var front = -1
var side = -1
for face in 0..<mesh.face_count():
let c = mesh.face_center(face)
let n = mesh.face_normal(face)
let model = int(mesh.attribute_value(models, face))
if front < 0 and model == 0 and n.z > 0.99:
front = face
if side < 0 and model == 1 and math.abs(n.y) < 0.2 and c.z > 1.0:
side = face
if front < 0 or side < 0:
trap(f"faces to intersect not found: {front} {side}")
selection_commands.choose_component(w, front, false)
selection_commands.choose_component(w, side, true)
tool_run.run(w, edit_cad_surfaces.intersect_verb)
modeling_commands.set_last_step(w, edit_cad_surfaces.both_faces_slot, 1.0, 0.0, 1.0)
preview_support.settle(w)
selection_commands.set_mode(w, 6)
preview_support.settle(w)
look(editor, -0.5, 0.35, 6.0, Vector3(0.3, 0.2, 0.6))
editor.panels.refresh()
elif scene == "surf_stitch":
cad(editor)
node_commands.add_node(w, "Solid Box", 40.0, 40.0)
let box = w.network.selected
let model = CadGeometry.model(preview_support.cooked(w, box).geometry, 0)
node_commands.add_node(w, edit_cad_surfaces.unstitch_verb, 40.0, 120.0)
node_commands.set_text(w, 0, CadModeling.face_name_of(model, 0))
node_commands.add_node(w, edit_cad_surfaces.stitch_verb, 40.0, 200.0)
_ = check(editor, 0)
node_commands.set_parameter(w, cad_check.sharp_slot, 1.0)
preview_support.settle(w)
look(editor, 0.62, 0.42, 58.0, Vector3(0.0, 4.0, 2.0))
editor.panels.refresh()
elif scene == "surf_project_node":
cad(editor)
node_commands.add_node(w, "Solid Box", 40.0, 40.0)
let box = w.network.selected
let model = CadGeometry.model(preview_support.cooked(w, box).geometry, 0)
var top = ""
for f in 0..<model.face_count():
let name = CadModeling.face_name_of(model, f)
let frame = CadModeling.face_frame(model, name)
if frame.found and frame.u.cross(frame.v).y > 0.999:
top = name
node_commands.add_node(w, "Curve", 40.0, 120.0)
let curve = w.network.selected
node_commands.set_text(w, 0, "-15 15 2; -5 15 -4; 5 15 5; 15 15 -1")
node_commands.add_node(w, edit_cad_surfaces.project_verb, 40.0, 200.0)
node_commands.set_text(w, 0, f"Curve{curve}")
node_commands.set_text(w, 1, top)
node_commands.add_node(w, edit_cad_surfaces.trim_verb, 40.0, 280.0)
let trim = w.network.selected
node_commands.set_text(w, 0, top)
node_commands.display_selected(w)
preview_support.settle(w)
let state = (w.network.find(trim) else trap("no Trim")).sketch_state
let markers = surface_ops.points_of(state, surface_ops.markers_head)
if markers.length > 0:
node_commands.set_text(w, 1, surface_ops.points_text([markers[0]]))
preview_support.settle(w)
look(editor, 0.62, 0.55, 75.0, Vector3(0.0, 5.0, 0.0))
editor.panels.refresh()
elif scene == "surf_deviation":
let (box, _) = filleted_box(editor, 2)
let id = check(editor, 2)
w.network.connect(box, id, 1)
node_commands.set_parameter(w, cad_check.deviation_slot, 1.0)
node_commands.set_parameter(w, cad_check.acceptable_slot, 0.05)
node_commands.set_parameter(w, cad_check.ramp_slot, 1.5)
look(editor, 0.62, 0.42, 58.0, Vector3(0.0, 4.0, 2.0))