Hello,<br><br>I have a problem of insert new cells in a polydata-mesh that have allready cells<br>in it. Look at my example an the comments between the lines:<br><br># loading 41059 triangle cells's<br>reader = vtk.vtkXMLPolyDataReader()<br>
reader.SetFileName("opt_mesh.vtp")<br>reader.Update()<br>mesh = reader.GetOutput()<br>mesh.BuildLinks(0)<br><br># removing some cells<br>mesh.RemoveCellReference(24285)<br>mesh.DeleteCell(24285)<br><br>mesh.RemoveCellReference(3526)<br>
mesh.DeleteCell(3526)<br><br># points used for a new cell<br>points = [3205L, 2950L, 3070L]<br><br># adding them to vtkIdList<br>pt_list = vtk.vtkIdList()<br>map(pt_list.InsertNextId, points)<br><br># adding cell to polydata<br>
new_cell_index = mesh.InsertNextCell(vtk.VTK_TRIANGLE, pt_list)<br><br># resize point-links-size<br>cell_list = vtk.vtkIdList()<br><br>for pt in points:<br> mesh.GetPointCells(pt, cell_list)<br> mesh.ResizeCellList(pt, cell_list.GetNumberOfIds() + 1)<br>
<br># add point to cell links by ones<br>mesh.AddCellReference(new_cell_nbr)<br><br># test whether I can get the right point-ids of the new cell<br>pt_list = vtk.vtkIdList()<br>mesh.GetCellPoints(new_cell_index, pt_list)<br>
cell_points = map(pt_list.GetId, xrange(pt_list.GetNumberOfIds()))<br><br>print points == cell_points # !!!!!!!!!!!!!! this will evalute as false<br><br>print cell_points # !!!!!!!!!!!!!!! >>> [0L, 1L, 2L]<br><br>
The last line shows, that vtk don't associate the right point ids with the<br>cell-nbr, but new_cell_index has the value 41060! When I use Allocate(1, 1) before<br>I insert the cell vtk gets the right cell-points, but get the points of other cells<br>
in the mesh will cause a Segmentation fault. This will happen also if I allocate via<br>Allocate(mesh.GetNumberOfCells() + 1, 1) (don't really know what the arguments<br>are for ... !?)<br><br>What is the solution of that issue?<br>
<br>I'm using VTK 5.2.<br><br>Greetings and a nice eastern.<br><br>