[vtkusers] not able to view .vtk file in 3D view

Mathieu Malaterre mathieu.malaterre at gmail.com
Fri Jul 31 06:17:12 EDT 2009


If you build GDCM, simply use gdcm2vtk to take as input a DICOM file
and write it as .vtk file.

Eg:
$ gdcm2vtk input.dcm output.vtk

Refs:
http://gdcm.sourceforge.net/
http://sourceforge.net/apps/mediawiki/gdcm/index.php?title=GDCM_Release_2.0#GDCM_2.0.12_.282008.2F06.2F12.29

On Fri, Jul 31, 2009 at 12:09 PM, Gururajan<gururajan.r at raster.in> wrote:
> Any one plz have a guess to me
>
> The following methods i have tried to write dicom series files into .VTK
> format.
>
> the problem is
>     am unable to view the written .VTK file.
>
> Reading Dicom Series files
>   vtkDICOMImageReader dicomreader = new vtkDICOMImageReader();
>     dicomreader.SetDirectoryName("/home/gururaj/MANIX/MANIX/CER-CT/ANGIO
> CT");
>     dicomreader.Update();
>
>
>
> the following are the types i have tried to write .VTK format using
> dicomreader.
> /*vtkPolyDataWriter polyWriter = new vtkPolyDataWriter();
>     polyWriter.SetFileName("/home/gururaj/eclipse
> Project/SimpleVTK/SimpleVtk/CardiacCT/Polydata.vtk");
>     polyWriter.SetInput(dicomreader.GetOutput());
>     polyWriter.SetFileTypeToASCII();
>     polyWriter.Write();
>     polyWriter.Update();
>     */
>
>     /*
>     vtkUnstructuredGridWriter unWriter = new vtkUnstructuredGridWriter();
>     unWriter.SetFileName("/home/gururaj/eclipse
> Project/SimpleVTK/SimpleVtk/CardiacCT/Undata.vtk");
>     unWriter.SetInput(dicomreader.GetOutput());
>     unWriter.SetFileTypeToASCII();
>     unWriter.Write();
>     unWriter.Update();
>     */
>     /*vtkImageData imgData = dicomreader.GetOutput();
>     imgData.SetSpacing(1, 1, 1);
>     imgData.SetOrigin(0,0,0);
>     vtkImageWriter imgWriter = new vtkImageWriter();
>     imgWriter.SetInput(imgData);
>     imgWriter.SetFileName("/home/gururaj/eclipse
> Project/SimpleVTK/SimpleVtk/CardiacCT/Imgdata.vtk");
>     imgWriter.SetFileDimensionality(3);
>     imgWriter.Update();
>     imgWriter.Write();
>     */
>
>     /*vtkStructuredPointsWriter stWriter = new vtkStructuredPointsWriter();
>     stWriter.SetInput(dicomreader.GetOutput());
>     stWriter.SetFileName("/home/gururaj/eclipse
> Project/SimpleVTK/SimpleVtk/CardiacCT/Imgdata.vtk");
>     stWriter.SetFileTypeToASCII();
>     stWriter.Update();
>     stWriter.Write();
>     */
>
>    /* vtkXMLImageDataWriter xWriter = new vtkXMLImageDataWriter();
>     xWriter.SetInput(dicomreader.GetOutput());
>     xWriter.SetFileName("/home/gururaj/eclipse
> Project/SimpleVTK/SimpleVtk/CardiacCT/Imgdata.vtk");
>     xWriter.Update();
>     xWriter.Write();
>     */
>
> the following method i have used to view .VTK file but all are helpless to
> me.
>  String strfilename = new String();
>     strfilename = "/home/gururaj/eclipse
> Project/SimpleVTK/SimpleVtk/CardiacCT/Imgdata.vtk";
>
>     //vtkPolyDataReader polyReader = new vtkPolyDataReader();
>     vtkPNGReader polyReader = new vtkPNGReader();
>
>     polyReader.SetFileName(strfilename);
>     polyReader.Update();
>
>
>     vtkPolyData polyData = new vtkPolyData();
>     polyData.DeepCopy(polyReader.GetOutput());
>
>     vtkPolyDataMapper polyMapper = new vtkPolyDataMapper();
>     polyMapper.SetInput(polyData);
>     polyMapper.Update();
>
>     vtkActor actor = new vtkActor();
>     actor.SetMapper(polyMapper);
>     actor.VisibilityOn();
>
>     vtkRenderer render = new vtkRenderer();
>     vtkRenderWindow renwindow = new vtkRenderWindow();
>     renwindow.AddRenderer(render);
>
>     vtkRenderWindowInteractor renintec = new vtkRenderWindowInteractor();
>     renintec.SetRenderWindow(renwindow);
>
>     render.AddActor(actor);
>     render.SetBackground(0.2,0.3,0);
>     renwindow.BordersOff();
>     renwindow.SetSize(500, 500);
>     renwindow.Render();
>     render.ResetCamera();
>     renintec.Start();
>
>
>
>
> _______________________________________________
> 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
>
>



-- 
Mathieu
http://mathieumalaterre.com



More information about the vtkusers mailing list