Skip to content

Commit

Permalink
Do test_multiple_difference with all engines
Browse files Browse the repository at this point in the history
A useful side effect is that this allows the test to run without
manifold3d, which is the default engine in this case.
  • Loading branch information
musicinmybrain committed Oct 15, 2024
1 parent 207ba23 commit 9232370
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tests/test_boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,21 @@ def test_multiple_difference():
spheres = [g.trimesh.creation.icosphere()]
spheres.extend(g.trimesh.creation.icosphere().apply_translation(c) for c in center)

# compute using meshes method
diff_base = spheres[0].difference(spheres[1:])
# compute using function call (should be identical)
diff_meth = g.trimesh.boolean.difference(spheres)
for engine, exists in engines:
if not exists:
g.log.warning("skipping boolean engine %s", engine)
continue

g.log.info("Testing multiple difference with engine %s", engine)

# compute using meshes method
diff_base = spheres[0].difference(spheres[1:], engine)
# compute using function call (should be identical)
diff_meth = g.trimesh.boolean.difference(spheres)

# both methods should produce the same result
assert np.isclose(diff_base.volume, diff_meth.volume)
assert diff_base.volume < spheres[0].volume
# both methods should produce the same result
assert np.isclose(diff_base.volume, diff_meth.volume)
assert diff_base.volume < spheres[0].volume

# should have done the diff
assert np.allclose(diff_base.extents, [1.5, 1.5, 2.0], atol=1e-8)
# should have done the diff
assert np.allclose(diff_base.extents, [1.5, 1.5, 2.0], atol=1e-8)

0 comments on commit 9232370

Please sign in to comment.