#[derive(Clone, Debug, PartialEq)]
pub enum Surface {
Plane {
origin: [f64; 3],
normal: [f64; 3],
},
Cylinder {
origin: [f64; 3],
axis: [f64; 3],
radius: f64,
},
Cone {
apex: [f64; 3],
axis: [f64; 3],
slope: f64,
},
Sphere {
center: [f64; 3],
radius: f64,
},
Torus {
center: [f64; 3],
axis: [f64; 3],
major_radius: f64,
minor_radius: f64,
},
BSpline(BSplineSurface),
LinearExtrusion {
profile: Curve,
direction: [f64; 3],
},
Revolution {
profile: Curve,
origin: [f64; 3],
axis: [f64; 3],
},
Faceted,
}
impl Surface {
pub fn kind(&self) -> &'static str {
match self {
Surface::Plane { .. } => "plane",
Surface::Cylinder { .. } => "cylinder",
Surface::Cone { .. } => "cone",
Surface::Sphere { .. } => "sphere",
Surface::Torus { .. } => "torus",
Surface::BSpline(_) => "bspline",
Surface::LinearExtrusion { .. } => "linear extrusion",
Surface::Revolution { .. } => "revolution",
Surface::Faceted => "faceted",
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum Curve {
Line {
origin: [f64; 3],
direction: [f64; 3],
},
Circle {
center: [f64; 3],
normal: [f64; 3],
x_axis: [f64; 3],
radius: f64,
},
Ellipse {
center: [f64; 3],
normal: [f64; 3],
x_axis: [f64; 3],
major: f64,
minor: f64,
},
BSpline(BSpline<3>),
}
impl Curve {
pub fn kind(&self) -> &'static str {
match self {
Curve::Line { .. } => "line",
Curve::Circle { .. } => "circle",
Curve::Ellipse { .. } => "ellipse",
Curve::BSpline(_) => "bspline",
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct BSpline<const D: usize> {
pub degree: u32,
pub control: Vec<[f64; D]>,
pub knots: Vec<f64>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct BSplineSurface {
pub degree_u: u32,
pub degree_v: u32,
pub control: Vec<Vec<[f64; 3]>>,
pub weights: Option<Vec<Vec<f64>>>,
pub knots_u: Vec<f64>,
pub knots_v: Vec<f64>,
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct TaggedMesh {
pub positions: Vec<[f64; 3]>,
pub triangles: Vec<[u32; 3]>,
pub triangle_surface: Vec<u32>,
pub surfaces: Vec<Surface>,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Frame {
pub origin: [f64; 3],
pub z: [f64; 3],
pub x: [f64; 3],
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Brep {
pub vertices: Vec<[f64; 3]>,
pub edges: Vec<Edge>,
pub faces: Vec<Face>,
pub shells: Vec<Shell>,
pub report: Report,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Edge {
pub start: u32,
pub end: u32,
pub curve: Curve,
pub range: [f64; 2],
pub seam: bool,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Face {
pub surface: Surface,
pub frame: Frame,
pub ref_radius: f64,
pub same_sense: bool,
pub loops: Vec<Loop>,
pub faceted: bool,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Loop {
pub coedges: Vec<Coedge>,
pub outer: bool,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Coedge {
pub edge: u32,
pub forward: bool,
pub pcurve: Option<BSpline<2>>,
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Shell {
pub faces: Vec<u32>,
pub void: bool,
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Report {
pub scale: f64,
pub mesh_genus: i64,
pub mesh_components: usize,
pub max_vertex_residual: f64,
pub max_edge_deviation: f64,
pub max_pcurve_deviation: f64,
pub max_chain_deviation: f64,
pub edge_chain_deviation: Vec<f64>,
pub face_triangles: Vec<Vec<u32>>,
pub tangencies: Vec<Tangency>,
pub notes: Vec<String>,
pub faces_uncrossed: bool,
}
#[derive(Clone, Debug, PartialEq)]
pub struct Tangency {
pub surfaces: [u32; 2],
pub contact: Contact,
}
#[derive(Clone, Debug, PartialEq)]
pub enum Contact {
Line {
point: [f64; 3],
direction: [f64; 3],
},
Circle {
center: [f64; 3],
normal: [f64; 3],
radius: f64,
},
Point {
point: [f64; 3],
},
Boundary {
surface: u32,
fixed_u: bool,
parameter: f64,
},
}