Hi Gurujan,<br> 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. <br><br>vtkPolyDataWriter * Writer = vtkPolyDataWriter::New();<br>
Writer->SetFileName("Output_left.vtk");<br>Writer->SetInput(pNormals_left->GetOutput());<br>Writer->SetFileTypeToBinary();<br>Writer->Write();<br>Writer->Update();<br><br>Thanks,<br>Vikrant Manne<br>
<br><div class="gmail_quote">On Wed, Jul 29, 2009 at 10:43 AM, Gururajan <span dir="ltr"><<a href="mailto:gururajan.r@raster.in">gururajan.r@raster.in</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi vikrant,<br>
its really working fine, but my way of creating .vtk file is seems to be<br>
wrong,<br>
<br>
Please can you help me in this, because written .vtk file could not open<br>
in the below code. plz help me<br>
<br>
<br>
below code i used for writing vtk files<br>
<div class="im">vtkImageWriter writer = new vtkImageWriter();//vtkImageWriter::New()<br>
writer.SetInput(dicomreader.GetOutput());<br>
//writer.AddInput(dicomreader.GetOutput());<br>
writer.SetFileName("/home/gururaj/eclipse<br>
</div>Project/SimpleVTK/SimpleVtk/CardiacCT/Ronald.vtk");<br>
<div class="im"> writer.SetFileDimensionality(3);<br>
<br>
writer.Update();<br>
writer.Write();<br>
<br>
</div>Thanks<br>
Guru<br>
<div><div></div><div class="h5"><br>
vikrant manne wrote:<br>
> Hi Gurujan,<br>
> You can try implementing the following cpp code to java. I guess this<br>
> works for VtkPolyData files.<br>
> Try using different Data readers (PolyDataReader,<br>
> UnstructuredGridReader or DataSetReader) depending on your VTK file.<br>
><br>
><br>
><br>
> // necessary headers from VTK Library<br>
> #include "vtkPolyDataMapper.h"<br>
> #include "vtkActor.h"<br>
> #include "vtkProperty.h"<br>
> #include "vtkRenderWindow.h"<br>
> #include "vtkRenderer.h"<br>
> #include "vtkRenderWindowInteractor.h"<br>
> #include <vtkDataSetWriter.h><br>
> #include <vtkSphereSource.h><br>
> #include <vtkPolyDataMapper.h><br>
> #include <vtkDataSetMapper.h><br>
> #include <vtkActor.h><br>
> #include <vtkProperty.h><br>
> #include <vtkPolyData.h><br>
> #include <vtkDataSetReader.h><br>
> #include <vtkDataSet.h><br>
> #include <vtkPolyDataNormals.h><br>
> #include <vtkTriangleFilter.h><br>
> #include <vtkStripper.h><br>
> #include <vtkPointData.h><br>
> #include <vtkPolyDataWriter.h><br>
> #include "vtkPolyDataReader.h"<br>
><br>
> #include <string><br>
><br>
> // MAIN<br>
><br>
> int main ()<br>
> {<br>
> std::string strCurFile = "VtkFile.vtk";<br>
> // Initialising a reader to read the VTK files<br>
> vtkPolyDataReader * pGridReader = vtkPolyDataReader::New();<br>
> pGridReader->SetFileName (strCurFile.c_str());<br>
> pGridReader->Update();<br>
><br>
> vtkPolyData* pData=vtkPolyData::New();<br>
> pData->DeepCopy(pGridReader->GetOutput());<br>
><br>
> // Mapper to map polygonal data to graphics primitives<br>
> vtkPolyDataMapper *Tmap = vtkPolyDataMapper::New();<br>
> Tmap->SetInput(pData);<br>
> // Updating the polydatamapper<br>
> Tmap->Update();<br>
> // Actor - used to display all the geometry<br>
> vtkActor* Actor = vtkActor::New();<br>
> Actor->SetMapper(Tmap);<br>
> Actor->VisibilityOn();<br>
><br>
> // a renderer and render window<br>
> vtkRenderer *ren1 = vtkRenderer::New();<br>
> vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
> renWin->AddRenderer(ren1);<br>
><br>
> // a window interactor<br>
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
> iren->SetRenderWindow(renWin);<br>
><br>
> // add the actors to the scene<br>
> ren1->AddActor(Actor);<br>
><br>
> // ren1->AddActor(outlineActor);<br>
> ren1->SetBackground(0.5,0.5,0.5); // Background color white<br>
><br>
> // render an image (lights and cameras are created automatically)<br>
> renWin->Render();<br>
><br>
> // begin mouse interaction<br>
> iren->Start();<br>
> // Deleting all instances after rendering<br>
> pGridReader->Delete();<br>
> Tmap->Delete();<br>
> pData->Delete();<br>
> Actor->Delete();<br>
><br>
><br>
> }<br>
><br>
> Thanks,<br>
> Vikrant Manne<br>
><br>
><br>
> On Tue, Jul 28, 2009 at 4:00 PM, Gururajan <<a href="mailto:gururajan.r@raster.in">gururajan.r@raster.in</a><br>
</div></div><div class="im">> <mailto:<a href="mailto:gururajan.r@raster.in">gururajan.r@raster.in</a>>> wrote:<br>
><br>
</div><div class="im">> john,<br>
><br>
> but i need it for java. how can i plug and please give some examples.<br>
><br>
> very kind to you<br>
><br>
> Thanks<br>
> Guru<br>
><br>
> John Drescher wrote:<br>
> > On Tue, Jul 28, 2009 at 4:52 PM, Gururajan<<a href="mailto:gururajan.r@raster.in">gururajan.r@raster.in</a><br>
</div><div class="im">> <mailto:<a href="mailto:gururajan.r@raster.in">gururajan.r@raster.in</a>>> wrote:<br>
> ><br>
> >> david,<br>
> >><br>
> >> thanks to the links,<br>
> >> but i need some examples which exactly takes .vtk file as input<br>
> to make<br>
> >> 3d rendering and display.<br>
> >> in those links there is no provision for .vtk files as input.<br>
> >><br>
> >> Please help me in this<br>
> >> Thanks for your valuable reply<br>
> >> Guru<br>
> >><br>
> >> David Doria wrote:<br>
> >><br>
> >>> On Tue, Jul 28, 2009 at 4:36 PM, Gururajan<br>
> <<a href="mailto:gururajan.r@raster.in">gururajan.r@raster.in</a> <mailto:<a href="mailto:gururajan.r@raster.in">gururajan.r@raster.in</a>><br>
</div>> >>> <mailto:<a href="mailto:gururajan.r@raster.in">gururajan.r@raster.in</a> <mailto:<a href="mailto:gururajan.r@raster.in">gururajan.r@raster.in</a>>>><br>
<div class="im">> wrote:<br>
> >>><br>
> >>> Hi all,<br>
> >>> Please any one can help me in this.<br>
> >>><br>
> >>> I have converted dicom series into .vtk format., but i do not<br>
> >>> know how<br>
> >>> to display this .vtk file in 3d view.<br>
> >>><br>
> >>> am using java eclipse with vtk.jar<br>
> >>><br>
> >>><br>
> >>><br>
> ><br>
> > Paraview definitely loads .vtk files and can display them in 3D.<br>
> ><br>
> > John<br>
> ><br>
><br>
> _______________________________________________<br>
</div>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a> <<a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a>><br>
<div><div></div><div class="h5">><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
><br>
<br>
</div></div></blockquote></div><br>