[vtkusers] Volume rendering

Lisa S. Avila lisa.avila at kitware.com
Thu Feb 15 13:28:16 EST 2001


Hello,

You cast to short - you need to cast to unsigned short.

Lisa


At 11:08 AM 2/15/2001, xiong fei wrote:
>Thank you for your advice. But when I try it in my
>program, that error still exist.
>"ERROR: In
>d:\nightly\vtk\graphics\vtkVolumeRayCastMapper.cxx,
>line 912
>vtkVolumeRayCastMapper (0x007EADB0): The scalar data
>type: 4 is not supported when volume rendering. Please
>convert the  data to unsigned char or unsigned short."
>
>I have put my sourse code below, can you take a look?
>Your help is greatly appreciated.
>
>//some codes from example "volProt.cxx"
>
>void main( int argc, char *argv[] )
>{
>     vtkDataSet *dataSet;
>     // read data
>     dataSet = ReadFinancialData();
>
>     if (! dataSet) exit(0);
>
>   // Create the renderer, render window, and
>interactor
>   vtkRenderer *ren1 = vtkRenderer::New();
>   vtkRenderWindow *renWin = vtkRenderWindow::New();
>     renWin->AddRenderer(ren1);
>   vtkRenderWindowInteractor *iren =
>vtkRenderWindowInteractor::New();
>     iren->SetRenderWindow(renWin);
>
>     vtkGaussianSplatter *popSplatter =
>vtkGaussianSplatter::New();
>     popSplatter->SetInput(dataSet);
>     popSplatter->SetSampleDimensions(50,50,50);
>     popSplatter->SetRadius(0.05);
>     popSplatter->ScalarWarpingOff();
>
>     vtkImageCast *cast = vtkImageCast::New();
>     cast->SetInput(popSplatter->GetOutput());
>     cast->SetOutputScalarTypeToShort();
>
>   // Read data from original dataset and transfer it
>to structuredpoints
>
>   // Create a transfer function mapping scalar value
>to opacity
>   vtkPiecewiseFunction *oTFun =
>vtkPiecewiseFunction::New();
>     oTFun->AddSegment(80, 0.0, 255, 1.0);
>
>   // Create a transfer function mapping scalar value
>to color (grey)
>   vtkPiecewiseFunction *cTFun =
>vtkPiecewiseFunction::New();
>     cTFun->AddSegment(0, 1.0, 255, 1.0);
>
>   // Create a property for the volume and set the
>transfer functions.
>   // Turn shading on and use trilinear interpolation
>   vtkVolumeProperty *volumeProperty =
>vtkVolumeProperty::New();
>     volumeProperty->SetColor(cTFun);
>     volumeProperty->SetScalarOpacity(oTFun);
>     volumeProperty->SetInterpolationTypeToLinear();
>     volumeProperty->ShadeOn();
>
>   // Create a ray function - this is a compositing ray
>function
>   vtkVolumeRayCastCompositeFunction *compositeFunction
>=
>     vtkVolumeRayCastCompositeFunction::New();
>
>   // Create the volume mapper and set the ray function
>and scalar input
>   vtkVolumeRayCastMapper *volumeMapper =
>vtkVolumeRayCastMapper::New();
>    //****
>     volumeMapper->SetInput(cast->GetOutput());
>
>volumeMapper->SetVolumeRayCastFunction(compositeFunction);
>
>   // Create the volume and set the mapper and property
>   vtkVolume *volume = vtkVolume::New();
>     volume->SetMapper(volumeMapper);
>     volume->SetProperty(volumeProperty);
>
>   // Add this volume to the renderer and get a closer
>look
>   ren1->AddVolume(volume);
>   ren1->GetActiveCamera()->Azimuth(20.0);
>   ren1->GetActiveCamera()->Dolly(1.60);
>   ren1->ResetCameraClippingRange();
>
>   renWin->SetSize(300,300);
>
>   renWin->Render();
>
>   SAVEIMAGE( renWin );
>
>   // Interact with the data at 3 frames per second
>   iren->SetDesiredUpdateRate(3.0);
>   iren->SetStillUpdateRate(0.001);
>   iren->Start();
>
>   // Clean up
>   ren1->Delete();
>   renWin->Delete();
>   iren->Delete();
>   popSplatter->Delete();
>   oTFun->Delete();
>   cTFun->Delete();
>   volumeProperty->Delete();
>   compositeFunction->Delete();
>   volumeMapper->Delete();
>   volume->Delete();
>}
>
>
>--- bo wang <bowang at iastate.edu> wrote: >
> > -----Original Message-----
> > From: xiong fei <xfpku at yahoo.com.sg>
> > To: vtkusers at public.kitware.com
> > <vtkusers at public.kitware.com>
> > Date: Wednesday, February 14, 2001 9:53 PM
> > Subject: Re: [vtkusers] Volume rendering
> >
> >
> > >Hi, all
> > >
> > >   Sorry to post this message again, but I am
> > really
> > >stuck now. As what was said before, I want to
> > >visualize some financial data using volume
> > rendering.
> > >But the question is how to do it?
> > >   I have tried vtkGaussianSplatter or
> > >vtkShepardMethod to transfer the raw data to be
> > >structured points, and it really did. However, when
> > I
> > >try to run the program, a error is reported :
> > >"vtkVolumeRayCastMapper (0x10031048): The scalar
> > data
> > >type: 10 is not supported when volume rendering.
> > >Please convert the  data to unsigned char or
> > unsigned
> > >short." So what shall I do next? can someone help
> > me?
> > >Thanks.
> >
> > use vtkImageCast to convert the data type.
> >
> >
> >
> >
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at:
> > <http://public.kitware.com/cgi-bin/vtkfaq>
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Mail ­ Free email you can access from anywhere!
>http://mail.yahoo.com.sg/
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: 
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers





More information about the vtkusers mailing list