Unsuccessful with vtkClipVoume

Prashanth Kini-P kini.p at pg.com
Thu Jan 27 09:42:48 EST 2000


I am trying to extract and visualize an arbitrarily oriented and/or
nonrectangular shaped chunk of a volume (vtkExtractVOI and vtkExtractGrid appear
to be suitable for only extracting axes-aligned sub VOIs).  My ultimate goal is
an interactive procedure where the user moves a 3D shape to intersect with the
volume and the intersection is returned.  I plan to implement thois as follows:
1. create surface by sampling implicit functions and isosurfacing it
2. obtain the transformation after the user has placed the actor
3. apply the transformation to the implicit function
4. and then hopefully use vtkClipVolume as below.

The code below is my attempt to clip a volume using an implicit sphere. I am
assuming that I need to resample the clipped unstructured grid onto structured
points in order to visualize (volume render) it. I tried to use vtkProbeFilter
to do that. In the end I get the following run-time error and segmentation
fault:

ERROR in vtkVolume.cxx, line 553
vtkVolume(0x104b4718): Need Scalar data to volume render

Where am I losing my scalars? Am I doing this right? Thanks in advance!!

Prashanth Kini
Procter & Gamble

******code excerpt*********


     vtkImageReader *reader = vtkImageReader::New();
     .........[set up the reader to read the volume]....

     vtkSphere *sphere = vtkSphere::New();
       sphere->SetRadius(maxrange/4);
       sphere->SetCenter(xcent,ycent,zcent);

//*******vtkClipVolume approach********************
     vtkClipVolume *clip = vtkClipVolume::New();
       clip->SetInput(reader->GetOutput());
       clip->SetClipFunction(sphere);
       clip->GenerateClippedOutputOn();
       clip->GenerateClipScalarsOn();

     vtkStructuredPoints *clipvolume = vtkStructuredPoints::New();
       clipvolume->SetDimensions(xsize,ysize,zsize);          //same settings as
used in vtkImageReader
       clipvolume->SetSpacing(xscale,yscale,zscale);
       clipvolume->SetOrigin(0.0,0.0,0.0);

     vtkProbeFilter *probe = vtkProbeFilter::New();
       probe->SetInput(clipvolume);
       probe->SetSource(clip->GetClippedOutput());

     vtkVolumeRayCastMapper *sphvolumemapper = vtkVolumeRayCastMapper::New();
       sphvolumemapper->SetScalarInput(clipvolume);
       sphvolumemapper->SetVolumeRayCastFunction(compositefunction);

     vtkVolume *spherevolume = vtkVolume::New();
       spherevolume->SetVolumeMapper(sphvolumemapper);
       spherevolume->SetVolumeProperty(volumeproperty);

     renderer->AddVolume(spherevolume);




-----------------------------------------------------------------------------
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