<br>Hi Xiaopeng,<br><br>It is likely that the source of the error is that<br>you are instantiating ITK objects inside your<br>constructor, but not associating them to <br>member variables of the &quot;SimpleView&quot; class.<br>
<br>Therefore, these ITK objects will be destroyed<br>by the time you get to the closing bracket of<br>your class constructor (the end of scope).<br><br><br>The typical solution here,<br>is that you should make:<br><br><p class="MsoNormal" style="">
<span style="font-size: 10pt; font-family: DotumChe;">  ReaderType::Pointer reader;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  FilterType::Pointer connector;</span></p><p class="MsoNormal" style=""><br><span style="font-size: 10pt; font-family: DotumChe;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">to be member variables of your class (move them to <br></span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">declaration of the SimpleView class in your header file)</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">and instantiate them in the constructor as</span></p><p class="MsoNormal" style=""><br><span style="font-size: 10pt; font-family: DotumChe;"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  this-&gt;reader = ReaderType::New();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  this-&gt;connector = FilterType::New();</span></p><br><br>In this way, they will stay alive for the lifetime<br>of the SimpleView class.<br>
<br><br><br>     Regards,<br><br><br>          Luis<br><br><br>-----------------------------------------------------------------<br><div class="gmail_quote">On Tue, Jun 15, 2010 at 10:06 AM, Xiaopeng Yang <span dir="ltr">&lt;<a href="mailto:yxp233@postech.ac.kr">yxp233@postech.ac.kr</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">








<div link="blue" vlink="purple" lang="EN-US">

<div>

<p class="MsoNormal">Dear VTK users,</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal"> I made a simple UI with QT for loading a DICOM image
by ITK and visualize it by VTK. Even I successfully debugged the code, but when
I ran the executable file, errors occurred: “An unhandled win32 exception
occurred in SimpleView.exe [448]”. Could you help me to check whether there is
any problem in my code?</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">SimpleView::SimpleView() </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">{</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  <span style="color: blue;">this</span>-&gt;ui = <span style="color: blue;">new</span> Ui_SimpleView;</span></p>

<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe; color: blue;">this</span><span style="font-size: 10pt; font-family: DotumChe;">-&gt;ui-&gt;setupUi(<span style="color: blue;">this</span>);</span></p>


<p class="MsoNormal" style="text-indent: 10.5pt;"> </p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe; color: green;">//Define ITK DICOM loader</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  <span style="color: blue;">typedef</span> itk::Image
&lt;<span style="color: blue;">unsigned</span> <span style="color: blue;">short</span>,
2&gt; ImageType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  <span style="color: blue;">typedef</span>
itk::ImageFileReader&lt;ImageType&gt;ReaderType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  <span style="color: green;">//Connect ITK to VTK</span></span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  <span style="color: blue;">typedef</span>
itk::ImageToVTKImageFilter&lt;ImageType&gt;FilterType;</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  ReaderType::Pointer reader = ReaderType::New();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  FilterType::Pointer connector = FilterType::New();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  reader-&gt;SetFileName(<span style="color: rgb(163, 21, 21);">&quot;C:/Documents
and Settings/edt/Desktop/QT Test3/ImageViewer/DICOM/portal47.dcm&quot;</span>);</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  connector-&gt;SetInput(reader-&gt;GetOutput());</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>

<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;">vtkImageViewer *viewer = vtkImageViewer::New();</span></p>

<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe; color: green;">  </span><span style="font-size: 10pt; font-family: DotumChe; color: blue;">this</span><span style="font-size: 10pt; font-family: DotumChe;">-&gt;ui-&gt;qvtkWidget_2-&gt;SetRenderWindow(viewer-&gt;GetRenderWindow());</span></p>


<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  viewer-&gt;SetupInteractor(<span style="color: blue;">this</span>-&gt;ui-&gt;qvtkWidget_2-&gt;GetRenderWindow()-&gt;GetInteractor());</span></p>


<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  viewer-&gt;SetInput(connector-&gt;GetOutput());</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  viewer-&gt;Render();</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  viewer-&gt;SetColorLevel(255);</span></p>

<p class="MsoNormal" style="text-indent: 10.5pt;"><span style="font-size: 10pt; font-family: DotumChe;">viewer-&gt;SetColorWindow(128);</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  connect(<span style="color: blue;">this</span>-&gt;ui-&gt;actionOpenFile,
SIGNAL(triggered()), <span style="color: blue;">this</span>,
SLOT(slotOpenFile()));</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">  connect(<span style="color: blue;">this</span>-&gt;ui-&gt;actionExit,
SIGNAL(triggered()), <span style="color: blue;">this</span>, SLOT(slotExit()));</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;">};</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: DotumChe;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt;">Thanks.</span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt;"> </span></p>

<p class="MsoNormal" style=""><span style="font-size: 10pt;">Xiaopeng</span><span></span></p>

</div>

</div>


</div></div><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>
<br></blockquote></div><br>