Skip to content

Commit 3004b11

Browse files
committed
Allow updating existing bodies too
Serena pointed out that if the extrude uses method=NEW, this will update old bodies by adding new surfaces, instead of creating new bodies. Let's be explicit about this.
1 parent fbd5b34 commit 3004b11

3 files changed

Lines changed: 71 additions & 12 deletions

File tree

modeling-cmds/openapi/api.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,7 +2939,6 @@
29392939
"type": "string",
29402940
"format": "uuid"
29412941
},
2942-
<<<<<<< HEAD
29432942
"edge_reference": {
29442943
"nullable": true,
29452944
"description": "Edge reference to use as the axis of revolution (new API). If both `edge_id` and `edge_reference` are provided, `edge_reference` takes precedence.",
@@ -2948,13 +2947,11 @@
29482947
"$ref": "#/components/schemas/EdgeSpecifier"
29492948
}
29502949
]
2951-
||||||| parent of 3cb4bff (Configurable seams)
2952-
=======
2950+
},
29532951
"keep_seams": {
29542952
"description": "When two collinear segments are extruded, what should happen? If true, creates a body with two surfaces. If false, creates a body with one surface, spanning both collinear segments.",
29552953
"default": false,
29562954
"type": "boolean"
2957-
>>>>>>> 3cb4bff (Configurable seams)
29582955
},
29592956
"opposite": {
29602957
"description": "Should the revolution also revolve in the opposite direction along the given axis? If so, this specifies its angle.",

modeling-cmds/src/ok_response.rs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define_ok_modeling_cmd_response_enum! {
2424
base64::Base64Data,
2525
id::ModelingCmdId,
2626
length_unit::LengthUnit,
27-
shared::{CurveType, EntityType, ExportFile, ExtrusionFaceCapType, PathCommand, Point2d, Point3d, BodiesCreated},
27+
shared::{CurveType, EntityType, ExportFile, ExtrusionFaceCapType, PathCommand, Point2d, Point3d, BodiesCreated, BodiesUpdated},
2828
units,
2929
};
3030

@@ -59,39 +59,59 @@ define_ok_modeling_cmd_response_enum! {
5959
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
6060
pub struct Extrude {
6161
/// Any new bodies created by the request.
62-
pub bodies: BodiesCreated,
62+
#[serde(default, skip_serializing_if = "BodiesCreated::is_empty")]
63+
pub bodies_created: BodiesCreated,
64+
/// Any existing bodies updated by the request.
65+
#[serde(default, skip_serializing_if = "BodiesUpdated::is_empty")]
66+
pub bodies_updated: BodiesUpdated,
6367
}
6468

6569
/// The response from the `ExtrudeToReference` endpoint.
6670
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
6771
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
6872
pub struct ExtrudeToReference {
6973
/// Any new bodies created by the request.
70-
pub bodies: BodiesCreated,
74+
#[serde(default, skip_serializing_if = "BodiesCreated::is_empty")]
75+
pub bodies_created: BodiesCreated,
76+
/// Any existing bodies updated by the request.
77+
#[serde(default, skip_serializing_if = "BodiesUpdated::is_empty")]
78+
pub bodies: BodiesUpdated,
7179
}
7280

7381
/// The response from the `TwistExtrude` endpoint.
7482
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
7583
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
7684
pub struct TwistExtrude {
7785
/// Any new bodies created by the request.
78-
pub bodies: BodiesCreated,
86+
#[serde(default, skip_serializing_if = "BodiesCreated::is_empty")]
87+
pub bodies_created: BodiesCreated,
88+
/// Any existing bodies updated by the request.
89+
#[serde(default, skip_serializing_if = "BodiesUpdated::is_empty")]
90+
pub bodies: BodiesUpdated,
7991
}
8092

8193
/// The response from the `Sweep` endpoint.
8294
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
8395
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
8496
pub struct Sweep {
8597
/// Any new bodies created by the request.
86-
pub bodies: BodiesCreated,
98+
#[serde(default, skip_serializing_if = "BodiesCreated::is_empty")]
99+
pub bodies_created: BodiesCreated,
100+
/// Any existing bodies updated by the request.
101+
#[serde(default, skip_serializing_if = "BodiesUpdated::is_empty")]
102+
pub bodies: BodiesUpdated,
87103
}
88104

89105
/// The response from the `Revolve` endpoint.
90106
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
91107
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
92108
pub struct Revolve {
93109
/// Any new bodies created by the request.
94-
pub bodies: BodiesCreated,
110+
#[serde(default, skip_serializing_if = "BodiesCreated::is_empty")]
111+
pub bodies_created: BodiesCreated,
112+
/// Any existing bodies updated by the request.
113+
#[serde(default, skip_serializing_if = "BodiesUpdated::is_empty")]
114+
pub bodies: BodiesUpdated,
95115
}
96116

97117
/// The response from the `Solid3dShellFace` endpoint.
@@ -146,7 +166,11 @@ define_ok_modeling_cmd_response_enum! {
146166
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
147167
pub struct RevolveAboutEdge {
148168
/// Any new bodies created by the request.
149-
pub bodies: BodiesCreated,
169+
#[serde(default, skip_serializing_if = "BodiesCreated::is_empty")]
170+
pub bodies_created: BodiesCreated,
171+
/// Any existing bodies updated by the request.
172+
#[serde(default, skip_serializing_if = "BodiesUpdated::is_empty")]
173+
pub bodies: BodiesUpdated,
150174
}
151175

152176
/// The response from the `CameraDragStart` endpoint.

modeling-cmds/src/shared.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ pub struct SurfaceEdgeReference {
19111911
}
19121912

19131913
/// List of bodies that were created by an operation.
1914-
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1914+
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
19151915
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
19161916
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
19171917
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
@@ -1921,6 +1921,31 @@ pub struct BodiesCreated {
19211921
pub bodies: Vec<BodyCreated>,
19221922
}
19231923

1924+
impl BodiesCreated {
1925+
/// Are there any bodies in this list?
1926+
pub fn is_empty(&self) -> bool {
1927+
self.bodies.is_empty()
1928+
}
1929+
}
1930+
1931+
/// List of bodies that were updated by an operation.
1932+
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default)]
1933+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1934+
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1935+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1936+
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1937+
pub struct BodiesUpdated {
1938+
/// All bodies created by this operation.
1939+
pub bodies: Vec<BodyUpdated>,
1940+
}
1941+
1942+
impl BodiesUpdated {
1943+
/// Are there any bodies in this list?
1944+
pub fn is_empty(&self) -> bool {
1945+
self.bodies.is_empty()
1946+
}
1947+
}
1948+
19241949
/// Details of a body that was created.
19251950
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
19261951
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
@@ -1934,6 +1959,19 @@ pub struct BodyCreated {
19341959
pub surfaces: Vec<SurfaceCreated>,
19351960
}
19361961

1962+
/// Details of a body that was updated.
1963+
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1964+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1965+
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1966+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1967+
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1968+
pub struct BodyUpdated {
1969+
/// The body's ID.
1970+
pub id: Uuid,
1971+
/// Surfaces added to this body.
1972+
pub surfaces: Vec<SurfaceCreated>,
1973+
}
1974+
19371975
/// Details of a surface that was created under some body.
19381976
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
19391977
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

0 commit comments

Comments
 (0)