[vtkusers] vtkImageAlgorithm output to preallocated buffer

David Gobbi david.gobbi at gmail.com
Sat Jan 21 08:56:11 EST 2017


On Sat, Jan 21, 2017 at 4:34 AM, Alessandro Volz <alessandro.volz at gmail.com>
wrote:

> I'm using vtkImageReslice to obtain a vtkImageData object that I read the
> output scalars from. All works fine.
> I'm now in a situation where it would make sense that I preallocate thee
> output buffer for the reslice to write into.
> Is there a way to do this?
> I thought I'd create a vtkImageData and SetScalarPointer on it, then
> SetOutput on the reslice. But I haven't been able to.
> Is there a way I could do this? Maybe I should create a vtkImageData
> subclass?


Instead of subclassing vtkImageData, it might be better to subclass
vtkImageReslice and override the AllocateOutputData() methods.  See the
current implementation of AllocateOutputData() here:
https://gitlab.kitware.com/vtk/vtk/blob/master/Common/ExecutionModel/
vtkImageAlgorithm.cxx#L198

But your idea of calling SetOutput() should work as long as you provide a
large enough output buffer of the correct data type.

 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170121/804db6cd/attachment.html>


More information about the vtkusers mailing list