Skip to content

Commit aa231cc

Browse files
authored
Custom chamfer profiles (#938)
* add ratio and angle to chamfer enum * ratio is not a length unit * add custom cut type * improve comment * add swap arg to Chamfer enum * change ratio to second_length * break out enum variants and imlp defualt * make members public * revert back to enum * undo revert * derive default * remove default impl for CustomParams
1 parent dc7de8c commit aa231cc

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

modeling-cmds/src/shared.rs

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,59 @@ use crate::{length_unit::LengthUnit, output::ExtrusionFaceInfo, units::UnitAngle
1111

1212
mod point;
1313

14-
/// What kind of cut to do
14+
/// Params required to perform a fillet cut of an edge.
1515
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1616
#[serde(rename_all = "snake_case")]
1717
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1818
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
19+
pub struct FilletParams {
20+
/// The second length affects the edge length of the second face of the cut. This will
21+
/// cause the fillet to take on the shape of a conic section, instead of an arc.
22+
pub second_length: Option<LengthUnit>,
23+
}
24+
25+
/// Params required to perform a chamfer cut of an edge.
26+
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
27+
#[serde(rename_all = "snake_case")]
28+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
29+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
30+
pub struct ChamferParams {
31+
/// The second length affects the edge length of the second face of the cut.
32+
pub second_length: Option<LengthUnit>,
33+
/// The angle of the chamfer, default is 45deg.
34+
pub angle: Option<Angle>,
35+
/// If true, the second length or angle is applied to the other face of the cut.
36+
pub swap: bool,
37+
}
38+
39+
/// Params required to perform a custom profile cut of an edge.
40+
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
41+
#[serde(rename_all = "snake_case")]
42+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
43+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
44+
pub struct CustomParams {
45+
/// The path that will be used for the custom profile.
46+
pub path: Uuid,
47+
}
48+
49+
/// What kind of cut to perform when cutting an edge.
50+
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
51+
#[serde(rename_all = "snake_case")]
52+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
53+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1954
pub enum CutType {
2055
/// Round off an edge.
21-
#[default]
22-
Fillet,
56+
Fillet(FilletParams),
2357
/// Cut away an edge.
24-
Chamfer,
58+
Chamfer(ChamferParams),
59+
/// A custom cut profile.
60+
Custom(CustomParams),
61+
}
62+
63+
impl Default for CutType {
64+
fn default() -> Self {
65+
crate::shared::CutType::Fillet(FilletParams::default())
66+
}
2567
}
2668

2769
/// A rotation defined by an axis, origin of rotation, and an angle.

0 commit comments

Comments
 (0)