[vtkusers] clean way to replace polydata
Marius Erdt
marius.erdt at gmx.de
Thu Mar 4 10:41:05 EST 2010
Hi vtk-users,
I've got a function that should recompute the normals of a vtkPolyData.
However, if I try to delete the input poly by calling Delete and assign
the output of the filter to its variable, the program chrashes.
void computeNormals( vtkPolyData* &poly ){
vtkPolyDataNormals* normalsGen = vtkPolyDataNormals::New();
normalsGen->SetInput( poly );
normalsGen->Update();
poly->Delete();
poly = NULL;
poly = vtkPolyData::New();
poly->DeepCopy( normalsGen->GetOutput() );
normalsGen->Delete();
}
The codes works if I don't delete the input PolyData. However, then I
got a memory leak since the data of the original poly is not released.
Does anyone knows a solution?
Thanks,
Marius
More information about the vtkusers
mailing list