[vtkusers] ray casting by VTK
Aashish Chaudhary
aashish.chaudhary at kitware.com
Fri Nov 8 11:59:25 EST 2013
On Fri, Nov 8, 2013 at 4:38 AM, zahra sahaf <sce2020sahaf at yahoo.com> wrote:
> 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,
>
Did you not see antything? Of you saw something but it didnot look right?
- Aashish
> I don't know what's the problem) Please help me :(
> Any help would be appreciated.
>
> vtkRenderer ren1 = vtkRenderer.New();
> vtkRenderWindow renwin = vtkRenderWindow.New();
> vtkRenderWindowInteractor iren =
> vtkRenderWindowInteractor.New();
> iren.SetRenderWindow(renwin);
> ren1.SetBackground(0, 0, 0);
> renwin.SetSize(600, 600);
>
> /////////// Read in data and add extract filters
> string filePath =
> System.IO.Path.GetFullPath(@"C:\Users\Sepid\Desktop\data\MRI-woman.raw");
> Debug.WriteLine(filePath);
> vtkImageReader reader = vtkImageReader.New();
> Debug.Write(filePath);
> reader.SetFileName(filePath);
> reader.SetDataScalarTypeToUnsignedChar();
> reader.SetDataByteOrderToLittleEndian();
> reader.SetDataOrigin(0, 0, 0);
> reader.SetFileDimensionality(3);
> reader.SetDataSpacing(1, 1.5, 1);
> reader.SetDataExtent(0, 255, 0, 108, 0, 255);
> reader.Update();
> //////////////////////////////////////////////////
> vtkVolumeRayCastMapper volumeMapper =
> vtkVolumeRayCastMapper.New();
> volumeMapper.SetInputConnection(reader.GetOutputPort());
>
> vtkVolumeRayCastCompositeFunction compositeFunction =
> vtkVolumeRayCastCompositeFunction.New();
>
> volumeMapper.SetVolumeRayCastFunction(compositeFunction);
> volumeMapper.SetSampleDistance(0.25);
>
> //////////////////////////////////////////////////
> vtkPiecewiseFunction opacityTransferFunction = new
> vtkPiecewiseFunction();
> opacityTransferFunction.AddPoint(1000, 0);
> opacityTransferFunction.AddPoint(1500, 0.2);
> opacityTransferFunction.AddPoint(2000, 0);
> ////////////////////////////////////////////////////
> vtkColorTransferFunction colorTransferFunction = new
> vtkColorTransferFunction();
> colorTransferFunction.AddRGBPoint(1000, 0, 0, 0);
> colorTransferFunction.AddRGBPoint(1500, 1, 0.5, 0.5);
> ///////////////////////////////////////////////////
> vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
> volumeProperty.SetColor(colorTransferFunction);
> volumeProperty.SetScalarOpacity(opacityTransferFunction);
> ///////////////////////////////////////////////////
> vtkVolume volume = new vtkVolume();
> volume.SetMapper(volumeMapper);
> volume.SetProperty(volumeProperty);
>
> ren1.AddVolume(volume);
> // ren1.AddViewProp(volume);
>
> iren.Initialize();
> iren.Start();
> renwin.Render();
>
>
> Bests,
> Zahra
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
--
| Aashish Chaudhary
| R&D Engineer
| Kitware Inc.
| www.kitware.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131108/40f3daae/attachment.htm>
More information about the vtkusers
mailing list