[Paraview] Convert file types with python
David Doria
daviddoria at gmail.com
Sat Apr 25 17:41:27 EDT 2009
On Sat, Apr 25, 2009 at 2:53 PM, pat marion <pat.marion at kitware.com> wrote:
> 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
>
Pat, I did exactly what you said and now have a function:
void WriteAPolyData(vtkSmartPointer<vtkPolyData> pd, std::string
&OutputFilename)
that seems to work!
At first I tried to put it in the public section of vtkOBJExporter.h/.cxx
and recompile Paraview/VTK, but it tells me there is a compiler parsing
error (there is nothing wrong with the syntax because it compiles fine
"outside" of VTK).
In vtkOBJExporter.h, I added
#include "vtkSmartPointer.h"
#include "vtkPolyData.h"
#include <string>
And under:
void PrintSelf(ostream& os, vtkIndent indent);
I added:
void WriteAPolyData(vtkSmartPointer<vtkPolyData> pd, std::string
&OutputFilename);
I put the function definition in vtkOBJExporter.cxx.
After fighting that for a while (with no resolution) I moved the declaration
outside the class (to the very bottom of vtkOBJExporter.h (as the function
doesn't actually rely on anything in the class anyway) and it compiled fine.
Can I commit this function? I feel like it would probably be useful for many
users. (I don't have write access).
As a side note : I have QT4.5 and cmake (with the latest cvs paraview/vtk)
wouldn't let me proceed installing vtk because the qt version was too high.
I commented out that check in the CMakeLists.txt file and it seemed to work
just fine... is there a reason that check is still there? Maybe it should be
decreased to a warning instead of a show-stopping error?
Thanks,
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090425/2b70acec/attachment.htm>
More information about the ParaView
mailing list