Hi David, Good question. I've worked with obj files before, but never in vtk. After a quick read of vtkOBJExporter, I think I can answer your question. I encourage you to take a look at the source code for vtkOBJExporter.cxx, it's actually quite readable. Here is what it does:
The exporter takes a renderer, gets the actors from the renderer, and loops for each actor. For each actor, it calls vtkOBJExporter::WriteAnActor. This method gets the material properties from the actor and writes them to the .mtl file. Then it gets the actor's dataset. If the dataset is not polydata, it converts it to polydata by pushing it through the vtkGeometryFilter. Then it writes the polydata's geometry to the .obj file. If you have some time and you want to improve this file, it might be helpful if you pulled some of the code from vtkOBJExporter::WriteAnActor and put it into a new subroutine named something like vtkOBJExporter::WriteAPolyData. Then you could use this method to write a .obj file from a polydata if you are not interested in having an accompanying.mtl file. Pat On Sat, Apr 25, 2009 at 2:19 PM, David Doria <[email protected]> wrote: > On Sat, Apr 25, 2009 at 2:03 PM, pat marion <[email protected]> wrote: >> >> > The only remaining question is why is there no obj support? >> > >> > Thanks, >> > >> > David >> >> There is the vtkOBJReader. It's not in paraview, but you can access >> it from the vtk.io module bundled with paraview. >> >> import paraview.vtk.io as vtkio >> >> # for pv 3.4, use instead: import vtkIOPython as vtkio >> # or on posix, import libvtkIOPython as vtkio >> >> r = vtkio.vtkOBJReader() >> w = vtkio.vtkXMLPolyDataWriter() >> r.SetFileName("/home/pat/porsche.obj") >> w.SetFileName("/home/pat/porsche.vtp") >> w.SetInput(r.GetOutput()) >> w.Write() >> >> >> The above code is purely in the vtk world, so you can't mix it with >> things from servermanager, and you can't do things like >> Reader(FileName=foo) >> >> Pat > > Thanks for the reading obj example, Pat. I looked at dir(vtkio) after > importing it, and it looks like there is an ObjReader, but not an ObjWriter > (makes sense, because I've been wondering the same thing about the missing > objwriter in c++ vtk). How do people generally write obj files from > polydata's? > > Thanks, > > David > > _______________________________________________ > Powered by 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 ParaView Wiki at: > http://paraview.org/Wiki/ParaView > > Follow this link to subscribe/unsubscribe: > http://www.paraview.org/mailman/listinfo/paraview > > _______________________________________________ Powered by 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 ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview
