[vtkusers] Volume rendering a dataset of only 2 scalars values,

Paul McGuinness mcguinpg at maths.tcd.ie
Fri Mar 26 05:52:53 EST 2004


Thanks Lisa,

I am still not getting the volume rendered image to appear. I have done
all of what you mentioed below. I should mention I suppose how I created
my data so you can understand what I am trying to achieve. I am trying to
perform volume rendering of complex foam structures. The foam structure is
read in from a file in vtkPolydata format, just vertices and triangular
facets. I then use GetPointData()->SetScalars(scalars) on the polydata
structure, all the vertices/points get scalar value of 1, everything else
is just zero.
Once I have that completed I can easy visualize my data using
vtkPolyDataMapper...etc.
To create my volume rendering in my pipeline I use the following:

vtkShepardMethod *shepard = vtkShepardMethod::New();
       shepard->SetInput(cube);
       shepard->SetNullValue(0);
       shepard->SetMaximumDistance(0.001);

vtkImageCast *imgcast = vtkImageCast::New();
       imgcast->SetInput(shepard->GetOutput());
       imgcast->SetOutputScalarTypeToUnsignedChar();
       imgcast->ClampOverflowOn();

And then use:

vtkPiecewiseFunction *opacityTransferFunction1 =
vtkPiecewiseFunction::New();
   opacityTransferFunction1->AddPoint(0,   0.0);
 opacityTransferFunction1->AddPoint(1,  1);

vtkColorTransferFunction *colorTransferFunction1 =
vtkColorTransferFunction::New();
    colorTransferFunction1->AddRGBPoint( 1, 1.0, 1.0, 1.0);
colorTransferFunction1->AddRGBPoint( 0, 0.0, 0.0, 0.0);

vtkVolumeProperty *volumeProperty1 = vtkVolumeProperty::New();
    volumeProperty1->SetColor(colorTransferFunction1);
    volumeProperty1->SetScalarOpacity(opacityTransferFunction1);
    volumeProperty1->ShadeOn();
    volumeProperty1->SetInterpolationTypeToLinear();

 vtkVolumeRayCastMapper *volumeMapper1 = vtkVolumeRayCastMapper::New();
          vtkVolumeRayCastCompositeFunction *compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
          volumeMapper1->SetVolumeRayCastFunction(compositeFunction);
          compositeFunction->Delete();
          volumeMapper1->SetInput(imgcast->GetOutput());


But I still get no rendering! Can you please help me again one this, or
are there easier methods to perform what I am try to achieve here?

Thanks,
Paul.




On Fri, 26 Mar 2004, Lisa Avila wrote:

> Hello Paul,
>
> Your example will perform volume rendering of your data but there are some
> issues with it. First, you set only one point in each of your functions -
> this makes them constant. So you have a constant opacity of 0.5 everywhere
> (regardless of scalar value) and a constant color of white. Doing a MIP
> projection you should get a cube-shaped object of constant RGBA
> (1,1,1,0.5).  Instead, you should add another point to your opacity
> function making scalar 0.0 have an opacity of 0.0 - now you should see a
> white circle (sphere - but constant color so looks like a circle) instead
> of a cube. Next, you may wish to use compositing (the
> vtkVolumeRayCastCompositeFunction, or switch to the faster
> vtkVolumeTextureMapper2D) instead of maximum intensity so that the
> ShadeOn() method will actually result in shading (it is ignored for MIP).
>
> Lisa
>
>
> At 09:04 PM 3/25/2004, Paul McGuinness wrote:
>
> >Hi vtk users,
> >
> >I have created a sphere in vtkImagedata format, it is built consisting of
> >two scalar values, 0 and 1. Scalar value 0 is set to all points inside and
> >outside the sphere and scalar value 1 is used for the boundary of the
> >sphere.
> >
> >I can create a isosurface (contour surface) of my sphere simply by using:
> >contour->SetValue(0,1);
> >
> >Now I need to create a volume rendering of this data. I am using the
> >following:
> >
> >vtkPiecewiseFunction *opacityTransferFunction1 = vtkPiecewiseFunction::New();
> >    opacityTransferFunction1->AddPoint(1,   0.5);
> >
> >vtkColorTransferFunction *colorTransferFunction1 =
> >vtkColorTransferFunction::New();
> >     colorTransferFunction1->AddRGBPoint(1, 1.0, 1.0, 1.0);
> >
> >vtkVolumeProperty *volumeProperty1 = vtkVolumeProperty::New();
> >     volumeProperty1->SetColor(colorTransferFunction1);
> >     volumeProperty1->SetScalarOpacity(opacityTransferFunction1);
> >     volumeProperty1->ShadeOn();
> >     volumeProperty1->SetInterpolationTypeToLinear();
> >
> >vtkVolumeRayCastMIPFunction  *MIPFunction= vtkVolumeRayCastMIPFunction::New();
> >vtkVolumeRayCastMapper *volumeMapper1 = vtkVolumeRayCastMapper::New();
> >    volumeMapper1->SetVolumeRayCastFunction(MIPFunction);
> >    volumeMapper1->SetInput(img->GetOutput());
> >
> >BUT I am getting nothing! Am I using this correctly? Can someone please
> >help to get this to work? I appreciate any suggestions.
> >
> >Many Thanks,
> >Paul.
> >_______________________________________________
> >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://www.vtk.org/mailman/listinfo/vtkusers
>
>
>



More information about the vtkusers mailing list