[vtkusers] Ray Cast not working

Lisa S. Avila lisa.avila at kitware.com
Mon May 13 00:34:52 EDT 2002


Here are a couple of guesses at why you are having problems.

1) Your data is not unsigned char or unsigned short

2) The fact that you have defined an opacity of 0.2 for scalar value 0.0 
but have not defined a color (and therefore by default it is black). It is 
therefore likely that you are accumulating opaque black before you 
encounter your surface.


Suggestions:

1) Change your transfer functions

2) Use a vtkVolumeRayCastIsosurfaceFunction instead, using a value between 
0 and 1 (maybe 0.5?).


Lisa



At 12:40 PM 5/11/2002 -0700, Gary L. Graf wrote:
>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);
>
>
>
>_______________________________________________
>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://public.kitware.com/mailman/listinfo/vtkusers





More information about the vtkusers mailing list