Skip to content
Merged
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
160 changes: 157 additions & 3 deletions modeling-cmds/openapi/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -643,17 +643,17 @@
]
},
"BodyType": {
"description": "Body type determining if the operation will create a solid or a surface.",
"description": "Body type determining if the operation will create a manifold (solid) body or a non-manifold collection of surfaces.",
"oneOf": [
{
"description": "Create a body that has two caps, creating a solid object.",
"description": "Defines a body that is manifold.",
"type": "string",
"enum": [
"solid"
]
},
{
"description": "Create only the surface of the body without any caps.",
"description": "Defines a body that is non-manifold (an open collection of connected surfaces).",
"type": "string",
"enum": [
"surface"
Expand Down Expand Up @@ -2270,6 +2270,48 @@
"type"
]
},
{
"description": "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, EntityDeleteChildren, Solid3dFlipFace If successful, the new body type will become \"Solid\".",
"type": "object",
"properties": {
"object_id": {
"description": "Which Solid3D is being joined.",
"type": "string",
"format": "uuid"
},
"type": {
"type": "string",
"enum": [
"solid3d_join"
]
}
},
"required": [
"object_id",
"type"
]
},
{
"description": "Retrieves the body type.",
"type": "object",
"properties": {
"object_id": {
"description": "The Solid3D whose body type is being queried.",
"type": "string",
"format": "uuid"
},
"type": {
"type": "string",
"enum": [
"solid3d_get_body_type"
]
}
},
"required": [
"object_id",
"type"
]
},
{
"description": "Command for revolving a solid 2d about a brep edge",
"type": "object",
Expand Down Expand Up @@ -2875,6 +2917,37 @@
"type"
]
},
{
"description": "Attempts to delete children entity from an entity. Note that this API may change the body type of certain entities from Solid to Surface.",
"type": "object",
"properties": {
"child_entity_ids": {
"description": "ID of the entity's child being deleted",
"type": "array",
"items": {
"type": "string",
"format": "uuid"
},
"uniqueItems": true
},
"entity_id": {
"description": "ID of the entity being modified",
"type": "string",
"format": "uuid"
},
"type": {
"type": "string",
"enum": [
"entity_delete_children"
]
}
},
"required": [
"child_entity_ids",
"entity_id",
"type"
]
},
{
"description": "What are all UUIDs of this entity's children?",
"type": "object",
Expand Down Expand Up @@ -3793,6 +3866,54 @@
"type"
]
},
{
"description": "Flips (reverses) a brep that is \"inside-out\".",
"type": "object",
"properties": {
"object_id": {
"description": "Which object is being flipped.",
"type": "string",
"format": "uuid"
},
"type": {
"type": "string",
"enum": [
"solid3d_flip"
]
}
},
"required": [
"object_id",
"type"
]
},
{
"description": "Flips (reverses) a face. If the solid3d body type is \"Solid\", then body type will become non-manifold (\"Surface\").",
"type": "object",
"properties": {
"face_id": {
"description": "Which face you want to flip.",
"type": "string",
"format": "uuid"
},
"object_id": {
"description": "Which object is being queried.",
"type": "string",
"format": "uuid"
},
"type": {
"type": "string",
"enum": [
"solid3d_flip_face"
]
}
},
"required": [
"face_id",
"object_id",
"type"
]
},
{
"description": "Add a hole to a Solid2d object before extruding it.",
"type": "object",
Expand Down Expand Up @@ -5964,6 +6085,39 @@
"type"
]
},
{
"description": "Create a new non-manifold body by intersecting all the input bodies, cutting and splitting all the faces at the intersection boundaries.",
"type": "object",
"properties": {
"body_ids": {
"description": "Which input bodies to intersect. Inputs with non-solid body types are permitted",
"type": "array",
"items": {
"type": "string",
"format": "uuid"
}
},
"tolerance": {
"description": "The maximum acceptable surface gap between the intersected bodies. Must be positive (i.e. greater than zero).",
"allOf": [
{
"$ref": "#/components/schemas/LengthUnit"
}
]
},
"type": {
"type": "string",
"enum": [
"boolean_imprint"
]
}
},
"required": [
"body_ids",
"tolerance",
"type"
]
},
{
"description": "Make a new path by offsetting an object by a given distance. The new path's ID will be the ID of this command.",
"type": "object",
Expand Down
73 changes: 73 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, EntityDeleteChildren, 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 whose 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 children 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 EntityDeleteChildren {
/// ID of the entity being modified
pub entity_id: Uuid,
/// ID of the entity's child being deleted
pub child_entity_ids: HashSet<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,27 @@ define_modeling_cmd_enum! {
pub edge_id: Uuid,
}

/// Flips (reverses) a brep that is "inside-out".
#[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 Solid3dFlip {
/// Which object is being flipped.
pub object_id: Uuid,
}

/// Flips (reverses) a face. If the solid3d body type is "Solid",
/// then 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,
}

/// 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 +1831,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
44 changes: 42 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 `EntityDeleteChildren` command.
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
pub struct EntityDeleteChildren {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be useful to return the body_type here, so the user knows if a solid became a surface. But that can be a future extension.

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

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

/// 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 +993,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
Loading
Loading