[vtkusers] converting .obj to .vtp

Greg Hanowski greg at tekknow.net
Thu Aug 29 22:17:49 EDT 2013


David,
I get your point.  Thanks for that valuable insight.

I'm pleased to report that I was finally able to compile VTK and also
ReadOBJ.  I was able to Run ReadOBJ with one of my arteries and it loaded it
ok!

Now I am trying to convert that to .VTP format so I saved ReadOBJ.cxx as
ReadOBJWriteVTP.cxx.  Next, using your insights and the WriteOBJ source, I
appended to the ReadOBJ.cxx source code the following lines:

  #include <vtkXMLPolyDataWriter.h>
  vtkSmartPointer<vtkXMLPolyDataWriter> writer =
vtkSmartPointer<vtkXMLPolyDataWriter>::New();
  writer->SetFileName("test.vtp");
  writer->SetInputConnection(reader->GetOutputPort());
  writer->Write();

It compiled ok.  When I run it...  I get the file test.vtp.  It worked!

Thank you,
Greg

-----Original Message-----
From: David Doria [mailto:daviddoria at gmail.com] 
Sent: Wednesday, August 28, 2013 5:37 AM
To: Greg Hanowski
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] converting .obj to .vtp

On Wed, Aug 28, 2013 at 12:43 AM, Greg Hanowski <greg at tekknow.net> wrote:
> David,
> ReadOBJ looks good but unfortunately WriteVTP appears to be only a 
> demo of how to write 10 points in .vtp format, not an entire model.
> Any other ideas?
> Greg

vtkXMLPolyDataWriter takes a vtkPolyData as its input (through SetInputData
or SetInputConnection). vtkOBJReader produces a vtkPolyData (through it's
GetOutput or GetOutputPort). You can connect the two directly.

David




More information about the vtkusers mailing list