Skip to content

Commit cbd698d

Browse files
authored
Ben/chamfer angle (#968)
* add ratio and angle to chamfer enum * ratio is not a length unit * add custom cut type * improve comment * add swap arg to Chamfer enum * change ratio to second_length * break out enum variants and imlp defualt * make members public * revert back to enum * undo revert * derive default * remove default impl for CustomParams * try enmu variant again * rm Fillet second_length * put second_length back * Create new Solid3dCutEdges endpoint * typo * redo openapi * fix wording of comments
1 parent afd7a73 commit cbd698d

File tree

4 files changed

+246
-1
lines changed

4 files changed

+246
-1
lines changed

modeling-cmds/openapi/api.json

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,118 @@
962962
}
963963
]
964964
},
965+
"CutTypeV2": {
966+
"description": "What kind of cut to perform when cutting an edge.",
967+
"oneOf": [
968+
{
969+
"description": "Round off an edge.",
970+
"type": "object",
971+
"properties": {
972+
"fillet": {
973+
"type": "object",
974+
"properties": {
975+
"radius": {
976+
"description": "The radius of the fillet.",
977+
"allOf": [
978+
{
979+
"$ref": "#/components/schemas/LengthUnit"
980+
}
981+
]
982+
},
983+
"second_length": {
984+
"nullable": true,
985+
"description": "The second length affects the edge length of the second face of the cut. This will cause the fillet to take on the shape of a conic section, instead of an arc.",
986+
"allOf": [
987+
{
988+
"$ref": "#/components/schemas/LengthUnit"
989+
}
990+
]
991+
}
992+
},
993+
"required": [
994+
"radius"
995+
]
996+
}
997+
},
998+
"required": [
999+
"fillet"
1000+
],
1001+
"additionalProperties": false
1002+
},
1003+
{
1004+
"description": "Cut away an edge.",
1005+
"type": "object",
1006+
"properties": {
1007+
"chamfer": {
1008+
"type": "object",
1009+
"properties": {
1010+
"angle": {
1011+
"nullable": true,
1012+
"description": "The angle of the chamfer, default is 45deg.",
1013+
"allOf": [
1014+
{
1015+
"$ref": "#/components/schemas/Angle"
1016+
}
1017+
]
1018+
},
1019+
"distance": {
1020+
"description": "The distance from the edge to cut on each face.",
1021+
"allOf": [
1022+
{
1023+
"$ref": "#/components/schemas/LengthUnit"
1024+
}
1025+
]
1026+
},
1027+
"second_distance": {
1028+
"nullable": true,
1029+
"description": "The second distance affects the edge length of the second face of the cut.",
1030+
"allOf": [
1031+
{
1032+
"$ref": "#/components/schemas/LengthUnit"
1033+
}
1034+
]
1035+
},
1036+
"swap": {
1037+
"description": "If true, the second distance or angle is applied to the other face of the cut.",
1038+
"type": "boolean"
1039+
}
1040+
},
1041+
"required": [
1042+
"distance",
1043+
"swap"
1044+
]
1045+
}
1046+
},
1047+
"required": [
1048+
"chamfer"
1049+
],
1050+
"additionalProperties": false
1051+
},
1052+
{
1053+
"description": "A custom cut profile.",
1054+
"type": "object",
1055+
"properties": {
1056+
"custom": {
1057+
"type": "object",
1058+
"properties": {
1059+
"path": {
1060+
"description": "The path that will be used for the custom profile.",
1061+
"type": "string",
1062+
"format": "uuid"
1063+
}
1064+
},
1065+
"required": [
1066+
"path"
1067+
]
1068+
}
1069+
},
1070+
"required": [
1071+
"custom"
1072+
],
1073+
"additionalProperties": false
1074+
}
1075+
]
1076+
},
9651077
"Direction": {
9661078
"description": "Specifies the sign of a co-ordinate axis.",
9671079
"oneOf": [
@@ -3866,6 +3978,72 @@
38663978
"type"
38673979
]
38683980
},
3981+
{
3982+
"description": "Cut the list of given edges with the given cut parameters.",
3983+
"type": "object",
3984+
"properties": {
3985+
"cut_type": {
3986+
"description": "The cut type and information required to perform the cut.",
3987+
"allOf": [
3988+
{
3989+
"$ref": "#/components/schemas/CutTypeV2"
3990+
}
3991+
]
3992+
},
3993+
"edge_ids": {
3994+
"description": "Which edges you want to cut.",
3995+
"default": [],
3996+
"type": "array",
3997+
"items": {
3998+
"type": "string",
3999+
"format": "uuid"
4000+
}
4001+
},
4002+
"extra_face_ids": {
4003+
"description": "What IDs should the resulting faces have? If you've only passed one edge ID, its ID will be the command ID used to send this command, and this field should be empty. If you've passed `n` IDs (to cut `n` edges), then this should be length `n-1`, and the first edge will use the command ID used to send this command.",
4004+
"default": [],
4005+
"type": "array",
4006+
"items": {
4007+
"type": "string",
4008+
"format": "uuid"
4009+
}
4010+
},
4011+
"object_id": {
4012+
"description": "Which object is being cut.",
4013+
"type": "string",
4014+
"format": "uuid"
4015+
},
4016+
"strategy": {
4017+
"description": "Which cutting algorithm to use.",
4018+
"default": "automatic",
4019+
"allOf": [
4020+
{
4021+
"$ref": "#/components/schemas/CutStrategy"
4022+
}
4023+
]
4024+
},
4025+
"tolerance": {
4026+
"description": "The maximum acceptable surface gap computed between the cut surfaces. Must be positive (i.e. greater than zero).",
4027+
"allOf": [
4028+
{
4029+
"$ref": "#/components/schemas/LengthUnit"
4030+
}
4031+
]
4032+
},
4033+
"type": {
4034+
"type": "string",
4035+
"enum": [
4036+
"solid3d_cut_edges"
4037+
]
4038+
}
4039+
},
4040+
"required": [
4041+
"cut_type",
4042+
"object_id",
4043+
"tolerance",
4044+
"type"
4045+
]
4046+
},
38694047
{
38704048
"description": "Determines whether a brep face is planar and returns its surface-local planar axes if so",
38714049
"type": "object",

modeling-cmds/src/def_enum.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ define_modeling_cmd_enum! {
2525
Angle,
2626
ComponentTransform,
2727
RelativeTo,
28-
CutType,
28+
CutType, CutTypeV2,
2929
CutStrategy,
3030
CameraMovement,
3131
ExtrudedFaceInfo, ExtrudeMethod,
@@ -931,6 +931,35 @@ define_modeling_cmd_enum! {
931931
pub extra_face_ids: Vec<Uuid>,
932932
}
933933

934+
/// Cut the list of given edges with the given cut parameters.
935+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
936+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
937+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
938+
pub struct Solid3dCutEdges {
939+
/// Which object is being cut.
940+
pub object_id: Uuid,
941+
/// Which edges you want to cut.
942+
#[serde(default)]
943+
pub edge_ids: Vec<Uuid>,
944+
/// The cut type and information required to perform the cut.
945+
pub cut_type: CutTypeV2,
946+
/// The maximum acceptable surface gap computed between the cut surfaces. Must be
947+
/// positive (i.e. greater than zero).
948+
pub tolerance: LengthUnit,
949+
/// Which cutting algorithm to use.
950+
#[serde(default)]
951+
pub strategy: CutStrategy,
952+
/// What IDs should the resulting faces have?
953+
/// If you've only passed one edge ID, its ID will
954+
/// be the command ID used to send this command, and this
955+
/// field should be empty.
956+
/// If you've passed `n` IDs (to cut `n` edges), then
957+
/// this should be length `n-1`, and the first edge will use
958+
/// the command ID used to send this command.
959+
#[serde(default)]
960+
pub extra_face_ids: Vec<Uuid>,
961+
}
962+
934963
/// Determines whether a brep face is planar and returns its surface-local planar axes if so
935964
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)]
936965
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]

