-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.rs
More file actions
35 lines (32 loc) · 1004 Bytes
/
Copy pathbasic.rs
File metadata and controls
35 lines (32 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use hypermesh::{
BooleanOp, BooleanProgram, MeshContext, Point3, PredicatePolicy, Real, Triangle, TriangleMesh,
boolean,
};
const CONTEXT: MeshContext = MeshContext::new(PredicatePolicy::APPROXIMATE_512);
fn tetrahedron(offset: i64) -> TriangleMesh {
let p = |x, y, z| Point3::new(Real::from(x + offset), Real::from(y), Real::from(z));
TriangleMesh::new(
vec![p(0, 0, 0), p(2, 0, 0), p(0, 2, 0), p(0, 0, 2)],
vec![
Triangle::new(0, 2, 1),
Triangle::new(0, 1, 3),
Triangle::new(1, 2, 3),
Triangle::new(2, 0, 3),
],
)
}
fn main() -> hypermesh::HypermeshResult<()> {
let first = tetrahedron(0);
let second = tetrahedron(3);
let result = boolean(
&CONTEXT,
&[first.as_ref(), second.as_ref()],
BooleanProgram::Operation(BooleanOp::Union),
)?
.into_value();
println!(
"{} exact output triangles",
result.results[0].triangles.len()
);
Ok(())
}