[vtkusers] vtkpython convert vtkMultiBlockDataSet to vtkDataSet
Tim Kostka
kostka at gmail.com
Tue Oct 9 17:15:31 EDT 2012
I’ve just started using vtkpython and have a hopefully basic question.
The output from vtkExodusIIReader is a vtkMultiBlockDataSet.
The input to vtkSurfaceFilter requires a vtkDataSet.
How do I get these two to talk to one another? My file only has a single
block.
Thanks,
Tim
-- error --
vtkStreamingDemandDrivenPipeline (0x17dee0c0): Input for connection
index 0 on input port index 0 for algorithm
vtkDataSetSurfaceFilter(0x17ded900) is of type vtkMultiBlockDataSet,
but a vtkDataSet is required.
-- error --
-- code --
import vtk
# load the geometry
wedge = vtk.vtkExodusIIReader()
wedge.SetFileName('mesh_wedge_only.g')
# extract a single block ???
block = vtk.vtkExtractBlock()
block.SetInputConnection(0, wedge.GetOutputPort())
block.AddIndex(0)
# extract the surface of the block
surface = vtk.vtkDataSetSurfaceFilter()
surface.SetInputConnection(0, block.GetOutputPort())
# break into triangles
triangles = vtk.vtkDataSetTriangleFilter()
triangles.SetInputConnection(0, surface.GetOutputPort())
# write to STL file
output = vtk.vtkSTLWriter()
output.SetFileTypeToBinary()
output.SetFileName('mesh_surface_clipped.stl')
output.SetInputConnection(0, triangles.GetOutputPort())
output.Update()
-- code --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121009/f78e08c5/attachment.htm>
More information about the vtkusers
mailing list