def test_inversions_repaired(simple_mesh): center = [0.5, 0.5, 0.5] orig_points = simple_mesh.points orig_triangles = simple_mesh.cells_dict["triangle"] assert center in Volume(orig_points, orig_triangles) inv_triangles = orig_triangles[:, ::-1] assert center not in Volume(orig_points, inv_triangles) assert center in Volume(orig_points, inv_triangles, validate=True)
def test_points(mesh): points = mesh.points vol = Volume(mesh.points, mesh.cells_dict["triangle"]) actual = sorted(tuple(p) for p in vol.points) expected = sorted(tuple(p) for p in points) assert actual == expected
def test_extents_validity(mesh): points = mesh.points vol = Volume(mesh.points, mesh.cells_dict["triangle"]) expected = np.array([points.min(axis=0), points.max(axis=0)], np.float32) actual = vol.extents assert np.allclose(expected, actual)
def test_points_roundtrip(mesh): points = mesh.points vol = Volume(mesh.points, mesh.cells_dict["triangle"]) expected = np.array(sorted(tuple(p) for p in points), dtype=np.float32) actual = np.array(sorted(tuple(p) for p in vol.points), dtype=np.float32) assert np.allclose(expected, actual)
def test_triangles(mesh): points = mesh.points triangles = mesh.cells_dict["triangle"] expected = trimesh.Trimesh(points, triangles) vol = Volume(mesh.points, triangles) actual = trimesh.Trimesh(vol.points, vol.faces) assert expected.volume == actual.volume
def test_can_repair_inversions(mesh): triangles = mesh.cells_dict["triangle"] triangles = triangles[:, ::-1] Volume(mesh.points, triangles, True)
def test_can_repair_hole(mesh): triangles = mesh.cells_dict["triangle"] triangles = triangles[:-1] Volume(mesh.points, triangles, True)
def test_no_validation(mesh): triangles = mesh.cells_dict["triangle"] Volume(mesh.points, triangles, True)