<div dir="ltr">I learnt that this seems to be a bug as reported here:<div><br></div><div><a href="http://www.paraview.org/Bug/bug_relationship_graph.php?bug_id=3661&graph=dependency">http://www.paraview.org/Bug/bug_relationship_graph.php?bug_id=3661&graph=dependency</a><br>
</div><div><br></div><div>From the link, I figured we can get around this issue by using GetDisplayExtent. So the following code works:</div><div><br></div><div><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">DICOM</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">Reader</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkDICOMImageReader</span>><span style="color:rgb(192,192,192)"> </span>reader<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkDICOMImageReader</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>reader->SetDirectoryName(<span style="color:rgb(0,128,0)">"/home/Images/DICOM"</span>);</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>reader-><span style="font-style:italic">Update</span>();</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><font color="#008000">Mapper</font></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageMapper</span>><span style="color:rgb(192,192,192)"> </span>imageMapper<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageMapper</span>>::New();</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>imageMapper-><span style="font-style:italic">SetInputData</span>(reader->GetOutput());</pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>imageMapper-><span style="font-style:italic">SetZSlice</span>(<span style="color:rgb(0,0,128)">12</span>);<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">does</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">not</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">work.</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><br></pre><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><font color="#008000">Actor</font></pre>
<div style="font-family:arial,sans-serif;font-size:13.333333969116211px"><span style="color:rgb(192,192,192)"></span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageActor</span>><span style="color:rgb(192,192,192)"> </span>mapActor<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><<span style="color:rgb(128,0,128)">vtkImageActor</span>>::New();<br>
</div><pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>mapActor-><span style="font-style:italic">SetInputData</span>(imageMapper->GetInput());</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)"> </span>mapActor->SetZSlice(<span style="color:rgb(0,0,128)">12</span>);<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">this</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">also</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">does</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">not</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">work.</span></pre>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 4, 2014 at 11:10 AM, Sam Raby <span dir="ltr"><<a href="mailto:rabysam28@gmail.com" target="_blank">rabysam28@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I am trying to read DICOM series using vtkImageActor. (Note: I know I can read them easily by vtkImageViewer2, however it is not suitable for my application).</div>
<div><br></div><div>
The problem is when I use SetZSlice, it does not update the slice and it always shows the first slice of DICOM. I call SetZSlice in both vtkImageActor and vtkImageMapper but it does not change the slice.</div><div><br></div>
<div>Thanks for any tips, and here is my simple code:</div><div><br></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">DICOM</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">Reader</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkDICOMImageReader</span><span style>></span><span style="color:rgb(192,192,192)"> </span><span style>reader</span><span style="color:rgb(192,192,192)"> </span><span style>=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkDICOMImageReader</span><span style>>::</span><span style>New</span><span style>();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>reader</span><span style>-></span><span style>SetDirectoryName</span><span style>(</span><span style="color:rgb(0,128,0)">"/home/Images/DICOM"</span><span style>);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>reader</span><span style>-></span><span style="font-style:italic">Update</span><span style>();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><font color="#008000">Mapper</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkImageMapper</span><span style>></span><span style="color:rgb(192,192,192)"> </span><span style>imageMapper</span><span style="color:rgb(192,192,192)"> </span><span style>=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkImageMapper</span><span style>>::</span><span style>New</span><span style>();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>imageMapper</span><span style>-></span><span style="font-style:italic">SetInputData</span><span style>(</span><span style>reader</span><span style>-></span><span style>GetOutput</span><span style>());</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>imageMapper</span><span style>-></span><span style="font-style:italic">SetZSlice</span><span style>(</span><span style="color:rgb(0,0,128)">12</span><span style>);</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">does</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">not</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">work.</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><font color="#008000">Actor</font></pre>
<div><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkImageActor</span><span style>></span><span style="color:rgb(192,192,192)"> </span><span style>mapActor</span><span style="color:rgb(192,192,192)"> </span><span style>=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkImageActor</span><span style>>::</span><span style>New</span><span style>();</span><br>
</div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>mapActor</span><span style>-></span><span style="font-style:italic">SetInputData</span><span style>(</span><span style>imageMapper</span><span style>-></span><span style>GetInput</span><span style>());</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>mapActor</span><span style>-></span><span style>SetZSlice</span><span style>(</span><span style="color:rgb(0,0,128)">12</span><span style>);</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">this</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">also</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">does</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">not</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">work.</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><font color="#008000">Visualization</font></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkRenderer</span><span style="color:rgb(192,192,192)"> </span><span style>*</span><span style>ren</span><span style>=</span><span style="color:rgb(128,0,128)">vtkRenderer</span><span style>::</span><span style>New</span><span style>();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>ren</span><span style>-></span><span style>AddActor</span><span style>(</span><span style>mapActor</span><span style>);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>ren</span><span style>-></span><span style>ResetCamera</span><span style>();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkRenderWindow</span><span style>></span><span style="color:rgb(192,192,192)"> </span><span style>renderWindow</span><span style="color:rgb(192,192,192)"> </span><span style>=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkRenderWindow</span><span style>>::</span><span style>New</span><span style>();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>renderWindow</span><span style>-></span><span style="font-style:italic">AddRenderer</span><span style>(</span><span style>ren</span><span style>);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkRenderWindowInteractor</span><span style>></span><span style="color:rgb(192,192,192)"> </span><span style>iren</span><span style="color:rgb(192,192,192)"> </span><span style>=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">vtkSmartPointer</span><span style><</span><span style="color:rgb(128,0,128)">vtkRenderWindowInteractor</span><span style>>::</span><span style>New</span><span style>();</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>iren</span><span style>-></span><span style>SetRenderWindow</span><span style>(</span><span style>renderWindow</span><span style>);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style>iren</span><span style>-></span><span style="font-style:italic">Start</span><span style>();</span></pre>
</div><div><br></div></div>
</blockquote></div><br></div>