Gabriele, <br>I am still not sure why this is not included - you can use my WriteAPolyData function that I cut out/modified from the vtkOBJExporter.<br>
Replace vtkOBJExporter.cxx/h in VTK/Rendering - then see WriteOBJ.cpp for an example.<br><br><a href="http://www.rpi.edu/~doriad/OBJWriter/">http://www.rpi.edu/~doriad/OBJWriter/</a><br><br>Maybe someone with write access can commit this?<br>
<br clear="all">Thanks,<br><br>David<br>
<br><br><div class="gmail_quote">On Fri, May 29, 2009 at 12:51 PM, Gabriele <span dir="ltr"><<a href="mailto:zibalmail@gmail.com" target="_blank">zibalmail@gmail.com</a>></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;">
Hello,<br>
<br>
I have spent a few hours already on this thing and I can't really understand why it does not work.<br>
<br>
I am trying to save an .obj file using vtkObjExporter, but only the mtl file is saved, no .obj.<br>
<br>
I include a simple function that should, in my humble opinion, read an obj file and just save it with a different name, but again only stores the .mtl file. Can anyone guess what's wrong?<br>
<br>
Thanks a lot,<br>
G<br>
<br>
<br>
#include <vtkOBJReader.h><br>
#include <string><br>
#include <vtkRenderer.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkOBJExporter.h><br>
<br>
<br>
void tryIO(std::string& name){<br>
<br>
vtkOBJReader *myObjReader;<br>
myObjReader = vtkOBJReader::New();<br>
myObjReader->SetFileName(name.c_str()); myObjReader->Update();<br>
vtkPolyData* model = vtkPolyData::New();<br>
model->DeepCopy(myObjReader->GetOutput());<br>
myObjReader->Delete();<br>
vtkOBJExporter* objExporter = vtkOBJExporter::New();<br>
std::string outName(name.substr(0, name.find_last_of('.')));<br>
outName += "_processed";<br>
objExporter->SetFilePrefix(outName.c_str());<br>
//set renderer to the read model<br>
vtkRenderer *renderer;<br>
renderer = vtkRenderer::New();<br>
vtkPolyDataMapper *myDataMapper = vtkPolyDataMapper::New();<br>
myDataMapper->SetInput(model);<br>
vtkActor *myActor = vtkActor::New();<br>
myActor->SetMapper(myDataMapper);<br>
//assign our actor to the renderer<br>
renderer->AddActor(myActor);<br>
vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
renWin->AddRenderer(renderer);<br>
objExporter->SetRenderWindow(renWin);<br>
objExporter->Write();<br>
objExporter->Delete(); renWin->Delete();<br>
renderer->Delete();<br>
myDataMapper->Delete();<br>
myActor->Delete();<br>
}<br>
<br>
<br>
<br>
<br>
int main(int argc, char* argv[]){<br>
std::string objName(argv[1]);<br>
tryIO( objName );<br>
<br>
}<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br>