[vtkusers] Ray Cast not working

Gary L. Graf glgraf at asu.edu
Sat May 11 15:40:30 EDT 2002


Hi,
  I have a vtkStructuredPoints ("altVol") which consists of a regular 3D
array of points and I want to display the object it represents as a
solid.  The scalar values are 0 if that grid point is outside the object
and 1 if the point is inside the object.  For various reasons, it would
be extremely difficult to change the dimensions of the array.  At some
locations, the object touches the boundary of the array.  I have tried
the contour filter, marching cubes, and a few others and I can generate
the surface but those filters leave gaps where the object contacts the
edge of the array.  As a result it no longer looks like a solid.
  My latest attempt was to try ray casting.  The code from the vtk
manual, p146, appeared to be a solution.  I implemented it as shown
below, but all I get is a blank screen.  I don't see anything obviously
wrong and I have played with numerous options, but nothing seems to
work.  Can anyone help me resolve this?  Unfortunately, I need some
graphics of this for a progress report due Tuesday, so an early response
would be GREATLY appreciated.  Thanks - Gary Graf

Code*****************************************************************************************************

vtkPiecewiseFunction *altVolOpacity = vtkPiecewiseFunction::New();
  altVolOpacity->AddPoint(0.0,  0.2);
  altVolOpacity->AddPoint(2.0,  0.8);

vtkColorTransferFunction *altVolColor = vtkColorTransferFunction::New();

  altVolColor->SetColorSpaceToRGB();
  altVolColor->AddRGBPoint  (0.2,   1.0,  0.0,  0.0);
  altVolColor->AddRGBPoint  (1.0,   0.0,  0.0,  1.0);
  altVolColor->AddRGBPoint  (20.0, 0.0,  1.0,  0.0);

vtkVolumeProperty *altVolProp = vtkVolumeProperty::New();
  altVolProp->SetColor(altVolColor);
  altVolProp->SetScalarOpacity(altVolOpacity);

vtkVolumeRayCastCompositeFunction *altVolComp =
vtkVolumeRayCastCompositeFunction::New();

vtkVolumeRayCastMapper *altVolMapper = vtkVolumeRayCastMapper::New();
  altVolMapper->SetVolumeRayCastFunction(altVolComp);
  altVolMapper->SetInput(altVol);

vtkVolume *altVolume = vtkVolume::New();
  altVolume->SetMapper(altVolMapper);
  altVolume->SetProperty(altVolProp);

  altRenderer->AddProp(altVolume);
     altRenderer->SetBackground(1,1,1);
     altRenWin->SetSize(450,450);






More information about the vtkusers mailing list