Beispiel #1
0
        rnd_idx[0] = (0, 1, 2)
        triangles = np.take_along_axis(triangles, rnd_idx, axis=1)
        mesh.triangles = o3d.utility.Vector3iVector(triangles)
        o3d.visualization.draw_geometries([mesh])
        sucess = mesh.orient_triangles()
        print('%s orientated: %s' % (name, 'yes' if sucess else 'no'))
        o3d.visualization.draw_geometries([mesh])

    # intersection tests
    print('#' * 80)
    print('Intersection tests')
    print('#' * 80)
    np.random.seed(30)
    bbox = o3d.geometry.create_mesh_box(20, 20, 20).translate((-10, -10, -10))
    meshes = [o3d.geometry.create_mesh_box() for _ in range(20)]
    meshes.append(o3d.geometry.create_mesh_sphere())
    meshes.append(o3d.geometry.create_mesh_cone())
    meshes.append(o3d.geometry.create_mesh_torus())
    dirs = [np.random.uniform(-0.1, 0.1, size=(3, )) for _ in meshes]
    for mesh in meshes:
        mesh.compute_vertex_normals()
        mesh.paint_uniform_color((0.5, 0.5, 0.5))
        mesh.translate(np.random.uniform(-7.5, 7.5, size=(3, )))
    vis = o3d.visualization.Visualizer()
    vis.create_window()
    for mesh in meshes:
        vis.add_geometry(mesh)
    for iter in range(1000):
        for mesh, dir in zip(meshes, dirs):
            mesh.paint_uniform_color((0.5, 0.5, 0.5))
            mesh.translate(dir)
Beispiel #2
0
        triangles = np.take_along_axis(triangles, rnd_idx, axis=1)
        mesh.triangles = o3d.utility.Vector3iVector(triangles)
        o3d.visualization.draw_geometries([mesh])
        sucess = mesh.orient_triangles()
        print('%s orientated: %s' % (name, 'yes' if sucess else 'no'))
        o3d.visualization.draw_geometries([mesh])

    # intersection tests
    print('#' * 80)
    print('Intersection tests')
    print('#' * 80)
    np.random.seed(30)
    bbox = o3d.geometry.TriangleMesh.create_box(20, 20, 20).translate(
        (-10, -10, -10))
    meshes = [o3d.geometry.TriangleMesh.create_box() for _ in range(20)]
    meshes.append(o3d.geometry.TriangleMesh.create_sphere())
    meshes.append(o3d.geometry.TriangleMesh.create_cone())
    meshes.append(o3d.geometry.TriangleMesh.create_torus())
    dirs = [np.random.uniform(-0.1, 0.1, size=(3,)) for _ in meshes]
    for mesh in meshes:
        mesh.compute_vertex_normals()
        mesh.paint_uniform_color((0.5, 0.5, 0.5))
        mesh.translate(np.random.uniform(-7.5, 7.5, size=(3,)))
    vis = o3d.visualization.Visualizer()
    vis.create_window()
    for mesh in meshes:
        vis.add_geometry(mesh)
    for iter in range(1000):
        for mesh, dir in zip(meshes, dirs):
            mesh.paint_uniform_color((0.5, 0.5, 0.5))
            mesh.translate(dir)