<html><body><div style="color:#000; background-color:#fff; font-family:garamond, new york, times, serif;font-size:14pt"><div><span>I am actually new to VTK. As a course project, I am going to implement a simple ray caster which could reads raw file and render that, my code is as follows: (unfortunately I did not get result, I don't know what's the problem) Please help me :(</span></div><div style="color: rgb(0, 0, 0); font-size: 19.09090805053711px; font-family: garamond, 'new york', times, serif; background-color: transparent; font-style: normal;">Any help would be appreciated.</div><div style="color: rgb(0, 0, 0); font-size: 19.09090805053711px; font-family: garamond, 'new york', times, serif; background-color: transparent; font-style: normal;"><br></div><div style="background-color: transparent;">vtkRenderer ren1 = vtkRenderer.New();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkRenderWindow renwin =
 vtkRenderWindow.New();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iren.SetRenderWindow(renwin);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ren1.SetBackground(0, 0, 0);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renwin.SetSize(600, 600);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /////////// &nbsp;Read in data and add extract filters</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string filePath = System.IO.Path.GetFullPath(@"C:\Users\Sepid\Desktop\data\MRI-woman.raw");</div><div
 style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Debug.WriteLine(filePath);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkImageReader reader = vtkImageReader.New();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Debug.Write(filePath);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.SetFileName(filePath);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.SetDataScalarTypeToUnsignedChar();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.SetDataByteOrderToLittleEndian();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.SetDataOrigin(0, 0, 0);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 reader.SetFileDimensionality(3);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.SetDataSpacing(1, 1.5, 1);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.SetDataExtent(0, 255, 0, 108, 0, 255);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reader.Update();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //////////////////////////////////////////////////</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkVolumeRayCastMapper volumeMapper = vtkVolumeRayCastMapper.New();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volumeMapper.SetInputConnection(reader.GetOutputPort());</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">&nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkVolumeRayCastCompositeFunction compositeFunction = vtkVolumeRayCastCompositeFunction.New();</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volumeMapper.SetVolumeRayCastFunction(compositeFunction);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volumeMapper.SetSampleDistance(0.25);</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //////////////////////////////////////////////////</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkPiecewiseFunction opacityTransferFunction = new vtkPiecewiseFunction();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; opacityTransferFunction.AddPoint(1000, 0);</div><div
 style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; opacityTransferFunction.AddPoint(1500, 0.2);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; opacityTransferFunction.AddPoint(2000, 0);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ////////////////////////////////////////////////////</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkColorTransferFunction colorTransferFunction = new vtkColorTransferFunction();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colorTransferFunction.AddRGBPoint(1000, 0, 0, 0);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colorTransferFunction.AddRGBPoint(1500, 1, 0.5, 0.5);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 ///////////////////////////////////////////////////</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkVolumeProperty volumeProperty = new vtkVolumeProperty();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volumeProperty.SetColor(colorTransferFunction);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volumeProperty.SetScalarOpacity(opacityTransferFunction);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ///////////////////////////////////////////////////</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vtkVolume volume = new vtkVolume();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; volume.SetMapper(volumeMapper);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; volume.SetProperty(volumeProperty);</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ren1.AddVolume(volume);</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// ren1.AddViewProp(volume);</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iren.Initialize();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iren.Start();</div><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renwin.Render();</div><div><br></div><div></div><div>&nbsp;</div><div>Bests,<br>Zahra</div></div></body></html>