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

Gururajan gururajan.r at raster.in
Fri Jul 31 09:25:53 EDT 2009


yes, thats what i mentioned, i have created .vtk files from reading
series of dicom files, my written (.vtk) files  are not displaying in my
application, thats y i attached my source for creating .vtk file and
displaying in the control. Please have look at it and guide me.,

i have used most of the writer to to write .vtk file
please see the below findings
Thanks
Guru

        setLayout(new BorderLayout());
       
         vtkDICOMImageReader dicomreader = new vtkDICOMImageReader();
         
dicomreader.SetDirectoryName("/home/gururaj/MANIX/MANIX/CER-CT/ANGIO CT");
          dicomreader.Update();
         
        vtkImageReader reader = new vtkImageReader();
       
       
          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();
         */

        /*
         * vtkPNGWriter pngWriter = new vtkPNGWriter();
         * pngWriter.SetInput(dicomreader.GetOutput());
         * pngWriter.SetFileDimensionality(3);pngWriter.SetFileName(
         * "/home/gururaj/eclipse
Project/SimpleVTK/SimpleVtk/CardiacCT/pngdata.png"
         * );
         */

        // 3d Construction
        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();

        /*
         * exitButton = new JButton("Exit");
exitButton.addActionListener(this);
         * //add(renWin, BorderLayout.CENTER); add(exitButton,
         * BorderLayout.EAST);
         */
        // 3d Construction
        /*
         * vtkRenderer renderer = new vtkRenderer();
         * renderer.AddActor(imgActor); renderer.ResetCamera();
         * renderer.UpdateLightsGeometryToFollowCamera(); renWin = new
         * vtkPanel(); renWin.GetRenderer().AddActor(imgActor);
         */

John Drescher wrote:
> On Fri, Jul 31, 2009 at 6:56 AM, Gururajan<gururajan.r at raster.in> wrote:
>   
>> I got the link and i went, but i dont know how to configure in my
>> application.
>>
>> What should i do for that.  "My aim is i have to  read dicom series
>> files and should display that in 3d view" thats what i have written my
>> code below.
>> your guidance  seems to be more helpful to me. Please guide me how i can
>> implement this in my java application.
>>
>>     
> BTW, You do not need to convert your dicom data to a .vtk file. VTK
> will read dicom formats and display them. You just need to write your
> vtk viewer in java.
>
> John
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090731/aac640d1/attachment.htm>


More information about the vtkusers mailing list