Example #1
0
def main():

    ## Create graphics interface.
    graphics = Graphics()

    file_name = 'centerlines.vtp'
    centerlines = read_centerlines(file_name)
    graphics.add_geometry(centerlines, color=[0.0, 0.6, 0.0], line_width=3)

    file_name = 'all_results_00500.vtu'
    mesh, surface = read_mesh(file_name)
    #graphics.add_geometry(surface, color=[0.8, 0.8, 0.8], wire=True)

    num_pts = mesh.GetNumberOfPoints()
    print('[main] mesh num pts: {0:d}'.format(num_pts))
    plane_dist = vtk.vtkDoubleArray()
    plane_dist.SetName("plane_dist")
    plane_dist.SetNumberOfComponents(1)
    plane_dist.SetNumberOfTuples(num_pts)
    for i in range(num_pts):
        plane_dist.SetValue(i, 0.0)
    mesh.GetPointData().AddArray(plane_dist)

    # extract_all_slices(renderer, centerlines, mesh)

    ## Create a mouse interactor for selecting centerline points.
    picking_keys = ['c']
    event_table = None
    event_table = {
        'c': (extract_slice, mesh),
    }

    graphics.init_picking(centerlines, picking_keys, event_table)

    ## Display window.
    graphics.show()