Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions modeling-cmds/src/def_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))]
Expand Down Expand Up @@ -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))]
Expand Down Expand Up @@ -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<Uuid>,
/// 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)]
Expand Down
39 changes: 37 additions & 2 deletions modeling-cmds/src/ok_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
}
Comment on lines +368 to +371
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation comment is incorrect and references the wrong command.

The comment says EntityGetChildUuid but the struct is EntityDeleteChild. This is a copy-paste error that will mislead developers and create confusion in generated documentation.

Fix:

/// The response from the `EntityDeleteChild` command.
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
pub struct EntityDeleteChild {
}
Suggested change
/// The response from the `EntityGetChildUuid` command.
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
pub struct EntityDeleteChild {
}
/// The response from the `EntityDeleteChild` command.
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
pub struct EntityDeleteChild {
}

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

/// The response from the `EntityGetNumChildren` command.
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
pub struct EntityGetNumChildren {
Expand Down Expand Up @@ -509,6 +528,11 @@ define_ok_modeling_cmd_response_enum! {
pub faces: Vec<Uuid>,
}

/// 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 {
Expand Down Expand Up @@ -964,6 +988,17 @@ define_ok_modeling_cmd_response_enum! {
pub extra_solid_ids: Vec<Uuid>,
}

/// 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<Uuid>,
}

/// The response from the 'SetGridScale'.
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
pub struct SetGridScale {}
Expand Down
6 changes: 3 additions & 3 deletions modeling-cmds/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,16 +1041,16 @@ impl From<EngineErrorCode> 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,
}

Expand Down
Loading