<br><div class="gmail_quote">On Sat, Apr 25, 2009 at 2:53 PM, pat marion <span dir="ltr">&lt;<a href="mailto:pat.marion@kitware.com">pat.marion@kitware.com</a>&gt;</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 David,<br>
<br>
Good question.  I&#39;ve worked with obj files before, but never in vtk.<br>
After a quick read of vtkOBJExporter, I think I can answer your<br>
question.  I encourage you to take a look at the source code for<br>
vtkOBJExporter.cxx, it&#39;s actually quite readable.  Here is what it<br>
does:<br>
<br>
<br>
The exporter takes a renderer, gets the actors from the renderer, and<br>
loops for each actor.  For each actor, it calls<br>
vtkOBJExporter::WriteAnActor.  This method gets the material<br>
properties from the actor and writes them to the .mtl file.  Then it<br>
gets the actor&#39;s dataset.  If the dataset is not polydata, it converts<br>
it to polydata by pushing it through the vtkGeometryFilter.  Then it<br>
writes the polydata&#39;s geometry to the .obj file.<br>
<br>
<br>
If you have some time and you want to improve this file, it might be<br>
helpful if you pulled some of the code from<br>
vtkOBJExporter::WriteAnActor and put it into a new subroutine named<br>
something like vtkOBJExporter::WriteAPolyData.  Then you could use<br>
this method to write a .obj file from a polydata if you are not<br>
interested in having an accompanying.mtl file.<br>
<font color="#888888"><br>
<br>
Pat<br>
</font></blockquote></div><br>Pat, I did exactly what you said and now have a function:<br>void WriteAPolyData(vtkSmartPointer&lt;vtkPolyData&gt; pd, std::string &amp;OutputFilename)<br>that seems to work! <br><br>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 &quot;outside&quot; of VTK).<br>
<br>In vtkOBJExporter.h, I added<br>#include &quot;vtkSmartPointer.h&quot;<br>#include &quot;vtkPolyData.h&quot;<br>#include &lt;string&gt;<br><br>And under:<br>  void PrintSelf(ostream&amp; os, vtkIndent indent);<br>I added:<br>
void WriteAPolyData(vtkSmartPointer&lt;vtkPolyData&gt; pd, std::string &amp;OutputFilename);<br><br>I put the function definition in vtkOBJExporter.cxx.<br><br>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&#39;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&#39;t have write access).<br>
<br>As a side note : I have QT4.5 and cmake (with the latest cvs paraview/vtk) wouldn&#39;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?<br>
<br>Thanks,<br><br>Dave<br>