use crate::lower::ir::WorkbenchKind;
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub enum OutputType {
#[default]
NotDetermined,
Geometry2D,
Geometry3D,
InvalidMixed,
}
impl OutputType {
pub fn merge(&self, other: &Self) -> OutputType {
match (self, other) {
(OutputType::NotDetermined, output_type) => *output_type,
(OutputType::Geometry2D, OutputType::NotDetermined)
| (OutputType::Geometry2D, OutputType::Geometry2D)
| (OutputType::Geometry3D, OutputType::NotDetermined)
| (OutputType::Geometry3D, OutputType::Geometry3D) => *self,
(OutputType::Geometry2D, OutputType::Geometry3D)
| (OutputType::Geometry3D, OutputType::Geometry2D)
| (OutputType::Geometry2D, OutputType::InvalidMixed)
| (OutputType::Geometry3D, OutputType::InvalidMixed)
| (OutputType::InvalidMixed, _) => OutputType::InvalidMixed,
}
}
}
impl std::fmt::Display for OutputType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match &self {
Self::NotDetermined => "Undetermined",
Self::Geometry2D => "2D",
Self::Geometry3D => "3D",
Self::InvalidMixed => "NO OUTPUT",
}
)
}
}
impl From<WorkbenchKind> for OutputType {
fn from(kind: WorkbenchKind) -> Self {
match kind {
WorkbenchKind::Sketch => Self::Geometry2D,
WorkbenchKind::Part => Self::Geometry3D,
WorkbenchKind::Operation => Self::NotDetermined,
}
}
}