vtkOBJReader QVTKwidget problem

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

vtkOBJReader QVTKwidget problem

massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: vtkOBJReader QVTKwidget problem

Joachim Pouderoux
Hi Massi,

Could you be more precise? Where exactly the program crashes in the ReadFile() function?
Are you sure that your file name pointer is not null?

J.

2013/2/7 Massinissa Bandou <[hidden email]>
Hi everyone!!!

I have a problem to display an object file with QVTKwidget. The program
crashes every time I call the ReadFile() function. Can anyone help me what's
wrong with this code???

class ObjectCleaning
{
private:
    Ui::ImageProcessing Widget;
    const char* fileName;
    vtkPolyData* data;
public:
    void ReadFile(const char* file){
        this->fileName=file;
        vtkOBJReader* obj = vtkOBJReader::New();
        obj->SetFileName(file);
        obj->Update();
        this->data=obj->GetOutput();
        this->Visualize(obj->GetOutputPort());
    }
void Visualize(vtkAlgorithmOutput* pdata){
        vtkSmartPointer<vtkPolyDataMapper> Mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
        Mapper->SetInputConnection(pdata);
        vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
        actor->SetMapper(Mapper);
        vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
        vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
        renderWindow->AddRenderer(renderer);
        renderer->AddActor(actor);
        renderer->ResetCamera();
        Widget.qvtkWidget->SetRenderWindow(renderWindow);
        Widget.qvtkWidget->update();
    }
}


I used an edit line to get the file path and I'm reading it as follows:
void OpenFile(){
      ObjectCleaning a;
      Widget.editline->setText(file);
      QString str = Widget.ImagePath->text();
      const char *filename = str.toLatin1();
      a.ReadFile(filename);
}


thx for your help!!

Massi






--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkOBJReader-QVTKwidget-problem-tp5718346.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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



--
Joachim Pouderoux
PhD, R&D Engineer
Kitware SAS

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: vtkOBJReader QVTKwidget problem

massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: vtkOBJReader QVTKwidget problem

Joachim Pouderoux
Could you confirm that you are your trying to open a Wavefront OBJ file?
Could you try to open the mni-surface-mesh.obj file available in the VTKData package?
Otherwise, if possible, send me your obj file and I will try to see what happen.
OBJ is quite a flexible file format and the reader may not support all variations.

Joachim

2013/2/7 Massinissa Bandou <[hidden email]>
Hi  Joachim,

Yes, I'm sure. the file name pointer is not null, I decide to write some
cout in the ReadFile(cons char* file):
void ReadFile(const char* file){
        std::cout<<file&lt;&lt;std::endl;
        this->fileName=file;
        std::cout<<file&lt;&lt;std::endl;
        vtkOBJReader* obj = vtkOBJReader::New();
        std::cout&lt;&lt;file&lt;&lt;std::endl;
        obj->SetFileName(file);
        std::cout<<file&lt;&lt;std::endl;
        obj->Update();
        std::cout<<file&lt;&lt;std::endl;
        this->data=obj->GetOutput();
        std::cout<<file&lt;&lt;std::endl;
        this->Visualize(obj->GetOutputPort());

    }


and it crashes when I update obj. I got:
C:/Users/Massi/Desktop/Data/Object/mesh.obj
C:/Users/Massi/Desktop/Data/Object/mesh.obj
C:/Users/Massi/Desktop/Data/Object/mesh.obj
C:/Users/Massi/Desktop/Data/Object/mesh.obj

even when I delete the update() it still crashes to the following code.

thx! for reply!

Massi




--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkOBJReader-QVTKwidget-problem-tp5718346p5718352.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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



--
Joachim Pouderoux
PhD, R&D Engineer
Kitware SAS

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: vtkOBJReader QVTKwidget problem

massinissa bandou-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: vtkOBJReader QVTKwidget problem

massinissa bandou-2
In reply to this post by Joachim Pouderoux
CONTENTS DELETED
The author has deleted this message.