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
24 changes: 24 additions & 0 deletions modeling-cmds/openapi/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -8084,6 +8084,30 @@
"closest_to",
"type"
]
},
{
"description": "Gets debug information about a sketch",
"type": "object",
"properties": {
"path_id": {
"description": "Which path to query",
"allOf": [
{
"$ref": "#/components/schemas/ModelingCmdId"
}
]
},
"type": {
"type": "string",
"enum": [
"sketch_get_info"
]
}
},
"required": [
"path_id",
"type"
]
}
]
},
Expand Down
11 changes: 11 additions & 0 deletions modeling-cmds/src/def_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2759,6 +2759,17 @@ define_modeling_cmd_enum! {
/// Assumed to be in absolute coordinates, relative to global (scene) origin.
pub closest_to: Point3d<f64>,
}

/// Gets debug information about a sketch
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, Builder)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct SketchGetInfo {
/// Which path to query
pub path_id: ModelingCmdId,
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions modeling-cmds/src/ok_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ define_ok_modeling_cmd_response_enum! {
use bon::Builder;
use uuid::Uuid;
use crate::shared::{
CurveDebug,
CameraSettings,
CameraViewState,
BodyType,
Expand Down Expand Up @@ -1403,5 +1404,17 @@ define_ok_modeling_cmd_response_enum! {
/// If there are no edges in the scene, returns None.
pub edge_id: Option<Uuid>,
}

/// The response from the 'SketchGetInfo'.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema, ModelingCmdOutput, Builder)]
#[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)]
pub struct SketchGetInfo {
/// All curves in this sketch.
pub curves: Vec<CurveDebug>,
/// OBJ representation of the topology from Toolpaths library.
pub region_obj: String,
/// How many regions the Toolpaths library thinks exist
pub region_count: u16,
}
}
}
29 changes: 29 additions & 0 deletions modeling-cmds/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use uuid::Uuid;
use crate::impl_extern_type;
use crate::{
def_enum::negative_one,
id::ModelingCmdId,
length_unit::LengthUnit,
output::ExtrusionFaceInfo,
units::{self, UnitAngle},
Expand Down Expand Up @@ -2207,3 +2208,31 @@ impl From<BodiesUpdated> for BodiesCreated {
fn one() -> f32 {
1.0
}

/// A debug-view of the segment of a curve.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema, Builder)]
pub struct CurveDebug {
/// Start point of segment or circle.
pub start: Option<Point2d<f64>>,
/// End point of segment.
pub end: Option<Point2d<f64>>,
/// Center point of segment.
pub center: Option<Point2d<f64>>,
/// Midpoint on a three point arc
pub mid: Option<Point2d<f64>>,
/// What kind of segment is it (line, arc, etc)
pub segment_type: CurveTypeDebug,
/// ID for this segment.
pub id: ModelingCmdId,
}

/// What type of curve is being viewed?
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub enum CurveTypeDebug {
/// Line with a start and end.
Line,
/// Arc with a start, end and center.
ThreePointArc,
/// Circle with a center and radius.
Circle,
}
Loading