kernel_api/solid_op.rs
1//! Solid operations as plain data: profiles, sweeps, primitives, dress-ups,
2//! patterns, surface steps and the op enum a chain runs.
3
4use serde::{Deserialize, Serialize};
5
6use crate::*;
7
8/// One segment of a closed 2D profile wire, in sketch-plane coordinates
9/// (millimetres). Arcs are encoded as three on-curve points so consumers
10/// never have to agree on a winding convention.
11#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
12#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
13pub enum ProfileSegment {
14 Line {
15 start: [f64; 2],
16 end: [f64; 2],
17 },
18 /// Circular arc through three points (start → mid → end).
19 Arc {
20 start: [f64; 2],
21 mid: [f64; 2],
22 end: [f64; 2],
23 },
24 Circle {
25 center: [f64; 2],
26 radius: f64,
27 },
28 /// Full ellipse. `major` is the vector from the center to a major-axis
29 /// vertex; the minor radius is `|major| * ratio` with `ratio` in (0, 1].
30 Ellipse {
31 center: [f64; 2],
32 major: [f64; 2],
33 ratio: f64,
34 },
35 /// Elliptical arc between two parameter angles (radians, counter-clockwise
36 /// in the ellipse frame where the major axis is at parameter 0).
37 EllipseArc {
38 center: [f64; 2],
39 major: [f64; 2],
40 ratio: f64,
41 start_param: f64,
42 end_param: f64,
43 },
44 /// Cubic B-spline through the given control points. A periodic spline
45 /// closes smoothly on itself; an open one runs first → last control point.
46 BSpline {
47 control_points: Vec<[f64; 2]>,
48 periodic: bool,
49 },
50 /// A B-spline of any degree over its own knots, rational when it has
51 /// weights: an exact conic arc, a spline drawn through points. An open
52 /// one's knots are clamped (`control points + degree + 1` of them), so
53 /// it runs first → last control point; a periodic one is a uniform ring
54 /// over its control points closing smoothly on itself, and its knots
55 /// are not used.
56 Nurbs {
57 degree: u32,
58 knots: Vec<f64>,
59 control_points: Vec<[f64; 2]>,
60 /// One per control point; empty when every weight is one.
61 #[serde(default, skip_serializing_if = "Vec::is_empty")]
62 weights: Vec<f64>,
63 #[serde(default)]
64 periodic: bool,
65 },
66}
67
68/// What a [`SolidOp::PipeThrough`] runs along.
69#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
70pub enum PipePath {
71 /// A sketch's wire.
72 Profile(Profile),
73 /// Edges of the running solid, joined end to end.
74 Edges(Vec<EdgeProbe>),
75 /// Edges of another solid (a native-format snapshot, moved by
76 /// `transform` into the body's frame), joined end to end; the probes
77 /// are in the body's frame.
78 EdgesOf {
79 shape: Vec<u8>,
80 transform: Option<Box<[[f64; 4]; 4]>>,
81 edges: Vec<EdgeProbe>,
82 },
83}
84
85/// One section of a [`SolidOp::LoftThrough`].
86#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
87pub enum LoftSection {
88 Profile(Profile),
89 /// The flat face of the running solid the probe finds, by its outer
90 /// and inner boundaries.
91 Face(FaceProbe),
92 /// A point the loft closes to, in the body's frame.
93 Point([f64; 3]),
94}
95
96/// A closed loop of profile segments. Consecutive segments share endpoints;
97/// a single `Circle` segment is a wire by itself.
98#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
99pub struct ProfileWire {
100 pub segments: Vec<ProfileSegment>,
101 /// The name of each segment, one per segment, by what it was drawn from
102 /// (a sketch element): the faces a feature sweeps from it are named by
103 /// it, so they keep their names while dimensions change. Empty, or a
104 /// zero, where a segment has no such name.
105 #[serde(default, skip_serializing_if = "Vec::is_empty")]
106 pub names: Vec<TopoName>,
107}
108
109impl ProfileWire {
110 /// A wire of `segments` with no names.
111 pub fn new(segments: Vec<ProfileSegment>) -> Self {
112 Self {
113 segments,
114 names: Vec::new(),
115 }
116 }
117
118 /// The name of segment `index`, when it has one.
119 pub fn name_of(&self, index: usize) -> Option<TopoName> {
120 self.names.get(index).copied().filter(|n| *n != 0)
121 }
122}
123
124/// The plane a profile lives on, in world coordinates (millimetres).
125#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
126pub struct ProfilePlane {
127 pub origin: [f64; 3],
128 pub x_axis: [f64; 3],
129 pub y_axis: [f64; 3],
130 pub normal: [f64; 3],
131}
132
133/// The XY plane through the origin.
134impl Default for ProfilePlane {
135 fn default() -> Self {
136 Self {
137 origin: [0.0; 3],
138 x_axis: [1.0, 0.0, 0.0],
139 y_axis: [0.0, 1.0, 0.0],
140 normal: [0.0, 0.0, 1.0],
141 }
142 }
143}
144
145/// How an extrusion combines with the body's existing solid.
146#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
147pub enum BooleanOp {
148 /// Replace / start the body's solid (first feature).
149 NewSolid,
150 /// Union with the existing solid (Pad on an existing body).
151 Fuse,
152 /// Subtract from the existing solid (Pocket).
153 Cut,
154 /// Keep only what the existing solid and the tool share.
155 Common,
156}
157
158/// A set of closed wires on one plane. The largest-area wire is the outer
159/// boundary, the rest become holes.
160#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
161pub struct Profile {
162 pub plane: ProfilePlane,
163 pub wires: Vec<ProfileWire>,
164}
165
166/// Where a one-directional extrusion stops.
167#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
168pub enum ExtrudeTermination {
169 /// Fixed length in millimetres.
170 Blind { distance: f64 },
171 /// Extend well past the base solid's bounding box in this direction.
172 ThroughAll,
173 /// Stop on the given world-space plane, shifted by `offset` along its
174 /// normal (a picked planar face plus an offset-to-face value).
175 UpToPlane {
176 point: [f64; 3],
177 normal: [f64; 3],
178 offset: f64,
179 },
180 /// Stop on the base solid's face named `name`, else the one nearest
181 /// `point` (a picked face, where it was picked), exactly on its surface
182 /// whatever its shape, pushed `offset` out along its outward normal.
183 /// With no base solid, or no face of it there, the plane through
184 /// `point` square to `normal`.
185 UpToFace {
186 point: [f64; 3],
187 normal: [f64; 3],
188 offset: f64,
189 #[serde(default)]
190 name: TopoName,
191 },
192 /// Stop at the first face of the base solid hit along the extrusion
193 /// direction, on its surface.
194 ToFirst,
195 /// Stop at the last face of the base solid hit along the extrusion
196 /// direction, on its surface.
197 ToLast,
198 /// Stop on a set of the base solid's faces: every line of the sweep
199 /// ends at the first of them it meets, moved `offset` further along the
200 /// sweep (a negative offset stops short).
201 UpToShape { faces: Vec<FaceProbe>, offset: f64 },
202 /// Stop on a face of another shape: the face of `shape` (a native-format
203 /// snapshot, moved by `transform`, a rigid row-major 4×4 matrix, into
204 /// the body's frame) nearest `point`, exactly on its surface whatever
205 /// its shape, pushed `offset` out along its outward normal.
206 UpToFaceOf {
207 shape: Vec<u8>,
208 transform: Option<Box<[[f64; 4]; 4]>>,
209 point: [f64; 3],
210 offset: f64,
211 },
212 /// Stop on a set of faces as `UpToShape` does, some of them the base
213 /// solid's (`faces`) and some of other shapes (`others`, faces other
214 /// bodies lend this one). Needs no base solid when every face is
215 /// another shape's.
216 UpToShapeOf {
217 faces: Vec<FaceProbe>,
218 others: Vec<FacesOf>,
219 offset: f64,
220 },
221}
222
223/// Faces of another shape: the faces of `shape` (a native-format snapshot,
224/// moved by `transform`, a rigid row-major 4×4 matrix, into the body's
225/// frame) nearest each of `points`.
226#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
227pub struct FacesOf {
228 pub shape: Vec<u8>,
229 pub transform: Option<Box<[[f64; 4]; 4]>>,
230 pub points: Vec<[f64; 3]>,
231}
232
233/// Where a revolution stops turning.
234#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
235pub enum RevolveTermination {
236 /// Through the sweep's own angles.
237 #[default]
238 Angle,
239 /// On the first face of the base solid the profile's centre meets as it
240 /// turns.
241 ToFirst,
242 /// On the last face of the base solid the profile's centre meets as it
243 /// turns.
244 ToLast,
245 /// On the base solid's face nearest the probe.
246 UpToFace(FaceProbe),
247}
248
249/// How a profile is swept into a solid.
250#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
251pub enum SweepKind {
252 /// Linear extrusion along `plane.normal` (or `direction` when set).
253 Extrude {
254 termination: ExtrudeTermination,
255 /// Independent termination for the opposite side of the sketch plane
256 /// (two-sided extrusion). `None` extrudes one side only.
257 second_side: Option<ExtrudeTermination>,
258 /// Extrude half the blind distance to each side of the sketch plane.
259 symmetric: bool,
260 /// Swap which side of the sketch plane is "forward".
261 reversed: bool,
262 /// Draft angle applied along the sweep; positive widens the far end.
263 taper_deg: f64,
264 /// Custom world-space sweep direction; `None` uses the plane normal.
265 direction: Option<[f64; 3]>,
266 },
267 /// Revolution about an axis lying IN the sketch plane, given in sketch
268 /// 2D coordinates (point + direction). `angle_deg` in (0, 360].
269 Revolve {
270 axis_origin: [f64; 2],
271 axis_dir: [f64; 2],
272 angle_deg: f64,
273 /// Independent sweep angle for the opposite rotation direction.
274 second_angle_deg: Option<f64>,
275 /// Center the sweep on the sketch plane (half the angle each way).
276 midplane: bool,
277 reversed: bool,
278 /// Where the turn stops; anything but `Angle` takes the angle from
279 /// what the profile meets and leaves the angles above unused.
280 #[serde(default)]
281 termination: RevolveTermination,
282 },
283 /// Sweep the profile along a helix whose axis lies in the sketch plane.
284 /// A cone angle moves every point away from the axis by tan(angle) of
285 /// every pitch it climbs.
286 Helix {
287 axis_origin: [f64; 2],
288 axis_dir: [f64; 2],
289 pitch: f64,
290 height: f64,
291 left_handed: bool,
292 cone_angle_deg: f64,
293 reversed: bool,
294 /// How many turns, when given: the pitch is then `height / turns`
295 /// and `pitch` is not read. A height of 0 with turns and growth is
296 /// a flat spiral.
297 #[serde(default)]
298 turns: Option<f64>,
299 /// How far every point moves away from the axis per turn, when
300 /// given, in place of `cone_angle_deg`.
301 #[serde(default)]
302 growth: Option<f64>,
303 },
304 /// Sweep the profile along a helix whose axis runs square to the sketch
305 /// plane through `axis_origin` (sketch 2D coordinates): every point of
306 /// the profile climbs its own helix about it, the profile staying
307 /// level. The rest reads as for `Helix`.
308 HelixNormal {
309 axis_origin: [f64; 2],
310 pitch: f64,
311 height: f64,
312 left_handed: bool,
313 cone_angle_deg: f64,
314 reversed: bool,
315 #[serde(default)]
316 turns: Option<f64>,
317 #[serde(default)]
318 growth: Option<f64>,
319 },
320}
321
322/// How a pipe's section turns as it runs down its path.
323#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
324pub enum PipeFrame {
325 /// Rotation-minimizing: the section neither twists nor kinks where the
326 /// path bends.
327 #[default]
328 RotationMinimizing,
329 /// The path's own curvature frame, turning with it.
330 Frenet,
331 /// The section turns about the path so that one direction of it keeps
332 /// pointing at a second path running beside the first.
333 Auxiliary { path: Profile },
334 /// The section keeps a fixed binormal: the world-space direction square
335 /// to the path that the section's frame holds all the way.
336 Binormal { direction: [f64; 3] },
337 /// The section keeps its orientation in space: carried along the path
338 /// without ever turning, as it is drawn.
339 Fixed,
340}
341
342impl PipeFrame {
343 /// The frame an older `frenet` flag named.
344 pub fn from_frenet(frenet: bool) -> Self {
345 if frenet {
346 PipeFrame::Frenet
347 } else {
348 PipeFrame::RotationMinimizing
349 }
350 }
351}
352
353/// Reads a [`PipeFrame`] or the `frenet` flag it stands in for.
354pub fn deserialize_pipe_frame<'de, D>(deserializer: D) -> Result<PipeFrame, D::Error>
355where
356 D: serde::Deserializer<'de>,
357{
358 #[derive(Deserialize)]
359 #[serde(untagged)]
360 enum Stored {
361 Flag(bool),
362 Frame(PipeFrame),
363 }
364 Ok(match Stored::deserialize(deserializer)? {
365 Stored::Flag(frenet) => PipeFrame::from_frenet(frenet),
366 Stored::Frame(frame) => frame,
367 })
368}
369
370/// How a pipe's section turns a sharp corner of its path.
371#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
372pub enum PipeCorner {
373 /// The section is carried into the corner and sheared onto the plane
374 /// bisecting it: the two legs meet on that mitre.
375 #[default]
376 Transformed,
377 /// Each leg runs on straight past the corner and the two are fused,
378 /// leaving the outside of the corner square.
379 Right,
380 /// The section turns about the corner, the outside of it rounded.
381 Round,
382}
383
384/// Parametric primitive shapes (dimensions in millimetres, angles degrees).
385#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
386pub enum PrimitiveKind {
387 Box {
388 length: f64,
389 width: f64,
390 height: f64,
391 },
392 Cylinder {
393 radius: f64,
394 height: f64,
395 angle_deg: f64,
396 },
397 Sphere {
398 radius: f64,
399 /// Latitude range and longitude sweep (three-angle parameterization).
400 angle1_deg: f64,
401 angle2_deg: f64,
402 angle3_deg: f64,
403 },
404 Cone {
405 radius1: f64,
406 radius2: f64,
407 height: f64,
408 angle_deg: f64,
409 },
410 Torus {
411 radius1: f64,
412 radius2: f64,
413 angle1_deg: f64,
414 angle2_deg: f64,
415 angle3_deg: f64,
416 },
417 /// An ellipsoid, cut as a sphere is: between two latitudes about its
418 /// third axis and through a sweep round it.
419 Ellipsoid {
420 radius1: f64,
421 radius2: f64,
422 radius3: f64,
423 #[serde(default = "south_pole")]
424 angle1_deg: f64,
425 #[serde(default = "north_pole")]
426 angle2_deg: f64,
427 #[serde(default = "full_turn")]
428 angle3_deg: f64,
429 },
430 /// A regular prism, its top shifted by the skew angles: leaning that
431 /// far from its axis toward its x and its y.
432 Prism {
433 sides: u32,
434 circumradius: f64,
435 height: f64,
436 #[serde(default)]
437 skew_x_deg: f64,
438 #[serde(default)]
439 skew_y_deg: f64,
440 },
441 /// A hollow cylinder: a wall between the radii `inner` and `outer`
442 /// about its axis, `height` tall. The inner radius is above zero and
443 /// below the outer.
444 Tube { outer: f64, inner: f64, height: f64 },
445 /// Box with an independently sized top rectangle (zero top spans give a
446 /// pyramid). Spans are along local X (`x2*`) and Z (`z2*`) at height Y.
447 Wedge {
448 xmin: f64,
449 xmax: f64,
450 ymin: f64,
451 ymax: f64,
452 zmin: f64,
453 zmax: f64,
454 x2min: f64,
455 x2max: f64,
456 z2min: f64,
457 z2max: f64,
458 },
459}
460
461fn south_pole() -> f64 {
462 -90.0
463}
464
465fn north_pole() -> f64 {
466 90.0
467}
468
469fn full_turn() -> f64 {
470 360.0
471}
472
473/// A right-handed placement frame in world coordinates (millimetres).
474#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
475pub struct Placement {
476 pub origin: [f64; 3],
477 pub x_axis: [f64; 3],
478 pub z_axis: [f64; 3],
479}
480
481impl Default for Placement {
482 fn default() -> Self {
483 Self {
484 origin: [0.0; 3],
485 x_axis: [1.0, 0.0, 0.0],
486 z_axis: [0.0, 0.0, 1.0],
487 }
488 }
489}
490
491/// Which edges of the current solid a dress-up applies to. Edges are
492/// identified geometrically: by a face they border (sample point on the
493/// face) or by a point near the edge itself.
494#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
495pub enum EdgeSelection {
496 All,
497 OfFaces(Vec<[f64; 3]>),
498 /// The edges bordering the picked faces, each found by its name when
499 /// it has one.
500 OfPickedFaces(Vec<FaceProbe>),
501 Near(Vec<[f64; 3]>),
502 /// Edges picked one by one: each the nearest edge to its point that
503 /// runs along its direction there.
504 Picked(Vec<EdgeProbe>),
505}
506
507/// A picked edge, as a point beside it and the way it runs there, and the
508/// names of the two faces it runs between. A rebuild finds the edge
509/// between faces of those names, the point choosing among several; without
510/// names, the nearest edge. A zero direction leaves the way open.
511#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)]
512pub struct EdgeProbe {
513 pub point: [f64; 3],
514 pub direction: [f64; 3],
515 #[serde(default)]
516 pub faces: [TopoName; 2],
517}
518
519/// How a thickness's walls meet across an edge of the solid.
520#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
521pub enum ThicknessJoin {
522 /// The walls run on until they meet: sharp corners.
523 #[default]
524 Intersection,
525 /// The walls round about the edge, the wall thickness its radius.
526 Arc,
527}
528
529impl ThicknessJoin {
530 pub const ALL: [ThicknessJoin; 2] = [ThicknessJoin::Intersection, ThicknessJoin::Arc];
531
532 pub fn label(&self) -> &'static str {
533 match self {
534 ThicknessJoin::Intersection => "Intersection",
535 ThicknessJoin::Arc => "Arc",
536 }
537 }
538}
539
540/// How a fillet closes a vertex where its rounds meet.
541#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Hash, Serialize, Deserialize)]
542pub enum FilletCorner {
543 /// Each round stops short of the vertex and one patch, tangent to them
544 /// all, fills the opening.
545 #[default]
546 Setback,
547 /// The ball rolls through the corner: no round stops short, and the
548 /// rounds meet along the curves where they cross.
549 RollingBall,
550}
551
552/// The section of a round set back a different distance on each face.
553#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
554pub enum RoundProfile {
555 /// The ellipse tangent to each face at its distance: with equal
556 /// distances, the circular round.
557 #[default]
558 Elliptical,
559 /// The conic tangent to each face at its distance whose middle stands
560 /// the share `rho` of the way from the chord between the contacts to
561 /// the edge: near 0 a bevel, 0.5 a parabola, near 1 the sharp edge.
562 Conic { rho: f64 },
563}
564
565/// A round meeting its faces at two distances: the fillet's `radius` on
566/// the reference face, `other` on the face across the edge.
567#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
568pub struct RoundDistances {
569 pub other: f64,
570 /// Measure `radius` on the edge's other face.
571 pub flip: bool,
572 pub profile: RoundProfile,
573}
574
575/// A round whose radius runs along its edges, taken as one run end to end:
576/// the fillet's `radius` at the run's start, `end` at its end, and any
577/// radii between at shares of the run's length, smoothly between them and
578/// never past them.
579#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
580pub struct VariableRadius {
581 pub end: f64,
582 /// `[share, radius]` pairs, each share of the run's length from its
583 /// start strictly between 0 and 1, in increasing order.
584 #[serde(default)]
585 pub between: Vec<[f64; 2]>,
586 /// Start the run at the other end.
587 #[serde(default)]
588 pub reversed: bool,
589}
590
591/// How a chamfer closes a vertex where three or more of its bevels meet.
592#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Hash, Serialize, Deserialize)]
593pub enum ChamferCorner {
594 /// The bevels mitre into one point.
595 #[default]
596 Point,
597 /// Each bevel stops at a small flat facet across the corner: a
598 /// triangle where three bevels meet.
599 Facet,
600}
601
602/// Chamfer sizing, mirroring the three standard input styles.
603#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
604pub enum ChamferSpec {
605 EqualDistance {
606 distance: f64,
607 },
608 /// `distance` on each face, or as far as a face too narrow for it goes,
609 /// edge by edge.
610 Auto {
611 distance: f64,
612 },
613 TwoDistances {
614 distance1: f64,
615 distance2: f64,
616 },
617 DistanceAngle {
618 distance: f64,
619 angle_deg: f64,
620 },
621}
622
623impl SolidOp {
624 /// What a fillet's or chamfer's largest size depends on, hashed: the
625 /// op with its sizes left out.
626 /// `None` for any other op.
627 pub fn size_limit_key(&self) -> Option<u64> {
628 use std::hash::{Hash, Hasher};
629 let sized = match self {
630 SolidOp::Fillet {
631 edges,
632 follow_tangent,
633 corner,
634 distances,
635 auto,
636 variable: None,
637 ..
638 } => SolidOp::Fillet {
639 radius: 0.0,
640 edges: edges.clone(),
641 follow_tangent: *follow_tangent,
642 corner: *corner,
643 // Each face's limit is its own, whatever the distances.
644 distances: distances.map(|d| RoundDistances { other: 0.0, ..d }),
645 auto: *auto,
646 variable: None,
647 },
648 SolidOp::Chamfer {
649 spec,
650 flip,
651 edges,
652 follow_tangent,
653 corner,
654 } => SolidOp::Chamfer {
655 spec: match *spec {
656 ChamferSpec::EqualDistance { .. } => {
657 ChamferSpec::EqualDistance { distance: 0.0 }
658 }
659 ChamferSpec::Auto { .. } => ChamferSpec::Auto { distance: 0.0 },
660 // Each face's limit is its own, whatever the distances.
661 ChamferSpec::TwoDistances { .. } => ChamferSpec::TwoDistances {
662 distance1: 0.0,
663 distance2: 0.0,
664 },
665 ChamferSpec::DistanceAngle { angle_deg, .. } => ChamferSpec::DistanceAngle {
666 distance: 0.0,
667 angle_deg,
668 },
669 },
670 flip: *flip,
671 edges: edges.clone(),
672 follow_tangent: *follow_tangent,
673 corner: *corner,
674 },
675 _ => return None,
676 };
677 let mut hasher = std::collections::hash_map::DefaultHasher::new();
678 format!("{sized:?}").hash(&mut hasher);
679 Some(hasher.finish())
680 }
681}
682
683/// Boolean between the running solid and an external tool solid.
684#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
685pub enum BoolKind {
686 Fuse,
687 Cut,
688 Common,
689}
690
691/// One step in a body's build history. Shape-producing steps (`Sweep`,
692/// `Loft`, `Pipe`, `Primitive`) carry a [`BooleanOp`]; the remaining steps
693/// modify or combine the running solid directly.
694///
695/// A package builds these, so a variant keeps its fields for as long as
696/// the contract's minor version holds: a new option comes as a new
697/// variant, or as a new struct that derives `Default`.
698#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
699pub enum SolidOp {
700 /// Start the chain from a snapshot of another solid, in the native
701 /// format `SolidBuildResult::brep_blob` carries. Only ever the first op.
702 Shape { brep: Vec<u8> },
703 Sweep {
704 profile: Profile,
705 kind: SweepKind,
706 op: BooleanOp,
707 },
708 /// Extrude a flat face of the running solid: its outer and inner
709 /// boundaries are the profile and its outward normal the sketch
710 /// normal. `kind` is an `Extrude`.
711 SweepFace {
712 face: FaceProbe,
713 kind: SweepKind,
714 op: BooleanOp,
715 },
716 /// Extrude a flat face of another shape (native-format `shape`, moved by
717 /// `transform` into this body's frame): the face of it at `point`, a
718 /// face another body lends this one.
719 SweepFaceOf {
720 shape: Vec<u8>,
721 transform: Option<Box<[[f64; 4]; 4]>>,
722 point: [f64; 3],
723 kind: SweepKind,
724 op: BooleanOp,
725 },
726 /// Revolve a profile until it meets a face of another shape
727 /// (native-format `shape`, moved by `transform` into this body's frame):
728 /// the face of it nearest `point`, a face another body lends this one.
729 /// `kind` is a `Revolve`, whose own termination is not read.
730 RevolveToFaceOf {
731 profile: Profile,
732 kind: SweepKind,
733 shape: Vec<u8>,
734 transform: Option<Box<[[f64; 4]; 4]>>,
735 point: [f64; 3],
736 op: BooleanOp,
737 },
738 /// Skin through two or more sections (in order), each a profile, a
739 /// flat face of the running solid (its boundary) or a point, which
740 /// only the first or last may be.
741 LoftThrough {
742 sections: Vec<LoftSection>,
743 ruled: bool,
744 closed: bool,
745 op: BooleanOp,
746 },
747 /// Skin through two or more section profiles (in order).
748 Loft {
749 sections: Vec<Profile>,
750 ruled: bool,
751 closed: bool,
752 op: BooleanOp,
753 },
754 /// Sweep a profile along an open or closed spine wire from another
755 /// sketch, the section turning as `frame` says and turning its corners
756 /// as `corner` says. With `sections`, the section changes shape down
757 /// the path, passing through each of them where it crosses the path,
758 /// in order, the profile first.
759 Pipe {
760 profile: Profile,
761 spine: Profile,
762 #[serde(default, alias = "frenet", deserialize_with = "deserialize_pipe_frame")]
763 frame: PipeFrame,
764 #[serde(default)]
765 corner: PipeCorner,
766 #[serde(default)]
767 sections: Vec<Profile>,
768 op: BooleanOp,
769 },
770 /// A pipe whose profile may be a flat face of the running solid, whose
771 /// path may be edges of a solid, and whose last section may be a point
772 /// it closes to; the rest reads as for `Pipe`.
773 PipeThrough {
774 profile: LoftSection,
775 path: PipePath,
776 #[serde(default)]
777 frame: PipeFrame,
778 #[serde(default)]
779 corner: PipeCorner,
780 #[serde(default)]
781 sections: Vec<LoftSection>,
782 op: BooleanOp,
783 },
784 Primitive {
785 kind: PrimitiveKind,
786 placement: Placement,
787 op: BooleanOp,
788 },
789 /// Round the selected edges; with `follow_tangent`, every edge meeting
790 /// one of them tangentially joins the selection, and so on along the
791 /// chain. With `distances`, the round meets one face `radius` from the
792 /// edge and the other `distances.other`. With `auto` and one edge, a
793 /// face too narrow for `radius` takes its contact as far as it goes
794 /// while the other's goes on to `radius`, the round turning elliptical.
795 /// With `variable`, the radius runs from `radius` along the edges.
796 Fillet {
797 radius: f64,
798 edges: EdgeSelection,
799 #[serde(default)]
800 follow_tangent: bool,
801 #[serde(default)]
802 corner: FilletCorner,
803 #[serde(default)]
804 distances: Option<RoundDistances>,
805 #[serde(default)]
806 auto: bool,
807 #[serde(default)]
808 variable: Option<VariableRadius>,
809 },
810 /// Round between two faces of the running solid, which need share no
811 /// edge: the ball rolling between them, its round filling or taking off
812 /// what lies between it and the faces' meeting (a step across a groove).
813 BlendFaces { radius: f64, faces: [FaceProbe; 2] },
814 /// Bevel the selected edges, taking tangent chains as a fillet does.
815 Chamfer {
816 spec: ChamferSpec,
817 flip: bool,
818 edges: EdgeSelection,
819 #[serde(default)]
820 follow_tangent: bool,
821 #[serde(default)]
822 corner: ChamferCorner,
823 },
824 /// Tilt the selected faces by `angle_deg` about their intersection with
825 /// the neutral plane.
826 Draft {
827 angle_deg: f64,
828 neutral_point: [f64; 3],
829 neutral_normal: [f64; 3],
830 pull_dir: Option<[f64; 3]>,
831 faces: Vec<[f64; 3]>,
832 /// The name of each face, one per point, found by name first; empty
833 /// or zero where a face has none.
834 #[serde(default, skip_serializing_if = "Vec::is_empty")]
835 face_names: Vec<TopoName>,
836 },
837 /// Merge adjacent faces of the solid that lie on one plane: the split
838 /// a fuse or cut leaves where two pieces meet flush.
839 Refine,
840 /// Offset faces of the running solid along their outward normals by
841 /// `distance` (negative into the material), the faces around them
842 /// following on their own surfaces.
843 OffsetFaces {
844 faces: Vec<[f64; 3]>,
845 #[serde(default, skip_serializing_if = "Vec::is_empty")]
846 face_names: Vec<TopoName>,
847 distance: f64,
848 },
849 /// Move faces of the running solid rigidly by `transform` (row-major,
850 /// a translation or a rotation), the faces around them following.
851 MoveFaces {
852 faces: Vec<[f64; 3]>,
853 #[serde(default, skip_serializing_if = "Vec::is_empty")]
854 face_names: Vec<TopoName>,
855 transform: [[f64; 4]; 4],
856 },
857 /// Remove faces of the running solid and close the openings from the
858 /// neighbouring faces' own geometry: a hole, a boss or a fillet taken
859 /// away. Faces as points on them, named where they have names.
860 RemoveFaces {
861 faces: Vec<[f64; 3]>,
862 #[serde(default, skip_serializing_if = "Vec::is_empty")]
863 face_names: Vec<TopoName>,
864 },
865 /// Hollow the solid, removing the faces sampled by `open_faces`.
866 Thickness {
867 value: f64,
868 open_faces: Vec<[f64; 3]>,
869 /// The name of each open face, one per point; empty or zero where
870 /// a face has none.
871 #[serde(default, skip_serializing_if = "Vec::is_empty")]
872 open_face_names: Vec<TopoName>,
873 inward: bool,
874 /// How the walls meet where the solid's faces meet.
875 #[serde(default)]
876 join: ThicknessJoin,
877 /// The walls stand on both sides of the solid's faces, `value` each
878 /// way, rather than on the one `inward` says.
879 #[serde(default, skip_serializing_if = "std::ops::Not::not")]
880 both_sides: bool,
881 },
882 /// Re-apply earlier steps' tool solids (or the whole current solid when
883 /// `originals` is empty) under each transform, fusing additive tools and
884 /// cutting subtractive ones. `originals` holds chain indices of earlier
885 /// shape-producing steps.
886 Transform {
887 transforms: Vec<[[f64; 4]; 4]>,
888 originals: Vec<usize>,
889 },
890 /// [`SolidOp::Transform`] with the originals themselves left out: the
891 /// steps `originals` names build their tools without adding or cutting
892 /// them, so only the transformed copies go in. With `originals` empty
893 /// the running solid gives way to its copies.
894 TransformCopies {
895 transforms: Vec<[[f64; 4]; 4]>,
896 originals: Vec<usize>,
897 },
898 /// [`SolidOp::Transform`] whose transforms the chain works out from
899 /// `steps` where the op stands, so a step may follow an edge of the
900 /// solid as it is there. Occurrence 0 is the original; with it among
901 /// `skipped`, only the copies go in, as [`SolidOp::TransformCopies`].
902 Pattern {
903 steps: Vec<PatternStep>,
904 originals: Vec<usize>,
905 /// Occurrences left out, by index: 0 the original, then each copy
906 /// in the order the steps make them.
907 #[serde(default, skip_serializing_if = "Vec::is_empty")]
908 skipped: Vec<u32>,
909 },
910 /// Boolean against an external solid (another body's shape snapshot,
911 /// ogeom native-format text bytes).
912 Boolean {
913 tool_brep: Vec<u8>,
914 kind: BoolKind,
915 /// Where the tool sits in this chain's frame, when the two bodies
916 /// are placed differently: a rigid row-major 4×4 matrix.
917 #[serde(default)]
918 tool_transform: Option<[[f64; 4]; 4]>,
919 },
920 /// A surface step: a sheet added to the body, or the body's sheets
921 /// joined, trimmed or mirrored.
922 Surface(SurfaceOp),
923 /// `op` with its booleans run at a stated tolerance: geometry within
924 /// `tolerance` mm of touching counts as touching, so faces that nearly
925 /// meet are joined rather than left with a gap or a sliver between
926 /// them. The op keeps its place in the chain, as a pattern's
927 /// `originals` count it.
928 WithTolerance { tolerance: f64, op: Box<SolidOp> },
929 /// A sketch carried along its plane's normal onto faces of the running
930 /// solid, each face split along the curves where they land; `mode`
931 /// says whether the regions the curves enclose then stand out of the
932 /// faces or sink into them by `height`.
933 Project {
934 profile: Profile,
935 faces: Vec<FaceProbe>,
936 mode: ProjectMode,
937 height: f64,
938 },
939 /// A sketch wrapped onto the curved surface its `faces` lie on: the
940 /// sketch's middle lands where a straight projection along its plane's
941 /// normal puts it, and the rest is laid onto the surface from there.
942 /// A cylinder or cone is unrolled, every length kept, the way across
943 /// the axis turning about it and the way along the axis following it;
944 /// any other surface takes it as a flat sheet laid by geodesic polar
945 /// coordinates, lengths out from the middle kept and lengths across
946 /// them stretched by the surface's curvature. Otherwise as
947 /// [`SolidOp::Project`].
948 Wrap {
949 profile: Profile,
950 faces: Vec<FaceProbe>,
951 mode: ProjectMode,
952 height: f64,
953 },
954 /// Keep the running solid's material on one side of a plane: the side
955 /// `normal` points to from `origin`. A plane that leaves nothing on
956 /// that side fails, saying so.
957 HalfSpace { origin: [f64; 3], normal: [f64; 3] },
958 /// Grow the running solid by `distance` everywhere along its faces'
959 /// outward normals, or shrink it with a negative one: every face moved
960 /// that far and the faces around it following, its topology kept.
961 OffsetSolid { distance: f64 },
962 /// Scale the running solid by `factors` along the body's X, Y and Z
963 /// about `centre`, or about the middle of its bounding box when that
964 /// is `None`. Equal factors keep its surfaces' kinds; unequal ones
965 /// restate them as the kernel's general transform does.
966 Scale {
967 factors: [f64; 3],
968 centre: Option<[f64; 3]>,
969 },
970 /// Keep one piece of the running shape: of its solids, the one
971 /// nearest `near`, the others left out.
972 KeepPiece { near: [f64; 3] },
973}
974
975/// What a [`SolidOp::Project`] makes of the faces a sketch lands on.
976#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
977pub enum ProjectMode {
978 /// The faces split along the sketch's curves, the solid's shape
979 /// unchanged: lines later features and face colours can use.
980 #[default]
981 Split,
982 /// The regions the curves enclose raised out of the faces.
983 Emboss,
984 /// The regions the curves enclose sunk into the faces.
985 Deboss,
986}
987
988impl ProjectMode {
989 pub const ALL: [ProjectMode; 3] =
990 [ProjectMode::Split, ProjectMode::Emboss, ProjectMode::Deboss];
991
992 pub fn label(&self) -> &'static str {
993 match self {
994 ProjectMode::Split => "Split lines",
995 ProjectMode::Emboss => "Emboss",
996 ProjectMode::Deboss => "Deboss",
997 }
998 }
999}
1000
1001/// A curve a surface is built from.
1002#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1003pub enum CurveSource {
1004 /// A chain of a sketch's curves, open or closed, on its plane.
1005 Sketch {
1006 plane: ProfilePlane,
1007 wire: ProfileWire,
1008 },
1009 /// An edge of the body's own shape as it stands where the step comes,
1010 /// found as a fillet's picked edges are.
1011 Edge(EdgeProbe),
1012 /// An edge of another body's shape: `brep` is that body's snapshot,
1013 /// `edge` finds the edge in its own frame, and `transform` (a rigid
1014 /// row-major 4×4 matrix) carries it to where it sits in this chain's
1015 /// frame, when the two bodies are placed differently.
1016 BodyEdge {
1017 brep: Vec<u8>,
1018 edge: EdgeProbe,
1019 #[serde(default)]
1020 transform: Option<Box<[[f64; 4]; 4]>>,
1021 },
1022}
1023
1024/// How a surface meets the faces beside it across a shared edge.
1025#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
1026pub enum Continuity {
1027 /// Touching: no gap, a crease allowed.
1028 #[default]
1029 G0,
1030 /// Tangent: no crease.
1031 G1,
1032 /// Curvature continuous: no change in how sharply it bends.
1033 G2,
1034}
1035
1036/// The steps of surface modelling. A constructive step (every one but
1037/// `Sew`, `TrimByPlane` and `Mirror`) adds its sheet to the body beside
1038/// what is there; the rest act on all of the body's shape.
1039#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1040pub enum SurfaceOp {
1041 /// Each curve swept straight along `direction` by `length`, both ways
1042 /// by half of it when `symmetric`.
1043 Extrude {
1044 curves: Vec<CurveSource>,
1045 direction: [f64; 3],
1046 length: f64,
1047 #[serde(default)]
1048 symmetric: bool,
1049 },
1050 /// Each curve turned by `angle_deg` about the axis through `origin`
1051 /// along `axis`.
1052 Revolve {
1053 curves: Vec<CurveSource>,
1054 origin: [f64; 3],
1055 axis: [f64; 3],
1056 angle_deg: f64,
1057 },
1058 /// The flat face closed planar loops bound, a loop inside another a
1059 /// hole in it.
1060 PlanarFill { curves: Vec<CurveSource> },
1061 /// The surface curves meeting end to end bound, meeting the faces the
1062 /// boundary edges belong to with `continuity`.
1063 Fill {
1064 boundary: Vec<CurveSource>,
1065 #[serde(default)]
1066 continuity: Continuity,
1067 },
1068 /// The surface of straight lines between two curves, end to end.
1069 Ruled {
1070 first: CurveSource,
1071 second: CurveSource,
1072 },
1073 /// A surface through section curves in order, closing back to the first
1074 /// when `closed`.
1075 Loft {
1076 sections: Vec<CurveSource>,
1077 #[serde(default)]
1078 closed: bool,
1079 },
1080 /// A profile curve swept along a path.
1081 Sweep {
1082 profile: Vec<CurveSource>,
1083 path: Vec<CurveSource>,
1084 #[serde(default)]
1085 frame: PipeFrame,
1086 },
1087 /// A surface through section curves in order that also follows guide
1088 /// curves, each crossing every section once: one face.
1089 GuidedLoft {
1090 sections: Vec<CurveSource>,
1091 guides: Vec<CurveSource>,
1092 },
1093 /// A profile running from the first rail's start to the second's,
1094 /// swept along both: at each point along them it is turned and scaled
1095 /// so its ends ride the rails.
1096 SweepTwoRails {
1097 profile: Vec<CurveSource>,
1098 first_rail: Vec<CurveSource>,
1099 second_rail: Vec<CurveSource>,
1100 },
1101 /// Faces carried off along their normals by `distance`, as new faces.
1102 Offset {
1103 faces: Vec<FaceProbe>,
1104 distance: f64,
1105 },
1106 /// Faces carried past picked edges of their boundary by `length`.
1107 Extend {
1108 edges: Vec<EdgeProbe>,
1109 length: f64,
1110 #[serde(default)]
1111 continuity: Continuity,
1112 },
1113 /// A surface bridging two edges, meeting each edge's face with
1114 /// `continuity`.
1115 Blend {
1116 first: EdgeProbe,
1117 second: EdgeProbe,
1118 #[serde(default)]
1119 continuity: Continuity,
1120 },
1121 /// Picked faces split along curves projected onto them.
1122 Split {
1123 faces: Vec<FaceProbe>,
1124 curves: Vec<CurveSource>,
1125 },
1126 /// The body's faces joined where their edges meet, or come within
1127 /// `gap` of each other (0 for exactly); a shell that closes becomes a
1128 /// solid.
1129 Sew {
1130 #[serde(default)]
1131 gap: f64,
1132 },
1133 /// A round of `radius` along picked edges where two faces of a sheet
1134 /// meet.
1135 Fillet { edges: Vec<EdgeProbe>, radius: f64 },
1136 /// A round of `radius` between two faces of the body that need share
1137 /// no edge, such as two separate surfaces, each cut back to where it
1138 /// meets the round. The ball rolls on the side each face's normal
1139 /// points to, on the other where `flip` says so.
1140 FilletFaces {
1141 first: FaceProbe,
1142 second: FaceProbe,
1143 radius: f64,
1144 #[serde(default)]
1145 flip: [bool; 2],
1146 },
1147 /// The body's sheets given `thickness` along their normals (both ways
1148 /// by half when `both_sides`): a solid.
1149 Thicken {
1150 thickness: f64,
1151 #[serde(default)]
1152 both_sides: bool,
1153 },
1154 /// The body's sheets cut by the plane through `origin`, the side
1155 /// `normal` points to kept.
1156 TrimByPlane { origin: [f64; 3], normal: [f64; 3] },
1157 /// The body's shape and its reflection in the plane through `origin`
1158 /// square to `normal`.
1159 Mirror { origin: [f64; 3], normal: [f64; 3] },
1160 /// The body's sheets cut by each other, the faces lying on `scan`
1161 /// kept (at least `share` of each face's area within `tolerance` of
1162 /// it) and sewn: a closed shell becomes a solid. The scan's
1163 /// triangles, `scan` vertices taken three by three from `triangles`,
1164 /// are in the body's frame.
1165 TrimByScan {
1166 scan: Vec<[f32; 3]>,
1167 triangles: Vec<u32>,
1168 tolerance: f64,
1169 share: f64,
1170 },
1171 /// A free-form (B-spline) sheet fitted to scattered `points`, such as
1172 /// a region of a scan, within `tolerance` of them where it can.
1173 FitScattered {
1174 points: Vec<[f64; 3]>,
1175 tolerance: f64,
1176 },
1177 /// A network of B-spline patches fitted to `points` at once, each
1178 /// patch bounded by curves of the network and meeting its neighbours
1179 /// across them without a gap, tangent unless the curve is a crease.
1180 /// The network's curves are `curves`, one chain each, then
1181 /// `polylines`; a patch names its sides in order round it as curve
1182 /// numbers from 1, negative where the curve runs against the walk and 0
1183 /// for a side shrunk to a point.
1184 FitNetwork {
1185 curves: Vec<CurveSource>,
1186 polylines: Vec<Vec<[f64; 3]>>,
1187 #[serde(default)]
1188 patches: Vec<[i32; 4]>,
1189 /// Additional patches with each side a chain in walking order.
1190 /// An empty side is shrunk to a point; chain entries are nonzero
1191 /// signed curve numbers, as in `patches`.
1192 #[serde(default)]
1193 chained: Vec<[Vec<i32>; 4]>,
1194 /// Parameter-correction passes after refinement.
1195 #[serde(default)]
1196 corrections: u32,
1197 points: Vec<[f64; 3]>,
1198 tolerance: f64,
1199 smoothing: f64,
1200 /// The curves, numbered from 1, the patches meet across creased.
1201 creases: Vec<u32>,
1202 },
1203}
1204
1205impl SurfaceOp {
1206 /// Whether the step makes a new sheet (and so may begin a chain).
1207 pub fn constructs(&self) -> bool {
1208 !matches!(
1209 self,
1210 SurfaceOp::Sew { .. }
1211 | SurfaceOp::Fillet { .. }
1212 | SurfaceOp::FilletFaces { .. }
1213 | SurfaceOp::Thicken { .. }
1214 | SurfaceOp::TrimByPlane { .. }
1215 | SurfaceOp::Mirror { .. }
1216 | SurfaceOp::Split { .. }
1217 | SurfaceOp::Extend { .. }
1218 | SurfaceOp::TrimByScan { .. }
1219 )
1220 }
1221}
1222
1223/// One step of a [`SolidOp::Pattern`]: each applies to every occurrence of
1224/// the steps before it, the original among them, which stands first.
1225#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1226pub enum PatternStep {
1227 /// A copy under each transform (rigid or not, row-major), the
1228 /// original, untransformed, left out.
1229 Transforms(Vec<[[f64; 4]; 4]>),
1230 /// Copies along a path.
1231 Path(PathLayout),
1232}
1233
1234/// The path a [`PathLayout`] runs along, in the chain's frame.
1235#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1236pub enum PatternPath {
1237 /// A chain of curves on a plane, walked from its first segment's
1238 /// start.
1239 Wire {
1240 plane: ProfilePlane,
1241 wire: ProfileWire,
1242 },
1243 /// The edge of the solid, where the step stands, that the probe finds,
1244 /// walked from its curve's start.
1245 Edge(EdgeProbe),
1246}
1247
1248/// Occurrences at stations along a path by arc length, the original at
1249/// the first: occurrence k is moved from where the first station stands
1250/// to where the k-th does, turned as the path turns between them when
1251/// `align`.
1252#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1253pub struct PathLayout {
1254 pub path: PatternPath,
1255 /// Occurrences, the original counted.
1256 pub count: u32,
1257 /// Millimetres between neighbours along the path; `None` spreads them
1258 /// over the whole of it, evenly round it when it closes.
1259 #[serde(default, skip_serializing_if = "Option::is_none")]
1260 pub spacing: Option<f64>,
1261 /// Walk the path from its end.
1262 #[serde(default)]
1263 pub reversed: bool,
1264 /// Turn each copy as the path's direction turns from the first
1265 /// station to its own, carried along the path without twisting.
1266 #[serde(default)]
1267 pub align: bool,
1268}
1269
1270impl SolidOp {
1271 /// The op itself, out of any [`SolidOp::WithTolerance`] around it.
1272 pub fn inner(&self) -> &SolidOp {
1273 match self {
1274 SolidOp::WithTolerance { op, .. } => op.inner(),
1275 op => op,
1276 }
1277 }
1278
1279 /// The tolerance the op's booleans run at, when one is stated: the
1280 /// outermost [`SolidOp::WithTolerance`]'s.
1281 pub fn boolean_tolerance(&self) -> Option<f64> {
1282 match self {
1283 SolidOp::WithTolerance { tolerance, .. } => Some(*tolerance),
1284 _ => None,
1285 }
1286 }
1287
1288 /// The op with its booleans run at `tolerance`, or as it is with none.
1289 pub fn with_boolean_tolerance(self, tolerance: Option<f64>) -> SolidOp {
1290 match tolerance {
1291 Some(tolerance) => SolidOp::WithTolerance {
1292 tolerance,
1293 op: Box::new(self),
1294 },
1295 None => self,
1296 }
1297 }
1298
1299 /// Whether the step makes a shape of its own, so a chain may begin with
1300 /// it: a new solid, or a surface step that adds a sheet.
1301 pub fn starts_shape(&self) -> bool {
1302 match self.inner() {
1303 SolidOp::Surface(op) => op.constructs(),
1304 _ => self.boolean_op() == Some(BooleanOp::NewSolid),
1305 }
1306 }
1307
1308 /// The boolean role of a shape-producing step; `None` for modifiers.
1309 pub fn boolean_op(&self) -> Option<BooleanOp> {
1310 match self.inner() {
1311 SolidOp::Sweep { op, .. }
1312 | SolidOp::SweepFace { op, .. }
1313 | SolidOp::SweepFaceOf { op, .. }
1314 | SolidOp::RevolveToFaceOf { op, .. }
1315 | SolidOp::Loft { op, .. }
1316 | SolidOp::LoftThrough { op, .. }
1317 | SolidOp::PipeThrough { op, .. }
1318 | SolidOp::Pipe { op, .. }
1319 | SolidOp::Primitive { op, .. } => Some(*op),
1320 // A snapshot is a solid in itself: it begins a chain.
1321 SolidOp::Shape { .. } => Some(BooleanOp::NewSolid),
1322 _ => None,
1323 }
1324 }
1325}