[vtkusers] Delete on vtkPolyDataReader

Will Schroeder will.schroeder at kitware.com
Tue Nov 14 20:36:35 EST 2000


Hi Francis-

Some bad mojo here. You've got to register the use of the output polydata
to make sure the polydata doesn't disappear with the filter. (The output 
initially
has a ref count of 1 because the filter is using it; when the filter 
disappears it
decrements the ref count and the output disappears.) Also, the Update()
is usually called on the filter, not the data object.

Try:

vtkPolyDataReader *PolyDataReader = vtkPolyDataReader::New();
vtkPolyData *PolyData;

PolyDataReader->SetFileName(FileName);
PolyDataReader->Update();
PolyData = PolyDataReader->GetOutput();
PolyData->Register(NULL);
PolyDataReader->Delete();
printf("pts read : %d\n", PolyData->GetNumberOfPoints() );

Will
>At 06:27 PM 11/14/2000 +0100, you wrote:
>Hello,
>
>I'm working with vtk 3.1 on NT4.0 SP4 / Visual C++ 6.0.
>I have problems with memory deallocations.
>
>For instance, in the following example, I use a vtkPolyDataReader, and I
>want to use the resulting vtkPolyData.
>I first get the output of the reader in a temporary vtkPolyData variable,
>and then I want to deallocate the reader, but if I do so, my temporary
>variable points a wrong memory place :
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20001114/a9cfdf8f/attachment.htm>


More information about the vtkusers mailing list