[vtkusers] can't write obj files
Gabriele
zibalmail at gmail.com
Sat May 30 12:28:26 EDT 2009
Thanks David,
So, is this a known bug?
Recompiling with your patch is not that easy for me as I am on a managed
machine. I have just tried to compile VTK on my home directory and
everything seemed to go fine, but when I later tried to compile my
application (which uses vtk), I get all sort of undefined reference
errors at link time, mainly opengl related...
I'll keep trying, but if anyone has a guess it'll be highly appreciated.
Cheers,
G
David Doria wrote:
> Gabriele,
> I am still not sure why this is not included - you can use my
> WriteAPolyData function that I cut out/modified from the vtkOBJExporter.
> Replace vtkOBJExporter.cxx/h in VTK/Rendering - then see WriteOBJ.cpp
> for an example.
>
> http://www.rpi.edu/~doriad/OBJWriter/
> <http://www.rpi.edu/%7Edoriad/OBJWriter/>
>
> Maybe someone with write access can commit this?
>
> Thanks,
>
> David
>
>
> On Fri, May 29, 2009 at 12:51 PM, Gabriele <zibalmail at gmail.com
> <mailto:zibalmail at gmail.com>> wrote:
>
> Hello,
>
> I have spent a few hours already on this thing and I can't really
> understand why it does not work.
>
> I am trying to save an .obj file using vtkObjExporter, but only
> the mtl file is saved, no .obj.
>
> 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?
>
> Thanks a lot,
> G
>
>
> #include <vtkOBJReader.h>
> #include <string>
> #include <vtkRenderer.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkOBJExporter.h>
>
>
> void tryIO(std::string& name){
>
> vtkOBJReader *myObjReader;
> myObjReader = vtkOBJReader::New();
> myObjReader->SetFileName(name.c_str()); myObjReader->Update();
> vtkPolyData* model = vtkPolyData::New();
> model->DeepCopy(myObjReader->GetOutput());
> myObjReader->Delete();
> vtkOBJExporter* objExporter = vtkOBJExporter::New();
> std::string outName(name.substr(0, name.find_last_of('.')));
> outName += "_processed";
> objExporter->SetFilePrefix(outName.c_str());
> //set renderer to the read model
> vtkRenderer *renderer;
> renderer = vtkRenderer::New();
> vtkPolyDataMapper *myDataMapper = vtkPolyDataMapper::New();
> myDataMapper->SetInput(model);
> vtkActor *myActor = vtkActor::New();
> myActor->SetMapper(myDataMapper);
> //assign our actor to the renderer
> renderer->AddActor(myActor);
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer(renderer);
> objExporter->SetRenderWindow(renWin);
> objExporter->Write();
> objExporter->Delete(); renWin->Delete();
> renderer->Delete();
> myDataMapper->Delete();
> myActor->Delete();
> }
>
>
>
>
> int main(int argc, char* argv[]){
> std::string objName(argv[1]);
> tryIO( objName );
>
> }
> _______________________________________________
> Powered by www.kitware.com <http://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 VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list