1mod manifold;
5mod triangulation;
6mod simplification;
7mod common;
8mod boolean03;
9mod boolean45;
10mod compose;
11mod tests;
12
13use crate::boolean03::boolean03;
14use crate::boolean45::boolean45;
15use crate::simplification::simplify_topology;
16use crate::triangulation::triangulate;
17use crate::common::*;
18use crate::manifold::*;
19
20pub use crate::common::{Real, Vec2, Vec3, Vec4, Mat3, K_PRECISION};
21
22pub mod prelude {
23 pub use crate::common::OpType;
24 pub use crate::manifold::Manifold;
25 pub use crate::compute_boolean;
26 pub use crate::compose::{compose, translate, scale, rotate, fractal};
27}
28
29pub fn compute_boolean(
30 mp: &Manifold,
31 mq: &Manifold,
32 op: OpType,
33) -> Result<Manifold, String> {
34 let eps = mp.eps.max(mq.eps);
35 let tol = mp.tol.max(mq.tol);
36
37 let b03 = boolean03(mp, mq, &op);
38 let mut b45 = boolean45(mp, mq, &b03, &op);
39 let mut trg = triangulate(mp, mq, &b45, eps)?;
40
41 simplify_topology(
42 &mut trg.hs,
43 &mut b45.ps,
44 &mut trg.ns,
45 &mut trg.rs,
46 b45.nv_from_p,
47 b45.nv_from_q,
48 eps
49 );
50
51 cleanup_unused_verts(
52 &mut b45.ps,
53 &mut trg.hs
54 );
55
56 Manifold::new_impl(
57 b45.ps,
58 trg.hs.chunks(3).map(|hs| Vec3u::new(hs[0].tail, hs[1].tail, hs[2].tail)).collect(),
59 Some(eps),
60 Some(tol)
61 )
62}
63
64