How to use the generic.get_mesh function in generic

To help you get started, we’ve selected a few generic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mikedh / trimesh / tests / test_color.py View on Github external
def test_visual(self):
        mesh = g.get_mesh('featuretype.STL')

        # stl shouldn't have any visual properties defined
        assert not mesh.visual.defined

        for facet in mesh.facets:
            mesh.visual.face_colors[facet] = g.trimesh.visual.random_color()

        assert mesh.visual.defined
        assert not mesh.visual.transparency

        mesh.visual.face_colors[0] = [10, 10, 10, 130]
        assert mesh.visual.transparency
github mikedh / trimesh / tests / test_texture.py View on Github external
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
github mikedh / trimesh / tests / test_obj.py View on Github external
def test_single_vn(self):
        """
        Make sure files with a single VN load.
        """
        m = g.get_mesh('singlevn.obj')
        assert len(m.vertices) > 0
        assert len(m.faces) > 0
github mikedh / trimesh / tests / test_color.py View on Github external
def test_concatenate(self):
        a = g.get_mesh('ballA.off')
        b = g.get_mesh('ballB.off')

        a.visual.face_colors = [255, 0, 0]
        r = a + b
        assert any(r.visual.face_colors.ptp(axis=0) > 1)
github mikedh / trimesh / tests / test_remesh.py View on Github external
def test_subdivide(self):
        meshes = [
            g.get_mesh('soup.stl'),  # a soup of random triangles
            g.get_mesh('cycloidal.ply'),  # a mesh with multiple bodies
            g.get_mesh('featuretype.STL')]  # a mesh with a single body

        for m in meshes:
            sub = m.subdivide()
            assert g.np.allclose(m.area, sub.area)
            assert len(sub.faces) > len(m.faces)

            v, f = g.trimesh.remesh.subdivide(
                vertices=m.vertices,
                faces=m.faces)

            max_edge = m.scale / 50
            v, f = g.trimesh.remesh.subdivide_to_size(
                vertices=m.vertices,
                faces=m.faces,
                max_edge=max_edge)
            ms = g.trimesh.Trimesh(vertices=v, faces=f)
github mikedh / trimesh / tests / test_gltf.py View on Github external
def test_gltf_pole(self):
        scene = g.get_mesh('simple_pole.glb')

        # should have multiple primitives
        assert len(scene.geometry) == 11

        export = scene.export(file_type='glb')
        assert len(export) > 0
        # check a roundtrip
        reloaded = g.trimesh.load(
            g.trimesh.util.wrap_as_stream(export),
            file_type='glb')
        # make basic assertions
        g.scene_equal(scene, reloaded)
github mikedh / trimesh / tests / test_color.py View on Github external
def test_vertex(self):

        m = g.get_mesh('torus.STL')

        m.visual.vertex_colors = [100, 100, 100, 255]

        assert len(m.visual.vertex_colors) == len(m.vertices)
github mikedh / trimesh / tests / test_scene.py View on Github external
def test_dupe(self):
        m = g.get_mesh('tube.obj')

        assert m.body_count == 1

        s = g.trimesh.scene.split_scene(m)
        assert len(s.graph.nodes) == 2
        assert len(s.graph.nodes_geometry) == 1
        assert len(s.duplicate_nodes) == 1
        assert len(s.duplicate_nodes[0]) == 1

        c = s.copy()
        assert len(c.graph.nodes) == 2
        assert len(c.graph.nodes_geometry) == 1
        assert len(c.duplicate_nodes) == 1
        assert len(c.duplicate_nodes[0]) == 1

        u = s.convert_units('in', guess=True)
github mikedh / trimesh / tests / test_collision.py View on Github external
def test_distance(self):
        # Ensure that FCL is importable
        try:
            g.trimesh.collision.CollisionManager()
        except ValueError:
            g.log.warning('skipping collision tests, no FCL installed')
            return

        cube = g.get_mesh('unit_cube.STL')

        tf1 = g.np.eye(4)
        tf1[:3, 3] = g.np.array([5, 0, 0])

        tf2 = g.np.eye(4)
        tf2[:3, 3] = g.np.array([-5, 0, 0])

        tf3 = g.np.eye(4)
        tf3[:3, 3] = g.np.array([2, 0, 0])

        tf4 = g.np.eye(4)
        tf4[:3, 3] = g.np.array([-2, 0, 0])

        # Test one-to-many distance checking
        m = g.trimesh.collision.CollisionManager()
        m.add_object('cube1', cube, tf1)
github mikedh / trimesh / tests / test_color.py View on Github external
def test_concatenate(self):
        a = g.get_mesh('ballA.off')
        b = g.get_mesh('ballB.off')

        a.visual.face_colors = [255, 0, 0]
        r = a + b
        assert any(r.visual.face_colors.ptp(axis=0) > 1)