[vtkusers] Volume data from application memory
Vidyadhar
vidyadhar at lucidindia.com
Thu Jan 24 23:22:26 EST 2008
Hi
You can create an instance of vtkImageData. Call SetOrigin, SetSpacing
methods as appropriate (or leave them at their default values). Call
SetDimensions(nX,nY,nZ) where your buffer dimensions will go (85x54x44).
Call SetNumberOfScalarComponents (I think you have only one component). Call
SetScalarTypeToXXX method (matching your buffer type). Now invoke
AllocateScalars method. Call GetScalarPointer() (void argument) and typecast
the returned pointer to your buffer data type. Now you can copy memory from
your buffer to the buffer allocated by vtkImageData instance. This way you
can copy your buffer into vtk's pipeline. There are ways in which you can
share buffer created by you with vtk's pipeline but these are somewhat
involved. Another possibility is, you create vtkImageData, configure it as
above, get pointer to the internal buffer and use that buffer to load your
data. I usually choose to let vtkImageData create and manage its internal
buffers, get pointer to it and programmatically fill the buffer with some
values.
HTH
Vidyadhar
----- Original Message -----
From: "Wesley Smith" <wesley.hoke at gmail.com>
To: <vtkusers at vtk.org>
Sent: Thursday, January 24, 2008 7:47 AM
Subject: [vtkusers] Volume data from application memory
> Hi,
> I'm just starting out using VTK and have been trying to figure out how
> to pass in volume data held in application memory (but not in any VTK
> class) into the VTK rendering system. From what I've seen, all of the
> examples use "Readers" which only look for data from file. Is there
> no such class that I can pass say a pointer along with the memory
> layout to? To make things more concrete, I'm using a library to load
> VASP files. From these, I get a buffer of data about 85x54x44 of
> scalar values. What's the best methodology for getting this data into
> VTK? Perusing the web, I've only seen examples that require
> subclassing a vtkReader of some sort. Is this the only way?
> (http://www.comp.leeds.ac.uk/drm/ExampleVolRender.cxx)
>
> thanks,
> wes
>
>
More information about the vtkusers
mailing list