Skip to content

Commit f9c92ef

Browse files
authored
3D boolean operations (#848)
Part of KittyCAD/engine#3243
1 parent b4739dd commit f9c92ef

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

modeling-cmds/src/def_enum.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,50 @@ define_modeling_cmd_enum! {
15571557
/// List of transforms to be applied to the object.
15581558
pub transforms: Vec<ComponentTransform>,
15591559
}
1560+
1561+
/// Create a new solid from combining other smaller solids.
1562+
/// In other words, every part of the input solids will be included in the output solid.
1563+
#[derive(
1564+
Clone, Debug, Deserialize, PartialEq, JsonSchema, Serialize, ModelingCmdVariant,
1565+
)]
1566+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1567+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1568+
pub struct BooleanUnion
1569+
{
1570+
/// Which solids to union together.
1571+
/// Cannot be empty.
1572+
pub solid_ids: Vec<Uuid>,
1573+
}
1574+
1575+
/// Create a new solid from intersecting several other solids.
1576+
/// In other words, the part of the input solids where they all overlap will be the output solid.
1577+
#[derive(
1578+
Clone, Debug, Deserialize, PartialEq, JsonSchema, Serialize, ModelingCmdVariant,
1579+
)]
1580+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1581+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1582+
pub struct BooleanIntersection
1583+
{
1584+
/// Which solids to intersect together
1585+
pub solid_ids: Vec<Uuid>,
1586+
}
1587+
1588+
/// Create a new solid from subtracting several other solids.
1589+
/// The 'target' is what will be cut from.
1590+
/// The 'tool' is what will be cut out from 'target'.
1591+
#[derive(
1592+
Clone, Debug, Deserialize, PartialEq, JsonSchema, Serialize, ModelingCmdVariant,
1593+
)]
1594+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
1595+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
1596+
pub struct BooleanSubtract
1597+
{
1598+
/// Geometry to cut out from.
1599+
pub target_ids: Vec<Uuid>,
1600+
/// Will be cut out from the 'target'.
1601+
pub tool_ids: Vec<Uuid>,
1602+
}
1603+
15601604
/// Make a new path by offsetting an object by a given distance.
15611605
/// The new path's ID will be the ID of this command.
15621606
#[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)]

modeling-cmds/src/ok_response.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,5 +845,18 @@ define_ok_modeling_cmd_response_enum! {
845845
/// The response from the 'SetGridReferencePlane'.
846846
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
847847
pub struct SetGridReferencePlane {}
848+
849+
/// The response from the 'BooleanUnion'.
850+
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
851+
pub struct BooleanUnion {}
852+
853+
/// The response from the 'BooleanIntersection'.
854+
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
855+
pub struct BooleanIntersection {}
856+
857+
/// The response from the 'BooleanSubtract'.
858+
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
859+
pub struct BooleanSubtract {}
860+
848861
}
849862
}

0 commit comments

Comments
 (0)