[vtkusers] vtkOBJReader QVTKwidget problem

Massinissa Bandou Massinissa.Bandou at USherbrooke.ca
Thu Feb 7 11:21:02 EST 2013


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.



More information about the vtkusers mailing list