modeling-cmds/src/ok_response.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ define_ok_modeling_cmd_response_enum! {
158158
pub struct Solid3dFilletEdge {
159159
}
160160

161+
/// The response from the `Solid3dCutEdges` endpoint.
162+
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
163+
pub struct Solid3dCutEdges {
164+
}
165+
166+
161167
/// The response from the `SendObject` endpoint.
162168
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema, ModelingCmdOutput)]
163169
pub struct SendObject {

modeling-cmds/src/shared.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,38 @@ pub enum CutType {
2424
Chamfer,
2525
}
2626

27+
/// What kind of cut to perform when cutting an edge.
28+
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)]
29+
#[serde(rename_all = "snake_case")]
30+
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
31+
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
32+
pub enum CutTypeV2 {
33+
/// Round off an edge.
34+
Fillet {
35+
/// The radius of the fillet.
36+
radius: LengthUnit,
37+
/// The second length affects the edge length of the second face of the cut. This will
38+
/// cause the fillet to take on the shape of a conic section, instead of an arc.
39+
second_length: Option<LengthUnit>,
40+
},
41+
/// Cut away an edge.
42+
Chamfer {
43+
/// The distance from the edge to cut on each face.
44+
distance: LengthUnit,
45+
/// The second distance affects the edge length of the second face of the cut.
46+
second_distance: Option<LengthUnit>,
47+
/// The angle of the chamfer, default is 45deg.
48+
angle: Option<Angle>,
49+
/// If true, the second distance or angle is applied to the other face of the cut.
50+
swap: bool,
51+
},
52+
/// A custom cut profile.
53+
Custom {
54+
/// The path that will be used for the custom profile.
55+
path: Uuid,
56+
},
57+
}
58+
2759
/// A rotation defined by an axis, origin of rotation, and an angle.
2860
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
2961
#[serde(rename_all = "snake_case")]

0 commit comments

Comments
 (0)