problem accessing vtkPolyData info from vtkTransformPolyDataFilter

Hi everybody.

I was using VTK 5.10 and decided to move to newer version. I found that there was a Migration/Replacement of SetInput and modified accordingly my code.

In terms of Polydata visualization, everything works fine.

However, I have problems reading the output of filters. In particular, I would like to access to vtkPolyData info (i.e. number of points and so on) form a vtkTransformPolyDataFilter.

In what follow the updated version of the code, which compile but doesn’t work as the previous version under VTK 5.10

//DEFINING
vtkSTLReader *volumeReader1 = vtkSTLReader::New();
vtkTransform *ActualPosition=vtkTransform::New();
vtkTransformPolyDataFilter *PositionFilter = vtkTransformPolyDataFilter::New();
vtkPolyData *MyPolyData;

//CONNECTING
volumeReader1->SetFileName(filename1);
PositionFilter->SetInputConnection(volumeReader1->GetOutputPort());
PositionFilter->SetTransform(ActualPosition);
MyPolyData = PositionFilter->GetOutput();
BonePolyData->Modified();
...

//READING INFO
int n = BonePolyData->GetNumberOfPoints();
//I also tried
int n = PositionFilter->GetOutput()->GetNumberOfPoints();

In both cases I got n = 0 while it should not be.

Any suggestion?
Thanks in advance

Michele

You need to call Update() on the filter before accessing its output.

There can be many other mistakes in the code but the snippet you included is so incomplete that it is hard to guess what is wrong.

Hi Andras,
thank you for the very prompt reply. Your solution works.

The problem was that in the previous version I could call MyPolydata->Upadate(), which took care of filter updating as well. With the new VTK version, it is no longer possible to call Update() methods for the polydata. I thought that ->modified() does the same, which is not the case. I take the chance to ask you if you could provide any reference explaining the differences between the two methods and which Classes do no longer support the Update() methods.

I am sorry I attached just a snippet. The idea was to isolate the piece of code generating the problems, so that was easier to identify the same. I actually isolated the single piece I posted. Next time I will pro
vide a complete code.

1 Like