reader.GetOutputPort() have a .mhd image
There are 6 planes which is defined by 3 points in which is get the normal of the plane.
I want to remove to a volume, a prism (6 faces) delimited by 6 planes.
volume, renderer, renderWindow, volumeMapper are all defined.
The code below gives the below error.
Can you help?
2021-03-01 13:18:04.341 ( 31.721s) [ ]vtkDemandDrivenPipeline:760 ERR| vtkCompositeDataPipeline (0000025F7D7C0280): Input for connection index 0 on input port index 0 for algorithm vtkOpenGLGPUVolumeRayCastMapper(0000025F7DA17BD0) is of type vtkUnstructuredGrid, but a vtkImageData is required.
You are feeding a vtkImageData to a filter that requires vtkUnstructuredGrid inputs.
You can use the filter vtkAdaptiveResampleToImage right before the volume mapper. This filter will resample your unstructured grid into a set of images with adaptive resolutions depending on the input geometry.
************************************************************************************************++
Traceback (most recent call last):
File âD:\zipback\visual studio 2015\Projects\RegistrationAR\RegistrationAR\teste1.pyâ, line 214, in thread_function
image1=vtk.vtkAdaptiveResampleToImage(extract.GetOutputPort())
AttributeError: module âvtkmodules.allâ has no attribute âvtkAdaptiveResampleToImageâ
You can try using vtkResampleToImage instead. There are 2 methods you might want to use with this filter: SetInputBounds(true) and SetSamplingDimensions(xdim, ydim, zdim).
The goal is to do volume rendering with clipping? If yes, then the usual way to do this is to feed the vtkImageData directly into the vtkVolumeMapper, and use the mapper to clip the data while it is being rendered. The SetClippingPlanes methods are documented here.
In general, using the mapperâs clipping planes is by far the most efficient method, unless the volume is very large and the prism region is very small.
If the prism region is much smaller than the volume, then you can compute the bounding box of the prism, and use this bounding box to crop the volume before feeding it into a mapper that will crop it with the prism.
Converting an image to an unstructured grid and vice-versa is very computationally expensive, so I would avoid that unless you have no other options.
Edit: if you just want to zero all of the image voxels that arenât inside the prism, this can be efficiently done with vtkImplicitFunctionToImageStencil. See TestStencilWithImplicitFunction.py, unfortunately itâs not a great example because it has few comments. There is a bit more explanation here.
The vtkPlanes class is more efficient to evaluate than vtkImplicitBoolean, so it will provide better performance.
Edit 2: Note that enums that are defined in VTK classes can be accessed like this: