Skip to content

Commit 3c512e9

Browse files
committed
Merge remote-tracking branch 'origin/main' into ben/chamfer_angle
2 parents 399bf8f + caecee0 commit 3c512e9

10 files changed

Lines changed: 73 additions & 10 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modeling-cmds/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "kittycad-modeling-cmds"
3-
version = "0.2.133"
3+
version = "0.2.139"
44
edition = "2021"
55
authors = ["KittyCAD, Inc."]
66
description = "Commands in the KittyCAD Modeling API"

modeling-cmds/src/def_enum.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ define_modeling_cmd_enum! {
3131
ExtrudedFaceInfo, ExtrudeMethod,
3232
AnnotationOptions, AnnotationType, CameraDragInteractionType, Color, DistanceType, EntityType,
3333
PathComponentConstraintBound, PathComponentConstraintType, PathSegment, PerspectiveCameraParameters,
34-
Point2d, Point3d, SceneSelectionType, SceneToolType, Opposite,
34+
Point2d, Point3d, ExtrudeReference, SceneSelectionType, SceneToolType, Opposite,
3535
},
3636
units,
3737
};
@@ -100,9 +100,11 @@ define_modeling_cmd_enum! {
100100
/// Segment to append to the path.
101101
/// This segment will implicitly begin at the current "pen" location.
102102
pub segment: PathSegment,
103+
/// Optional label to associate with the new path segment.
104+
#[serde(default, skip_serializing_if = "Option::is_none")]
105+
pub label: Option<String>,
103106
}
104107

105-
106108
/// Command for extruding a solid 2d.
107109
#[derive(
108110
Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
@@ -128,6 +130,28 @@ define_modeling_cmd_enum! {
128130
pub extrude_method: ExtrudeMethod,
129131
}
130132

133+
/// Command for extruding a solid 2d to a reference geometry.
134+
#[derive(
135+
Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant,
136+
)]
137+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
138+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
139+
pub struct ExtrudeToReference {
140+
/// Which sketch to extrude.
141+
/// Must be a closed 2D solid.
142+
pub target: ModelingCmdId,
143+
/// Reference to extrude to.
144+
/// Extrusion occurs along the target's normal until it is as close to the reference as possible.
145+
pub reference: ExtrudeReference,
146+
/// Which IDs should the new faces have?
147+
/// If this isn't given, the engine will generate IDs.
148+
#[serde(default)]
149+
pub faces: Option<ExtrudedFaceInfo>,
150+
/// Should the extrusion create a new object or be part of the existing object.
151+
#[serde(default)]
152+
pub extrude_method: ExtrudeMethod,
153+
}
154+
131155
fn default_twist_extrude_section_interval() -> Angle {
132156
Angle::from_degrees(15.0)
133157
}
@@ -568,8 +592,8 @@ define_modeling_cmd_enum! {
568592
pub start_angle: Angle,
569593
/// Is the helix rotation clockwise?
570594
pub is_clockwise: bool,
571-
/// Length of the helix.
572-
pub length: LengthUnit,
595+
/// Length of the helix. If None, the length of the cylinder will be used instead.
596+
pub length: Option<LengthUnit>,
573597
}
574598

575599
/// Create a helix using the specified parameters.

modeling-cmds/src/ok_response.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ define_ok_modeling_cmd_response_enum! {
4949
pub struct Extrude {
5050
}
5151

52+
/// The response from the `ExtrudeToReference` endpoint.
53+
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
54+
pub struct ExtrudeToReference {
55+
}
56+
5257
/// The response from the `TwistExtrude` endpoint.
5358
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
5459
pub struct TwistExtrude {

modeling-cmds/src/shared.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,34 @@ pub enum ExtrudeMethod {
824824
Merge,
825825
}
826826

827+
/// Type of reference geometry to extrude to.
828+
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
829+
#[serde(rename_all = "snake_case")]
830+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
831+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
832+
pub enum ExtrudeReference {
833+
/// Extrudes along the normal of the top face until it is as close to the entity as possible.
834+
/// An entity can be a solid, a path, a face, etc.
835+
EntityReference {
836+
/// The UUID of the entity to extrude to.
837+
entity_id: Uuid,
838+
},
839+
/// Extrudes until the top face is as close as possible to this given axis.
840+
Axis {
841+
/// The axis to extrude to.
842+
axis: Point3d<f64>,
843+
/// Point the axis goes through.
844+
/// Defaults to (0, 0, 0).
845+
#[serde(default)]
846+
point: Point3d<LengthUnit>,
847+
},
848+
/// Extrudes until the top face is as close as possible to this given point.
849+
Point {
850+
/// The point to extrude to.
851+
point: Point3d<LengthUnit>,
852+
},
853+
}
854+
827855
/// IDs for the extruded faces.
828856
#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone)]
829857
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

modeling-cmds/src/units.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl UnitLength {
7070

7171
/// The valid types of angle formats.
7272
#[derive(
73+
Default,
7374
Display,
7475
FromStr,
7576
Copy,
@@ -83,6 +84,7 @@ impl UnitLength {
8384
Ord,
8485
PartialOrd,
8586
UnitConversion,
87+
Hash,
8688
)]
8789
#[cfg_attr(feature = "tabled", derive(tabled::Tabled))]
8890
#[serde(rename_all = "snake_case")]
@@ -92,8 +94,11 @@ impl UnitLength {
9294
#[cfg_attr(feature = "python", pyo3::pyclass, pyo3_stub_gen::derive::gen_stub_pyclass_enum)]
9395
pub enum UnitAngle {
9496
/// Degrees <https://en.wikipedia.org/wiki/Degree_(angle)>
97+
#[default]
98+
#[display("deg")]
9599
Degrees,
96100
/// Radians <https://en.wikipedia.org/wiki/Radian>
101+
#[display("rad")]
97102
Radians,
98103
}
99104

modeling-cmds/tests/python_stub_dupes.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ fn print_duplicate_stub_names() {
3737
.map(|(n, c)| (n.to_string(), c))
3838
.collect();
3939

40-
eprintln!("duplicate classes: {:?}", dup_classes);
41-
eprintln!("duplicate enums: {:?}", dup_enums);
42-
43-
// This is informational; do not fail test. If we decide to enforce, we can assert emptiness.
40+
assert!(dup_classes.is_empty(), "Duplicate class names: {dup_classes:?}");
41+
assert!(dup_enums.is_empty(), "Duplicate enum names: {dup_enums:?}");
4442
}

modeling-session/examples/cube_png.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ async fn main() -> Result<()> {
9090
end: point,
9191
relative: false,
9292
},
93+
label: Default::default(),
9394
}
9495
.into(),
9596
)

modeling-session/examples/cube_png_batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ async fn main() -> Result<()> {
8787
cmd: ModelingCmd::ExtendPath(ExtendPath {
8888
path,
8989
segment: PathSegment::Line { end, relative: false },
90+
label: Default::default(),
9091
}),
9192
}),
9293
);

modeling-session/examples/lsystem_png_batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ async fn main() -> Result<()> {
121121
},
122122
relative: false,
123123
},
124+
label: Default::default(),
124125
}),
125126
});
126127
}

0 commit comments

Comments
 (0)