[vtkusers] 3D scalar volume visualization

Artem Babayan artem.paraview at googlemail.com
Thu May 6 12:11:37 EDT 2010


Hello,

I am trying to obtain rendering of 3D concentration data defined on
structured grid (corresponding to DATASET STRUCTURED_POINTS *.vtk file format).
An objective is to get semi-transparent 3D volume, like what is shown
when this file is
opened in Paraview.

I have set up the 'opacity' and 'color transfer' function, but  what I
am apparently getting is the
slice of data on some surface (??) which can be rotated/moved through
the volumetric data
in interactive window (see attached screenshots). Data on this surface
look correct and 'slices' are
semitransparent, but this not 3D 'cloud' which I would expect.

I am surely doing something wrong, but what? The very simple source
code is below:

   //read the volume from file
   vtkSmartPointer<vtkStructuredPointsReader> reader_conc=
                   vtkSmartPointer<vtkStructuredPointsReader>::New();
   reader_conc->SetFileName("conc_3d.vtk");

   //Create a mapper
   vtkSmartPointer<vtkFixedPointVolumeRayCastMapper> mapper_conc =
                vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();
   mapper_conc->SetInput(reader_conc->GetOutput());

   //create volume
   vtkSmartPointer<vtkVolume> volume =
                         vtkSmartPointer<vtkVolume>::New();

  //let it be semitransparent for all data
   vtkPiecewiseFunction *oTFun = vtkPiecewiseFunction::New();
   oTFun->AddPoint(0., 0.5, 0.5, 1.0);
   oTFun->AddPoint(1.5, 0.5, 0.5, 1.0);

 //color transfer function -- blue for empty and red for high concentration
   vtkColorTransferFunction *cTFun = vtkColorTransferFunction::New();
   cTFun->AddRGBPoint(   0.0, 0.0, 0.0, 1 );
   cTFun->AddRGBPoint(  1e-25, .0, .1, .8 );
   cTFun->AddRGBPoint( 1e-15, .1, .3, 0.6 );
   cTFun->AddRGBPoint( 1.3, 1.0, .0, 0.0 );

//set volume property
   vtkVolumeProperty *property = vtkVolumeProperty::New();
   property->SetScalarOpacity(oTFun);
   property->SetColor(cTFun);
   property->SetInterpolationTypeToLinear();
   property->SetScalarOpacityUnitDistance(2.0);

   volume->SetMapper(mapper_conc);
   volume->SetProperty(property);

     // a renderer and render window
   vtkSmartPointer<vtkRenderer> renderer =
                           vtkSmartPointer<vtkRenderer>::New();
   renderer->SetBackground(0.9, 0.9, 0.9);

   vtkSmartPointer<vtkRenderWindow> renderWindow =
                           vtkSmartPointer<vtkRenderWindow>::New();
   renderWindow->SetSize(900, 600);
   renderWindow->AddRenderer(renderer);

     // add the volume to renderer
   renderer->AddVolume(volume);

     // an interactor
   vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
   iren->SetRenderWindow(renderWindow);

     renderWindow->Render();
     // begin mouse interaction
      iren->Start();
   return 0;

Thank you for any help

Best wishes
Artem
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic_0.png
Type: image/png
Size: 13430 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100506/e33d15da/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic_1.png
Type: image/png
Size: 13799 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100506/e33d15da/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic_2.png
Type: image/png
Size: 15956 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100506/e33d15da/attachment-0002.png>


More information about the vtkusers mailing list