def test_empty_mesh(self): """ What happens when we call functions on an empty mesh? """ mesh = Mesh(np.zeros((0, 3), np.float32), np.zeros((0, 3), int)) mesh.simplify(1.0) assert len(mesh.vertices_zyx) == len(mesh.normals_zyx) == len( mesh.faces) == 0 mesh.simplify(0.1) assert len(mesh.vertices_zyx) == len(mesh.normals_zyx) == len( mesh.faces) == 0 mesh.laplacian_smooth(0) assert len(mesh.vertices_zyx) == len(mesh.normals_zyx) == len( mesh.faces) == 0 mesh.laplacian_smooth(2) assert len(mesh.vertices_zyx) == len(mesh.normals_zyx) == len( mesh.faces) == 0 mesh.stitch_adjacent_faces() assert len(mesh.vertices_zyx) == len(mesh.normals_zyx) == len( mesh.faces) == 0 mesh.serialize(fmt='obj') assert len(mesh.vertices_zyx) == len(mesh.normals_zyx) == len( mesh.faces) == 0 mesh.serialize(fmt='drc') assert len(mesh.vertices_zyx) == len(mesh.normals_zyx) == len( mesh.faces) == 0 mesh.compress() concatenate_meshes((mesh, mesh)) assert len(mesh.vertices_zyx) == len(mesh.normals_zyx) == len( mesh.faces) == 0
def process_sv(decimation, decimation_lib, max_sv_vertices, output_format, sv: int, mesh: Mesh): try: orig_vertices = len(mesh.vertices_zyx) if orig_vertices == 0: final_decimation = 1.0 else: final_decimation = min(decimation, max_sv_vertices / len(mesh.vertices_zyx)) if decimation_lib == "openmesh": mesh.simplify_openmesh(final_decimation) elif decimation_lib == "fq-in-memory": mesh.simplify(decimation, True) elif decimation_lib == "fq-via-disk": mesh.simplify(decimation, False) else: raise AssertionError() final_vertices = len(mesh.vertices_zyx) effective_decimation = final_vertices / orig_vertices mesh_bytes = mesh.serialize(fmt=output_format) return sv, orig_vertices, final_vertices, final_decimation, effective_decimation, mesh_bytes except Exception as ex: raise RuntimeError(f"Failed processing SV {sv}: {type(ex)}") from ex