Skip to content

Commit fbd5b34

Browse files
committed
Non-destructive, partial extrudes/revolves/sweeps etc
This proposes a new way to surface extrude/revolve/sweep for sketch 2. Instead of extruding an entire sketch (solid2D) at once, we instead take a list of segments and extrude each of those separately. Each segment has a (segment ID, new body ID) pair, so the segment IDs are NOT absorbed into new body IDs. The sketch and all its segments are not modified.
1 parent 4078758 commit fbd5b34

4 files changed

Lines changed: 195 additions & 3 deletions

File tree

modeling-cmds/openapi/api.json

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,11 @@
22882288
}
22892289
]
22902290
},
2291+
"keep_seams": {
2292+
"description": "When two collinear segments are extruded, what should happen? If true, creates a body with two separate surfaces. If false, creates a body with one surface, spanning both collinear segments.",
2293+
"default": false,
2294+
"type": "boolean"
2295+
},
22912296
"merge_coplanar_faces": {
22922297
"nullable": true,
22932298
"description": "Only used if the extrusion is created from a face and extrude_method = Merge If true, coplanar faces will be merged and seams will be hidden. Otherwise, seams between the extrusion and original body will be shown.",
@@ -2302,8 +2307,17 @@
23022307
}
23032308
]
23042309
},
2310+
"segments": {
2311+
"nullable": true,
2312+
"description": "If given, extrude each of these segments into a separate body with the given ID.",
2313+
"type": "array",
2314+
"items": {
2315+
"type": "string",
2316+
"format": "uuid"
2317+
}
2318+
},
23052319
"target": {
2306-
"description": "Which sketch to extrude. Must be a closed 2D solid.",
2320+
"description": "Which sketch to extrude. Must be a 2D sketch.",
23072321
"allOf": [
23082322
{
23092323
"$ref": "#/components/schemas/ModelingCmdId"
@@ -2355,6 +2369,11 @@
23552369
}
23562370
]
23572371
},
2372+
"keep_seams": {
2373+
"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.",
2374+
"default": false,
2375+
"type": "boolean"
2376+
},
23582377
"reference": {
23592378
"description": "Reference to extrude to. Extrusion occurs along the target's normal until it is as close to the reference as possible.",
23602379
"allOf": [
@@ -2363,6 +2382,15 @@
23632382
}
23642383
]
23652384
},
2385+
"segments": {
2386+
"nullable": true,
2387+
"description": "If given, extrude each of these segments into a separate body with the given ID.",
2388+
"type": "array",
2389+
"items": {
2390+
"type": "string",
2391+
"format": "uuid"
2392+
}
2393+
},
23662394
"target": {
23672395
"description": "Which sketch to extrude. Must be a closed 2D solid.",
23682396
"allOf": [
@@ -2439,6 +2467,20 @@
24392467
}
24402468
]
24412469
},
2470+
"keep_seams": {
2471+
"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.",
2472+
"default": false,
2473+
"type": "boolean"
2474+
},
2475+
"segments": {
2476+
"nullable": true,
2477+
"description": "If given, extrude each of these segments into a separate body with the given ID.",
2478+
"type": "array",
2479+
"items": {
2480+
"type": "string",
2481+
"format": "uuid"
2482+
}
2483+
},
24422484
"target": {
24432485
"description": "Which sketch to extrude. Must be a closed 2D solid.",
24442486
"allOf": [
@@ -2491,6 +2533,11 @@
24912533
}
24922534
]
24932535
},
2536+
"keep_seams": {
2537+
"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.",
2538+
"default": false,
2539+
"type": "boolean"
2540+
},
24942541
"relative_to": {
24952542
"description": "What is this sweep relative to?",
24962543
"default": "sketch_plane",
@@ -2504,6 +2551,15 @@
25042551
"description": "If true, the sweep will be broken up into sub-sweeps (extrusions, revolves, sweeps) based on the trajectory path components.",
25052552
"type": "boolean"
25062553
},
2554+
"segments": {
2555+
"nullable": true,
2556+
"description": "If given, extrude each of these segments into a separate body with the given ID.",
2557+
"type": "array",
2558+
"items": {
2559+
"type": "string",
2560+
"format": "uuid"
2561+
}
2562+
},
25072563
"target": {
25082564
"description": "Which sketch to sweep. Must be a closed 2D solid.",
25092565
"allOf": [
@@ -2583,6 +2639,11 @@
25832639
}
25842640
]
25852641
},
2642+
"keep_seams": {
2643+
"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.",
2644+
"default": false,
2645+
"type": "boolean"
2646+
},
25862647
"opposite": {
25872648
"description": "Should the revolution also revolve in the opposite direction along the given axis? If so, this specifies its angle.",
25882649
"default": "None",
@@ -2600,6 +2661,15 @@
26002661
}
26012662
]
26022663
},
2664+
"segments": {
2665+
"nullable": true,
2666+
"description": "If given, extrude each of these segments into a separate body with the given ID.",
2667+
"type": "array",
2668+
"items": {
2669+
"type": "string",
2670+
"format": "uuid"
2671+
}
2672+
},
26032673
"target": {
26042674
"description": "Which sketch to revolve. Must be a closed 2D solid.",
26052675
"allOf": [
@@ -2869,6 +2939,7 @@
28692939
"type": "string",
28702940
"format": "uuid"
28712941
},
2942+
<<<<<<< HEAD
28722943
"edge_reference": {
28732944
"nullable": true,
28742945
"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.",
@@ -2877,6 +2948,13 @@
28772948
"$ref": "#/components/schemas/EdgeSpecifier"
28782949
}
28792950
]
2951+
||||||| parent of 3cb4bff (Configurable seams)
2952+
=======
2953+
"keep_seams": {
2954+
"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.",
2955+
"default": false,
2956+
"type": "boolean"
2957+
>>>>>>> 3cb4bff (Configurable seams)
28802958
},
28812959
"opposite": {
28822960
"description": "Should the revolution also revolve in the opposite direction along the given axis? If so, this specifies its angle.",
@@ -2887,6 +2965,15 @@
28872965
}
28882966
]
28892967
},
2968+
"segments": {
2969+
"nullable": true,
2970+
"description": "If given, extrude each of these segments into a separate body with the given ID.",
2971+
"type": "array",
2972+
"items": {
2973+
"type": "string",
2974+
"format": "uuid"
2975+
}
2976+
},
28902977
"target": {
28912978
"description": "Which sketch to revolve. Must be a closed 2D solid.",
28922979
"allOf": [

modeling-cmds/src/def_enum.rs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,17 @@ define_modeling_cmd_enum! {
128128
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
129129
pub struct Extrude {
130130
/// Which sketch to extrude.
131-
/// Must be a closed 2D solid.
131+
/// Must be a 2D sketch.
132132
pub target: ModelingCmdId,
133+
/// If given, extrude each of these segments into a separate body with the given ID.
134+
#[serde(default, skip_serializing_if = "Option::is_none")]
135+
pub segments: Option<Vec<Uuid>>,
136+
/// When two collinear segments are extruded, what should happen?
137+
/// If true, creates a body with two separate surfaces.
138+
/// If false, creates a body with one surface, spanning both collinear segments.
139+
#[serde(default)]
140+
#[builder(default)]
141+
pub keep_seams: bool,
133142
/// How far off the plane to extrude
134143
pub distance: LengthUnit,
135144
/// Which IDs should the new faces have?
@@ -169,6 +178,15 @@ define_modeling_cmd_enum! {
169178
/// Which sketch to extrude.
170179
/// Must be a closed 2D solid.
171180
pub target: ModelingCmdId,
181+
/// If given, extrude each of these segments into a separate body with the given ID.
182+
#[serde(default, skip_serializing_if = "Option::is_none")]
183+
pub segments: Option<Vec<Uuid>>,
184+
/// When two collinear segments are extruded, what should happen?
185+
/// If true, creates a body with two surfaces.
186+
/// If false, creates a body with one surface, spanning both collinear segments.
187+
#[serde(default)]
188+
#[builder(default)]
189+
pub keep_seams: bool,
172190
/// Reference to extrude to.
173191
/// Extrusion occurs along the target's normal until it is as close to the reference as possible.
174192
pub reference: ExtrudeReference,
@@ -202,6 +220,15 @@ define_modeling_cmd_enum! {
202220
/// Which sketch to extrude.
203221
/// Must be a closed 2D solid.
204222
pub target: ModelingCmdId,
223+
/// If given, extrude each of these segments into a separate body with the given ID.
224+
#[serde(default, skip_serializing_if = "Option::is_none")]
225+
pub segments: Option<Vec<Uuid>>,
226+
/// When two collinear segments are extruded, what should happen?
227+
/// If true, creates a body with two surfaces.
228+
/// If false, creates a body with one surface, spanning both collinear segments.
229+
#[serde(default)]
230+
#[builder(default)]
231+
pub keep_seams: bool,
205232
/// How far off the plane to extrude
206233
pub distance: LengthUnit,
207234
/// Which IDs should the new faces have?
@@ -239,6 +266,15 @@ define_modeling_cmd_enum! {
239266
/// Which sketch to sweep.
240267
/// Must be a closed 2D solid.
241268
pub target: ModelingCmdId,
269+
/// If given, extrude each of these segments into a separate body with the given ID.
270+
#[serde(default, skip_serializing_if = "Option::is_none")]
271+
pub segments: Option<Vec<Uuid>>,
272+
/// When two collinear segments are extruded, what should happen?
273+
/// If true, creates a body with two surfaces.
274+
/// If false, creates a body with one surface, spanning both collinear segments.
275+
#[serde(default)]
276+
#[builder(default)]
277+
pub keep_seams: bool,
242278
/// Path along which to sweep.
243279
pub trajectory: ModelingCmdId,
244280
/// If true, the sweep will be broken up into sub-sweeps (extrusions, revolves, sweeps) based on the trajectory path components.
@@ -271,6 +307,15 @@ define_modeling_cmd_enum! {
271307
/// Which sketch to revolve.
272308
/// Must be a closed 2D solid.
273309
pub target: ModelingCmdId,
310+
/// If given, extrude each of these segments into a separate body with the given ID.
311+
#[serde(default, skip_serializing_if = "Option::is_none")]
312+
pub segments: Option<Vec<Uuid>>,
313+
/// When two collinear segments are extruded, what should happen?
314+
/// If true, creates a body with two surfaces.
315+
/// If false, creates a body with one surface, spanning both collinear segments.
316+
#[serde(default)]
317+
#[builder(default)]
318+
pub keep_seams: bool,
274319
/// The origin of the extrusion axis
275320
pub origin: Point3d<LengthUnit>,
276321
/// The axis of the extrusion (taken from the origin)
@@ -422,6 +467,15 @@ define_modeling_cmd_enum! {
422467
/// Which sketch to revolve.
423468
/// Must be a closed 2D solid.
424469
pub target: ModelingCmdId,
470+
/// If given, extrude each of these segments into a separate body with the given ID.
471+
#[serde(default, skip_serializing_if = "Option::is_none")]
472+
pub segments: Option<Vec<Uuid>>,
473+
/// When two collinear segments are extruded, what should happen?
474+
/// If true, creates a body with two surfaces.
475+
/// If false, creates a body with one surface, spanning both collinear segments.
476+
#[serde(default)]
477+
#[builder(default)]
478+
pub keep_seams: bool,
425479
/// The edge to use as the axis of revolution, must be linear and lie in the plane of the solid
426480
#[serde(default, skip_serializing_if = "Option::is_none")]
427481
pub edge_id: Option<Uuid>,

modeling-cmds/src/ok_response.rs

Lines changed: 13 additions & 1 deletion
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},
27+
shared::{CurveType, EntityType, ExportFile, ExtrusionFaceCapType, PathCommand, Point2d, Point3d, BodiesCreated},
2828
units,
2929
};
3030

@@ -58,30 +58,40 @@ define_ok_modeling_cmd_response_enum! {
5858
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
5959
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
6060
pub struct Extrude {
61+
/// Any new bodies created by the request.
62+
pub bodies: BodiesCreated,
6163
}
6264

6365
/// The response from the `ExtrudeToReference` endpoint.
6466
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
6567
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
6668
pub struct ExtrudeToReference {
69+
/// Any new bodies created by the request.
70+
pub bodies: BodiesCreated,
6771
}
6872

6973
/// The response from the `TwistExtrude` endpoint.
7074
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
7175
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
7276
pub struct TwistExtrude {
77+
/// Any new bodies created by the request.
78+
pub bodies: BodiesCreated,
7379
}
7480

7581
/// The response from the `Sweep` endpoint.
7682
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
7783
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
7884
pub struct Sweep {
85+
/// Any new bodies created by the request.
86+
pub bodies: BodiesCreated,
7987
}
8088

8189
/// The response from the `Revolve` endpoint.
8290
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
8391
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
8492
pub struct Revolve {
93+
/// Any new bodies created by the request.
94+
pub bodies: BodiesCreated,
8595
}
8696

8797
/// The response from the `Solid3dShellFace` endpoint.
@@ -135,6 +145,8 @@ define_ok_modeling_cmd_response_enum! {
135145
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
136146
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
137147
pub struct RevolveAboutEdge {
148+
/// Any new bodies created by the request.
149+
pub bodies: BodiesCreated,
138150
}
139151

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

modeling-cmds/src/shared.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,45 @@ pub struct SurfaceEdgeReference {
19101910
pub edges: Vec<FractionOfEdge>,
19111911
}
19121912

1913+
/// List of bodies that were created by an operation.
1914+
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1915+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1916+
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1917+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1918+
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1919+
pub struct BodiesCreated {
1920+
/// All bodies created by this operation.
1921+
pub bodies: Vec<BodyCreated>,
1922+
}
1923+
1924+
/// Details of a body that was created.
1925+
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1926+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1927+
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1928+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1929+
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1930+
pub struct BodyCreated {
1931+
/// The body's ID.
1932+
pub id: Uuid,
1933+
/// Surfaces this body contains.
1934+
pub surfaces: Vec<SurfaceCreated>,
1935+
}
1936+
1937+
/// Details of a surface that was created under some body.
1938+
#[derive(Builder, Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
1939+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1940+
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1941+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1942+
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
1943+
pub struct SurfaceCreated {
1944+
/// The surface's ID.
1945+
pub id: Uuid,
1946+
/// Which number face of the parent body is this?
1947+
pub primitive_face_index: u32,
1948+
/// Which segment IDs was this surface swept from?
1949+
pub from_segments: Vec<Uuid>,
1950+
}
1951+
19131952
fn one() -> f32 {
19141953
1.0
19151954
}

0 commit comments

Comments
 (0)