示例#1
0
def test_STL(tmp_path):
    mesh = cpt.Sphere().mesh.merged()
    filepath = tmp_path / "test.stl"
    write_STL(filepath, mesh.vertices, mesh.faces)
    reloaded_mesh = load_STL(str(filepath), name="Bla")

    assert reloaded_mesh.name == "Bla"
    assert np.allclose(mesh.vertices, reloaded_mesh.vertices)
示例#2
0
def test_STL(tmp_path):
    try:

        mesh = Sphere().mesh.merged()
        filepath = tmp_path / "test.stl"
        write_STL(filepath, mesh.vertices, mesh.faces)
        reloaded_mesh = load_STL(str(filepath), name="Bla")

        assert reloaded_mesh.name == "Bla"
        assert np.allclose(mesh.vertices, reloaded_mesh.vertices)
        # Cannot compare the faces. The STL writer changed all quadrangles to two triangles.

    except ImportError:
        warn("VTK is not installed and thus has not been tested.")