How to use the generic.trimesh.util.is_shape 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_scene.py View on Github external
for s in [scene_split, scene_base]:
                pre = s.md5()
                assert len(s.geometry) > 0
                assert s.is_valid

                flattened = s.graph.to_flattened()
                g.json.dumps(flattened)
                edgelist = s.graph.to_edgelist()
                g.json.dumps(edgelist)

                assert s.bounds.shape == (2, 3)
                assert s.centroid.shape == (3,)
                assert s.extents.shape == (3,)
                assert isinstance(s.scale, float)
                assert g.trimesh.util.is_shape(s.triangles, (-1, 3, 3))
                assert len(s.triangles) == len(s.triangles_node)

                assert s.md5() == pre
                assert s.md5() is not None

                # should be some duplicate nodes
                assert len(s.duplicate_nodes) > 0

                # should be a single scene camera
                assert isinstance(s.camera, g.trimesh.scene.cameras.Camera)
                # should be autogenerated lights
                assert len(s.lights) > 0
                # all lights should be lights
                assert all(isinstance(L, g.trimesh.scene.lighting.Light)
                           for L in s.lights)
                # all lights should be added to scene graph
github mikedh / trimesh / tests / test_obj.py View on Github external
def test_obj_quad(self):
        mesh = g.get_mesh('quadknot.obj')
        # make sure some data got loaded
        assert g.trimesh.util.is_shape(mesh.faces, (-1, 3))
        assert g.trimesh.util.is_shape(mesh.vertices, (-1, 3))

        assert mesh.is_watertight
        assert mesh.is_winding_consistent
github mikedh / trimesh / tests / test_loaded.py View on Github external
def test_obj_groups(self):
        # a wavefront file with groups defined
        mesh = g.get_mesh('groups.obj')

        # make sure some data got loaded
        assert g.trimesh.util.is_shape(mesh.faces, (-1, 3))
        assert g.trimesh.util.is_shape(mesh.vertices, (-1, 3))

        # make sure groups are the right length
        assert len(mesh.metadata['face_groups']) == len(mesh.faces)

        # check to make sure there is signal not just zeros
        assert mesh.metadata['face_groups'].ptp() > 0
github mikedh / trimesh / tests / test_primitives.py View on Github external
def test_primitives(self):
        for primitive in self.primitives:
            # make sure faces and vertices are correct
            assert g.trimesh.util.is_shape(primitive.faces,
                                           (-1, 3))
            assert g.trimesh.util.is_shape(primitive.vertices,
                                           (-1, 3))
            # check dtype of faces and vertices
            assert primitive.faces.dtype.kind == 'i'
            assert primitive.vertices.dtype.kind == 'f'

            assert primitive.volume > 0.0
            assert primitive.area > 0.0

            # convert to base class trimesh
            as_mesh = primitive.to_mesh()

            try:
                assert as_mesh.volume > 0.0
                assert as_mesh.area > 0.0
github mikedh / trimesh / tests / test_obj.py View on Github external
def test_obj_quad(self):
        mesh = g.get_mesh('quadknot.obj')
        # make sure some data got loaded
        assert g.trimesh.util.is_shape(mesh.faces, (-1, 3))
        assert g.trimesh.util.is_shape(mesh.vertices, (-1, 3))

        assert mesh.is_watertight
        assert mesh.is_winding_consistent
github mikedh / trimesh / tests / test_obj.py View on Github external
def test_obj_groups(self):
        # a wavefront file with groups defined
        mesh = g.get_mesh('groups.obj')

        # make sure some data got loaded
        assert g.trimesh.util.is_shape(mesh.faces, (-1, 3))
        assert g.trimesh.util.is_shape(mesh.vertices, (-1, 3))
github mikedh / trimesh / tests / test_loaded.py View on Github external
def test_obj_multiobj(self):
        # test a wavefront file with multiple objects in the same file
        meshes = g.get_mesh('two_objects.obj')
        self.assertTrue(len(meshes) == 2)

        for mesh in meshes:
            # make sure some data got loaded
            assert g.trimesh.util.is_shape(mesh.faces, (-1, 3))
            assert g.trimesh.util.is_shape(mesh.vertices, (-1, 3))

            assert mesh.is_watertight
            assert mesh.is_winding_consistent
github mikedh / trimesh / tests / test_creation.py View on Github external
def check_triangulation(v, f, true_area):
    assert g.trimesh.util.is_shape(v, (-1, 2))
    assert v.dtype.kind == 'f'
    assert g.trimesh.util.is_shape(f, (-1, 3))
    assert f.dtype.kind == 'i'

    tri = g.trimesh.util.stack_3D(v)[f]
    area = g.trimesh.triangles.area(tri).sum()
    assert g.np.isclose(area, true_area)
github mikedh / trimesh / tests / test_obj.py View on Github external
def test_obj_split_attributes(self):
        # test a wavefront file where pos/uv/norm have different indices
        # and where multiple objects share vertices
        # Note 'process=False' to avoid merging vertices
        scene = g.get_mesh('joined_tetrahedra.obj',
                           process=False,
                           split_object=True,
                           group_material=False)

        assert len(scene.geometry) == 2

        geom = list(scene.geometry.values())

        assert g.trimesh.util.is_shape(geom[0].faces, (4, 3))
        assert g.trimesh.util.is_shape(geom[0].vertices, (9, 3))
        assert g.trimesh.util.is_shape(geom[1].faces, (4, 3))
        assert g.trimesh.util.is_shape(geom[1].vertices, (9, 3))
github mikedh / trimesh / tests / test_creation.py View on Github external
def check_triangulation(v, f, true_area):
    assert g.trimesh.util.is_shape(v, (-1, 2))
    assert v.dtype.kind == 'f'
    assert g.trimesh.util.is_shape(f, (-1, 3))
    assert f.dtype.kind == 'i'

    tri = g.trimesh.util.stack_3D(v)[f]
    area = g.trimesh.triangles.area(tri).sum()
    assert g.np.isclose(area, true_area)