Hi,<br><br>You should use cast-&gt;SetInputConnection( reader-&gt;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">&lt;<a href="mailto:laurent.mundeleer@uclouvain.be">laurent.mundeleer@uclouvain.be</a>&gt;</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&#39;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&lt;vtkMetaImageReader&gt; reader = vtkSmartPointer&lt;vtkMetaImageReader&gt;::New();<br>
// and have no delete at the end of the reading<br>
..<br>
reader-&gt;Update();<br>
...<br>
imageData = reader-&gt;GetOutput();<br>
<br>
// no delete on the reader<br>
<br>
/------------------------------------------<br>
<br>
// in renderer method :<br>
    vtkSmartPointer&lt;vtkImageCast&gt; castSource =vtkSmartPointer&lt;vtkImageCast&gt;::New();<br>
    castSource-&gt;SetOutputScalarTypeToUnsignedChar();<br>
    castSource-&gt;SetInput(imageData); // seg fault<br>
    castSource-&gt;Update();<br>
<br>
/---------------------------------------------<br>
// or in unit test :<br>
vtkImageData*volume = readingMethod();<br>
...<br>
double *origin = volume-&gt;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>