Exemple #1
0
    def test_remote(self):
        """
        Try loading a remote mesh using requests
        """
        # get a unit cube from localhost
        with g.serve_meshes() as address:
            mesh = g.trimesh.exchange.load.load_remote(url=address +
                                                       '/unit_cube.STL')

        assert g.np.isclose(mesh.volume, 1.0)
        assert isinstance(mesh, g.trimesh.Trimesh)
Exemple #2
0
    def test_remote(self):
        """
        Try loading a remote mesh using requests
        """
        # get a unit cube from localhost
        with g.serve_meshes() as address:
            mesh = g.trimesh.exchange.load.load_remote(
                url=address + '/unit_cube.STL')

        assert g.np.isclose(mesh.volume, 1.0)
        assert isinstance(mesh, g.trimesh.Trimesh)
Exemple #3
0
    def test_fuze(self):

        # create a local web server to test remote assets
        with g.serve_meshes() as address:
            # see if web resolvers work
            tex = g.trimesh.exchange.load.load_remote(url=address +
                                                      '/fuze.obj',
                                                      process=False)
            g.check_fuze(tex)

            # see if web + zip resolvers work
            scene = g.trimesh.exchange.load.load_remote(url=address +
                                                        '/fuze.zip',
                                                        process=False)

            # zip files get loaded into a scene
            assert len(scene.geometry) == 1
            # scene should just be a fuze bottle
            g.check_fuze(next(iter(scene.geometry.values())))

        # obj with texture, assets should be loaded
        # through a FilePathResolver
        m = g.get_mesh('fuze.obj', process=False)
        g.check_fuze(tex)

        # obj with texture, assets should be loaded
        # through a ZipResolver into a scene
        scene = g.get_mesh('fuze.zip', process=False)

        # zip files get loaded into a scene
        assert len(scene.geometry) == 1
        m = next(iter(scene.geometry.values()))
        g.check_fuze(m)

        # the PLY should have textures defined
        m = g.get_mesh('fuze.ply', process=False)
        g.check_fuze(m)

        # ASCII PLY should have textures defined
        m = g.get_mesh('fuze_ascii.ply', process=False)
        g.check_fuze(m)

        # textured meshes should subdivide OK-ish
        s = m.subdivide()
        assert len(s.visual.uv) == len(s.vertices)

        # load without doing the vertex separation
        # will look like garbage but represents original
        # and skips "disconnect vertices with different UV"
        b = g.get_mesh('fuze.ply', process=False, fix_texture=False)
        assert len(b.vertices) == 502
        assert len(b.visual.uv) == 502
    def test_fuze(self):

        def check_fuze(fuze):
            """
            Check the classic textured mesh: a fuze bottle
            """
            # these loaded fuze bottles should have textures
            assert isinstance(
                fuze.visual, g.trimesh.visual.TextureVisuals)

            # image should be loaded with correct resolution
            assert fuze.visual.material.image.size == (1024, 1024)

            # UV coordinates should be unmerged correctly
            assert len(fuze.visual.uv) == 664

            # UV coordinates shouldn't be all zero- ish
            assert fuze.visual.uv[:, :2].ptp(axis=0).min() > 0.1

            # vertices should correspond with UV
            assert fuze.vertices.shape == (664, 3)

            # convert TextureVisuals to ColorVisuals
            viz = fuze.visual.to_color()
            assert viz.kind == 'vertex'

            # should be actual colors defined
            assert viz.vertex_colors.ptp(axis=0).ptp() != 0

        # create a local web server to test remote assets
        with g.serve_meshes() as address:
            # see if web resolvers work
            tex = g.trimesh.exchange.load.load_remote(
                url=address + '/fuze.obj', process=False)
            check_fuze(tex)

            # see if web + zip resolvers work
            scene = g.trimesh.exchange.load.load_remote(
                url=address + '/fuze.zip', process=False)

            # zip files get loaded into a scene
            assert len(scene.geometry) == 1
            # scene should just be a fuze bottle
            check_fuze(next(iter(scene.geometry.values())))

        # obj with texture, assets should be loaded
        # through a FilePathResolver
        m = g.get_mesh('fuze.obj', process=False)
        check_fuze(tex)

        # obj with texture, assets should be loaded
        # through a ZipResolver into a scene
        scene = g.get_mesh('fuze.zip', process=False)

        # zip files get loaded into a scene
        assert len(scene.geometry) == 1
        m = next(iter(scene.geometry.values()))
        check_fuze(m)

        # the PLY should have textures defined
        m = g.get_mesh('fuze.ply', process=False)
        check_fuze(m)

        # ASCII PLY should have textures defined
        m = g.get_mesh('fuze_ascii.ply', process=False)
        check_fuze(m)
    
        # load without doing the vertex separation
        # will look like garbage but represents original
        # and skips "disconnect vertices with different UV"
        b = g.get_mesh('fuze.ply',
                       process=False,
                       fix_texture=False)
        assert len(b.vertices) == 502
        assert len(b.visual.uv) == 502
Exemple #5
0
    def test_fuze(self):

        def check_fuze(fuze):
            """
            Check the classic textured mesh: a fuze bottle
            """
            # these loaded fuze bottles should have textures
            assert isinstance(
                fuze.visual, g.trimesh.visual.TextureVisuals)

            # image should be loaded with correct resolution
            assert fuze.visual.material.image.size == (1024, 1024)

            # UV coordinates should be unmerged correctly
            assert len(fuze.visual.uv) == 664

            # UV coordinates shouldn't be all zero- ish
            assert fuze.visual.uv[:, :2].ptp(axis=0).min() > 0.1

            # vertices should correspond with UV
            assert fuze.vertices.shape == (664, 3)

            # convert TextureVisuals to ColorVisuals
            viz = fuze.visual.to_color()
            assert viz.kind == 'vertex'

            # should be actual colors defined
            assert viz.vertex_colors.ptp(axis=0).ptp() != 0

        # create a local web server to test remote assets
        with g.serve_meshes() as address:
            # see if web resolvers work
            tex = g.trimesh.exchange.load.load_remote(
                url=address + '/fuze.obj', process=False)
            check_fuze(tex)

            # see if web + zip resolvers work
            scene = g.trimesh.exchange.load.load_remote(
                url=address + '/fuze.zip', process=False)

            # zip files get loaded into a scene
            assert len(scene.geometry) == 1
            # scene should just be a fuze bottle
            check_fuze(next(iter(scene.geometry.values())))

        # obj with texture, assets should be loaded
        # through a FilePathResolver
        m = g.get_mesh('fuze.obj', process=False)
        check_fuze(tex)

        # obj with texture, assets should be loaded
        # through a ZipResolver into a scene
        scene = g.get_mesh('fuze.zip', process=False)

        # zip files get loaded into a scene
        assert len(scene.geometry) == 1
        m = next(iter(scene.geometry.values()))
        check_fuze(m)

        # the PLY should have textures defined
        m = g.get_mesh('fuze.ply', process=False)
        check_fuze(m)

        # ASCII PLY should have textures defined
        m = g.get_mesh('fuze_ascii.ply', process=False)
        check_fuze(m)

        # load without doing the vertex separation
        # will look like garbage but represents original
        # and skips "disconnect vertices with different UV"
        b = g.get_mesh('fuze.ply',
                       process=False,
                       fix_texture=False)
        assert len(b.vertices) == 502
        assert len(b.visual.uv) == 502