[vtkusers] vtkOBJReader QVTKwidget problem
Joachim Pouderoux
joachim.pouderoux at kitware.com
Thu Feb 7 11:30:10 EST 2013
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 <Massinissa.Bandou at usherbrooke.ca>
> 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 Enginee*r
*Kitware SAS <http://www.kitware.fr>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130207/ff85db5e/attachment.htm>
More information about the vtkusers
mailing list