[vtkusers] vtkVolumeReader

Amy Henderson amy.henderson at kitware.com
Mon Apr 5 15:01:17 EDT 2004


At 02:55 PM 4/5/2004, Vetria Byrd wrote:
>Sorry about the reply, I was hitting the reply to and not reply to all.
>

No problem.

>I am trying to create a 3D volume (a 5x5x5 cube).
>The data files (5 files – one for each slice) consists of zero’s and one’s 
>where the one’s indicate there is an object in that particular cell of the 
>cube, zero’s indicate the cell is empty.  I want to render the cube/object 
>using the marching cubes algorithm.
>

Try using vtkImageReader or vtkImageReader2. They allow you to specify the 
data type of the data you are trying to load.

- Amy

>Vetria
>
>
>-----Original Message-----
>From: Amy Henderson [mailto:amy.henderson at kitware.com]
>Sent: Monday, April 05, 2004 1:42 PM
>To: byrdv at cis.uab.edu; 'Amy Henderson'
>Subject: RE: [vtkusers] vtkVolumeReader
>
>Vetria,
>
>I just noticed the you replied only to me and not the the vtkusers list. 
>Please keep the discussion on the list so other people can help if 
>necessary and so there is a record of the solution to this problem if 
>other people encounter the same thing.
>
>What kind of data are you trying to load? Depending on the type of your 
>data, you might want to try loading it using one of the subclasses of 
>vtkImageReader2. These readers can handle 3D data by reading in a series 
>of 2D slices.
>
>- Amy
>
>At 02:32 PM 4/5/2004, Vetria Byrd wrote:
>
>When I try creating an instance of vtkVolume16Reader the code complies 
>with no errors but when I try to run it I get:
>
>ERROR: In C:\Program Files\vtk42\IO\vtkVolume16Reader.cxx, line 375
>vtkVolume16Reader (0x022B5400): Error reaading raw pgm data!
>
>So, I thought I would try vtkVolumeReader.
>
>Vetria
>
>-----Original Message-----
>From: Amy Henderson [mailto:amy.henderson at kitware.com]
>Sent: Monday, April 05, 2004 12:14 PM
>To: byrdv at cis.uab.edu; 'Amy Henderson'
>Subject: RE: [vtkusers] vtkVolumeReader
>
>Did you intend to create an instance of vtkVolume16Reader? vtkVolumeReader 
>has a pure virtual method, so you can't instantiate it; you have to create 
>an instance of one of its concrete subclasses (e.g., vtkVolume16Reader, 
>which I see in your list of include files).
>
>- Amy
>
>At 01:08 PM 4/5/2004, Vetria Byrd wrote:
>
>Yes.
>
>Here’s the entire file:
>
>//
>// This example reads a volume dataset, extracts an isosurface and 
>displays it.
>//
>
>#include "vtkRenderer.h"
>#include "vtkRenderWindow.h"
>#include "vtkRenderWindowInteractor.h"
>#include "vtkVolume16Reader.h"
>#include "vtkVolumeReader.h"
>#include "vtkObject.h"
>#include "vtkMarchingCubes.h"
>#include "vtkPolyDataMapper.h"
>#include "vtkActor.h"
>#include "vtkOutlineFilter.h"
>#include "vtkCamera.h"
>#include "vtkProperty.h"
>#include "vtkPolyDataNormals.h"
>#include "vtkContourFilter.h"
>
>int main (int argc, char **argv)
>{
>   if (argc < 2)
>     {
>       cout << "Usage: " << argv[0] << " DATADIR/cube/slice" << endl;
>     return 1;
>     }
>
>
>   vtkRenderer *ren = vtkRenderer::New();
>   vtkRenderWindow *renWin = vtkRenderWindow::New();
>     renWin->AddRenderer(ren);
>   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>     iren->SetRenderWindow(renWin);
>
>  *vtkVolumeReader *volReader = vtkVolumeReader::New();
>     volReader->SetImageRange (1,5);
>     volReader->SetFilePrefix (argv[1]);
>     volReader->SetDataSpacing (1,1,1);
>     volReader->Update();
>
>   // An isosurface, or contour value of 1 is known to correspond to the 
> object.
>   vtkMarchingCubes *iso =vtkMarchingCubes::New();
>      iso->SetInput(volReader->GetOutput() );
>      iso->SetValue(0,1);
>
>   vtkPolyDataMapper *isoMapper = vtkPolyDataMapper::New();
>       isoMapper->SetInput(iso->GetOutput() );
>       isoMapper->ScalarVisibilityOff();
>
>   vtkActor *isoActor = vtkActor::New();
>       isoActor->SetMapper(isoMapper);
>
>   vtkOutlineFilter *outline = vtkOutlineFilter::New();
>       outline->SetInput( (vtkDataSet *) volReader->GetOutput() );
>
>    vtkPolyDataMapper *outlineMapper = vtkPolyDataMapper::New();
>       outlineMapper->SetInput(outline->GetOutput() );
>
>    vtkActor *outlineActor = vtkActor::New();
>       outlineActor->SetMapper(outlineMapper);
>       outlineActor->VisibilityOff();
>
>    //
>    // Add the actors to the renderer, set the background and size
>    //
>    ren->AddActor(outlineActor);
>    ren->AddActor(isoActor);
>    ren->SetBackground(0.2,0.3,0.4);
>    renWin->SetSize(450,450);
>    ren->GetActiveCamera()->Elevation(90);
>    ren->GetActiveCamera()->SetViewUp(0,0,-1);
>
>    iren->Initialize();
>
>    // render the image
>    iren->Start();
>
>
>    return 0;
>}
>
>-----Original Message-----
>From: Amy Henderson [mailto:amy.henderson at kitware.com]
>Sent: Monday, April 05, 2004 11:59 AM
>To: byrdv at cis.uab.edu; 'vtkusers'
>Subject: Re: [vtkusers] vtkVolumeReader
>
>Vetria,
>
>Did you include the vtkVolumeReader header file (#include 
>"vtkVolumeReader.h")?
>
>- Amy
>
>At 12:47 PM 4/5/2004, Vetria Byrd wrote:
>
>I have manually created data files that consists of zero’s and one’s (no 
>header info) to resemble a (5x5x5) 3D cube.
>There are 5 data files.  When I try to use vtkVolumeReader I get the 
>following error message:
>
>error C2440: 'initializing' : cannot convert from 'class vtkObject *' to 
>'class vtkVolumeReader *'
>         Types pointed to are unrelated; conversion requires 
> reinterpret_cast, C-style cast or function-style cast
>
>This is where the error occurs:
>:
>:
>
>   vtkVolumeReader *volReader = vtkVolumeReader::New();
>     volReader->SetImageRange (1,5);
>     volReader->SetFilePrefix (argv[1]);
>     volReader->SetDataSpacing (1,1,1);
>     volReader->Update();
>
>Any assistance will be greatly appreciated.
>Thanks,
>_______________
>Vetria L. Byrd
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040405/fad85524/attachment.htm>


More information about the vtkusers mailing list