[vtkusers] display .vtk files in window

Gururajan gururajan.r at raster.in
Wed Jul 29 12:39:26 EDT 2009


Vikrant
  very kind of you. 
am trying that after your reply. even am getting the following error
Please kindly have a look at it.
see my attached file & please help me,.

ERROR: In /home/juju/VTK5.0/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
line 774
vtkStreamingDemandDrivenPipeline (0x8bd76e50): Input for connection
index 0 on input port index 0 for algorithm
vtkPolyDataWriter(0x8bd78680) is of type vtkImageData, but a vtkPolyData
is required.

ERROR: In /home/juju/VTK5.0/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
line 774
vtkStreamingDemandDrivenPipeline (0x8bd76e50): Input for connection
index 0 on input port index 0 for algorithm
vtkPolyDataWriter(0x8bd78680) is of type vtkImageData, but a vtkPolyData
is required.

ERROR: In /home/juju/VTK5.0/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
line 774
vtkStreamingDemandDrivenPipeline (0x8bd76e50): Input for connection
index 0 on input port index 0 for algorithm
vtkPolyDataWriter(0x8bd78680) is of type vtkImageData, but a vtkPolyData
is required.

Once again thank you so much
Guru



vikrant manne wrote:
> Hi Gurujan,
>  Trying using the polydata writer. And also re-check if u have used
> the Normals before giving the data to  Mapper. Make sure your  last
> input of the mapper is same as the input to the Writer.
>
> vtkPolyDataWriter * Writer = vtkPolyDataWriter::New();
> Writer->SetFileName("Output_left.vtk");
> Writer->SetInput(pNormals_left->GetOutput());
> Writer->SetFileTypeToBinary();
> Writer->Write();
> Writer->Update();
>
> Thanks,
> Vikrant Manne
>
> On Wed, Jul 29, 2009 at 10:43 AM, Gururajan <gururajan.r at raster.in
> <mailto:gururajan.r at raster.in>> wrote:
>
>     Hi vikrant,
>     its really working fine, but my way of creating .vtk file is seems
>     to be
>     wrong,
>
>     Please can you help me in this, because written .vtk file could
>     not open
>     in the below code. plz help me
>
>
>     below code i used for writing vtk files
>     vtkImageWriter writer = new  vtkImageWriter();//vtkImageWriter::New()
>        writer.SetInput(dicomreader.GetOutput());
>        //writer.AddInput(dicomreader.GetOutput());
>        writer.SetFileName("/home/gururaj/eclipse
>     Project/SimpleVTK/SimpleVtk/CardiacCT/Ronald.vtk");
>        writer.SetFileDimensionality(3);
>
>        writer.Update();
>        writer.Write();
>
>     Thanks
>     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>
>     > <mailto: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>
>     >     <mailto: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>>
>     >     >>> <mailto: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>
>     <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
>     >
>     >
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: SimpleVTK.java
Type: text/x-java
Size: 3534 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090729/89c208c0/attachment.java>


More information about the vtkusers mailing list