Volume Rendering
Lisa S. Avila
lisa.avila at kitware.com
Wed Dec 8 22:10:53 EST 1999
Hello Sandeep,
When you say "nothing gets rendered" do you mean that you see nothing
(background) for the volume, but you do see the outline?
Here are a few thoughts I have:
If you see a white cube, then the problem is your transfer functions - you
have mapped all scalar values to opaque white.
If you downloaded VTK at the end of October or early November, and you are
seeing warning messages about using obsolete methods, then you may have the
version of VTK that does nothing when you do SetVolumeMapper() and
SetVolumeProperty(). These methods are now obsolete - they print warnings
and call the correct methods (SetMapper() and SetProperty()) but for a 3
week or so time period they did not call the new methods and just printed
the warning.
If neither of those turn out to be your problem, try starting from vol.cxx
or volSimple.tcl and modify it to read your data. (Of course, first verify
that the original works). Maybe that will help track it down.
As for vtkScalars - you can store anything in there as long as you set the
DataType. VTK_FLOAT is just the default.
Lisa
At 05:36 AM 12/7/99 -0800, Sandeep Pulla wrote:
>Hi,
>
>I'm trying to raycast an 8-bit volume and am running into all sorts of
>problems. The program seems to be reading the data(vtk/tiff) fine, only
>nothing gets rendered. What am I doing wrong ? (Forgive me if my problem is
>too trivial).
>
>Relevant source code is below (version 2.4):
>-----------------------------------------------------------------
>void main()
>{
> vtkRenderer *ren = vtkRenderer::New();
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren);
> renWin->DoubleBufferOff();
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
>
>/* I use one of these input formats... */
>/* VTK */
> char FileName[] = "C:\\Vox99\\VolRen\\t.vtk";
> vtkStructuredPointsReader *reader = vtkStructuredPointsReader::New();
> reader->SetFileName(FileName);
> reader->Update();
>
>/* Multiple TIFF files */
> vtkImageReader *reader = vtkImageReader::New();
> reader->SetFilePrefix("C:\\VOX99\\TIF\\C01F");
> reader->SetFilePattern("%s%.4d.tif");
> reader->SetDataScalarTypeToUnsignedChar();
> reader->SetDataExtent(0,511,0,511,1,64);
> reader->SetDataByteOrderToBigEndian();
> reader->Update();
>/* Raw data */
> vtkStructuredPoints *pts;
> pts = ReadRawData(512,512,5,"C:\\Vox99\\VolRen\\t.raw");
>
> vtkColorTransferFunction *colorTransfer = vtkColorTransferFunction::New();
> colorTransfer->AddRGBSegment(0, 1.0, 1.0, 1.0, 255, 1.0, 1.0, 1.0);
>
> vtkPiecewiseFunction *opacityTransfer = vtkPiecewiseFunction::New();
> opacityTransfer->AddSegment(0, 1.0, 255, 1.0);
>
> vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
> volumeProperty->SetColor(colorTransfer);
> volumeProperty->SetScalarOpacity(opacityTransfer);
> volumeProperty->SetInterpolationTypeToLinear();
> volumeProperty->ShadeOn();
>
> vtkVolumeRayCastCompositeFunction *compositeFunction =
>vtkVolumeRayCastCompositeFunction::New();
> vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
> volumeMapper->SetInput(reader->GetOutput());
> volumeMapper->SetVolumeRayCastFunction(compositeFunction);
>
> vtkVolume *volume = vtkVolume::New();
> volume->SetVolumeMapper(volumeMapper);
> volume->SetVolumeProperty(volumeProperty);
>
> vtkOutlineFilter *outline = vtkOutlineFilter::New();
> outline->SetInput(reader->GetOutput());
> vtkPolyDataMapper* outlineMapper = vtkPolyDataMapper::New();
> outlineMapper->SetInput(outline->GetOutput());
> vtkActor* outlineActor = vtkActor::New();
> outlineActor->SetMapper(outlineMapper);
> outlineActor->GetProperty()->SetColor(1,1,1);
>
> ren->AddVolume(volume);
> ren->AddActor(outlineActor);
> renWin->Render();
> iren->Start();
>}
>
>Another problem is that I'm unable to use raw data because:
> a. I need to use vtkScalars and,
> b. vtkScalars stores data as float and,
> c. vtkVolumeRayCastMapper does not accept float !
>
>Notice that my raw data is 8-bit, only the intermediate (vtkScalars) turns
>it into float.
>
>How do I get around this ?
>
>
>Thanks,
>Sandeep
>
>P.S. If you're interested, here's how I read in raw data:
>
>vtkStructuredPoints* ReadRawData(int Nx, int Ny, int Nz, char* FileName)
>{
> vtkStructuredPoints *pts = vtkStructuredPoints::New();
> pts->SetDimensions(Nx,Ny,Nz);
> vtkScalars *scalars = new vtkScalars;
> unsigned char value;
> int i, j, k, jOffset, kOffset;
> ifstream ifs(FileName);
> if(!ifs)
> error("ReadRawData: Unable to open file");
> for(k = 0; k < Nz; k++)
> {
> kOffset = k * Ny * Nx;
> for(j = 0; j < Ny; j++)
> {
> jOffset = j * Nx;
> for(i = 0; i < Nx; i++)
> {
> ifs >> value;
> if(!ifs)
> error("ReadRawData: Error reading from file");
> scalars->InsertScalar(i + jOffset + kOffset,value);
> }
> }
> }
> ifs.close();
> pts->GetPointData()->SetScalars(scalars);
> scalars->Delete();
> return pts;
>}
>
>
>
>______________________________________________________
>Get Your Private, Free Email at http://www.hotmail.com
>
>
>-----------------------------------------------------------------------------
>This is the private VTK discussion list. Please keep messages on-topic.
>Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
>To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
><majordomo at gsao.med.ge.com>. For help, send message body containing
>"info vtkusers" to the same address. Live long and prosper.
>-----------------------------------------------------------------------------
>
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list