[Paraview] Convert file types with python
pat marion
pat.marion at kitware.com
Sat Apr 25 20:26:05 EDT 2009
Hi Dave,
Usually we try to minimize the number of extra includes placed into a
header. Is it possible to rewrite the method declaration as:
void WriteAPolyData(vtkPolyData* pd, const char *OutputFilename);
and then replace the 3 added includes with the line:
class vtkPolyData;
About your compile error, you didn't include the specific error
message so I can only guess, but I think it is a parse error from the
python wrapper. The python wrapper doesn't recognize template
arguments like vtkSmartPointer or std::strings. If a method uses such
types then its declaration must be preceded with a line containing
//BTX and followed by //ETX, this tells the parser to skip over the
declaration. It also means this method will not be available from
python.
Another suggestion, in vtk it is preferred to use vtkstd::string or
vtkStdString instead of std::string.
Pat
On Sat, Apr 25, 2009 at 5:41 PM, David Doria <daviddoria at gmail.com> wrote:
>
> 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
>
> _______________________________________________
> 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
>
>
More information about the ParaView
mailing list