Hi Massi,<br><br>Could you be more precise? Where exactly the program crashes in the ReadFile() function?<br>Are you sure that your file name pointer is not null?<br><br>J.<br><br><div class="gmail_quote">2013/2/7 Massinissa Bandou <span dir="ltr"><<a href="mailto:Massinissa.Bandou@usherbrooke.ca" target="_blank">Massinissa.Bandou@usherbrooke.ca</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi everyone!!!<br>
<br>
I have a problem to display an object file with QVTKwidget. The program<br>
crashes every time I call the ReadFile() function. Can anyone help me what's<br>
wrong with this code???<br>
<br>
class ObjectCleaning<br>
{<br>
private:<br>
Ui::ImageProcessing Widget;<br>
const char* fileName;<br>
vtkPolyData* data;<br>
public:<br>
void ReadFile(const char* file){<br>
this->fileName=file;<br>
vtkOBJReader* obj = vtkOBJReader::New();<br>
obj->SetFileName(file);<br>
obj->Update();<br>
this->data=obj->GetOutput();<br>
this->Visualize(obj->GetOutputPort());<br>
}<br>
void Visualize(vtkAlgorithmOutput* pdata){<br>
vtkSmartPointer<vtkPolyDataMapper> Mapper =<br>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
Mapper->SetInputConnection(pdata);<br>
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();<br>
actor->SetMapper(Mapper);<br>
vtkSmartPointer<vtkRenderer> renderer =<br>
vtkSmartPointer<vtkRenderer>::New();<br>
vtkSmartPointer<vtkRenderWindow> renderWindow =<br>
vtkSmartPointer<vtkRenderWindow>::New();<br>
renderWindow->AddRenderer(renderer);<br>
renderer->AddActor(actor);<br>
renderer->ResetCamera();<br>
Widget.qvtkWidget->SetRenderWindow(renderWindow);<br>
Widget.qvtkWidget->update();<br>
}<br>
}<br>
<br>
<br>
I used an edit line to get the file path and I'm reading it as follows:<br>
void OpenFile(){<br>
ObjectCleaning a;<br>
Widget.editline->setText(file);<br>
QString str = Widget.ImagePath->text();<br>
const char *filename = str.toLatin1();<br>
a.ReadFile(filename);<br>
}<br>
<br>
<br>
thx for your help!!<br>
<br>
Massi<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/vtkOBJReader-QVTKwidget-problem-tp5718346.html" target="_blank">http://vtk.1045678.n5.nabble.com/vtkOBJReader-QVTKwidget-problem-tp5718346.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<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><br clear="all"><br>-- <br><b>Joachim Pouderoux</b><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font size="1"><i>PhD, R&D Enginee</i>r</font> <br>
<b><font size="1"><a href="http://www.kitware.fr" target="_blank">Kitware SAS</a></font></b><br></blockquote>