<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1170" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>hi all </FONT></DIV>
<DIV><FONT face=Arial size=2>please colud anybody llok into the following code
and tell me where the error exactly is.</FONT></DIV>
<DIV><FONT face=Arial size=2>I took most of the following code from the
Python example</FONT></DIV>
<DIV><FONT face=Arial
size=2>vtk42\Examples\VolumeRendering\Python\SimpleRayCast.py </FONT></DIV>
<DIV><FONT face=Arial size=2>The only change is instead of <FONT
size=3>vtkStructuredPointsReader i'm using vtkStructuredPoints
</FONT></FONT><FONT face=Arial size=2></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><FONT color=#0000ff size=2>
<P>void</FONT><FONT size=2> VolumeMapper(</FONT><FONT color=#0000ff
size=2>void</FONT><FONT size=2>)</FONT></P>
<P><FONT size=2>{</FONT></P>
<P><FONT color=#008000 size=2>// Create the standard renderer, render window and
interactor</P></FONT><FONT size=2>
<P>vtkRenderer *ren = vtkRenderer::New();</P>
<P>vtkRenderWindow *renWin = vtkRenderWindow::New();</P>
<P>renWin->AddRenderer(ren);</P>
<P>vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();</P>
<P>iren->SetRenderWindow(renWin);</P>
<P>vtkStructuredPoints *sp = vtkStructuredPoints::New();</P>
<P>sp->SetDimensions(5, 5, 5);</P>
<P>sp->SetOrigin(0, 0, 0);</P>
<P>sp->SetSpacing(2, 2, 2);</P>
<P>vtkUnsignedIntArray *scalars = vtkUnsignedIntArray::New();</P>
<P>scalars->SetNumberOfTuples(1);</P>
<P>scalars->SetNumberOfValues(64);</P>
<P></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2> (</FONT><FONT
color=#0000ff size=2>int</FONT><FONT size=2> i=0; i< 64; i++)</P>
<P>{</P>
<P>scalars->SetValue(i,125);</P>
<P>}</P>
<P>sp->GetCellData()->SetScalars(scalars);</P>
<P></P></FONT><FONT color=#008000 size=2>
<P>// Create transfer mapping scalar value to opacity</P></FONT><FONT size=2>
<P>vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New();</P>
<P>opacityTransferFunction->AddPoint(20, 0.0);</P>
<P>opacityTransferFunction->AddPoint(255, 0.2);</P></FONT><FONT color=#008000
size=2>
<P>//# Create transfer mapping scalar value to color</P></FONT><FONT size=2>
<P>vtkColorTransferFunction *colorTransferFunction =
vtkColorTransferFunction::New();</P>
<P>colorTransferFunction->AddRGBPoint(0.0, 0.0, 0.0, 0.0);</P>
<P>colorTransferFunction->AddRGBPoint(64.0, 1.0, 0.0, 0.0);</P>
<P>colorTransferFunction->AddRGBPoint(128.0, 0.0, 0.0, 1.0);</P>
<P>colorTransferFunction->AddRGBPoint(192.0, 0.0, 1.0, 0.0);</P>
<P>colorTransferFunction->AddRGBPoint(255.0, 0.0, 0.2, 0.0);</P></FONT><FONT
color=#008000 size=2>
<P>// The property describes how the data will look</P></FONT><FONT size=2>
<P>vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();</P>
<P>volumeProperty->SetColor(colorTransferFunction);</P>
<P>volumeProperty->SetScalarOpacity(opacityTransferFunction);</P>
<P>volumeProperty->ShadeOn();</P></FONT><FONT color=#008000 size=2>
<P>//volumeProperty->SetInterpolationTypeToLinear();</P>
<P>// The mapper / ray cast function know how to render the data</P></FONT><FONT
size=2>
<P>vtkVolumeRayCastCompositeFunction *compositeFunction =
vtkVolumeRayCastCompositeFunction::New();</P>
<P>vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();</P>
<P>volumeMapper->SetVolumeRayCastFunction(compositeFunction);</P>
<P>volumeMapper->SetInput(sp);<STRONG>
----------------------------------->//</STRONG>here is the change from python
code </P></FONT><FONT color=#008000 size=2>
<P>// The volume holds the mapper and the property and</P>
<P>// can be used to position/orient the volume</P></FONT><FONT size=2>
<P>vtkVolume *volume = vtkVolume::New();</P>
<P>volume->SetMapper(volumeMapper);</P>
<P>volume->SetProperty(volumeProperty);</P>
<P>ren->AddVolume(volume);</P>
<P>ren->SetBackground(1, 1, 1);</P></FONT><FONT color=#008000 size=2>
<P>//renWin->SetSize(600, 600);</P>
<P>//renWin->Render();</P>
<P>//renWin.AddObserver("AbortCheckEvent", CheckAbort)</P>
<P><FONT color=#000000></FONT> </P>
<P>//vtkActor *actor2 = vtkActor::New();</P>
<P>//actor2->SetMapper(volumeMapper);</P>
<P>//ren->AddActor(actor2);</P></FONT><FONT color=#0000ff size=2>
<P>int</FONT><FONT size=2> ipen = renWin->GetEventPending();</P>
<P>iren->Initialize();</P>
<P>renWin->Render();</P>
<P>iren->Start();</P>
<P>ren->Delete();</P>
<P>renWin->Delete();</P>
<P>iren->Delete();</P>
<P>opacityTransferFunction->Delete();</P>
<P>colorTransferFunction->Delete();</P>
<P>volumeProperty->Delete();</P>
<P>compositeFunction->Delete();</P>
<P>volumeMapper->Delete();</P>
<P>volume->Delete();</P>
<P>sp->Delete();</P>
<P>scalars->Delete();</P>
<P>}</P>
<P> </P>
<P>thanks in advance</P>
<P>rgds</P>
<P>krishna</P></FONT></FONT></DIV></BODY></HTML>