use serde::{Deserialize, Serialize};
use crate::*;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ProjectedEdge {
Point([f64; 2]),
Line { start: [f64; 2], end: [f64; 2] },
Circle {
centre: [f64; 2],
radius: f64,
range: (f64, f64),
},
Ellipse {
centre: [f64; 2],
major: [f64; 2],
ratio: f64,
range: (f64, f64),
},
Parabola {
vertex: [f64; 2],
axis: [f64; 2],
focal: f64,
range: (f64, f64),
},
Hyperbola {
centre: [f64; 2],
major: [f64; 2],
minor: [f64; 2],
range: (f64, f64),
},
Spline {
degree: u32,
knots: Vec<f64>,
control_points: Vec<[f64; 2]>,
weights: Vec<f64>,
},
Polyline(Vec<[f64; 2]>),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SectionCurve {
pub curve: ProjectedEdge,
pub points: Vec<[f64; 3]>,
#[serde(default)]
pub reversed: bool,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SectionRun {
pub curves: Vec<SectionCurve>,
pub closed: bool,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct LoopEdge {
pub points: Vec<[f64; 3]>,
#[serde(default)]
pub seam: bool,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Drawing2d {
pub unit_mm: Option<f64>,
pub curves: Vec<DrawingCurve>,
#[serde(default)]
pub texts: Vec<DrawingText>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DrawingCurve {
pub hidden: bool,
pub shape: DrawingShape,
#[serde(default)]
pub layer: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DrawingText {
pub at: [f64; 2],
pub height: f64,
pub angle: f64,
pub text: String,
#[serde(default)]
pub layer: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum DrawingShape {
Polyline {
points: Vec<[f64; 2]>,
bulges: Vec<f64>,
closed: bool,
},
Arc {
centre: [f64; 2],
radius: f64,
start_angle: f64,
end_angle: f64,
},
Circle {
centre: [f64; 2],
radius: f64,
},
Ellipse {
centre: [f64; 2],
major: [f64; 2],
ratio: f64,
start_param: f64,
end_param: f64,
},
Spline {
points: Vec<[f64; 2]>,
closed: bool,
},
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct VolumeRegion {
pub missing: bool,
pub volume: f64,
pub depth: f64,
pub layer: bool,
pub min: [f64; 3],
pub max: [f64; 3],
pub unsure: bool,
}
#[derive(Debug, Clone)]
pub struct Overlap {
pub volume_mm3: f64,
pub centre_mm: [f64; 3],
pub mesh: TriMesh,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Gap {
pub distance_mm: f64,
pub on_a: [f64; 3],
pub on_b: [f64; 3],
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MedialPath {
pub points: Vec<[f64; 2]>,
pub clearance: Vec<f64>,
pub boundary_ends: [bool; 2],
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct Narrowest {
pub at: [f64; 2],
pub clearance: f64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MedialRegion {
pub wires: Vec<usize>,
pub paths: Vec<MedialPath>,
pub narrowest: Option<Narrowest>,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)]
pub struct FaceProbe {
pub point: [f64; 3],
pub normal: [f64; 3],
#[serde(default)]
pub name: TopoName,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum ShapeProbe {
Face {
point: [f64; 3],
normal: [f64; 3],
#[serde(default)]
name: TopoName,
},
Edge {
point: [f64; 3],
direction: [f64; 3],
#[serde(default)]
faces: [TopoName; 2],
#[serde(default, skip_serializing_if = "Option::is_none")]
along: Option<f64>,
},
Mass,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum ProbeAnswer {
Face {
point: [f64; 3],
normal: [f64; 3],
surface: FaceSurface,
},
Edge {
point: [f64; 3],
direction: [f64; 3],
start: [f64; 3],
end: [f64; 3],
middle: [f64; 3],
circle: Option<ProbedCircle>,
#[serde(default, skip_serializing_if = "Option::is_none")]
along: Option<([f64; 3], [f64; 3])>,
},
Mass {
centre: [f64; 3],
axes: [[f64; 3]; 3],
},
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct ProbedCircle {
pub centre: [f64; 3],
pub normal: [f64; 3],
pub radius: f64,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct ChainProbe {
pub after_op: usize,
pub probe: ShapeProbe,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)]
pub struct ProjectionProbe {
pub point: [f64; 3],
#[serde(default)]
pub faces: [TopoName; 2],
#[serde(default)]
pub section: bool,
pub plane: ProfilePlane,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct ChainProjection {
pub after_op: usize,
pub probe: ProjectionProbe,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CentreLine {
pub points: Vec<[f64; 3]>,
pub length: f64,
pub deviation: f64,
pub straight: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub struct RecognizedHole {
pub entry: [f64; 3],
pub direction: [f64; 3],
pub diameter: f64,
pub depth: f64,
pub through: bool,
pub drill_point_deg: Option<f64>,
pub faces: Vec<([f64; 3], [f64; 3])>,
}
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct EdgeContinuity {
pub point: [f64; 3],
pub gap: f64,
pub angle_deg: f64,
#[serde(default)]
pub curvature: Option<f64>,
}
pub type FacePoints = ([f64; 3], Vec<([f64; 3], [f64; 3])>);
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct PathFrame {
pub point: [f64; 3],
pub tangent: [f64; 3],
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PathFrames {
pub length: f64,
pub closed: bool,
pub frames: Vec<PathFrame>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ConstructionShape {
Point([f64; 3]),
Axis {
origin: [f64; 3],
z: [f64; 3],
x: [f64; 3],
},
Polyline {
points: Vec<[f64; 3]>,
closed: bool,
},
Circle {
centre: [f64; 3],
normal: [f64; 3],
radius: f64,
},
Plane {
origin: [f64; 3],
normal: [f64; 3],
x_axis: [f64; 3],
u: [f64; 2],
v: [f64; 2],
},
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ConstructionItem {
pub name: String,
pub shape: ConstructionShape,
}
#[derive(Debug, Clone, Default)]
pub struct IgesExport {
pub text: String,
pub warnings: Vec<String>,
}