[vtkusers] Reading from memory as opposed to file

David Gobbi david.gobbi at gmail.com
Fri Mar 21 21:49:13 EDT 2014


Hi David,

Use vtkImageImport.  It has an interface that is nearly identical to
vtkImageReader2, except that instead of having a SetFileName()
method, it has a SetImportVoidPointer() method.

So if your vector is named "data", do something like this:

importer->SetImportVoidPointer(&data[0]);
importer->SetDataScalarTypeToDouble();
importer->SetDataExtent(0, 255, 0, 255, 0, 0);
etcetera.

  David

On Fri, Mar 21, 2014 at 6:27 PM,  <dfcsingh at sri.utoronto.ca> wrote:
>
> Hi vtkusers,
>
> In my experience with vtk thus far I've used vtkImageReader2 to read
> various MR file types and display them. For my next project I need to
> visualize raw MR data. To this end I would like to do some pre-processing
> on the data before passing it to a vtk pipeline. At the end of the
> processing in c++ I have a vector of doubles. Is there a way to feed this
> vector to vtkImageReader2 (or something similar)?
> My google-fu yielded setmemorybuffer however I'm not sure how to pass this
> function a vector and more importantly it wasn't showing up as a member of
> vtkImageReader2 when I attempted to test it (using vtk 5.6.1)
> I'd appreciate any help,
> David


More information about the vtkusers mailing list