Skip to main content

microcad_core/geo3d/
mod.rs

1// Copyright © 2024-2026 The µcad authors <info@microcad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! 3D Geometry
5
6mod align;
7mod bounds;
8mod collection;
9mod extrude;
10mod geometry;
11mod mesh;
12mod plane;
13mod reflect;
14mod triangle;
15mod vertex;
16
17pub use align::*;
18pub use bounds::*;
19pub use collection::*;
20pub use extrude::*;
21pub use geometry::*;
22pub use manifold_rust::manifold::Manifold;
23pub use mesh::TriangleMesh;
24pub use plane::Plane;
25pub use reflect::*;
26pub use vertex::Vertex;
27
28use crate::BooleanOp;
29
30impl From<BooleanOp> for manifold_rust::types::OpType {
31    fn from(op: BooleanOp) -> Self {
32        match op {
33            BooleanOp::Union => manifold_rust::types::OpType::Add,
34            BooleanOp::Intersect => manifold_rust::types::OpType::Intersect,
35            BooleanOp::Subtract => manifold_rust::types::OpType::Subtract,
36            _ => unimplemented!(),
37        }
38    }
39}
40
41#[test]
42fn test_mesh_volume() {
43    let manifold = Manifold::sphere(1.0, 512);
44    let mesh = TriangleMesh::from(manifold.get_mesh_gl(0));
45
46    let volume = mesh.volume();
47    assert!((volume - 4.0 / 3.0 * std::f64::consts::PI).abs() < 1e-3);
48}