diff --git a/modeling-cmds/src/def_enum.rs b/modeling-cmds/src/def_enum.rs index 1b62cfa0..402838f0 100644 --- a/modeling-cmds/src/def_enum.rs +++ b/modeling-cmds/src/def_enum.rs @@ -263,6 +263,32 @@ define_modeling_cmd_enum! { pub hollow: bool, } + /// Command for joining a Surface (non-manifold) body back to a Solid. + /// All of the surfaces should already be contained within the body mated topologically. + /// This operation should be the final step after a sequence of Solid modeling commands such as + /// BooleanImprint, EntityDeleteChild, Solid3dFlipFace + /// If successful, the new body type will become "Solid". + #[derive( + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct Solid3dJoin { + /// Which Solid3D is being joined. + pub object_id: Uuid, + } + + /// Retrieves the body type. + #[derive( + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct Solid3dGetBodyType { + /// The Solid3D who's body type is being queried. + pub object_id: Uuid, + } + /// Command for revolving a solid 2d about a brep edge #[derive( Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, @@ -497,6 +523,18 @@ define_modeling_cmd_enum! { pub child_index: u32, } + /// Attempts to delete a child entity from an entity. + /// Note that this API may change the body type of certain entities from Solid to Surface. + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct EntityDeleteChild { + /// ID of the entity being modified + pub entity_id: Uuid, + /// ID of the entity's child being deleted + pub child_entity_id: Uuid, + } + /// What are all UUIDs of this entity's children? #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] @@ -842,6 +880,21 @@ define_modeling_cmd_enum! { pub edge_id: Uuid, } + /// Flips (reverses) a face. If the solid3d body already has a "Solid" body type, + /// and preserve_solid is false, then the body type will become non-manifold ("Surface"). + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct Solid3dFlipFace { + /// Which object is being queried. + pub object_id: Uuid, + /// Which face you want to flip. + pub face_id: Uuid, + /// Convenience parameter to reverse the entire body inside-out (flip all faces). + /// If the body type of the solid3d is already "Solid". + pub preserve_solid: bool, + } + /// Add a hole to a Solid2d object before extruding it. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] @@ -1772,6 +1825,20 @@ define_modeling_cmd_enum! { pub tolerance: LengthUnit, } + /// Create a new non-manifold body by intersecting all the input bodies, cutting and splitting all the faces at the intersection boundaries. + #[derive( + Clone, Debug, Deserialize, PartialEq, JsonSchema, Serialize, ModelingCmdVariant, + )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct BooleanImprint + { + /// Which input bodies to intersect. Inputs with non-solid body types are permitted + pub body_ids: Vec, + /// The maximum acceptable surface gap between the intersected bodies. Must be positive (i.e. greater than zero). + pub tolerance: LengthUnit, + } + /// Make a new path by offsetting an object by a given distance. /// The new path's ID will be the ID of this command. #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] diff --git a/modeling-cmds/src/ok_response.rs b/modeling-cmds/src/ok_response.rs index 91cf46f4..44f69bae 100644 --- a/modeling-cmds/src/ok_response.rs +++ b/modeling-cmds/src/ok_response.rs @@ -10,8 +10,11 @@ define_ok_modeling_cmd_response_enum! { use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; - use crate::shared::CameraSettings; - use crate::shared::CameraViewState; + use crate::shared::{ + CameraSettings, + CameraViewState, + BodyType, + }; use crate::{self as kittycad_modeling_cmds}; use crate::{ @@ -74,6 +77,18 @@ define_ok_modeling_cmd_response_enum! { pub struct Solid3dShellFace { } + /// The response from the `Solid3dJoin` endpoint. + #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] + pub struct Solid3dJoin { + } + + /// The response from the `Solid3dGetBodyType` endpoint. + #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] + pub struct Solid3dGetBodyType { + /// The body type + pub body_type: BodyType, + } + /// The response from the `RevolveAboutEdge` endpoint. #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] pub struct RevolveAboutEdge { @@ -350,6 +365,10 @@ define_ok_modeling_cmd_response_enum! { /// The UUID of the child entity. pub entity_id: Uuid, } + /// The response from the `EntityGetChildUuid` command. + #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] + pub struct EntityDeleteChild { + } /// The response from the `EntityGetNumChildren` command. #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] pub struct EntityGetNumChildren { @@ -509,6 +528,11 @@ define_ok_modeling_cmd_response_enum! { pub faces: Vec, } + /// The response from the `Solid3dFlipFace` command. + #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] + pub struct Solid3dFlipFace { + } + /// The response from the `Solid3dGetAllOppositeEdges` command. #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] pub struct Solid3dGetAllOppositeEdges { @@ -964,6 +988,17 @@ define_ok_modeling_cmd_response_enum! { pub extra_solid_ids: Vec, } + /// The response from the 'BooleanImprint'. + #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] + pub struct BooleanImprint { + /// If the operation produced just one body, then its ID will be the + /// ID of the modeling command request. + /// But if any extra bodies are produced, then their IDs will be included + /// here. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub extra_solid_ids: Vec, + } + /// The response from the 'SetGridScale'. #[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)] pub struct SetGridScale {} diff --git a/modeling-cmds/src/shared.rs b/modeling-cmds/src/shared.rs index f8fec200..628a9364 100644 --- a/modeling-cmds/src/shared.rs +++ b/modeling-cmds/src/shared.rs @@ -1041,16 +1041,16 @@ impl From for http::StatusCode { } } -/// Body type determining if the operation will create a solid or a surface. +/// Body type determining if the operation will create a manifold (solid) body or a non-manifold collection of surfaces. #[derive(Default, Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case")] #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum BodyType { - ///Create a body that has two caps, creating a solid object. + ///Defines a body that is manifold. #[default] Solid, - ///Create only the surface of the body without any caps. + ///Defines a body that is non-manifold (an open collection of connected surfaces). Surface, }