Get the data from vtkAlgorithmOutput

I applied the marching cubes algorithm on a volume. The output is a vtkAlgorithmOutput (output_port variable) as shown by the following code. I want to extract the actual points (locations inside the volume coordinates) of the different iso-surfaces obtained by the marching cubes algorithms. Could you please help me as I want to apply some processing on these iso-surfaces? Any language is acceptable.

surface = vtkMarchingCubes()
surface.SetInputData(volume)
surface.ComputeNormalsOn()
surface.SetValue(0, 255)
output_port = surface.GetOutputPort()

Hello,

vtkMarchingCubes is a vtkPolyDataAlorithm subclass: https://vtk.org/doc/nightly/html/classvtkPolyDataAlgorithm.html . Hence, it has a GetOutput() method which returns a pointer to an usable vtkPolyData object. GetOutputPort() is just a plug to make up processing pipelines by joining several algorithms and filters.

take care,

Paulo

1 Like

Thank you, Paulo,
I was able to save the vtkPolyData object using vtkXMLPolyDataWriter to make some processing on the iso-surfaces. Is there a better way to save the data?

1 Like

Better in what sense? I mean, if you seek portability, saving to XML is a good choice. If you want to minimize file size, you can use vtkPolyDataWriter which persists objects in a proprietary binary or ASCII format (*.vtk).

1 Like