Hi,<br><br>You should use cast->SetInputConnection( reader->GetOutputPort( ) ); instead of the old fashion SetInput.<br>IMHO, the problem is that your smart pointer, for some reasons (reference count becomes null), decided to deallocate the reader, and thus the underlying output.<br>
<br>HTH,<br>Jerome<br><br><div class="gmail_quote">2011/6/7 Laurent Mundeleer <span dir="ltr"><<a href="mailto:laurent.mundeleer@uclouvain.be">laurent.mundeleer@uclouvain.be</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi everyone,<br>
I have a strange problem in reading a MetaImage.<br>
I have a segmentation fault when I access the vtkImageData, but if I use a direct pointer instead of a smartPointer on the vtkImageReader it's ok (but I have a memory leak).<br>
<br>
What am I doing wrong ?<br>
Here are some code extracts of what is working :<br>
<br>
// in reader method :<br>
...<br>
vtkImageData *imageData = 0;<br>
...<br>
<br>
vtkMetaImageReader* reader = vtkMetaImageReader::New();<br>
//add to replace : vtkSmartPointer<vtkMetaImageReader> reader = vtkSmartPointer<vtkMetaImageReader>::New();<br>
// and have no delete at the end of the reading<br>
..<br>
reader->Update();<br>
...<br>
imageData = reader->GetOutput();<br>
<br>
// no delete on the reader<br>
<br>
/------------------------------------------<br>
<br>
// in renderer method :<br>
vtkSmartPointer<vtkImageCast> castSource =vtkSmartPointer<vtkImageCast>::New();<br>
castSource->SetOutputScalarTypeToUnsignedChar();<br>
castSource->SetInput(imageData); // seg fault<br>
castSource->Update();<br>
<br>
/---------------------------------------------<br>
// or in unit test :<br>
vtkImageData*volume = readingMethod();<br>
...<br>
double *origin = volume->GetOrigin(); // seg fault<br>
<br>
<br>
Thank you for any help,<br>
Best Regards,<br>
<br>
++<br>
Laurent<br>
<br>
<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>