Sampling implicit functions onto volumes for clipping

Prashanth Kini-P kini.p at pg.com
Wed Jan 26 17:28:32 EST 2000


I am trying to extract a portion of a volume.  I did not have much luck with
vtkClipVolume so I am trying a different approach: Create a binary structured
points mask and use vtkImageMask to extract(mask out) a subportion of the
volume.

As a trial I would like to sample the the implicit function created by vtkSphere
onto a structured points dataset to create a spherical VOI. The following code
does not do it. It creates a rectangular volume (of the specified dimensions)
with varying scalar values. Any suggestions on getting this right will be
greatly appreciated.

Any suggestions on correctly using vtkClipVolume would also be great! The
example in the users guide only shows an example of clipping based on a scalar
value.

Thanks,
Prashanth
-------------------------------------


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

     vtkScalars *vals = vtkScalars::New();
       vals->SetDataTypeToUnsignedChar();
       vals->InsertNextScalar(255);

     vtkSampleFunction *thespheresample = vtkSampleFunction::New();
       thespheresample->SetImplicitFunction(sphere);
//     thespheresample->CappingOn();
//     thespheresample->ComputeNormalsOff();
       thespheresample->SetSampleDimensions(xsize,ysize,zsize);
       thespheresample->SetModelBounds(volbounds[0],volbounds[1],
                                          volbounds[2],volbounds[3],
                                          volbounds[4],volbounds[5]);
       thespheresample->SetScalars(vals);


     vtkVolumeRayCastMapper *sphvolumemapper = vtkVolumeRayCastMapper::New();
       sphvolumemapper->SetScalarInput(thespheresample->GetOutput());
       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