[vtkusers] Adding cell to polydata with existing cells - error in cell association of points (maybe a problem of python wrapper or generall)

Charles Monty Burns ch.monty.burns at googlemail.com
Sat Apr 11 08:26:31 EDT 2009


Hello,

I have a problem of insert new cells in a polydata-mesh that have allready
cells
in it. Look at my example an the comments between the lines:

# loading 41059 triangle cells's
reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName("opt_mesh.vtp")
reader.Update()
mesh = reader.GetOutput()
mesh.BuildLinks(0)

# removing some cells
mesh.RemoveCellReference(24285)
mesh.DeleteCell(24285)

mesh.RemoveCellReference(3526)
mesh.DeleteCell(3526)

# points used for a new cell
points = [3205L, 2950L, 3070L]

# adding them to vtkIdList
pt_list = vtk.vtkIdList()
map(pt_list.InsertNextId, points)

# adding cell to polydata
new_cell_index = mesh.InsertNextCell(vtk.VTK_TRIANGLE, pt_list)

# resize point-links-size
cell_list = vtk.vtkIdList()

for pt in points:
    mesh.GetPointCells(pt, cell_list)
    mesh.ResizeCellList(pt, cell_list.GetNumberOfIds() + 1)

# add point to cell links by ones
mesh.AddCellReference(new_cell_nbr)

# test whether I can get the right point-ids of the new cell
pt_list = vtk.vtkIdList()
mesh.GetCellPoints(new_cell_index, pt_list)
cell_points = map(pt_list.GetId, xrange(pt_list.GetNumberOfIds()))

print points == cell_points # !!!!!!!!!!!!!! this will evalute as false

print cell_points # !!!!!!!!!!!!!!! >>> [0L, 1L, 2L]

The last line shows, that vtk don't associate the right point ids with the
cell-nbr, but new_cell_index has the value 41060! When I use Allocate(1, 1)
before
I insert the cell vtk gets the right cell-points, but get the points of
other cells
in the mesh will cause a Segmentation fault. This will happen also if I
allocate via
Allocate(mesh.GetNumberOfCells() + 1, 1) (don't really know what the
arguments
are for ... !?)

What is the solution of that issue?

I'm using VTK 5.2.

Greetings and a nice eastern.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090411/d1f59dae/attachment.htm>


More information about the vtkusers mailing list