microcad_core/
boolean_op.rs

1// Copyright © 2024-2025 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Boolean operations
5
6#[derive(Debug)]
7/// Boolean operations
8pub enum BooleanOp {
9    /// Computes the union R = P ∪ Q
10    Union,
11    /// computes the difference R = P ∖ Q
12    Subtract,
13    /// computes the complement R=P̅
14    Complement,
15    /// computes the intersection R = P ∩ Q
16    Intersect,
17}
18
19use geo::OpType;
20
21impl From<BooleanOp> for OpType {
22    fn from(op: BooleanOp) -> Self {
23        Self::from(&op)
24    }
25}
26
27impl From<&BooleanOp> for OpType {
28    fn from(op: &BooleanOp) -> Self {
29        match op {
30            BooleanOp::Subtract => OpType::Difference,
31            BooleanOp::Union => OpType::Union,
32            BooleanOp::Intersect => OpType::Intersection,
33            BooleanOp::Complement => OpType::Xor,
34        }
35    }
36}