* kernel: a blend runs along chains of several faces and lines closed rims up (#764) A blend's chain may run along the boundaries of several faces (a tube's rim along the halves of its wall): each edge continues from its own best-facing face, read station by station. Before, a chain had to be the edges of one face, so every rim of a revolved or cylindrical surface was refused. Two closed chains blend from matching seams: the second chain's start (searched by arclength, then narrowed) and direction are the ones that put each station closest to its partner, so rims whose seams sit apart no longer twist. A picked `seam` point on each chain fixes the start instead. A closed chain against an open one is refused. Closed chains leave towards each other's centroid, not a point on the rim. Stations are read on the edges' own curves, not on the chords of the length table (they sat up to the chord's sagitta inside a curved edge), and the reported gap is measured to the curves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGeCa5jWWdroMWvXxN3LLM * kernel: closed blend chains run round the same way; Hermite strip and seam tests (#764) The second of two closed chains runs round the same way as the first (by their area vectors), so a picked seam turns the blend by just the angle between the seams instead of folding it over. The nearer pairing decides only when the loops stand almost at right angles. Tests for the issue's gates: the blend between two offset box rims is the analytic cubic Hermite strip (control points from the chord) and keeps the top faces' normal along both seams; picked seams a quarter apart turn the blend a quarter round. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGeCa5jWWdroMWvXxN3LLM * surface.blend: `seam` picks where each chain's stations start (#764) A point on each chain, saved with the feature (one pending format change), moved with the design like `align`, and refused when it is not two points. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGeCa5jWWdroMWvXxN3LLM * surface.blend: a test between two tube rims, their seams picked and saved (#764) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGeCa5jWWdroMWvXxN3LLM * Blend dialog: edges at each end, continuity and bulge per end, stitch (#764) SURFACE › CREATE › Blend Surface opens a dialog: the edges the blend leaves and the ones it arrives at, each end's continuity (G0–G3) and bulge, and Stitch to both bodies. Edit Feature brings it back and keeps what the dialog does not show (align and seam points). Labels in every locale catalog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGeCa5jWWdroMWvXxN3LLM * ROADMAP: M8 Blend runs along several faces, pairs closed rims and has a dialog (#764) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGeCa5jWWdroMWvXxN3LLM * kernel: a blend station on the vertex between two support faces is read on the neighbour (#764) A station where a tube wall's two halves meet sits at a corner of one half's parameters; with a leave direction that turns round the wall (tubes off each other's axis) the shape could not be read there and the blend was refused. The neighbouring chain edge's face holds the same point and reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGeCa5jWWdroMWvXxN3LLM * blend: review clean-ups (#764) - ChainLine keeps one list of samples instead of four parallel lists. - frames_on and boundary_gap take the chain's ChainLine instead of rebuilding it. - A station is read on the neighbouring face only when it sits on the vertex the two edges share, each face once, and each face keeps its own walk. - The seam rule (a closed chain starts at it, an open one runs from the nearer end) lives in ChainLine::start_at_seam; pair_with reuses the start of its both-ways search. - support_faces projects with curveblend::project; loop_area sits with plane_through. - surface.blend parses `align` and `seam` through one point_pair; the Blend and Ruled dialogs share body_and_edges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGeCa5jWWdroMWvXxN3LLM --------- Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -57,7 +57,7 @@ PCB / Package, Render, Animation, Simulation, Manufacture/CAM, Drawings.
|
||||
| M5 | Persistent naming of faces and edges (docs/book/src/dev/naming.md): faces named from their exact kernel-reported history (sketch curve sides, caps, revolve sections, primitive sides, blends, shell inner walls, pattern/mirror copies; split pieces told apart by the faces around them, lumps of a cut body named after their faces), edges by their faces; fillets/chamfers, sketches on faces, shell/draft/offset/replace faces, hole placements, joint origins and face appearances resolve by name first and warn when the entity split or vanished: done. sheet metal edges by base sketch line and flange side, shell inner faces, sweep and loft roles: done. kernel-reported face history: done (merged faces answer to every name; operations without history yet fall back to geometric names, flagged unverified; format 14 keeps older designs' geometric names). Left: history through sheet metal, plastic, surface and emboss features; FaceSource certificates through history | in progress | 20 |
|
||||
| M6 | UI depth: selection feedback and origin (done), timeline editing (done: hover and selection highlight modifier faces, including fillets and chamfers; edit feature, history marker drag, dependency-checked single and multi-item reorder, suppress, rename, delete with dependents, re-resolved references; redefining selections refreshes persistent edge/face references while retaining feature identity and dimension names; optional compact named left feature history with rollback bar, multi-selection and persistent folders above the parts browser), right-docked dialogs (done), live previews for every feature dialog (done), keyboard-first commands with on-canvas value boxes and sketch inline dimensions (done), drag manipulators with automatic join/cut (done: extrude incl. two sides, fillet, shell, hole depth, move, pattern spacing, revolve rotator, extrude taper), dark theme (done), right-click menu with Repeat (done), measure tool (done), section analysis (done), selection filter (done), drag-solve of sketch points (done); appearance controls now preserve body/face/component targeting, named transparent looks, reuse/search and override removal; preferences | in progress | 6 |
|
||||
| M7 | Thin extrude (walls along open or closed curves: centre, inside, outside or two sides; mitred corners, crossing walls joined; #721), sweep, loft (incl. to a point), rib and web (to next / depth), emboss (planar faces and exact radial emboss/deboss of bounded orthogonal profiles on complete exterior cylinders/sleeves), thread (cosmetic, and modelled M3–M20 outside and inside: the ISO profile screwed in as a faceted cut), coil (smooth B-spline helical walls), pipe, pattern on path, patterns of bodies and components, replace face (parallel), align, remove, feature copy/paste: done. Unique eligible cylindrical targets are inferred for new Emboss features. Left: general curved-face emboss and exact (unfaceted) modelled threads | in progress | 12 |
|
||||
| M8 | Surface workspace (#772). Done: Patch (sketch regions; edge loops filled G0, plus `crown`), Stitch, Thicken (planes and cylinders), Extend (straight edges of planar surfaces), Trim (by a plane, a face or sketch curves swept onto the surface, keeping a side or the picked regions; mutual trim of two surfaces, extended to meet and stitched, #767), Delete Face (healing), Boundary Fill, zebra/draft/curvature-map analysis, Surface Extrude/Revolve/Sweep/Loft from open and closed curves, Offset, Unstitch and Reverse Normal; the continuity-driven core (`kernel/src/bridge.rs`, G0–G3 Hermite rows) with **Blend** (`surface.blend`, #764), **Match** (`surface.match`), **Boundary** (`surface.boundary`, #763 — two sketch curves exact with G0–G3, three or four as the flat patch of their loop, and curve networks: Coons and Gordon surfaces through sketch, 3D-sketch or edge curves, a point for a three-sided side, G1/G2 against the faces along one direction's edges, joined into their body on request; G1/G2 on two sides that meet at a corner waits for the Gregory-type corner), **Fair** (`surface.fair`, CV fairing), **continuity analysis** (`inspect.continuity`, #770; a toolbar tool with edge markers and a legend, and curvature combs along face isocurves) and a multi-section **loft** with per-end continuity and crown, and guide rails on solid and surface lofts (one or two, scaling or stretching the sections between; #201). Also in the Class-A pass: G1…G4 blend curves in the sketch, chord and variable-radius fillets on curved edges (with honest refusals where the fit cannot hold), and a G2 corner patch where filleted edges meet (kernel; the command refuses until the patch's sections can be sewn to the blends' contacts). Left: bias/form-factor fillet sections (design recorded), a Gregory-type corner, surface Fillet between separate surface bodies (#769), Ruled (#762), Untrim (#761), curved-face Extend (#760), and every remaining #757–#772 item | deferred | — |
|
||||
| M8 | Surface workspace (#772). Done: Patch (sketch regions; edge loops filled G0, plus `crown`), Stitch, Thicken (planes and cylinders), Extend (straight edges of planar surfaces), Trim (by a plane, a face or sketch curves swept onto the surface, keeping a side or the picked regions; mutual trim of two surfaces, extended to meet and stitched, #767), Delete Face (healing), Boundary Fill, zebra/draft/curvature-map analysis, Surface Extrude/Revolve/Sweep/Loft from open and closed curves, Offset, Unstitch and Reverse Normal; the continuity-driven core (`kernel/src/bridge.rs`, G0–G3 Hermite rows) with **Blend** (`surface.blend`, #764: edge chains along one or several faces, closed rims paired seam to seam or from picked seams, a dialog), **Match** (`surface.match`), **Boundary** (`surface.boundary`, #763 — two sketch curves exact with G0–G3, three or four as the flat patch of their loop, and curve networks: Coons and Gordon surfaces through sketch, 3D-sketch or edge curves, a point for a three-sided side, G1/G2 against the faces along one direction's edges, joined into their body on request; G1/G2 on two sides that meet at a corner waits for the Gregory-type corner), **Fair** (`surface.fair`, CV fairing), **continuity analysis** (`inspect.continuity`, #770; a toolbar tool with edge markers and a legend, and curvature combs along face isocurves) and a multi-section **loft** with per-end continuity and crown, and guide rails on solid and surface lofts (one or two, scaling or stretching the sections between; #201). Also in the Class-A pass: G1…G4 blend curves in the sketch, chord and variable-radius fillets on curved edges (with honest refusals where the fit cannot hold), and a G2 corner patch where filleted edges meet (kernel; the command refuses until the patch's sections can be sewn to the blends' contacts). Left: bias/form-factor fillet sections (design recorded), a Gregory-type corner, surface Fillet between separate surface bodies (#769), Ruled (#762), Untrim (#761), curved-face Extend (#760), and every remaining #757–#772 item | deferred | — |
|
||||
| M9 | Components and assemblies: New Component / Create Components from Bodies, active component, per-component origin/bodies/sketches/timeline entries, occurrences with transforms, Copy/Paste vs Paste New, nested Browser tree with visibility and isolate; Ground, Move/Copy of occurrences, joints (rigid, revolute, slider, cylindrical, pin-slot, planar, ball) by joint origins with limits and Drive Joints, closed kinematic loops (four-bar, slider-crank: the loop's other joints follow the driven one on its branch, and driving stops where a loop can no longer close), cams (`joint.cam`: a revolute cam drives a slider or revolute follower along a closed sketch profile or the cam's edges, knife, roller or flat followers, worked out again when the profile changes; drives, studies, closed loops, contact sets), As-built Joint, Rigid Group, Contact Sets (driving and motion studies stop where bodies in a set would pass through each other), Motion Study (joint values keyed along a timeline, playback, export of occurrence positions as JSON/CSV), motion analysis (joint values and a point's path charted over a study as value, velocity and acceleration; the parts that collide along a study, with the steps where they do), Exploded views (automatic or by hand, shown without changing placements); interference, per-component physical properties; STEP with assembly structure; URDF export for robot simulators (links with meshes, mass and inertia; joint chains whose values match Drive Joints; docs/urdf.md). Physical properties now measure material-aware component/occurrence placements, descendants and repeated instances, including pending moves and body reassignment offsets; contact geometry and automatic exploded centres respect those offsets. Groundwork done: component tree, occurrences with transforms (instances, Paste New), world placement, active component as authoring frame, ground, Capture/Revert Position, moving bodies and sketches. UI: ASSEMBLE panel dialogs for New Component, Joint (snaps on faces, edges, circles and vertices; animated motion preview; offsets, flip, limits), As-built Joint, Joint Origin, Rigid Group, Drive Joints (live slider), Motion Link, Cam and Interference (overlaps shown red); joints in the timeline and the Browser | in progress | 32 |
|
||||
| M10 | Sheet metal: flange (base, edge, contour), hem, unfold/refold, convert, flat pattern + DXF, rules: done. PLASTIC enclosure subset: Boss, Rib, Web, Lip/Groove, Snap Fit, Rest, Plastic Rules (library, edit, assign; rule draft and clearance as feature defaults): done, tested against hand-computed geometry. UI: SHEET METAL and PLASTIC tabs with dialogs (live preview, Edit Feature, pre-selection) for Flange, Hem, Unfold/Refold, Convert, Sheet Metal Rules, Create Flat Pattern (flat view with bend lines, bend table CSV/JSON and DXF export with exact circle/arc/line cutouts), Boss, Lip/Groove, Snap Fit, Rest, Manage and Assign Plastic Rules; Fold (bend along a sketch line); flanges meeting at a corner closed at any angle with the rule's gap; edge flanges with their own angle and height per edge in one feature; corner reliefs (notch, round, rectangular, tear) chosen by the rule; Convert to Sheet Metal from a solid or shelled body by its bend edges (flat faces, sharp bends) | in progress | 36 |
|
||||
| M11 | 2D drawings | deferred | — |
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
"Current orthographic view (1:1 mm)": "Aktuální pravoúhlý pohled (1:1 mm)",
|
||||
"Current perspective view": "Aktuální perspektivní pohled",
|
||||
"Curvature (G2)": "Křivost (G2)",
|
||||
"Curvature change (G3)": "Změna křivosti (G3)",
|
||||
"Customize Toolbar": "Přizpůsobit panel nástrojů",
|
||||
"Delete all": "Smazat vše",
|
||||
"Delete rule": "Smazat pravidlo",
|
||||
@@ -113,6 +114,7 @@
|
||||
"Follow camera (Look At sketches)": "Sledovat kameru (náčrty natočené k pohledu)",
|
||||
"Follow the camera (Look At sketches)": "Sledovat kameru (náčrty natočené k pohledu)",
|
||||
"Font": "Písmo",
|
||||
"From edges": "Výchozí hrany",
|
||||
"Full Length": "Celá délka",
|
||||
"Grid": "Mřížka",
|
||||
"Height": "Výška",
|
||||
@@ -250,6 +252,7 @@
|
||||
"Step": "Krok",
|
||||
"Steps": "Kroky",
|
||||
"Stitch the kept pieces": "Sešít ponechané části",
|
||||
"Stitch to both bodies": "Sešít s oběma tělesy",
|
||||
"Style": "Styl",
|
||||
"Suppressed": "Potlačeno",
|
||||
"Surface": "Plocha",
|
||||
@@ -270,6 +273,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "Tento potomek je sdílený. Změny polohy se projeví ve všech kopiích jeho rodiče.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "Tato plocha nemůže poskytnout trvalé připojení. Zvolte jinou plochu nebo výslovně použijte pevnou rovinu.",
|
||||
"To Offset": "Odsazení k objektu",
|
||||
"To edges": "Cílové hrany",
|
||||
"Tolerance": "Tolerance",
|
||||
"Trimming tool (plane, face or curves)": "Ořezávací nástroj (rovina, plocha nebo křivky)",
|
||||
"Turn off section analysis before exporting the view.": "Před exportem pohledu vypněte analýzu řezu.",
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"Current orthographic view (1:1 mm)": "Aktuelle orthogonale Ansicht (1:1 mm)",
|
||||
"Current perspective view": "Aktuelle perspektivische Ansicht",
|
||||
"Curvature (G2)": "Krümmung (G2)",
|
||||
"Curvature change (G3)": "Krümmungsänderung (G3)",
|
||||
"Direction": "Richtung",
|
||||
"Do not export hidden edges": "Verdeckte Kanten nicht exportieren",
|
||||
"Don't ask again": "Nicht mehr fragen",
|
||||
@@ -44,6 +45,7 @@
|
||||
"Faces": "Flächen",
|
||||
"Find in Browser": "Im Browser suchen",
|
||||
"Flat": "Flach",
|
||||
"From edges": "Ausgangskanten",
|
||||
"Hidden edges": "Verdeckte Kanten",
|
||||
"Holes": "Löcher",
|
||||
"Holes (edges on them)": "Löcher (ihre Kanten)",
|
||||
@@ -92,6 +94,7 @@
|
||||
"Sketch points": "Skizzenpunkte",
|
||||
"Slot width": "Langlochbreite",
|
||||
"Stitch the kept pieces": "Behaltene Teile vernähen",
|
||||
"Stitch to both bodies": "Mit beiden Körpern vernähen",
|
||||
"Study": "Untersuchung",
|
||||
"Surface": "Flächenkörper",
|
||||
"TRIM": "TRIMMEN",
|
||||
@@ -100,6 +103,7 @@
|
||||
"Thickness Outside": "Dicke außen",
|
||||
"Thin": "Dünnwandig",
|
||||
"Thin Extrude": "Dünnwandig extrudieren",
|
||||
"To edges": "Zielkanten",
|
||||
"Trimming tool (plane, face or curves)": "Trimmwerkzeug (Ebene, Fläche oder Kurven)",
|
||||
"Turn off section analysis before exporting the view.": "Deaktivieren Sie die Schnittanalyse, bevor Sie die Ansicht exportieren.",
|
||||
"Type": "Typ",
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"Arc length": "Arc length",
|
||||
"Area": "Area",
|
||||
"Attachment": "Attachment",
|
||||
"BLEND SURFACE": "BLEND SURFACE",
|
||||
"BOUNDARY SURFACE": "BOUNDARY SURFACE",
|
||||
"BROWSER": "BROWSER",
|
||||
"Bend Line Position": "Bend Line Position",
|
||||
@@ -79,6 +80,7 @@
|
||||
"Current orthographic view (1:1 mm)": "Current orthographic view (1:1 mm)",
|
||||
"Current perspective view": "Current perspective view",
|
||||
"Curvature (G2)": "Curvature (G2)",
|
||||
"Curvature change (G3)": "Curvature change (G3)",
|
||||
"Customize Toolbar": "Customize Toolbar",
|
||||
"Delete all": "Delete all",
|
||||
"Delete rule": "Delete rule",
|
||||
@@ -100,6 +102,8 @@
|
||||
"Edit Profile Sketch": "Edit Profile Sketch",
|
||||
"Enable rule": "Enable rule",
|
||||
"Enabled": "Enabled",
|
||||
"End bulge": "End bulge",
|
||||
"End continuity": "End continuity",
|
||||
"Explode": "Explode",
|
||||
"Explode Text": "Explode Text",
|
||||
"Export Animation…": "Export Animation…",
|
||||
@@ -122,6 +126,7 @@
|
||||
"Follow camera (Look At sketches)": "Follow camera (Look At sketches)",
|
||||
"Follow the camera (Look At sketches)": "Follow the camera (Look At sketches)",
|
||||
"Font": "Font",
|
||||
"From edges": "From edges",
|
||||
"Full Length": "Full Length",
|
||||
"Grid": "Grid",
|
||||
"Height": "Height",
|
||||
@@ -262,9 +267,12 @@
|
||||
"Stand it up": "Stand it up",
|
||||
"Stand it up: a quarter turn about X, as one Move feature you can undo.": "Stand it up: a quarter turn about X, as one Move feature you can undo.",
|
||||
"Stand this part up?": "Stand this part up?",
|
||||
"Start bulge": "Start bulge",
|
||||
"Start continuity": "Start continuity",
|
||||
"Step": "Step",
|
||||
"Steps": "Steps",
|
||||
"Stitch the kept pieces": "Stitch the kept pieces",
|
||||
"Stitch to both bodies": "Stitch to both bodies",
|
||||
"Study": "Study",
|
||||
"Style": "Style",
|
||||
"Suppressed": "Suppressed",
|
||||
@@ -286,6 +294,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "This child is shared. Position changes apply to every copy of its parent.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.",
|
||||
"To Offset": "To Offset",
|
||||
"To edges": "To edges",
|
||||
"Tolerance": "Tolerance",
|
||||
"Too close": "Too close",
|
||||
"Trimming tool (plane, face or curves)": "Trimming tool (plane, face or curves)",
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"Current orthographic view (1:1 mm)": "Vista ortográfica actual (1:1 mm)",
|
||||
"Current perspective view": "Vista en perspectiva actual",
|
||||
"Curvature (G2)": "Curvatura (G2)",
|
||||
"Curvature change (G3)": "Cambio de curvatura (G3)",
|
||||
"Customize Toolbar": "Personalizar barra de herramientas",
|
||||
"Delete all": "Eliminar todo",
|
||||
"Delete rule": "Eliminar regla",
|
||||
@@ -120,6 +121,7 @@
|
||||
"Follow camera (Look At sketches)": "Seguir cámara (orientar hacia los bocetos)",
|
||||
"Follow the camera (Look At sketches)": "Seguir la cámara (orientar hacia los bocetos)",
|
||||
"Font": "Fuente",
|
||||
"From edges": "Aristas de origen",
|
||||
"Full Length": "Longitud total",
|
||||
"Grid": "Cuadrícula",
|
||||
"Height": "Altura",
|
||||
@@ -263,6 +265,7 @@
|
||||
"Step": "Paso",
|
||||
"Steps": "Pasos",
|
||||
"Stitch the kept pieces": "Coser las piezas conservadas",
|
||||
"Stitch to both bodies": "Coser a ambos cuerpos",
|
||||
"Study": "Estudio",
|
||||
"Style": "Estilo",
|
||||
"Suppressed": "Suprimido",
|
||||
@@ -284,6 +287,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "Este elemento secundario es compartido. Los cambios de posición se aplican a todas las copias de su elemento principal.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "Esta cara no permite una vinculación persistente. Elige otra cara o utiliza expresamente un plano fijo.",
|
||||
"To Offset": "Hasta desfase",
|
||||
"To edges": "Aristas de destino",
|
||||
"Tolerance": "Tolerancia",
|
||||
"Too close": "Demasiado cerca",
|
||||
"Trimming tool (plane, face or curves)": "Herramienta de recorte (plano, cara o curvas)",
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"Current orthographic view (1:1 mm)": "Vue orthographique actuelle (1:1 mm)",
|
||||
"Current perspective view": "Vue en perspective actuelle",
|
||||
"Curvature (G2)": "Courbure (G2)",
|
||||
"Curvature change (G3)": "Variation de courbure (G3)",
|
||||
"Customize Toolbar": "Personnaliser la barre d'outils",
|
||||
"Delete all": "Tout supprimer",
|
||||
"Delete rule": "Supprimer la règle",
|
||||
@@ -122,6 +123,7 @@
|
||||
"Follow camera (Look At sketches)": "Suivre la caméra (vue normale aux esquisses)",
|
||||
"Follow the camera (Look At sketches)": "Suivre la caméra (vue normale aux esquisses)",
|
||||
"Font": "Police",
|
||||
"From edges": "Arêtes de départ",
|
||||
"Full Length": "Longueur totale",
|
||||
"Grid": "Grille",
|
||||
"Height": "Hauteur",
|
||||
@@ -265,6 +267,7 @@
|
||||
"Step": "Étape",
|
||||
"Steps": "Étapes",
|
||||
"Stitch the kept pieces": "Coudre les parties conservées",
|
||||
"Stitch to both bodies": "Coudre aux deux corps",
|
||||
"Study": "Étude",
|
||||
"Style": "Style",
|
||||
"Suppressed": "Désactivé",
|
||||
@@ -286,6 +289,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "Cet enfant est partagé. Les changements de position s'appliquent à toutes les copies de son parent.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "Cette face ne peut pas fournir de rattachement durable. Choisissez une autre face ou utilisez explicitement un plan fixe.",
|
||||
"To Offset": "Jusqu'au décalage",
|
||||
"To edges": "Arêtes d'arrivée",
|
||||
"Tolerance": "Tolérance",
|
||||
"Too close": "Trop proches",
|
||||
"Trimming tool (plane, face or curves)": "Outil d'ajustement (plan, face ou courbes)",
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
"Current orthographic view (1:1 mm)": "Vista ortográfica actual (1:1 mm)",
|
||||
"Current perspective view": "Vista en perspectiva actual",
|
||||
"Curvature (G2)": "Curvatura (G2)",
|
||||
"Curvature change (G3)": "Cambio de curvatura (G3)",
|
||||
"Customize Toolbar": "Personalizar a barra de ferramentas",
|
||||
"Delete all": "Eliminar todo",
|
||||
"Delete rule": "Eliminar a regra",
|
||||
@@ -113,6 +114,7 @@
|
||||
"Follow camera (Look At sketches)": "Seguir a cámara (Mirar cara aos bosquexos)",
|
||||
"Follow the camera (Look At sketches)": "Seguir a cámara (Mirar cara aos bosquexos)",
|
||||
"Font": "Tipo de letra",
|
||||
"From edges": "Arestas de orixe",
|
||||
"Full Length": "Lonxitude completa",
|
||||
"Grid": "Grella",
|
||||
"Height": "Altura",
|
||||
@@ -250,6 +252,7 @@
|
||||
"Step": "Paso",
|
||||
"Steps": "Pasos",
|
||||
"Stitch the kept pieces": "Coser as pezas mantidas",
|
||||
"Stitch to both bodies": "Coser aos dous corpos",
|
||||
"Style": "Estilo",
|
||||
"Suppressed": "Suprimida",
|
||||
"Surface": "Superficie",
|
||||
@@ -270,6 +273,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "Este fillo está compartido. Os cambios de posición aplícanse a todas as copias do seu pai.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "Esta cara non pode ofrecer unha ancoraxe duradeira. Escolle outra cara ou usa expresamente un plano fixo.",
|
||||
"To Offset": "Ata o desprazamento",
|
||||
"To edges": "Arestas de destino",
|
||||
"Tolerance": "Tolerancia",
|
||||
"Trimming tool (plane, face or curves)": "Ferramenta de recorte (plano, cara ou curvas)",
|
||||
"Turn off section analysis before exporting the view.": "Desactiva a análise de sección antes de exportar a vista.",
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"Current orthographic view (1:1 mm)": "Vista ortografica corrente (1:1 mm)",
|
||||
"Current perspective view": "Vista prospettica corrente",
|
||||
"Curvature (G2)": "Curvatura (G2)",
|
||||
"Curvature change (G3)": "Variazione di curvatura (G3)",
|
||||
"Customize Toolbar": "Personalizza barra degli strumenti",
|
||||
"Delete all": "Elimina tutto",
|
||||
"Delete rule": "Elimina regola",
|
||||
@@ -121,6 +122,7 @@
|
||||
"Follow camera (Look At sketches)": "Segui la camera (Vista normale agli schizzi)",
|
||||
"Follow the camera (Look At sketches)": "Segui la camera (Vista normale agli schizzi)",
|
||||
"Font": "Carattere",
|
||||
"From edges": "Spigoli di partenza",
|
||||
"Full Length": "Lunghezza totale",
|
||||
"Grid": "Griglia",
|
||||
"Height": "Altezza",
|
||||
@@ -260,6 +262,7 @@
|
||||
"Stand this part up?": "Raddrizzare questa parte?",
|
||||
"Step": "Passo",
|
||||
"Steps": "Passi",
|
||||
"Stitch to both bodies": "Cuci a entrambi i corpi",
|
||||
"Study": "Studio",
|
||||
"Style": "Stile",
|
||||
"Suppressed": "Sospeso",
|
||||
@@ -279,6 +282,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "Questo elemento figlio è condiviso. Le modifiche alla posizione si applicano a ogni copia del padre.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "Questa faccia non consente un collegamento persistente. Scegli un'altra faccia o usa esplicitamente un piano fisso.",
|
||||
"To Offset": "Fino a una distanza",
|
||||
"To edges": "Spigoli di arrivo",
|
||||
"Tolerance": "Tolleranza",
|
||||
"Too close": "Troppo vicini",
|
||||
"Turn off section analysis before exporting the view.": "Disattiva l'analisi in sezione prima di esportare la vista.",
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"Arc length": "円弧の長さ",
|
||||
"Area": "表面積",
|
||||
"Attachment": "アタッチメント",
|
||||
"BLEND SURFACE": "ブレンドサーフェス",
|
||||
"BOUNDARY SURFACE": "境界サーフェス",
|
||||
"BROWSER": "ブラウザ",
|
||||
"Bend Line Position": "曲げ線位置",
|
||||
@@ -79,6 +80,7 @@
|
||||
"Current orthographic view (1:1 mm)": "現在の平行投影(実寸・mm)",
|
||||
"Current perspective view": "現在の透視投影",
|
||||
"Curvature (G2)": "曲率 (G2)",
|
||||
"Curvature change (G3)": "曲率変化 (G3)",
|
||||
"Customize Toolbar": "ツールバーのカスタマイズ",
|
||||
"Delete all": "すべて削除",
|
||||
"Delete rule": "ルールを削除",
|
||||
@@ -100,6 +102,8 @@
|
||||
"Edit Profile Sketch": "プロファイルスケッチを編集",
|
||||
"Enable rule": "ルールを有効化",
|
||||
"Enabled": "有効",
|
||||
"End bulge": "終了側の膨らみ",
|
||||
"End continuity": "終了側の連続性",
|
||||
"Explode": "分解",
|
||||
"Explode Text": "テキストを分解",
|
||||
"Export Animation…": "アニメーションをエクスポート…",
|
||||
@@ -122,6 +126,7 @@
|
||||
"Follow camera (Look At sketches)": "カメラ追従(スケッチを正面視)",
|
||||
"Follow the camera (Look At sketches)": "カメラ追従(スケッチを正面視)",
|
||||
"Font": "フォント",
|
||||
"From edges": "開始側エッジ",
|
||||
"Full Length": "全長",
|
||||
"Grid": "グリッド",
|
||||
"Height": "高さ",
|
||||
@@ -262,9 +267,12 @@
|
||||
"Stand it up": "正立させる",
|
||||
"Stand it up: a quarter turn about X, as one Move feature you can undo.": "正立させる: 取り消し可能な1つの移動フィーチャーとして、X軸周りに90度回転します。",
|
||||
"Stand this part up?": "このパーツを正立させますか?",
|
||||
"Start bulge": "開始側の膨らみ",
|
||||
"Start continuity": "開始側の連続性",
|
||||
"Step": "ステップ",
|
||||
"Steps": "ステップ数",
|
||||
"Stitch the kept pieces": "残した部分をステッチ",
|
||||
"Stitch to both bodies": "両方のボディにステッチ",
|
||||
"Study": "スタディ",
|
||||
"Style": "スタイル",
|
||||
"Suppressed": "抑制",
|
||||
@@ -286,6 +294,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "この子要素は共有されています。位置の変更は親のすべてのコピーに適用されます。",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "この面は安定したアタッチメントを提供できません。別の面を選択するか、固定平面を明示的に使用してください。",
|
||||
"To Offset": "オフセットまで",
|
||||
"To edges": "終了側エッジ",
|
||||
"Tolerance": "公差",
|
||||
"Too close": "近すぎる",
|
||||
"Trimming tool (plane, face or curves)": "トリムツール(平面、面、または曲線)",
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"Current orthographic view (1:1 mm)": "현재 직교 투영 뷰 (1:1 mm)",
|
||||
"Current perspective view": "현재 원근 투영 뷰",
|
||||
"Curvature (G2)": "곡률 (G2)",
|
||||
"Curvature change (G3)": "곡률 변화 (G3)",
|
||||
"Direction": "방향",
|
||||
"Do not export hidden edges": "숨겨진 모서리 내보내지 않기",
|
||||
"Don't ask again": "다시 묻지 않기",
|
||||
@@ -44,6 +45,7 @@
|
||||
"Faces": "면",
|
||||
"Find in Browser": "브라우저에서 찾기",
|
||||
"Flat": "플랫",
|
||||
"From edges": "시작 모서리",
|
||||
"Hidden edges": "숨겨진 모서리",
|
||||
"Holes": "구멍",
|
||||
"Holes (edges on them)": "구멍 (구멍의 모서리)",
|
||||
@@ -92,6 +94,7 @@
|
||||
"Sketch points": "스케치 점",
|
||||
"Slot width": "슬롯 폭",
|
||||
"Stitch the kept pieces": "유지한 부분 재봉",
|
||||
"Stitch to both bodies": "두 바디에 재봉",
|
||||
"Study": "연구",
|
||||
"Surface": "곡면",
|
||||
"TRIM": "트림",
|
||||
@@ -100,6 +103,7 @@
|
||||
"Thickness Outside": "바깥쪽 두께",
|
||||
"Thin": "얇은 벽",
|
||||
"Thin Extrude": "얇은 벽 돌출",
|
||||
"To edges": "끝 모서리",
|
||||
"Trimming tool (plane, face or curves)": "트림 도구(평면, 면 또는 곡선)",
|
||||
"Turn off section analysis before exporting the view.": "뷰를 내보내기 전에 단면 분석을 끄세요.",
|
||||
"Type": "유형",
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
"Current orthographic view (1:1 mm)": "Vista ortográfica atual (1:1 mm)",
|
||||
"Current perspective view": "Vista em perspectiva atual",
|
||||
"Curvature (G2)": "Curvatura (G2)",
|
||||
"Curvature change (G3)": "Variação de curvatura (G3)",
|
||||
"Customize Toolbar": "Personalizar barra de ferramentas",
|
||||
"Delete all": "Excluir tudo",
|
||||
"Delete rule": "Excluir regra",
|
||||
@@ -113,6 +114,7 @@
|
||||
"Follow camera (Look At sketches)": "Seguir a câmera (Olhar para os esboços)",
|
||||
"Follow the camera (Look At sketches)": "Seguir a câmera (Olhar para os esboços)",
|
||||
"Font": "Fonte",
|
||||
"From edges": "Arestas de origem",
|
||||
"Full Length": "Comprimento total",
|
||||
"Grid": "Grade",
|
||||
"Height": "Altura",
|
||||
@@ -250,6 +252,7 @@
|
||||
"Step": "Passo",
|
||||
"Steps": "Passos",
|
||||
"Stitch the kept pieces": "Costurar as partes mantidas",
|
||||
"Stitch to both bodies": "Costurar aos dois corpos",
|
||||
"Style": "Estilo",
|
||||
"Suppressed": "Suprimido",
|
||||
"Surface": "Superfície",
|
||||
@@ -270,6 +273,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "Este filho é compartilhado. Mudanças de posição se aplicam a todas as cópias do pai.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "Esta face não pode fornecer uma fixação duradoura. Escolha outra face ou use explicitamente um plano fixo.",
|
||||
"To Offset": "Deslocamento final",
|
||||
"To edges": "Arestas de destino",
|
||||
"Tolerance": "Tolerância",
|
||||
"Trimming tool (plane, face or curves)": "Ferramenta de aparo (plano, face ou curvas)",
|
||||
"Turn off section analysis before exporting the view.": "Desative a análise de seção antes de exportar a vista.",
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
"Create Issue — review draft": "Создать Issue — проверить черновик",
|
||||
"Cube": "Куб",
|
||||
"Curvature (G2)": "Кривизна (G2)",
|
||||
"Curvature change (G3)": "Изменение кривизны (G3)",
|
||||
"Customize Toolbar": "Настроить панель инструментов",
|
||||
"Delete all": "Удалить все",
|
||||
"Delete rule": "Удалить правило",
|
||||
@@ -102,6 +103,7 @@
|
||||
"Follow camera (Look At sketches)": "Следовать за камерой (эскизы «Взгляд на»)",
|
||||
"Follow the camera (Look At sketches)": "Следовать за камерой (эскизы «Взгляд на»)",
|
||||
"Font": "Шрифт",
|
||||
"From edges": "Начальные рёбра",
|
||||
"Full Length": "Полная длина",
|
||||
"Grid": "Сетка",
|
||||
"Height": "Высота",
|
||||
@@ -223,6 +225,7 @@
|
||||
"Step": "Шаг",
|
||||
"Steps": "Шаги",
|
||||
"Stitch the kept pieces": "Сшить оставленные части",
|
||||
"Stitch to both bodies": "Сшить с обоими телами",
|
||||
"Study": "Исследование",
|
||||
"Style": "Стиль",
|
||||
"Suppressed": "Подавлено",
|
||||
@@ -241,6 +244,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "Этот дочерний объект общий. Изменения положения применятся ко всем копиям родителя.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "Эта грань не может обеспечить надёжную привязку. Выберите другую грань или явно используйте фиксированную плоскость.",
|
||||
"To Offset": "До смещения",
|
||||
"To edges": "Конечные рёбра",
|
||||
"Tolerance": "Допуск",
|
||||
"Trimming tool (plane, face or curves)": "Инструмент обрезки (плоскость, грань или кривые)",
|
||||
"Type": "Тип",
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
"Countersink angle": "Konik havşa açısı",
|
||||
"Create Issue — review draft": "Sorun oluştur — taslağı gözden geçirin",
|
||||
"Cube": "Küp",
|
||||
"Curvature change (G3)": "Eğrilik değişimi (G3)",
|
||||
"Customize Toolbar": "Araç çubuğunu özelleştir",
|
||||
"Delete all": "Tümünü sil",
|
||||
"Delete rule": "Kuralı sil",
|
||||
@@ -107,6 +108,7 @@
|
||||
"Follow camera (Look At sketches)": "Kamera takibi (eskizlerde Bak)",
|
||||
"Follow the camera (Look At sketches)": "Kamera takibi (eskizlerde Bak)",
|
||||
"Font": "Yazı tipi",
|
||||
"From edges": "Başlangıç kenarları",
|
||||
"Full Length": "Tam uzunluk",
|
||||
"Grid": "Izgara",
|
||||
"Height": "Yükseklik",
|
||||
@@ -241,6 +243,7 @@
|
||||
"Step": "Adım",
|
||||
"Steps": "Adımlar",
|
||||
"Stitch the kept pieces": "Korunan parçaları dik",
|
||||
"Stitch to both bodies": "Her iki gövdeye dik",
|
||||
"Study": "Etüt",
|
||||
"Style": "Stil",
|
||||
"Suppressed": "Bastırılmış",
|
||||
@@ -260,6 +263,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "Bu alt öğe paylaşılıyor. Konum değişiklikleri üst öğesinin tüm kopyalarına uygulanır.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "Bu yüz kalıcı bir bağlama sağlayamaz. Başka bir yüz seçin veya açıkça sabit bir düzlem kullanın.",
|
||||
"To Offset": "Ofsete kadar",
|
||||
"To edges": "Bitiş kenarları",
|
||||
"Tolerance": "Tolerans",
|
||||
"Trimming tool (plane, face or curves)": "Kırpma aracı (düzlem, yüz veya eğriler)",
|
||||
"Type": "Tür",
|
||||
|
||||
@@ -79,6 +79,7 @@
|
||||
"Current orthographic view (1:1 mm)": "Поточний ортографічний вид (1:1 mm)",
|
||||
"Current perspective view": "Поточний перспективний вид",
|
||||
"Curvature (G2)": "Кривина (G2)",
|
||||
"Curvature change (G3)": "Зміна кривини (G3)",
|
||||
"Customize Toolbar": "Налаштувати панель інструментів",
|
||||
"Delete all": "Видалити все",
|
||||
"Delete rule": "Видалити правило",
|
||||
@@ -122,6 +123,7 @@
|
||||
"Follow camera (Look At sketches)": "Стежити за камерою (ескізи наведення)",
|
||||
"Follow the camera (Look At sketches)": "Стежити за камерою (ескізи наведення)",
|
||||
"Font": "Шрифт",
|
||||
"From edges": "Початкові ребра",
|
||||
"Full Length": "Повна довжина",
|
||||
"Grid": "Сітка",
|
||||
"Height": "Висота",
|
||||
@@ -265,6 +267,7 @@
|
||||
"Step": "Крок",
|
||||
"Steps": "Кроки",
|
||||
"Stitch the kept pieces": "Зшити залишені частини",
|
||||
"Stitch to both bodies": "Зшити з обома тілами",
|
||||
"Study": "Дослідження",
|
||||
"Style": "Стиль",
|
||||
"Suppressed": "Придушено",
|
||||
@@ -286,6 +289,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "Цей дочірній об'єкт спільний. Зміни положення застосовуються до кожної копії батьківського.",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "Ця грань не може забезпечити надійну прив'язку. Виберіть іншу грань або явно використайте фіксовану площину.",
|
||||
"To Offset": "До зсуву",
|
||||
"To edges": "Кінцеві ребра",
|
||||
"Tolerance": "Допуск",
|
||||
"Too close": "Занадто близько",
|
||||
"Trimming tool (plane, face or curves)": "Інструмент обрізання (площина, грань або криві)",
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
"Arc length": "弧长",
|
||||
"Area": "面积",
|
||||
"Attachment": "附着",
|
||||
"BLEND SURFACE": "混合曲面",
|
||||
"BOUNDARY SURFACE": "边界曲面",
|
||||
"BROWSER": "浏览器",
|
||||
"Bend Line Position": "弯折线位置",
|
||||
@@ -79,6 +80,7 @@
|
||||
"Current orthographic view (1:1 mm)": "当前正交视图(1:1毫米)",
|
||||
"Current perspective view": "当前透视视图",
|
||||
"Curvature (G2)": "曲率 (G2)",
|
||||
"Curvature change (G3)": "曲率变化 (G3)",
|
||||
"Customize Toolbar": "自定义工具栏",
|
||||
"Delete all": "全部删除",
|
||||
"Delete rule": "删除规则",
|
||||
@@ -100,6 +102,8 @@
|
||||
"Edit Profile Sketch": "编辑轮廓草图",
|
||||
"Enable rule": "启用规则",
|
||||
"Enabled": "已启用",
|
||||
"End bulge": "终止鼓度",
|
||||
"End continuity": "终止连续性",
|
||||
"Explode": "爆炸",
|
||||
"Explode Text": "分解文字",
|
||||
"Export Animation…": "导出动画…",
|
||||
@@ -122,6 +126,7 @@
|
||||
"Follow camera (Look At sketches)": "跟随相机(注视草图)",
|
||||
"Follow the camera (Look At sketches)": "跟随相机(注视草图)",
|
||||
"Font": "字体",
|
||||
"From edges": "起始边",
|
||||
"Full Length": "全长",
|
||||
"Grid": "网格",
|
||||
"Height": "高度",
|
||||
@@ -262,9 +267,12 @@
|
||||
"Stand it up": "将其立起",
|
||||
"Stand it up: a quarter turn about X, as one Move feature you can undo.": "将其立起:绕 X 轴旋转四分之一周,作为一个可撤销的移动特征。",
|
||||
"Stand this part up?": "立起此零件?",
|
||||
"Start bulge": "起始鼓度",
|
||||
"Start continuity": "起始连续性",
|
||||
"Step": "步骤",
|
||||
"Steps": "步数",
|
||||
"Stitch the kept pieces": "缝合保留的部分",
|
||||
"Stitch to both bodies": "缝合到两个实体",
|
||||
"Study": "研究",
|
||||
"Style": "样式",
|
||||
"Suppressed": "已抑制",
|
||||
@@ -286,6 +294,7 @@
|
||||
"This child is shared. Position changes apply to every copy of its parent.": "此子项是共享的。位置更改会应用到其父项的每个副本。",
|
||||
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "此面无法提供持久附着。请选择其他面或显式使用固定平面。",
|
||||
"To Offset": "偏移",
|
||||
"To edges": "终止边",
|
||||
"Tolerance": "公差",
|
||||
"Too close": "过近",
|
||||
"Trimming tool (plane, face or curves)": "修剪工具(平面、面或曲线)",
|
||||
|
||||
@@ -1455,6 +1455,11 @@ pub enum FeatureKind {
|
||||
/// Points the blend leaves towards, when the faces at the picks do not say: [from, to].
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
align: Option<[Position; 2]>,
|
||||
/// Where each chain's stations start, when two closed chains should not pair the way
|
||||
/// that keeps the blend from twisting: a point on each chain, [from, to]. An open chain
|
||||
/// starts at the end nearer its point.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
seam: Option<[Position; 2]>,
|
||||
/// Sew the blend onto its two bodies where the boundaries meet.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
stitch: bool,
|
||||
|
||||
@@ -141,7 +141,7 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
FeatureKind::SurfaceBlend { from, to, continuity, bulge, align, stitch } => {
|
||||
FeatureKind::SurfaceBlend { from, to, continuity, bulge, align, seam, stitch } => {
|
||||
let a = st.body(&from.body).ok_or_else(|| DocError::Unknown(format!("body `{}`", from.body)))?.body.clone();
|
||||
let b = st.body(&to.body).ok_or_else(|| DocError::Unknown(format!("body `{}`", to.body)))?.body.clone();
|
||||
if from.edges.is_empty() || to.edges.is_empty() {
|
||||
@@ -155,6 +155,7 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature,
|
||||
*continuity,
|
||||
*bulge,
|
||||
align.map(|[p, q]| [p.0, q.0]),
|
||||
seam.map(|[p, q]| [p.0, q.0]),
|
||||
BLEND_STATIONS,
|
||||
*stitch,
|
||||
)?;
|
||||
|
||||
@@ -159,10 +159,16 @@ pub(super) fn fixtures() -> Vec<(&'static str, Value)> {
|
||||
"orientation": "parallel", "twist": "surface_sweep.twist", "scale": "surface_sweep.scale"}),
|
||||
),
|
||||
("surface_loft", json!({"type": "surface_loft", "sections": []})),
|
||||
("surface_blend", json!({"type": "surface_blend", "from": {"body": "B", "edges": [o]}, "to": {"body": "C", "edges": [o]}, "align": [o, o]})),
|
||||
(
|
||||
"surface_blend",
|
||||
json!({"type": "surface_blend", "from": {"body": "B", "edges": [o]}, "to": {"body": "C", "edges": [o]}, "align": [o, o], "seam": [o, o]}),
|
||||
),
|
||||
("surface_offset", json!({"type": "surface_offset", "faces": [o], "distance": "soff.distance", "tolerance": "soff.tolerance"})),
|
||||
// The Class-A surface family (surface.blend/boundary/match/fair).
|
||||
("surface_blend", json!({"type": "surface_blend", "from": {"body": "B", "edges": [o]}, "to": {"body": "C", "edges": [o]}, "align": [o, o]})),
|
||||
(
|
||||
"surface_blend",
|
||||
json!({"type": "surface_blend", "from": {"body": "B", "edges": [o]}, "to": {"body": "C", "edges": [o]}, "align": [o, o], "seam": [o, o]}),
|
||||
),
|
||||
("surface_boundary", json!({"type": "surface_boundary", "sketch": 1, "curves": ["l1", "l2"]})),
|
||||
(
|
||||
"surface_network",
|
||||
|
||||
@@ -150,12 +150,12 @@ surface_sweep
|
||||
surface_sweep_options
|
||||
surface_loft
|
||||
surface_blend
|
||||
moves: align[0][0], align[0][1], align[0][2], align[1][0], align[1][1], align[1][2], from.edges[0][0], from.edges[0][1], from.edges[0][2], to.edges[0][0], to.edges[0][1], to.edges[0][2]
|
||||
moves: align[0][0], align[0][1], align[0][2], align[1][0], align[1][1], align[1][2], from.edges[0][0], from.edges[0][1], from.edges[0][2], seam[0][0], seam[0][1], seam[0][2], seam[1][0], seam[1][1], seam[1][2], to.edges[0][0], to.edges[0][1], to.edges[0][2]
|
||||
surface_offset
|
||||
moves: faces[0][0], faces[0][1], faces[0][2]
|
||||
face points: [0, 0, 0]
|
||||
surface_blend
|
||||
moves: align[0][0], align[0][1], align[0][2], align[1][0], align[1][1], align[1][2], from.edges[0][0], from.edges[0][1], from.edges[0][2], to.edges[0][0], to.edges[0][1], to.edges[0][2]
|
||||
moves: align[0][0], align[0][1], align[0][2], align[1][0], align[1][1], align[1][2], from.edges[0][0], from.edges[0][1], from.edges[0][2], seam[0][0], seam[0][1], seam[0][2], seam[1][0], seam[1][1], seam[1][2], to.edges[0][0], to.edges[0][1], to.edges[0][2]
|
||||
surface_boundary
|
||||
surface_network
|
||||
moves: u[1].edges[0][0], u[1].edges[0][1], u[1].edges[0][2], v[1].point[0], v[1].point[1], v[1].point[2]
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
//! A `SurfaceBlend` (Blend Surface, #764) may save `seam`: a point on each of its two edge chains
|
||||
//! where their stations start. Older designs need no transformation: a blend without `seam` pairs
|
||||
//! its chains by itself; the last release asks for an update instead of meeting a seam it can't
|
||||
//! read.
|
||||
@@ -63,7 +63,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
CommandSpec::new("surface.blend", "Blend Surface", blend)
|
||||
.at("SURFACE", "CREATE")
|
||||
.icon("surface_blend")
|
||||
.params("from, to: {body, edges: [[x,y,z]]} (points on the edges of one chain of each body: two picks on the same edge is that one edge, more chain up); continuity?: [g0|g1|g2|g3, g0|g1|g2|g3] (each end, default g1: how much of the surface at the picked edges the blend repeats — the tangent plane, the curvature, or how that curvature changes); bulge?: [number, number] (default 0: how full each end leaves, -0.9 flattest to 3 fullest); align?: [[x,y,z], [x,y,z]] (a point each end leaves towards, when the faces at the picks do not say); stitch?: bool (sew the blend onto its two bodies where the boundaries meet, replacing them); name?, body_name?"),
|
||||
.params("from, to: {body, edges: [[x,y,z]]} (points on the edges of one chain of each body: two picks on the same edge is that one edge, more chain up); continuity?: [g0|g1|g2|g3, g0|g1|g2|g3] (each end, default g1: how much of the surface at the picked edges the blend repeats — the tangent plane, the curvature, or how that curvature changes); bulge?: [number, number] (default 0: how full each end leaves, -0.9 flattest to 3 fullest); align?: [[x,y,z], [x,y,z]] (a point each end leaves towards, when the faces at the picks do not say); seam?: [[x,y,z], [x,y,z]] (a point on each chain its stations start from: two closed chains otherwise pair the way that keeps the blend from twisting; an open chain starts at the end nearer its point; a closed chain blends only to a closed chain); stitch?: bool (sew the blend onto its two bodies where the boundaries meet, replacing them); name?, body_name?"),
|
||||
CommandSpec::new("surface.untrim", "Untrim", untrim)
|
||||
.at("SURFACE", "MODIFY")
|
||||
.icon("surface_untrim")
|
||||
@@ -237,18 +237,18 @@ fn blend(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
[one(list.first())?, one(list.get(1))?]
|
||||
}
|
||||
};
|
||||
let align = match p.get("align") {
|
||||
None | Some(Value::Null) => None,
|
||||
Some(v) => {
|
||||
let list = v.as_array().filter(|a| a.len() == 2).ok_or_else(|| bad(cmd, "`align` must be two points, one per end"))?;
|
||||
let point = |x: Option<&Value>| -> Result<solidcraft_geom::Vec3> {
|
||||
x.and_then(vec3).ok_or_else(|| bad(cmd, "each `align` entry must be a point [x,y,z]"))
|
||||
};
|
||||
Some([Position(point(list.first())?), Position(point(list.get(1))?)])
|
||||
}
|
||||
};
|
||||
let align = point_pair(p, cmd, "align", "one per end")?;
|
||||
let seam = point_pair(p, cmd, "seam", "one on each chain")?;
|
||||
let stitch = bool_(p, "stitch").unwrap_or(false);
|
||||
add_feature(s, p, FeatureKind::SurfaceBlend { from, to, continuity, bulge, align, stitch })
|
||||
add_feature(s, p, FeatureKind::SurfaceBlend { from, to, continuity, bulge, align, seam, stitch })
|
||||
}
|
||||
|
||||
/// An optional pair of points `key` (`null` as none): `which` says what each one is.
|
||||
fn point_pair(p: &Value, cmd: &str, key: &str, which: &str) -> Result<Option<[Position; 2]>> {
|
||||
let Some(v) = p.get(key).filter(|v| !v.is_null()) else { return Ok(None) };
|
||||
let list = v.as_array().filter(|a| a.len() == 2).ok_or_else(|| bad(cmd, format!("`{key}` must be two points, {which}")))?;
|
||||
let point = |x: Option<&Value>| x.and_then(vec3).map(Position).ok_or_else(|| bad(cmd, format!("each `{key}` entry must be a point [x,y,z]")));
|
||||
Ok(Some([point(list.first())?, point(list.get(1))?]))
|
||||
}
|
||||
|
||||
fn surface_extrude(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
@@ -1807,6 +1807,57 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// `surface.blend` between two tube rims: each rim runs along both halves of its tube's wall
|
||||
/// (two faces), the rims are closed, and the blend is the wall between them, straight up the
|
||||
/// axis. Picked `seam` points turn it, are saved with the design, and a closed rim does not
|
||||
/// blend to an open edge.
|
||||
#[test]
|
||||
fn surface_blend_bridges_two_tube_rims() {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.cylinder", json!({"radius": 10, "height": 30, "body_name": "Low"}));
|
||||
run(&mut s, "surface.unstitch", json!({"body": "Low", "faces": [[0, 0, 30]]}));
|
||||
run(&mut s, "solid.cylinder", json!({"radius": 10, "height": 30, "base": [0, 0, 40], "body_name": "High"}));
|
||||
run(&mut s, "surface.unstitch", json!({"body": "High", "faces": [[0, 0, 40]]}));
|
||||
let rim = |z: f64| -> Value {
|
||||
json!((0..8).map(|k| f64::from(k) * 0.785 + 0.1).map(|a| json!([10.0 * a.cos(), 10.0 * a.sin(), z])).collect::<Vec<_>>())
|
||||
};
|
||||
// Unstitching keeps the wall under the body's own name.
|
||||
let blend = json!({"from": {"body": "Low", "edges": rim(30.0)}, "to": {"body": "High", "edges": rim(40.0)}, "continuity": ["g1", "g1"], "body_name": "Neck"});
|
||||
run(&mut s, "surface.blend", blend.clone());
|
||||
// The wall between: radius 10 and straight up, so 2π·10·10 of area.
|
||||
let want = 2.0 * std::f64::consts::PI * 100.0;
|
||||
assert!((area(&s, "Neck") - want).abs() < want * 1e-3, "{} vs {want}", area(&s, "Neck"));
|
||||
let turn = |s: &Session, name: &str| {
|
||||
let grid = solidcraft_kernel::sample_grid(&s.world_state().body(name).unwrap().body, 17, 5).unwrap();
|
||||
grid.iter()
|
||||
.map(|row| {
|
||||
let (a, b) = (row[0], row[row.len() - 1]);
|
||||
(a.y.atan2(a.x) - b.y.atan2(b.x)).rem_euclid(std::f64::consts::TAU).to_degrees()
|
||||
})
|
||||
.map(|d| d.min(360.0 - d))
|
||||
.fold(0.0, f64::max)
|
||||
};
|
||||
assert!(turn(&s, "Neck") < 0.1, "straight up the axis: {}°", turn(&s, "Neck"));
|
||||
// Seams a quarter apart: the blend turns a quarter round, and reads back the same.
|
||||
let mut turned = blend.clone();
|
||||
turned["seam"] = json!([[10, 0, 30], [0, 10, 40]]);
|
||||
turned["body_name"] = json!("Twist");
|
||||
run(&mut s, "surface.blend", turned);
|
||||
assert!((turn(&s, "Twist") - 90.0).abs() < 0.1, "{}°", turn(&s, "Twist"));
|
||||
assert!(s.doc.to_json().contains("\"seam\""), "the seam is saved");
|
||||
let cold = Session::new(solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap());
|
||||
assert!((turn(&cold, "Twist") - 90.0).abs() < 0.1, "read back: {}°", turn(&cold, "Twist"));
|
||||
// A closed rim does not blend to an open edge; a seam that is not two points is refused.
|
||||
run(&mut s, "solid.box", json!({"length": 40, "width": 10, "height": 10, "corner": [-20, 30, 30], "body_name": "Block"}));
|
||||
let open = s.execute("surface.blend", &json!({"from": {"body": "Low", "edges": rim(30.0)}, "to": {"body": "Block", "edges": [[0, 30, 40]]}}));
|
||||
assert!(open.as_ref().is_err_and(|e| e.to_string().contains("closed chain")), "{open:?}");
|
||||
for seam in [json!([[0, 0, 0]]), json!("x"), json!([[0, 0, 0], "y"])] {
|
||||
let mut bad = blend.clone();
|
||||
bad["seam"] = seam.clone();
|
||||
assert!(s.execute("surface.blend", &bad).is_err(), "{seam}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A tube whose top face is taken off (`surface.unstitch`), and points round its rim.
|
||||
fn open_tube() -> (Session, Value) {
|
||||
let mut s = Session::default();
|
||||
|
||||
@@ -803,6 +803,7 @@ fn hostile_params_never_panic() {
|
||||
"kind",
|
||||
"prefix",
|
||||
"orientation",
|
||||
"seam",
|
||||
"twist",
|
||||
"scale",
|
||||
"continuity",
|
||||
|
||||
+319
-100
@@ -137,49 +137,161 @@ pub fn chain_closes(chain: &[mt::Edge]) -> bool {
|
||||
first.front().id() == last.back().id()
|
||||
}
|
||||
|
||||
/// The stations of a chain of edges, `count` of them evenly along its length, and the length
|
||||
/// itself. A chain that closes is sampled with its last station back on its first.
|
||||
fn chain_samples(edges: &[mt::Edge], count: usize) -> Result<(Vec<Vec3>, f64)> {
|
||||
/// Samples per edge used for the length table.
|
||||
const PER_EDGE: usize = 64;
|
||||
let mut poly: Vec<Vec3> = Vec::with_capacity(edges.len() * (PER_EDGE + 1));
|
||||
for e in edges {
|
||||
let c = e.curve();
|
||||
let (t0, t1) = c.range_tuple();
|
||||
if !(t1 > t0) || ![t0, t1].into_iter().all(f64::is_finite) {
|
||||
return Err(KernelError::Invalid("an edge has no parameter range".into()));
|
||||
/// A point of a [`ChainLine`]'s polyline: where it is, its arclength along the chain, the chain
|
||||
/// edge (its index) the segment from it runs along, and that edge's curve parameter there.
|
||||
#[derive(Clone, Copy)]
|
||||
struct Sample {
|
||||
p: Vec3,
|
||||
s: f64,
|
||||
edge: usize,
|
||||
t: f64,
|
||||
}
|
||||
|
||||
/// A chain of edges measured by arclength through a fine polyline on it, so that a station is read
|
||||
/// on the edge's own curve, not on a chord. A chain that closes ends back on its first point.
|
||||
struct ChainLine {
|
||||
curves: Vec<mt::Curve>,
|
||||
samples: Vec<Sample>,
|
||||
closed: bool,
|
||||
}
|
||||
|
||||
impl ChainLine {
|
||||
fn of(edges: &[mt::Edge]) -> Result<ChainLine> {
|
||||
/// Samples per edge used for the length table.
|
||||
const PER_EDGE: usize = 64;
|
||||
let mut samples: Vec<Sample> = Vec::with_capacity(edges.len() * (PER_EDGE + 1) + 1);
|
||||
let mut curves = Vec::with_capacity(edges.len());
|
||||
let push = |samples: &mut Vec<Sample>, p: Vec3, edge: usize, t: f64| {
|
||||
let s = samples.last().map_or(0.0, |last| last.s + last.p.dist(p));
|
||||
samples.push(Sample { p, s, edge, t });
|
||||
};
|
||||
for (i, e) in edges.iter().enumerate() {
|
||||
let c = e.curve();
|
||||
let (t0, t1) = c.range_tuple();
|
||||
if !(t1 > t0) || ![t0, t1].into_iter().all(f64::is_finite) {
|
||||
return Err(KernelError::Invalid("an edge has no parameter range".into()));
|
||||
}
|
||||
for k in 0..=PER_EDGE {
|
||||
// The segment that starts at this point: along this edge, or the zero-length join
|
||||
// to the next edge.
|
||||
let t = t0 + (t1 - t0) * k as f64 / PER_EDGE as f64;
|
||||
push(&mut samples, from_p3(c.subs(t)), i, t);
|
||||
}
|
||||
curves.push(c);
|
||||
}
|
||||
for k in 0..=PER_EDGE {
|
||||
poly.push(from_p3(c.subs(t0 + (t1 - t0) * k as f64 / PER_EDGE as f64)));
|
||||
let closed = chain_closes(edges);
|
||||
if closed && let Some(first) = samples.first().copied() {
|
||||
push(&mut samples, first.p, edges.len().saturating_sub(1), first.t);
|
||||
}
|
||||
let line = ChainLine { curves, samples, closed };
|
||||
let total = line.length();
|
||||
if !(total > 1e-9) || !total.is_finite() {
|
||||
return Err(KernelError::Invalid("the edge chain has no length".into()));
|
||||
}
|
||||
Ok(line)
|
||||
}
|
||||
if chain_closes(edges)
|
||||
&& let Some(first) = poly.first().copied()
|
||||
{
|
||||
poly.push(first);
|
||||
|
||||
fn length(&self) -> f64 {
|
||||
self.samples.last().map_or(0.0, |x| x.s)
|
||||
}
|
||||
let mut cum = Vec::with_capacity(poly.len());
|
||||
cum.push(0.0);
|
||||
for w in poly.windows(2) {
|
||||
let (Some(a), Some(b)) = (w.first(), w.get(1)) else { continue };
|
||||
let Some(last) = cum.last().copied() else { break };
|
||||
cum.push(last + a.dist(*b));
|
||||
|
||||
/// The point at arclength `s` (wrapped round a closed chain, clamped on an open one), on its
|
||||
/// edge's own curve, and the chain edge it is on.
|
||||
fn at(&self, s: f64) -> Result<(Vec3, usize)> {
|
||||
let total = self.length();
|
||||
let s = if self.closed { s.rem_euclid(total) } else { s.clamp(0.0, total) };
|
||||
let hi = self.samples.partition_point(|x| x.s < s).clamp(1, self.samples.len().saturating_sub(1));
|
||||
let fail = || KernelError::Failed("bridge: sample".into());
|
||||
let (lo, hi) = (self.samples.get(hi - 1).ok_or_else(fail)?, self.samples.get(hi).ok_or_else(fail)?);
|
||||
let curve = self.curves.get(lo.edge).ok_or_else(fail)?;
|
||||
let span = hi.s - lo.s;
|
||||
if !(span > 1e-12) {
|
||||
// The zero-length join between two edges: the end of the edge it belongs to.
|
||||
return Ok((from_p3(curve.subs(lo.t)), lo.edge));
|
||||
}
|
||||
let f = ((s - lo.s) / span).clamp(0.0, 1.0);
|
||||
Ok((from_p3(curve.subs(lo.t + (hi.t - lo.t) * f)), lo.edge))
|
||||
}
|
||||
let total = cum.last().copied().unwrap_or(0.0);
|
||||
if !(total > 1e-9) || !total.is_finite() {
|
||||
return Err(KernelError::Invalid("the edge chain has no length".into()));
|
||||
|
||||
/// `count` stations evenly along the chain, from arclength `start` (a closed chain's seam; an
|
||||
/// open chain always runs end to end), forwards or backwards. A closed chain's last station is
|
||||
/// back on its first.
|
||||
fn stations(&self, count: usize, start: f64, backwards: bool) -> Result<Vec<(Vec3, usize)>> {
|
||||
let total = self.length();
|
||||
let start = if self.closed {
|
||||
start
|
||||
} else if backwards {
|
||||
total
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let sign = if backwards { -1.0 } else { 1.0 };
|
||||
(0..count).map(|i| self.at(start + sign * total * i as f64 / (count.max(2) - 1) as f64)).collect()
|
||||
}
|
||||
let mut out = Vec::with_capacity(count);
|
||||
for i in 0..count {
|
||||
let s = total * i as f64 / (count.max(2) - 1) as f64;
|
||||
let hi = cum.partition_point(|x| *x < s).clamp(1, poly.len().saturating_sub(1));
|
||||
let (Some(a), Some(b)) = (poly.get(hi - 1), poly.get(hi)) else { return Err(KernelError::Failed("bridge: sample".into())) };
|
||||
let (Some(&lo), Some(&hi_s)) = (cum.get(hi - 1), cum.get(hi)) else { return Err(KernelError::Failed("bridge: sample".into())) };
|
||||
let span = hi_s - lo;
|
||||
let t = if span > 1e-12 { (s - lo) / span } else { 0.0 };
|
||||
out.push(*a + (*b - *a) * t);
|
||||
|
||||
/// The chain edges `p` (a station on chain edge `edge`) lies on: that edge, and the edge before
|
||||
/// or after it when `p` is on the vertex they share.
|
||||
fn edges_at(&self, p: Vec3, edge: usize) -> [Option<usize>; 3] {
|
||||
let count = self.curves.len();
|
||||
let tol = self.length() * 1e-9 + 1e-12;
|
||||
let Some(curve) = self.curves.get(edge) else { return [Some(edge), None, None] };
|
||||
let (t0, t1) = curve.range_tuple();
|
||||
let at = |t: f64| from_p3(curve.subs(t)).dist(p) <= tol;
|
||||
let before = at(t0).then(|| edge.checked_sub(1).or(self.closed.then(|| count.saturating_sub(1)))).flatten();
|
||||
let after = at(t1).then(|| Some(edge + 1).filter(|e| *e < count).or(self.closed.then_some(0))).flatten();
|
||||
[Some(edge), before, after]
|
||||
}
|
||||
|
||||
/// Where stations start from `seam` (a point on the chain), and whether they run backwards: a
|
||||
/// closed chain starts at it, an open one runs from the end it is nearer.
|
||||
fn start_at_seam(&self, seam: Vec3) -> (f64, bool) {
|
||||
let s = self.nearest(seam);
|
||||
if self.closed { (s, false) } else { (0.0, s > self.length() / 2.0) }
|
||||
}
|
||||
|
||||
/// The arclength of the chain's point nearest `p`, and how far `p` is from the chain: the
|
||||
/// nearest point of the fine polyline, then refined on that edge's own curve.
|
||||
fn nearest_with_distance(&self, p: Vec3) -> (f64, f64) {
|
||||
let mut best = (f64::INFINITY, 0.0, 0usize, 0.0);
|
||||
for w in self.samples.windows(2) {
|
||||
let (Some(a), Some(b)) = (w.first(), w.get(1)) else { continue };
|
||||
let len = a.p.dist(b.p);
|
||||
let f = if len > 1e-12 { ((p - a.p).dot(b.p - a.p) / (len * len)).clamp(0.0, 1.0) } else { 0.0 };
|
||||
let d = p.dist(a.p + (b.p - a.p) * f);
|
||||
if d < best.0 {
|
||||
best = (d, a.s + len * f, a.edge, a.t + (b.t - a.t) * f);
|
||||
}
|
||||
}
|
||||
let (chord, s, edge, hint) = best;
|
||||
let on_curve = self.curves.get(edge).and_then(|c| {
|
||||
let (t0, t1) = c.range_tuple();
|
||||
let t = c.search_nearest_parameter(p3(p), Some(hint), 100)?;
|
||||
(t0..=t1).contains(&t).then(|| from_p3(c.subs(t)).dist(p))
|
||||
});
|
||||
(s, on_curve.map_or(chord, |d| d.min(chord)))
|
||||
}
|
||||
|
||||
/// The arclength of the chain's point nearest `p`.
|
||||
fn nearest(&self, p: Vec3) -> f64 {
|
||||
self.nearest_with_distance(p).0
|
||||
}
|
||||
|
||||
/// The middle of the chain: a closed chain's centroid (what it surrounds), an open chain's
|
||||
/// point halfway along.
|
||||
fn middle(&self) -> Result<Vec3> {
|
||||
if !self.closed {
|
||||
return Ok(self.at(self.length() / 2.0)?.0);
|
||||
}
|
||||
let mut sum = Vec3::ZERO;
|
||||
let mut weight = 0.0;
|
||||
for w in self.samples.windows(2) {
|
||||
let (Some(a), Some(b)) = (w.first(), w.get(1)) else { continue };
|
||||
let len = a.p.dist(b.p);
|
||||
sum += (a.p + b.p) * (0.5 * len);
|
||||
weight += len;
|
||||
}
|
||||
Ok(sum * (1.0 / weight.max(1e-300)))
|
||||
}
|
||||
Ok((out, total))
|
||||
}
|
||||
|
||||
/// The support surface's frames along `edges` (a chain of its own edges), for a bridge that
|
||||
@@ -188,19 +300,61 @@ pub fn frames(face: &mt::Face, edges: &[mt::Edge], leave: Vec3, count: usize) ->
|
||||
if !(2..=4097).contains(&count) {
|
||||
return Err(KernelError::Invalid("a bridge needs 2 to 4097 stations".into()));
|
||||
}
|
||||
let line = ChainLine::of(edges)?;
|
||||
let stations = line.stations(count, 0.0, false)?;
|
||||
frames_on(&vec![face.clone(); edges.len()], &stations, &line, leave)
|
||||
}
|
||||
|
||||
/// The frames at `stations` (points on `line`, each with the index of the chain edge it is on),
|
||||
/// each read on the support face of its own edge (`faces`, one per chain edge): a chain may run
|
||||
/// along the boundaries of several faces, a tube's rim along the halves of its wall. A station on
|
||||
/// the vertex where two of those faces meet sits at a corner of one face's parameters, where the
|
||||
/// shape may not be readable along the leave direction; it is then read on the other face, which
|
||||
/// holds the same point.
|
||||
fn frames_on(faces: &[mt::Face], stations: &[(Vec3, usize)], line: &ChainLine, leave: Vec3) -> Result<Vec<Frame>> {
|
||||
let leave =
|
||||
leave.normalized().filter(|l| l.is_finite()).ok_or_else(|| KernelError::Invalid("the leave direction must be a finite vector".into()))?;
|
||||
let (pts, length) = chain_samples(edges, count)?;
|
||||
let support = Support::of(face, length)?;
|
||||
let mut walk = Walk::new(length);
|
||||
let along = |n: Vec3| -> Result<Vec3> {
|
||||
(leave - n * leave.dot(n))
|
||||
.normalized()
|
||||
.ok_or_else(|| KernelError::Invalid("the leave direction is normal to the support surface: it has no tangent plane there".to_string()))
|
||||
};
|
||||
let mut out = Vec::with_capacity(pts.len());
|
||||
for p in &pts {
|
||||
out.push(support.station(*p, &along, &mut walk, true)?.0);
|
||||
let length = line.length();
|
||||
// One support per distinct face, each with its own walk (a parameter hint means nothing on
|
||||
// another surface).
|
||||
let mut supports: Vec<(mt::FaceID, Support, Walk)> = Vec::new();
|
||||
let mut out = Vec::with_capacity(stations.len());
|
||||
'stations: for (p, edge) in stations {
|
||||
let mut tried: Vec<mt::FaceID> = Vec::with_capacity(2);
|
||||
let mut refusal: Option<KernelError> = None;
|
||||
for e in line.edges_at(*p, *edge).into_iter().flatten() {
|
||||
let Some(face) = faces.get(e) else { continue };
|
||||
let id = face.id();
|
||||
if tried.contains(&id) {
|
||||
continue;
|
||||
}
|
||||
tried.push(id);
|
||||
let k = match supports.iter().position(|(f, _, _)| *f == id) {
|
||||
Some(k) => k,
|
||||
None => {
|
||||
supports.push((id, Support::of(face, length)?, Walk::new(length)));
|
||||
supports.len() - 1
|
||||
}
|
||||
};
|
||||
let Some((_, support, walk)) = supports.get_mut(k) else { continue };
|
||||
match support.station(*p, &along, walk, true) {
|
||||
Ok((frame, _)) => {
|
||||
out.push(frame);
|
||||
continue 'stations;
|
||||
}
|
||||
// The station's own face's refusal is the one reported when the other cannot read
|
||||
// it either.
|
||||
Err(err) => {
|
||||
refusal.get_or_insert(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Err(refusal.unwrap_or_else(|| KernelError::Failed("bridge: a station's edge has no support face".into())));
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
@@ -595,72 +749,133 @@ pub fn sample_grid(body: &Body, along: usize, across: usize) -> Result<Vec<Vec<V
|
||||
|
||||
/// The most any point of a bridge's boundary row is from the chain it was built on — the row at
|
||||
/// `v0` for the first boundary, at `v1` for the second: what a stitch would have to close up.
|
||||
fn boundary_gap(made: &Body, chain: &[mt::Edge], at_end: bool) -> Result<f64> {
|
||||
fn boundary_gap(made: &Body, line: &ChainLine, at_end: bool) -> Result<f64> {
|
||||
let face = made.solid.face_iter().next().ok_or_else(|| KernelError::Failed("bridge: no face".into()))?;
|
||||
let surf = face.surface();
|
||||
let (Some((u0, u1)), Some((v0, v1))) = surf.try_range_tuple() else {
|
||||
return Err(KernelError::Failed("bridge: the surface is unbounded".into()));
|
||||
};
|
||||
let v = if at_end { v1 } else { v0 };
|
||||
let (poly, _) = chain_samples(chain, 257)?;
|
||||
let mut worst: f64 = 0.0;
|
||||
for i in 0..=256 {
|
||||
let u = u0 + (u1 - u0) * i as f64 / 256.0;
|
||||
let p = from_p3(surf.subs(u, v));
|
||||
let mut best = f64::INFINITY;
|
||||
for w in poly.windows(2) {
|
||||
let (Some(a), Some(b)) = (w.first(), w.get(1)) else { continue };
|
||||
let t = if b.dist(*a) > 1e-12 { ((p - *a).dot(*b - *a) / b.dist(*a).powi(2)).clamp(0.0, 1.0) } else { 0.0 };
|
||||
best = best.min(p.dist(*a + (*b - *a) * t));
|
||||
}
|
||||
worst = worst.max(best);
|
||||
worst = worst.max(line.nearest_with_distance(from_p3(surf.subs(u, v))).1);
|
||||
}
|
||||
Ok(worst)
|
||||
}
|
||||
|
||||
/// The midpoint of a chain of edges.
|
||||
fn chain_mid(edges: &[mt::Edge]) -> Result<Vec3> {
|
||||
let (pts, _) = chain_samples(edges, 3)?;
|
||||
pts.get(1).copied().ok_or_else(|| KernelError::Failed("bridge: no chain".into()))
|
||||
/// Which face of `body` the blend continues from along each edge of a chain (one per edge, in
|
||||
/// chain order): of the faces each edge bounds, the one whose tangent plane holds as much of
|
||||
/// `leave` as possible there. A chain may run along several faces (a tube's rim along the halves
|
||||
/// of its wall).
|
||||
fn support_faces(body: &Body, chain: &[mt::Edge], leave: Vec3) -> Result<Vec<mt::Face>> {
|
||||
let mut out = Vec::with_capacity(chain.len());
|
||||
for edge in chain {
|
||||
let curve = edge.curve();
|
||||
let (t0, t1) = curve.range_tuple();
|
||||
let mid = from_p3(curve.subs(0.5 * (t0 + t1)));
|
||||
let mut best: Option<(f64, mt::Face)> = None;
|
||||
for face in body.solid.face_iter() {
|
||||
if !face.edge_iter().any(|f| f.id() == edge.id()) {
|
||||
continue;
|
||||
}
|
||||
let Some((q, n, _)) = crate::curveblend::project(face, mid, None) else { continue };
|
||||
if q.dist(mid) > body.size() * 1e-6 + 1e-9 {
|
||||
continue;
|
||||
}
|
||||
let score = (leave - n * leave.dot(n)).len();
|
||||
if best.as_ref().is_none_or(|(b, _)| score > *b) {
|
||||
best = Some((score, face.clone()));
|
||||
}
|
||||
}
|
||||
let (score, face) = best.ok_or_else(|| KernelError::Invalid("no face of the body holds a picked edge".into()))?;
|
||||
if score < 0.2 {
|
||||
return Err(KernelError::Invalid(
|
||||
"the direction towards the other boundary lies in no face at the picked edges: give `align` points to leave by".into(),
|
||||
));
|
||||
}
|
||||
out.push(face);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Which face of `body` the blend should continue from a chain, and the direction it leaves in:
|
||||
/// the face whose tangent plane holds as much of `leave` as possible.
|
||||
fn support_face(body: &Body, chain: &[mt::Edge], leave: Vec3) -> Result<(mt::Face, Vec3)> {
|
||||
let mut best: Option<(f64, mt::Face)> = None;
|
||||
for face in body.solid.face_iter() {
|
||||
if !chain.iter().all(|e| face.edge_iter().any(|f| f.id() == e.id())) {
|
||||
continue;
|
||||
}
|
||||
let mid = chain_mid(chain)?;
|
||||
let surf = face.surface();
|
||||
let Some((u, v)) = surf.search_nearest_parameter(p3(mid), None, 100) else { continue };
|
||||
if from_p3(surf.subs(u, v)).dist(mid) > body.size() * 1e-6 + 1e-9 {
|
||||
continue;
|
||||
}
|
||||
let normal = surf.normal(u, v);
|
||||
let n = Vec3::new(normal.x, normal.y, normal.z).normalized().unwrap_or(Vec3::ZERO);
|
||||
let in_plane = leave - n * leave.dot(n);
|
||||
let score = in_plane.len();
|
||||
if best.as_ref().is_none_or(|(b, _)| score > *b) {
|
||||
best = Some((score, face.clone()));
|
||||
/// Where the second chain's stations start, and which way they run, so that they pair with the
|
||||
/// first chain's `a` station by station. An open chain runs from the end `seam` (a point on it)
|
||||
/// is nearer, or else the way that puts its ends nearer their partners. A closed chain runs round
|
||||
/// the same way as the first (by their area vectors; the nearer pairing when they stand almost
|
||||
/// at right angles), from `seam` when given, or else from the start that puts each station
|
||||
/// closest to its partner: two rims whose seams sit apart would otherwise give a twisted blend.
|
||||
fn pair_with(a: &[(Vec3, usize)], line: &ChainLine, seam: Option<Vec3>) -> Result<Vec<(Vec3, usize)>> {
|
||||
let count = a.len();
|
||||
let cost = |start: f64, backwards: bool| -> Result<f64> {
|
||||
Ok(line.stations(count, start, backwards)?.iter().zip(a).map(|((q, _), (p, _))| p.dist(*q)).sum())
|
||||
};
|
||||
// The least-cost start and way round among `starts` × `directions`.
|
||||
let best_of = |starts: &[f64], directions: &[bool]| -> Result<(f64, bool)> {
|
||||
let mut best = (0.0, false, f64::INFINITY);
|
||||
for &start in starts {
|
||||
for &backwards in directions {
|
||||
let c = cost(start, backwards)?;
|
||||
if c < best.2 {
|
||||
best = (start, backwards, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok((best.0, best.1))
|
||||
};
|
||||
if !line.closed {
|
||||
let backwards = match seam {
|
||||
Some(p) => line.start_at_seam(p).1,
|
||||
None => cost(0.0, true)? < cost(0.0, false)?,
|
||||
};
|
||||
return line.stations(count, 0.0, backwards);
|
||||
}
|
||||
let (score, face) = best.ok_or_else(|| KernelError::Invalid("no face of the body holds the picked edges".into()))?;
|
||||
if score < 0.2 {
|
||||
return Err(KernelError::Invalid(
|
||||
"the direction towards the other boundary lies in no face at the picked edges: give `align` points to leave by".into(),
|
||||
));
|
||||
let total = line.length();
|
||||
let spacing = total / (count.max(2) - 1) as f64;
|
||||
let coarse: Vec<f64> = (0..4 * (count.max(2) - 1)).map(|k| k as f64 * spacing / 4.0).collect();
|
||||
// The way round: the same sense as the first loop, unless the two loops stand almost at right
|
||||
// angles (then the area vectors cannot say, and the nearer pairing does, with its start).
|
||||
let ring =
|
||||
|pts: &[(Vec3, usize)]| crate::plane_fit::loop_area(&pts.iter().take(pts.len().saturating_sub(1)).map(|(p, _)| *p).collect::<Vec<_>>());
|
||||
let (area_a, area_b) = (ring(a), ring(&line.stations(count, 0.0, false)?));
|
||||
let agree = area_a.dot(area_b);
|
||||
let (backwards, nearest_start) = if agree.abs() > 0.2 * area_a.len() * area_b.len() {
|
||||
(agree < 0.0, None)
|
||||
} else {
|
||||
let (start, backwards) = best_of(&coarse, &[false, true])?;
|
||||
(backwards, Some(start))
|
||||
};
|
||||
if let Some(p) = seam {
|
||||
return line.stations(count, line.start_at_seam(p).0, backwards);
|
||||
}
|
||||
Ok((face, leave))
|
||||
// The best of starts four to a station spacing, narrowed down to a thousandth of a spacing
|
||||
// (the cost is smooth near its least).
|
||||
let mut start = match nearest_start {
|
||||
Some(start) => start,
|
||||
None => best_of(&coarse, &[backwards])?.0,
|
||||
};
|
||||
let (mut lo, mut hi) = (start - spacing / 4.0, start + spacing / 4.0);
|
||||
while hi - lo > spacing * 1e-3 {
|
||||
let (m1, m2) = (lo + (hi - lo) / 3.0, hi - (hi - lo) / 3.0);
|
||||
if cost(m1, backwards)? <= cost(m2, backwards)? {
|
||||
hi = m2;
|
||||
} else {
|
||||
lo = m1;
|
||||
}
|
||||
start = 0.5 * (lo + hi);
|
||||
}
|
||||
line.stations(count, start, backwards)
|
||||
}
|
||||
|
||||
/// A blend surface between two picked edge chains of two bodies: the surfaces the blend leaves
|
||||
/// and arrives at are the faces the chains bound (the best-facing one at each side), and each
|
||||
/// side repeats that surface up to its requested continuity. `align` overrides the direction
|
||||
/// each side leaves in (points in world space); `crown` how full each side is; `stitch` sews the
|
||||
/// blend to its two bodies where their boundaries meet. The reply's `gap`, if any, is how far the
|
||||
/// blend's own boundary lay from the chains it was built on.
|
||||
/// and arrives at are the faces the chains bound (along each edge, the best-facing one), and each
|
||||
/// side repeats that surface up to its requested continuity. Two closed chains blend station to
|
||||
/// station from their seams — `seam` (a point on each chain) when given, otherwise the pairing
|
||||
/// that keeps the blend from twisting; a closed chain does not blend to an open one. `align`
|
||||
/// overrides the direction each side leaves in (points in world space); `crown` how full each side
|
||||
/// is; `stitch` sews the blend to its two bodies where their boundaries meet. The reply's `gap`, if
|
||||
/// any, is how far the blend's own boundary lay from the chains it was built on.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn blend_between(
|
||||
a: &Body,
|
||||
picks_a: &[Vec3],
|
||||
@@ -669,6 +884,7 @@ pub fn blend_between(
|
||||
orders: [Continuity; 2],
|
||||
crown: [f64; 2],
|
||||
align: Option<[Vec3; 2]>,
|
||||
seam: Option<[Vec3; 2]>,
|
||||
samples: usize,
|
||||
stitch: bool,
|
||||
) -> Result<(Body, f64)> {
|
||||
@@ -677,9 +893,16 @@ pub fn blend_between(
|
||||
if !(5..=401).contains(&samples) {
|
||||
return Err(KernelError::Invalid("a blend needs 5 to 401 stations".into()));
|
||||
}
|
||||
if align.iter().chain(&seam).flatten().any(|p| !p.is_finite()) {
|
||||
return Err(KernelError::Invalid("`align` and `seam` points must be finite".into()));
|
||||
}
|
||||
let chain_a = chain(a, picks_a)?;
|
||||
let chain_b = chain(b, picks_b)?;
|
||||
let (mid_a, mid_b) = (chain_mid(&chain_a)?, chain_mid(&chain_b)?);
|
||||
let (line_a, line_b) = (ChainLine::of(&chain_a)?, ChainLine::of(&chain_b)?);
|
||||
if line_a.closed != line_b.closed {
|
||||
return Err(KernelError::Invalid("a closed chain blends only to a closed chain, and an open one only to an open one".into()));
|
||||
}
|
||||
let (mid_a, mid_b) = (line_a.middle()?, line_b.middle()?);
|
||||
let (leave_a, leave_b) = match align {
|
||||
Some([p, q]) => (
|
||||
(p - mid_a).normalized().ok_or_else(|| KernelError::Invalid("`align` must not sit on the boundary".into()))?,
|
||||
@@ -690,19 +913,15 @@ pub fn blend_between(
|
||||
(mid_a - mid_b).normalized().ok_or_else(|| KernelError::Invalid("the two boundaries coincide: there is nothing to blend".into()))?,
|
||||
),
|
||||
};
|
||||
let (face_a, leave_a) = support_face(a, &chain_a, leave_a)?;
|
||||
let (face_b, leave_b) = support_face(b, &chain_b, leave_b)?;
|
||||
let frames_a = frames(&face_a, &chain_a, leave_a, samples)?;
|
||||
let mut frames_b = frames(&face_b, &chain_b, leave_b, samples)?;
|
||||
// The two chains are sampled from their own starts: turn one round when that pairs the
|
||||
// stations better (the blend is built station to station).
|
||||
let direct: f64 = frames_a.iter().zip(&frames_b).map(|(x, y)| x.p.dist(y.p)).sum();
|
||||
let reversed: f64 = frames_a.iter().zip(frames_b.iter().rev()).map(|(x, y)| x.p.dist(y.p)).sum();
|
||||
if reversed < direct {
|
||||
frames_b.reverse();
|
||||
}
|
||||
let faces_a = support_faces(a, &chain_a, leave_a)?;
|
||||
let faces_b = support_faces(b, &chain_b, leave_b)?;
|
||||
let (start_a, backwards_a) = seam.map_or((0.0, false), |[p, _]| line_a.start_at_seam(p));
|
||||
let stations_a = line_a.stations(samples, start_a, backwards_a)?;
|
||||
let stations_b = pair_with(&stations_a, &line_b, seam.map(|[_, q]| q))?;
|
||||
let frames_a = frames_on(&faces_a, &stations_a, &line_a, leave_a)?;
|
||||
let frames_b = frames_on(&faces_b, &stations_b, &line_b, leave_b)?;
|
||||
let made = bridge(&frames_a, &frames_b, orders, crown)?;
|
||||
let gap = boundary_gap(&made, &chain_a, false)?.max(boundary_gap(&made, &chain_b, true)?);
|
||||
let gap = boundary_gap(&made, &line_a, false)?.max(boundary_gap(&made, &line_b, true)?);
|
||||
let faces: Vec<mt::Face> = made.solid.face_iter().cloned().collect();
|
||||
let mut rec = crate::record::Rebuild::default();
|
||||
for f in &faces {
|
||||
|
||||
@@ -242,3 +242,141 @@ fn continuity_parses_its_words() {
|
||||
assert_eq!(Continuity::parse(""), None);
|
||||
assert_eq!([Continuity::G0, Continuity::G1, Continuity::G2, Continuity::G3].map(Continuity::conditions), [1, 2, 3, 4]);
|
||||
}
|
||||
|
||||
/// A radius-10 tube along z from `z0` to `z0 + 30`, turned `turn` radians about its axis (which
|
||||
/// moves where its rim's seam sits), with the end face at `open_at` taken off: a surface body
|
||||
/// whose rim there is a closed chain.
|
||||
fn open_tube(z0: f64, turn: f64, open_at: f64) -> Body {
|
||||
let c = cylinder(Vec3::new(0.0, 0.0, z0), Vec3::Z, 10.0, 30.0).unwrap();
|
||||
let c = crate::transform(&c, Vec3::ZERO, Vec3::ZERO, Vec3::Z, turn).unwrap();
|
||||
let (_, rest) = crate::surfaces::unstitch(&c, &[Vec3::new(0.0, 0.0, open_at)]).unwrap();
|
||||
rest.unwrap()
|
||||
}
|
||||
|
||||
/// Points round a radius-10 rim at height `z`.
|
||||
fn rim_at(z: f64) -> Vec<Vec3> {
|
||||
(0..8).map(|k| f64::from(k) * std::f64::consts::FRAC_PI_4 + 0.1).map(|a| Vec3::new(10.0 * a.cos(), 10.0 * a.sin(), z)).collect()
|
||||
}
|
||||
|
||||
/// How far a blend between two coaxial rims turns round the axis: the most, over its stations,
|
||||
/// of the angle between where a cross-section starts and where it ends (zero for straight
|
||||
/// rulings parallel to the axis).
|
||||
fn worst_turn(body: &Body) -> f64 {
|
||||
let grid = sample_grid(body, 33, 9).unwrap();
|
||||
grid.iter()
|
||||
.map(|row| {
|
||||
let (a, b) = (row[0], row[row.len() - 1]);
|
||||
angle_deg(Vec3::new(a.x, a.y, 0.0), Vec3::new(b.x, b.y, 0.0))
|
||||
})
|
||||
.fold(0.0, f64::max)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_blend_between_closed_rims_lines_their_seams_up() {
|
||||
// Two coaxial tubes 10 apart, the upper one turned a quarter round: its rim's seam is 90°
|
||||
// from the lower rim's. The blend between them is the cylinder wall between: every ruling
|
||||
// straight up the axis, none turning round it.
|
||||
let low = open_tube(0.0, 0.0, 30.0);
|
||||
let high = open_tube(40.0, std::f64::consts::FRAC_PI_2, 40.0);
|
||||
for orders in [[Continuity::G0, Continuity::G0], [Continuity::G1, Continuity::G1], [Continuity::G2, Continuity::G2]] {
|
||||
let (made, gap) = blend_between(&low, &rim_at(30.0), &high, &rim_at(40.0), orders, [0.0, 0.0], None, None, 65, false).unwrap();
|
||||
let turn = worst_turn(&made);
|
||||
// The boundary is a cubic through the stations on the rim: between them it strays by the
|
||||
// interpolation error of a circle at 65 stations (about 2e-5 mm here).
|
||||
assert!(gap < 1e-4, "{orders:?}: the boundary stays on the rims: {gap}");
|
||||
assert!(turn < 0.1, "{orders:?}: the blend turns {turn}° round the axis");
|
||||
// The wall between: radius 10 everywhere (G1 and G2 repeat a straight wall).
|
||||
for row in sample_grid(&made, 17, 9).unwrap() {
|
||||
for p in row {
|
||||
assert!((Vec3::new(p.x, p.y, 0.0).len() - 10.0).abs() < 1e-5, "{orders:?}: off the wall at {p:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_closed_chain_blends_only_to_a_closed_chain() {
|
||||
// The tube's closed rim against one open edge of a box's top.
|
||||
let tube = open_tube(0.0, 0.0, 30.0);
|
||||
let b = box_solid(Vec3::new(-20.0, 30.0, 30.0), Vec3::new(20.0, 40.0, 40.0)).unwrap();
|
||||
let err = blend_between(&tube, &rim_at(30.0), &b, &[Vec3::new(0.0, 30.0, 40.0)], [Continuity::G1; 2], [0.0, 0.0], None, None, 33, false);
|
||||
assert!(matches!(&err, Err(KernelError::Invalid(m)) if m.contains("closed chain")), "{err:?}");
|
||||
let err = blend_between(&b, &[Vec3::new(0.0, 30.0, 40.0)], &tube, &rim_at(30.0), [Continuity::G1; 2], [0.0, 0.0], None, None, 33, false);
|
||||
assert!(matches!(&err, Err(KernelError::Invalid(m)) if m.contains("closed chain")), "{err:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_blend_between_offset_strips_is_the_cubic_hermite_strip() {
|
||||
// Two 40-long boxes 10 apart in y, the second standing 5 higher: the blend from the first's
|
||||
// top rim (y = 10, z = 10) to the second's (y = 20, z = 15), G1 at both ends. Every
|
||||
// cross-section is the cubic Bézier that leaves each top face along it, at the speed chord/3
|
||||
// (chord = |(10, 5)|): control points (10, 10), (10 + chord/9, 10), (20 - chord/9, 15),
|
||||
// (20, 15) in (y, z), the same at every x.
|
||||
let a = box_solid(Vec3::new(0.0, 0.0, 0.0), Vec3::new(40.0, 10.0, 10.0)).unwrap();
|
||||
let b = box_solid(Vec3::new(0.0, 20.0, 5.0), Vec3::new(40.0, 30.0, 15.0)).unwrap();
|
||||
let (made, gap) =
|
||||
blend_between(&a, &[Vec3::new(20.0, 10.0, 10.0)], &b, &[Vec3::new(20.0, 20.0, 15.0)], [Continuity::G1; 2], [0.0, 0.0], None, None, 9, false)
|
||||
.unwrap();
|
||||
assert!(gap < 1e-9, "straight rims: the boundary is on them exactly: {gap}");
|
||||
let chord = 125f64.sqrt();
|
||||
let control = [(10.0, 10.0), (10.0 + chord / 9.0, 10.0), (20.0 - chord / 9.0, 15.0), (20.0, 15.0)];
|
||||
let bezier = |t: f64| {
|
||||
let w = [(1.0 - t).powi(3), 3.0 * t * (1.0 - t).powi(2), 3.0 * t * t * (1.0 - t), t.powi(3)];
|
||||
control.iter().zip(w).fold((0.0, 0.0), |(y, z), ((cy, cz), w)| (y + cy * w, z + cz * w))
|
||||
};
|
||||
let across = 11;
|
||||
for row in sample_grid(&made, 9, across).unwrap() {
|
||||
for (j, p) in row.iter().enumerate() {
|
||||
let (y, z) = bezier(j as f64 / (across - 1) as f64);
|
||||
assert!((p.y - y).abs() < 1e-9 && (p.z - z).abs() < 1e-9, "at v = {j}/{}: {p:?} vs the Hermite strip ({y}, {z})", across - 1);
|
||||
}
|
||||
}
|
||||
// G1 at both seams: the blend's normal is the top faces' (±z) all along each rim.
|
||||
let face = made.solid.face_iter().next().unwrap();
|
||||
let surf = face.surface();
|
||||
let (Some((u0, u1)), Some((v0, v1))) = surf.try_range_tuple() else { panic!("unbounded") };
|
||||
for i in 0..=16 {
|
||||
let u = u0 + (u1 - u0) * i as f64 / 16.0;
|
||||
for v in [v0, v1] {
|
||||
let n = surf.normal(u, v);
|
||||
let worst = angle_deg(Vec3::new(n.x, n.y, n.z), Vec3::Z).min(angle_deg(Vec3::new(n.x, n.y, n.z), Vec3::Z * -1.0));
|
||||
assert!(worst < 0.01, "at u = {u}, v = {v}: the normal is {worst}° off the top faces'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_picked_seam_sets_where_a_closed_blend_starts() {
|
||||
// The same coaxial rims as above, but the upper chain told to start a quarter round from where
|
||||
// the lower one starts: the blend then turns a quarter round the axis, as asked.
|
||||
let low = open_tube(0.0, 0.0, 30.0);
|
||||
let high = open_tube(40.0, 0.0, 40.0);
|
||||
let free = blend_between(&low, &rim_at(30.0), &high, &rim_at(40.0), [Continuity::G1; 2], [0.0, 0.0], None, None, 65, false).unwrap().0;
|
||||
assert!(worst_turn(&free) < 0.1, "unpicked: no turn ({}°)", worst_turn(&free));
|
||||
let first = sample_grid(&free, 2, 2).unwrap()[0][0];
|
||||
let quarter = Vec3::new(-first.y, first.x, 40.0);
|
||||
let seams = Some([Vec3::new(first.x, first.y, 30.0), quarter]);
|
||||
let turned = blend_between(&low, &rim_at(30.0), &high, &rim_at(40.0), [Continuity::G1; 2], [0.0, 0.0], None, seams, 65, false).unwrap().0;
|
||||
let turn = worst_turn(&turned);
|
||||
assert!((turn - 90.0).abs() < 0.1, "the picked seams turn the blend a quarter round: {turn}°");
|
||||
// Seam points that are not numbers are refused.
|
||||
let bad = Some([Vec3::new(f64::NAN, 0.0, 30.0), quarter]);
|
||||
assert!(blend_between(&low, &rim_at(30.0), &high, &rim_at(40.0), [Continuity::G1; 2], [0.0, 0.0], None, bad, 65, false).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_blend_between_offset_tubes_reads_stations_on_the_walls_seams() {
|
||||
// A radius-10 tube and a radius-6 one standing 8 off its axis: the blend leaves each rim at an
|
||||
// angle, so a station on the vertex where a wall's two halves meet is at a corner of one
|
||||
// half's parameters. It is read on the other half, and the blend builds at every order.
|
||||
let low = open_tube(0.0, 0.0, 30.0);
|
||||
let high = cylinder(Vec3::new(8.0, 0.0, 50.0), Vec3::Z, 6.0, 25.0).unwrap();
|
||||
let (_, high) = crate::surfaces::unstitch(&high, &[Vec3::new(8.0, 0.0, 50.0)]).unwrap();
|
||||
let high = high.unwrap();
|
||||
let rim6: Vec<Vec3> = rim_at(50.0).into_iter().map(|p| Vec3::new(8.0 + p.x * 0.6, p.y * 0.6, 50.0)).collect();
|
||||
for orders in [[Continuity::G1; 2], [Continuity::G2; 2], [Continuity::G3; 2]] {
|
||||
let made = blend_between(&low, &rim_at(30.0), &high, &rim6, orders, [0.0, 0.0], None, None, 41, false);
|
||||
let (_, gap) = made.unwrap_or_else(|e| panic!("{orders:?}: {e:?}"));
|
||||
assert!(gap < 1e-3, "{orders:?}: {gap}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,17 @@ pub(crate) fn plane_through(pts: &[mt::Point3]) -> Option<mt::Plane> {
|
||||
Some(mt::Plane::new(o, o + x, o + y))
|
||||
}
|
||||
|
||||
/// The area vector of a closed polygon (Newell's method): normal to the loop, as long as the area
|
||||
/// it encloses, pointing the way the loop runs round by the right-hand rule.
|
||||
pub(crate) fn loop_area(points: &[Vec3]) -> Vec3 {
|
||||
let mut n = Vec3::ZERO;
|
||||
for (i, p) in points.iter().enumerate() {
|
||||
let Some(q) = points.get((i + 1) % points.len()) else { continue };
|
||||
n += Vec3::new((p.y - q.y) * (p.z + q.z), (p.z - q.z) * (p.x + q.x), (p.x - q.x) * (p.y + q.y));
|
||||
}
|
||||
n * 0.5
|
||||
}
|
||||
|
||||
/// The point of `c` at `t` (`None` where an intersection curve cannot find it).
|
||||
fn curve_point(c: &mt::Curve, t: f64) -> Option<Vec3> {
|
||||
let p = match c {
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
//! The Blend Surface dialog (#764): edges at each end, the continuity and bulge of each end and
|
||||
//! the stitch toggle become `surface.blend`, and Edit Feature brings them back with what the
|
||||
//! dialog does not show (the seams) kept as they were.
|
||||
use crate::dialogs::Kind;
|
||||
use crate::dialogs_surface::Surf;
|
||||
use crate::scenario::Harness;
|
||||
use serde_json::json;
|
||||
use solidcraft_engine::doc::{FeatureKind, kernel::Continuity};
|
||||
use solidcraft_engine::geom::Vec3;
|
||||
|
||||
fn ok(h: &mut Harness) {
|
||||
h.frames(2);
|
||||
h.step(&json!({"widget":"OK"})).unwrap();
|
||||
// An edit is applied off the UI thread: give it the frames it takes.
|
||||
for _ in 0..200 {
|
||||
if h.app.dialog.is_none() {
|
||||
break;
|
||||
}
|
||||
h.frames(1);
|
||||
}
|
||||
assert!(h.app.dialog.is_none(), "{:?} {:?} {:?}", h.app.preview.error, h.app.dialog.as_ref().map(|d| (&d.error, &d.inputs)), h.app.session.log);
|
||||
}
|
||||
|
||||
/// What the blend feature `name` was made with: the bodies at each end, continuity, bulge, seams
|
||||
/// and stitch.
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn blend(h: &Harness, name: &str) -> (String, String, [Continuity; 2], [f64; 2], Option<[Vec3; 2]>, bool) {
|
||||
match &h.app.session.doc.find_feature(name).unwrap().kind {
|
||||
FeatureKind::SurfaceBlend { from, to, continuity, bulge, seam, stitch, .. } => {
|
||||
(from.body.to_string(), to.body.to_string(), *continuity, *bulge, seam.map(|[p, q]| [p.0, q.0]), *stitch)
|
||||
}
|
||||
k => panic!("{k:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn edges_at_each_end_make_a_blend_and_come_back_in_an_edit() {
|
||||
let mut h = Harness::new();
|
||||
h.app.run("solid.box", json!({"length": 40, "width": 10, "height": 10, "corner": [0, 0, 0], "body_name": "A"})).unwrap();
|
||||
h.app.run("solid.box", json!({"length": 40, "width": 10, "height": 10, "corner": [0, 20, 5], "body_name": "B"})).unwrap();
|
||||
let from = crate::dialogs::edge_sel(&h.app.session, Vec3::new(20.0, 10.0, 10.0)).unwrap();
|
||||
let to = crate::dialogs::edge_sel(&h.app.session, Vec3::new(20.0, 20.0, 15.0)).unwrap();
|
||||
h.step(&json!({"call":"ui.start","params":{"command":"surface.blend"}})).unwrap();
|
||||
h.frames(3);
|
||||
assert!(h.widget("From edges").is_some() && h.widget("Start continuity").is_some() && h.widget("End bulge").is_some());
|
||||
let d = h.app.dialog.as_mut().unwrap();
|
||||
d.inputs[0].items = vec![from];
|
||||
d.inputs[1].items = vec![to];
|
||||
let Kind::Surface(Surf::Blend { continuity, bulge, .. }) = &mut d.kind else { panic!("{:?}", d.kind) };
|
||||
*continuity = [2, 1];
|
||||
*bulge = [0.5, 0.0];
|
||||
ok(&mut h);
|
||||
let name = h.app.session.doc.features.last().unwrap().name.clone();
|
||||
let (a, b, continuity, bulge, seam, stitch) = blend(&h, &name);
|
||||
assert_eq!((a.as_str(), b.as_str()), ("A", "B"));
|
||||
assert_eq!(continuity, [Continuity::G2, Continuity::G1]);
|
||||
assert_eq!((bulge, seam, stitch), ([0.5, 0.0], None, false));
|
||||
assert_eq!(h.app.session.world_state().bodies.len(), 3, "a new surface body beside the boxes");
|
||||
// A blend made by the command with a seam the dialog does not show: an edit keeps it.
|
||||
h.app.session.execute("edit.undo", &json!({})).unwrap();
|
||||
h.app
|
||||
.run(
|
||||
"surface.blend",
|
||||
json!({"from": {"body": "A", "edges": [[20, 10, 10]]}, "to": {"body": "B", "edges": [[20, 20, 15]]},
|
||||
"continuity": ["g2", "g1"], "seam": [[0, 10, 10], [0, 20, 15]]}),
|
||||
)
|
||||
.unwrap();
|
||||
let name = h.app.session.doc.features.last().unwrap().name.clone();
|
||||
h.step(&json!({"call":"ui.editFeature","params":{"feature":name}})).unwrap();
|
||||
h.frames(8);
|
||||
let d = h.app.dialog.as_mut().unwrap();
|
||||
assert!(matches!(d.kind, Kind::Surface(Surf::Blend { continuity: [2, 1], stitch: false, .. })), "{:?}", d.kind);
|
||||
assert_eq!((d.inputs[0].items.len(), d.inputs[1].items.len()), (1, 1), "{:?}", d.inputs);
|
||||
let Kind::Surface(Surf::Blend { stitch, .. }) = &mut d.kind else { panic!() };
|
||||
*stitch = true;
|
||||
ok(&mut h);
|
||||
let (_, _, continuity, _, seam, stitch) = blend(&h, &name);
|
||||
assert_eq!(continuity, [Continuity::G2, Continuity::G1]);
|
||||
assert_eq!(seam, Some([Vec3::new(0.0, 10.0, 10.0), Vec3::new(0.0, 20.0, 15.0)]));
|
||||
assert!(stitch);
|
||||
assert_eq!(h.app.session.world_state().bodies.len(), 1, "stitched onto both boxes");
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Dialogs for the surface tools and face splitting (#19): Surface Extrude, Revolve, Sweep and
|
||||
//! Loft, Offset and Ruled Surface, Boundary Surface, Patch, Stitch, Thicken, Extend, Trim, Untrim
|
||||
//! Loft, Offset and Ruled Surface, Blend and Boundary Surface, Patch, Stitch, Thicken, Extend, Trim, Untrim
|
||||
//! and Split Face. Each has a live preview and Edit Feature.
|
||||
|
||||
use serde_json::{Map, Value, json};
|
||||
@@ -32,6 +32,13 @@ pub enum Surf {
|
||||
Loft {
|
||||
rail_fit: usize,
|
||||
},
|
||||
/// `continuity`: an index into [`BLEND_CONTINUITY`] for each end, [from, to]; `bulge`: how
|
||||
/// full each end leaves (0 is the plain bridge); `stitch`: sew the blend onto both bodies.
|
||||
Blend {
|
||||
continuity: [usize; 2],
|
||||
bulge: [f64; 2],
|
||||
stitch: bool,
|
||||
},
|
||||
/// `continuity`: an index into [`PATCH_CONTINUITY`] (for a loop of sketch curves, how much of
|
||||
/// the sketch's plane each side repeats; for picked edges, how the surface meets the faces
|
||||
/// beside them); `join`: sew the surface into the body of its edges.
|
||||
@@ -91,6 +98,7 @@ impl Surf {
|
||||
Surf::Revolve { .. } => "SURFACE REVOLVE",
|
||||
Surf::Sweep(_) => "SURFACE SWEEP",
|
||||
Surf::Loft { .. } => "SURFACE LOFT",
|
||||
Surf::Blend { .. } => "BLEND SURFACE",
|
||||
Surf::Boundary { .. } => "BOUNDARY SURFACE",
|
||||
Surf::Patch { .. } => "PATCH",
|
||||
Surf::Unstitch => "UNSTITCH",
|
||||
@@ -122,6 +130,11 @@ impl Surf {
|
||||
/// How a patch on edges meets the faces beside its loop (labels, and the `continuity` parameter).
|
||||
const PATCH_CONTINUITY: [(&str, &str); 3] = [("Position (G0)", "g0"), ("Tangent (G1)", "g1"), ("Curvature (G2)", "g2")];
|
||||
|
||||
/// How much of the surface at its edges each end of a blend repeats (labels, and the
|
||||
/// `continuity` words).
|
||||
const BLEND_CONTINUITY: [(&str, &str); 4] =
|
||||
[("Position (G0)", "g0"), ("Tangent (G1)", "g1"), ("Curvature (G2)", "g2"), ("Curvature change (G3)", "g3")];
|
||||
|
||||
/// What a boundary surface becomes: a body of its own, or part of the body of its edges.
|
||||
const BOUNDARY_OPS: [&str; 2] = ["New Body", "Join"];
|
||||
|
||||
@@ -152,6 +165,7 @@ fn inputs(k: &Surf) -> Vec<SelInput> {
|
||||
let [rail, rail2] = crate::dialogs_sweep::rail_inputs();
|
||||
vec![SelInput::new("Sections (one sketch each)", PROFILES | CURVES, true), rail, rail2]
|
||||
}
|
||||
Surf::Blend { .. } => vec![SelInput::new("From edges", EDGES, true), SelInput::new("To edges", EDGES, true)],
|
||||
Surf::Boundary { .. } => vec![SelInput::new("Curves", CURVES | EDGES, true), SelInput::new("Cross curves", CURVES | EDGES, true)],
|
||||
Surf::Patch { .. } => vec![SelInput::new("Boundary", PROFILES | EDGES, true), SelInput::new("Pass through", VERTICES | FACES, true)],
|
||||
Surf::Unstitch => vec![SelInput::new("Body, or faces to take out", BODIES | FACES, true)],
|
||||
@@ -182,6 +196,7 @@ pub fn start(_app: &SolveApp, id: &str) -> Option<(Kind, Vec<SelInput>)> {
|
||||
"surface.revolve" => Surf::Revolve { angle: "360 deg".into(), symmetric: false, axis: None },
|
||||
"surface.sweep" => Surf::Sweep(crate::dialogs_sweep::SweepOpts::default()),
|
||||
"surface.loft" => Surf::Loft { rail_fit: 0 },
|
||||
"surface.blend" => Surf::Blend { continuity: [1, 1], bulge: [0.0, 0.0], stitch: false },
|
||||
"surface.boundary" => Surf::Boundary { continuity: 1, join: false },
|
||||
"surface.patch" => Surf::Patch { continuity: 0 },
|
||||
"surface.unstitch" => Surf::Unstitch,
|
||||
@@ -292,6 +307,26 @@ pub fn rows(ui: &mut egui::Ui, k: &mut Surf) -> bool {
|
||||
combo(ui, "pa_cont", &PATCH_CONTINUITY.map(|(label, _)| label), continuity);
|
||||
ui.end_row();
|
||||
}
|
||||
Surf::Blend { continuity, bulge, stitch } => {
|
||||
// One row per end, so the dialog keeps its docked width.
|
||||
let [from, to] = continuity;
|
||||
let [from_bulge, to_bulge] = bulge;
|
||||
row_label(ui, "Start continuity");
|
||||
combo(ui, "bl_cont0", &BLEND_CONTINUITY.map(|(label, _)| label), from);
|
||||
ui.end_row();
|
||||
row_label(ui, "Start bulge");
|
||||
ui.add(egui::DragValue::new(from_bulge).range(-0.9..=3.0).speed(0.01).max_decimals(2));
|
||||
ui.end_row();
|
||||
row_label(ui, "End continuity");
|
||||
combo(ui, "bl_cont1", &BLEND_CONTINUITY.map(|(label, _)| label), to);
|
||||
ui.end_row();
|
||||
row_label(ui, "End bulge");
|
||||
ui.add(egui::DragValue::new(to_bulge).range(-0.9..=3.0).speed(0.01).max_decimals(2));
|
||||
ui.end_row();
|
||||
row_label(ui, "Stitch to both bodies");
|
||||
ui.checkbox(stitch, "");
|
||||
ui.end_row();
|
||||
}
|
||||
Surf::Boundary { continuity, join } => {
|
||||
row_label(ui, "Continuity");
|
||||
combo(ui, "bo_cont", &PATCH_CONTINUITY.map(|(label, _)| label), continuity);
|
||||
@@ -343,6 +378,17 @@ fn body_and_faces(picks: &[Sel]) -> Result<(String, Vec<Value>), String> {
|
||||
Ok((body, faces))
|
||||
}
|
||||
|
||||
/// The body of picked edges (all of one body) and a point on each edge.
|
||||
fn body_and_edges(picks: &[Sel]) -> Result<(String, Vec<Value>), String> {
|
||||
let body_of = |x: &Sel| if let Sel::Edge { body, .. } = x { Some(body.clone()) } else { None };
|
||||
let body = picks.iter().find_map(body_of).ok_or("pick edges of a body")?;
|
||||
if picks.iter().any(|x| body_of(x).as_ref() != Some(&body)) {
|
||||
return Err("pick edges of one body".into());
|
||||
}
|
||||
let edges = picks.iter().filter_map(|x| if let Sel::Edge { point, .. } = x { Some(pt(*point)) } else { None }).collect();
|
||||
Ok((body, edges))
|
||||
}
|
||||
|
||||
/// The sketch, profiles and curves of a surface builder's picks (all in one sketch).
|
||||
fn sheet_picks(app: &SolveApp, picks: &[Sel]) -> Result<Value, String> {
|
||||
let profiles: Vec<(u64, usize)> =
|
||||
@@ -548,6 +594,25 @@ pub fn commands(app: &SolveApp, k: &Surf, inputs: &[SelInput], extra: &Map<Strin
|
||||
crate::dialogs_sweep::rail_params(app, *rail_fit, [items(inputs, 1), items(inputs, 2)], &mut p)?;
|
||||
("surface.loft", p)
|
||||
}
|
||||
Surf::Blend { continuity, bulge, stitch } => {
|
||||
need(0, "the edges the blend leaves")?;
|
||||
need(1, "the edges the blend arrives at")?;
|
||||
let side = |i: usize| -> Result<Value, String> {
|
||||
let (body, edges) = body_and_edges(items(inputs, i))?;
|
||||
Ok(json!({"body": body, "edges": edges}))
|
||||
};
|
||||
let word = |i: usize| BLEND_CONTINUITY.get(i).map_or("g1", |(_, w)| *w);
|
||||
let mut p = json!({
|
||||
"from": side(0)?,
|
||||
"to": side(1)?,
|
||||
"continuity": [word(continuity[0]), word(continuity[1])],
|
||||
"bulge": bulge,
|
||||
});
|
||||
if *stitch {
|
||||
p["stitch"] = json!(true);
|
||||
}
|
||||
("surface.blend", p)
|
||||
}
|
||||
Surf::Boundary { continuity, join } => {
|
||||
need(0, "the curves (sketch curves or edges)")?;
|
||||
let word = PATCH_CONTINUITY.get(*continuity).map_or("g0", |(_, w)| *w);
|
||||
@@ -632,13 +697,7 @@ pub fn commands(app: &SolveApp, k: &Surf, inputs: &[SelInput], extra: &Map<Strin
|
||||
}
|
||||
Surf::Ruled { distance, mode, angle, flip, round } => {
|
||||
need(0, "the edges to rule from")?;
|
||||
let edge_body = |x: &Sel| if let Sel::Edge { body, .. } = x { Some(body.clone()) } else { None };
|
||||
let body = items(inputs, 0).iter().find_map(edge_body).ok_or("pick edges of a body")?;
|
||||
if items(inputs, 0).iter().any(|x| edge_body(x).as_ref() != Some(&body)) {
|
||||
return Err("pick edges of one body".into());
|
||||
}
|
||||
let edges: Vec<Value> =
|
||||
items(inputs, 0).iter().filter_map(|x| if let Sel::Edge { point, .. } = x { Some(pt(*point)) } else { None }).collect();
|
||||
let (body, edges) = body_and_edges(items(inputs, 0))?;
|
||||
let mode = RULED_MODES.get(*mode).map_or("normal", |(_, m)| *m);
|
||||
let mut p = json!({"body": body, "edges": edges, "distance": distance, "mode": mode});
|
||||
if mode == "angle" {
|
||||
@@ -846,6 +905,22 @@ pub fn for_feature(app: &SolveApp, kind: &FeatureKind, frame: &Mat) -> Option<(K
|
||||
],
|
||||
)
|
||||
}
|
||||
FeatureKind::SurfaceBlend { from, to, continuity, bulge, align, seam, stitch } => {
|
||||
let index = |c: &solidcraft_engine::doc::kernel::Continuity| BLEND_CONTINUITY.iter().position(|(_, w)| *w == c.as_str()).unwrap_or(1);
|
||||
let k = Surf::Blend { continuity: continuity.each_ref().map(index), bulge: *bulge, stitch: *stitch };
|
||||
// What the dialog does not show is kept as it was: the leave directions and the seams.
|
||||
let mut extra = Map::new();
|
||||
for (key, points) in [("align", align), ("seam", seam)] {
|
||||
if let Some([p, q]) = points {
|
||||
extra.insert(key.into(), json!([pt(p.0), pt(q.0)]));
|
||||
}
|
||||
}
|
||||
let mut ins = inputs(&k);
|
||||
for (inp, side) in ins.iter_mut().zip([from, to]) {
|
||||
inp.items = side.edges.iter().filter_map(edge).collect();
|
||||
}
|
||||
return Some((Kind::Surface(k), ins, extra));
|
||||
}
|
||||
FeatureKind::SurfaceBoundary { curves, orders, crown, samples, .. } => {
|
||||
let first = orders.first().copied().unwrap_or(solidcraft_engine::doc::kernel::Continuity::G1);
|
||||
let index = PATCH_CONTINUITY.iter().position(|(_, w)| *w == first.as_str());
|
||||
|
||||
@@ -119,6 +119,8 @@ pub use file_picker::FilePickerFuture;
|
||||
#[cfg(test)]
|
||||
mod blend_arrow_tests;
|
||||
#[cfg(test)]
|
||||
mod blend_dialog_tests;
|
||||
#[cfg(test)]
|
||||
mod boundary_dialog_tests;
|
||||
pub(crate) mod display_lod;
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user