[vtkusers] display .vtk files in window

Gururajan gururajan.r at raster.in
Wed Jul 29 08:45:34 EDT 2009


Hi vikrant,

So kind of you for your effort. Its working fine to me.
but i did some mistake in writing .vtk files (it gives me following
error when i try to open of my written .vtk files) but when i try to
open some downloaded .vtk files it works fine.
<Error>
ERROR: In /home/juju/VTK5.0/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
line 689
vtkStreamingDemandDrivenPipeline (0x8c5a87e0): Input port 0 of algorithm
vtkImageChangeInformation(0x8c5a7fd0) has 0 connections but is not optional.

ERROR: In /home/juju/VTK5.0/VTK/IO/vtkDataReader.cxx, line 432
vtkPolyDataReader (0x8c5aa510): Unrecognized file type: ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
for file: /home/gururaj/eclipse
Project/SimpleVTK/SimpleVtk/CardiacCT/Image.vtk
</Error>

*Am using following method to write .vtk *
<code>
vtkDICOMImageReader dicomreader = new vtkDICOMImageReader();
dicomreader.SetDirectoryName("/home/gururaj/eclipse
Project/SimpleVTK/SimpleVtk/CardiacCT/Single");
dicomreader.Update();
System.out.println("File Dimension " + dicomreader.GetFileDimensionality());



vtkImageWriter writer = new vtkImageWriter();//vtkImageWriter::New()
//writer.SetInput(dicomreader.GetOutput());
writer.AddInput(dicomreader.GetOutput());
writer.SetFileName("/home/gururaj/eclipse
Project/SimpleVTK/SimpleVtk/CardiacCT/Image.vtk");
writer.SetFileDimensionality(3);

writer.Update();
writer.Write();
</code>

Please can you suggest me


Regards
Guru

vikrant manne wrote:
> Hi Gurujan,
> You can try implementing the following cpp code to java. I guess this
> works for VtkPolyData files.
> Try using different Data readers (PolyDataReader,
> UnstructuredGridReader or DataSetReader) depending on your VTK file.
>
>
>
> // necessary headers from VTK Library
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkProperty.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindowInteractor.h"
> #include <vtkDataSetWriter.h>
> #include <vtkSphereSource.h>
> #include <vtkPolyDataMapper.h>
> #include <vtkDataSetMapper.h>
> #include <vtkActor.h>
> #include <vtkProperty.h>
> #include <vtkPolyData.h>
> #include <vtkDataSetReader.h>
> #include <vtkDataSet.h>
> #include <vtkPolyDataNormals.h>
> #include <vtkTriangleFilter.h>
> #include <vtkStripper.h>
> #include <vtkPointData.h>
> #include <vtkPolyDataWriter.h>
> #include "vtkPolyDataReader.h"
>
> #include <string>
>
> // MAIN
>
> int main ()
> {
> std::string strCurFile = "VtkFile.vtk";
> // Initialising a reader to read the VTK files
> vtkPolyDataReader * pGridReader = vtkPolyDataReader::New();
> pGridReader->SetFileName (strCurFile.c_str());
> pGridReader->Update();
>
> vtkPolyData* pData=vtkPolyData::New();
> pData->DeepCopy(pGridReader->GetOutput());
>
> // Mapper to map polygonal data to graphics primitives
> vtkPolyDataMapper *Tmap = vtkPolyDataMapper::New();
> Tmap->SetInput(pData);
> // Updating the polydatamapper
> Tmap->Update();
> // Actor - used to display all the geometry
> vtkActor* Actor = vtkActor::New();
> Actor->SetMapper(Tmap);
> Actor->VisibilityOn();
>
> // a renderer and render window
> vtkRenderer *ren1 = vtkRenderer::New();
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren1);
>
> // a window interactor
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
>
> // add the actors to the scene
> ren1->AddActor(Actor);
>
> // ren1->AddActor(outlineActor);
> ren1->SetBackground(0.5,0.5,0.5); // Background color white
>
> // render an image (lights and cameras are created automatically)
> renWin->Render();
>
> // begin mouse interaction
> iren->Start();
> // Deleting all instances after rendering
> pGridReader->Delete();
> Tmap->Delete();
> pData->Delete();
> Actor->Delete();
>
>
> }
>
> Thanks,
> Vikrant Manne
>
>
> On Tue, Jul 28, 2009 at 4:00 PM, Gururajan <gururajan.r at raster.in
> <mailto:gururajan.r at raster.in>> wrote:
>
>     john,
>
>     but i need it for java. how can i plug and please give some examples.
>
>     very kind to you
>
>     Thanks
>     Guru
>
>     John Drescher wrote:
>     > On Tue, Jul 28, 2009 at 4:52 PM, Gururajan<gururajan.r at raster.in
>     <mailto:gururajan.r at raster.in>> wrote:
>     >
>     >> david,
>     >>
>     >> thanks to the links,
>     >> but i need some examples which exactly takes .vtk file as input
>     to make
>     >> 3d rendering and display.
>     >> in those links there is no provision for .vtk files as input.
>     >>
>     >> Please help me in this
>     >> Thanks for your valuable reply
>     >> Guru
>     >>
>     >> David Doria wrote:
>     >>
>     >>> On Tue, Jul 28, 2009 at 4:36 PM, Gururajan
>     <gururajan.r at raster.in <mailto:gururajan.r at raster.in>
>     >>> <mailto:gururajan.r at raster.in <mailto:gururajan.r at raster.in>>>
>     wrote:
>     >>>
>     >>> Hi all,
>     >>> Please any one can help me in this.
>     >>>
>     >>> I have converted dicom series into .vtk format., but i do not
>     >>> know how
>     >>> to display this .vtk file in 3d view.
>     >>>
>     >>> am using java eclipse with vtk.jar
>     >>>
>     >>>
>     >>>
>     >
>     > Paraview definitely loads .vtk files and can display them in 3D.
>     >
>     > John
>     >
>
>     _______________________________________________
>     Powered by www.kitware.com <http://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
>
>




More information about the vtkusers mailing list