Skip to main content

geop_core_topology/
body.rs

1use std::fmt;
2
3use super::ids::{ShellId, SolidId};
4
5/// A whole the operations act on: a solid, or a sheet — a shell belonging to
6/// no solid (see [`crate::Shell`]).
7///
8/// A boolean's operands, what remesh imprints onto each other and what a
9/// split cuts with are bodies: their faces, edges and vertices are all that
10/// matters to imprinting, and a sheet has those just as a solid does.
11#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
12pub enum Body {
13    Solid(SolidId),
14    Sheet(ShellId),
15}
16
17impl fmt::Display for Body {
18    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19        match self {
20            Body::Solid(id) => write!(f, "{id}"),
21            Body::Sheet(id) => write!(f, "sheet {id}"),
22        }
23    }
24}
25
26impl From<SolidId> for Body {
27    fn from(id: SolidId) -> Self {
28        Body::Solid(id)
29    }
30}