Skip to content

Commit 19ee600

Browse files
Expose Extrude Method (#905)
* add new argument to extrude endpoint * switch over to enum for method * serde enum to snake_case * change Add to Merge * fix tests * spelling and improving comment of api --------- Co-authored-by: Adam Chalmers <[email protected]>
1 parent dee1467 commit 19ee600

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

modeling-cmds/src/def_enum.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ define_modeling_cmd_enum! {
2828
CutType,
2929
CutStrategy,
3030
CameraMovement,
31-
ExtrudedFaceInfo,
31+
ExtrudedFaceInfo, ExtrudeMethod,
3232
AnnotationOptions, AnnotationType, CameraDragInteractionType, Color, DistanceType, EntityType,
3333
PathComponentConstraintBound, PathComponentConstraintType, PathSegment, PerspectiveCameraParameters,
3434
Point2d, Point3d, SceneSelectionType, SceneToolType, Opposite,
@@ -123,6 +123,10 @@ define_modeling_cmd_enum! {
123123
/// If so, this specifies its distance.
124124
#[serde(default)]
125125
pub opposite: Opposite<LengthUnit>,
126+
/// Should the extrusion create a new object or be part of the existing object. If a
127+
/// new object is created, the command id will be the id of the newly created object.
128+
#[serde(default)]
129+
pub extrude_method: ExtrudeMethod,
126130
}
127131

128132
fn default_twist_extrude_section_interval() -> Angle {

modeling-cmds/src/shared.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,22 @@ impl From<EngineErrorCode> for http::StatusCode {
728728
}
729729
}
730730

731+
/// Extrusion method determining if the extrusion will be part of the existing object or an
732+
/// entirely new object.
733+
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
734+
#[serde(rename_all = "snake_case")]
735+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
736+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
737+
pub enum ExtrudeMethod {
738+
/// Create a new object that is not connected to the object it is extruded from. This will
739+
/// result in two objects after the operation.
740+
New,
741+
/// This extrusion will be part of object it is extruded from. This will result in one object
742+
/// after the operation.
743+
#[default]
744+
Merge,
745+
}
746+
731747
/// IDs for the extruded faces.
732748
#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone)]
733749
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

modeling-session/examples/cube_png.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ async fn main() -> Result<()> {
109109
target: path,
110110
faces: None,
111111
opposite: Default::default(),
112+
extrude_method: Default::default(),
112113
}
113114
.into(),
114115
)

modeling-session/examples/cube_png_batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ async fn main() -> Result<()> {
100100
target: path,
101101
faces: None,
102102
opposite: Default::default(),
103+
extrude_method: Default::default(),
103104
}),
104105
cmd_id: random_id(),
105106
});

modeling-session/examples/lsystem_png_batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ async fn main() -> Result<()> {
139139
target: path,
140140
faces: None,
141141
opposite: Default::default(),
142+
extrude_method: Default::default(),
142143
}),
143144
cmd_id: random_id(),
144145
});

0 commit comments

Comments
 (0)