[vtkusers] clip polyline

Kurt Sansom kayarre at gmail.com
Fri Jun 1 15:30:42 EDT 2018


Hi all,
  I am trying to clip a polyline with vtk. currently I am able to find the
point where I want to "snip" line. however when I attempt to do this it
doesn't seem to work.

the approach I am taking is to edit the individual cell by storing the Ids
and then updating them.


        pts_ids = vtk.vtkIdList()

        cell = centerlines.GetCell(cellIds.GetId(0))
        N_ids_cell = cell.GetPointIds().GetNumberOfIds()
        for i in range(N_ids_cell):
            pt_id_cell = cell.GetPointIds().GetId(i)

            #skip ids outside of the surface
            if (n_out_idx < 0 and int(pt_id_cell) < mvidx):
                continue
            elif (n_out_idx > 0 and int(pt_id_cell) > mvidx):
                continue
            pts_ids.InsertNextId(pt_id_cell)

        print(N_ids_cell, pts_ids.GetNumberOfIds())

        cell.GetPointIds().SetNumberOfIds(pts_ids.GetNumberOfIds())
        for i in range(pts_ids.GetNumberOfIds()):
            cell.GetPointIds().SetId(i,pts_ids.GetId(i))

Regards,
 ~Kurt
-- 
Kurt Sansom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180601/069d54dd/attachment.html>


More information about the vtkusers mailing list