Skip to content

Commit 2535246

Browse files
authored
Surface extrude (#1005)
* define BodyType * connect rust and cxx enum * add bodyType to other extrude methods * fix build errors * fix typo * redo openapi
1 parent fa3069b commit 2535246

File tree

6 files changed

+73
-0
lines changed

6 files changed

+73
-0
lines changed

modeling-cmds/openapi/api.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,25 @@
642642
"direction"
643643
]
644644
},
645+
"BodyType": {
646+
"description": "Body type determining if the operation will create a solid or a surface.",
647+
"oneOf": [
648+
{
649+
"description": "Create a body that has two caps, creating a solid object.",
650+
"type": "string",
651+
"enum": [
652+
"solid"
653+
]
654+
},
655+
{
656+
"description": "Create only the surface of the body without any caps.",
657+
"type": "string",
658+
"enum": [
659+
"surface"
660+
]
661+
}
662+
]
663+
},
645664
"CameraDragInteractionType": {
646665
"description": "The type of camera drag interaction.",
647666
"oneOf": [
@@ -1829,6 +1848,15 @@
18291848
"description": "Command for extruding a solid 2d.",
18301849
"type": "object",
18311850
"properties": {
1851+
"body_type": {
1852+
"description": "Should this extrude create a solid body or a surface?",
1853+
"default": "solid",
1854+
"allOf": [
1855+
{
1856+
"$ref": "#/components/schemas/BodyType"
1857+
}
1858+
]
1859+
},
18321860
"distance": {
18331861
"description": "How far off the plane to extrude",
18341862
"allOf": [
@@ -1890,6 +1918,15 @@
18901918
"description": "Command for extruding a solid 2d to a reference geometry.",
18911919
"type": "object",
18921920
"properties": {
1921+
"body_type": {
1922+
"description": "Should this extrude create a solid body or a surface?",
1923+
"default": "solid",
1924+
"allOf": [
1925+
{
1926+
"$ref": "#/components/schemas/BodyType"
1927+
}
1928+
]
1929+
},
18931930
"extrude_method": {
18941931
"description": "Should the extrusion create a new object or be part of the existing object.",
18951932
"default": "merge",
@@ -1954,6 +1991,15 @@
19541991
}
19551992
]
19561993
},
1994+
"body_type": {
1995+
"description": "Should this extrude create a solid body or a surface?",
1996+
"default": "solid",
1997+
"allOf": [
1998+
{
1999+
"$ref": "#/components/schemas/BodyType"
2000+
}
2001+
]
2002+
},
19572003
"center_2d": {
19582004
"description": "Center to twist about (relative to 2D sketch)",
19592005
"default": {

modeling-cmds/src/def_enum.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ define_modeling_cmd_enum! {
2323
length_unit::LengthUnit,
2424
shared::{
2525
Angle,
26+
BodyType,
2627
ComponentTransform,
2728
RelativeTo,
2829
CutType, CutTypeV2,
@@ -128,6 +129,9 @@ define_modeling_cmd_enum! {
128129
/// Should the extrusion create a new object or be part of the existing object.
129130
#[serde(default)]
130131
pub extrude_method: ExtrudeMethod,
132+
/// Should this extrude create a solid body or a surface?
133+
#[serde(default)]
134+
pub body_type: BodyType,
131135
}
132136

133137
/// Command for extruding a solid 2d to a reference geometry.
@@ -150,6 +154,9 @@ define_modeling_cmd_enum! {
150154
/// Should the extrusion create a new object or be part of the existing object.
151155
#[serde(default)]
152156
pub extrude_method: ExtrudeMethod,
157+
/// Should this extrude create a solid body or a surface?
158+
#[serde(default)]
159+
pub body_type: BodyType,
153160
}
154161

155162
fn default_twist_extrude_section_interval() -> Angle {
@@ -182,6 +189,9 @@ define_modeling_cmd_enum! {
182189
pub angle_step_size: Angle,
183190
///The twisted surface loft tolerance
184191
pub tolerance: LengthUnit,
192+
/// Should this extrude create a solid body or a surface?
193+
#[serde(default)]
194+
pub body_type: BodyType,
185195
}
186196

187197
/// Extrude the object along a path.

modeling-cmds/src/shared.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,19 @@ impl From<EngineErrorCode> for http::StatusCode {
10411041
}
10421042
}
10431043

1044+
/// Body type determining if the operation will create a solid or a surface.
1045+
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
1046+
#[serde(rename_all = "snake_case")]
1047+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1048+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1049+
pub enum BodyType {
1050+
///Create a body that has two caps, creating a solid object.
1051+
#[default]
1052+
Solid,
1053+
///Create only the surface of the body without any caps.
1054+
Surface,
1055+
}
1056+
10441057
/// Extrusion method determining if the extrusion will be part of the existing object or an
10451058
/// entirely new object.
10461059
#[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
@@ -1342,6 +1355,7 @@ impl_extern_type! {
13421355
// Scene
13431356
SceneSelectionType = "Enums::_SceneSelectionType"
13441357
SceneToolType = "Enums::_SceneToolType"
1358+
BodyType = "Enums::_BodyType"
13451359
EntityType = "Enums::_EntityType"
13461360
AnnotationType = "Enums::_AnnotationType"
13471361
AnnotationTextAlignmentX = "Enums::_AnnotationTextAlignmentX"

modeling-session/examples/cube_png.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ async fn main() -> Result<()> {
113113
faces: None,
114114
opposite: Default::default(),
115115
extrude_method: Default::default(),
116+
body_type: Default::default(),
116117
}
117118
.into(),
118119
)

modeling-session/examples/cube_png_batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ async fn main() -> Result<()> {
104104
faces: None,
105105
opposite: Default::default(),
106106
extrude_method: Default::default(),
107+
body_type: Default::default(),
107108
}),
108109
cmd_id: random_id(),
109110
});

modeling-session/examples/lsystem_png_batch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ async fn main() -> Result<()> {
143143
faces: None,
144144
opposite: Default::default(),
145145
extrude_method: Default::default(),
146+
body_type: Default::default(),
146147
}),
147148
cmd_id: random_id(),
148149
});

0 commit comments

Comments
 (0)