<div dir="ltr"><div class="gmail_default">
<p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif">Hi all!</p><p class="gmail-p1" style=""><span style="font-family:"trebuchet ms",sans-serif">I have a problem using vtkOSPRayPass. I'm reading a DICOM series with vtkDICOMImageReader.</span></p><p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif">My code is :</p><p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif">..bla bla bla</p><p class="gmail-p1">vtkNew<span class="gmail-s1"><</span>vtkGPUVolumeRayCastMapper<span class="gmail-s1">> volumeMapper;</span></p><p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space"> </span>volumeMapper-></span>SetAutoAdjustSampleDistances<span class="gmail-s1">(</span><span class="gmail-s2">0</span><span class="gmail-s1">);</span></p><p class="gmail-p3"><span class="gmail-Apple-converted-space"> </span>volumeMapper-><span class="gmail-s3">SetSampleDistance</span>(<span class="gmail-s2">0.5</span>);</p><p class="gmail-p4"><span class="gmail-Apple-converted-space"> </span></p><p class="gmail-p1"><span class="gmail-s1"><span class="gmail-Apple-converted-space"> </span></span>vtkDICOMImageReader<span class="gmail-s1">* reader = </span>vtkDICOMImageReader<span class="gmail-s1">::</span><span class="gmail-s3">New</span><span class="gmail-s1">();</span></p><p class="gmail-p5"><span class="gmail-s1"><span class="gmail-Apple-converted-space"> </span>reader-></span><span class="gmail-s3">SetDirectoryName</span><span class="gmail-s1">(</span>"Path/to/my/DICOM"<span class="gmail-s1">);</span></p><p class="gmail-p3"><span class="gmail-Apple-converted-space"> </span>reader-><span class="gmail-s3">Update</span>();</p><p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space"> </span>volumeMapper-></span>SetInputConnection<span class="gmail-s1">(reader-></span>GetOutputPort<span class="gmail-s1">());</span></p><p class="gmail-p4"><span class="gmail-Apple-converted-space"> </span></p><p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif">
</p><p class="gmail-p3"><span class="gmail-Apple-converted-space"> </span>volumeMapper-><span class="gmail-s3">AddObserver</span>(<span class="gmail-s4">vtkCommand</span>::<span class="gmail-s3">ErrorEvent</span>, errorObserver);</p><p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif"> vtkNew<span class="gmail-s1"><</span>vtkPiecewiseFunction<span class="gmail-s1">> pwf;</span> </p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>pwf-><span class="gmail-s2">AddPoint</span>(-<span class="gmail-s3">3024</span>, <span class="gmail-s3">0.0</span>);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>pwf-><span class="gmail-s2">AddPoint</span>(-<span class="gmail-s3">16</span>, <span class="gmail-s3">0.0</span>);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>pwf-><span class="gmail-s2">AddPoint</span>(<span class="gmail-s3">641</span>, <span class="gmail-s3">0.05</span>);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>pwf-><span class="gmail-s2">AddPoint</span>(<span class="gmail-s3">3071</span>, <span class="gmail-s3">0.1</span>);</p>
<p class="gmail-p3" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>ctf-><span class="gmail-s2">AddRGBPoint</span>( -<span class="gmail-s3">3024</span>, <span class="gmail-s3">0</span>, <span class="gmail-s3">0</span>, <span class="gmail-s3">0</span>, <span class="gmail-s3">0.5</span>, <span class="gmail-s3">0.0</span> );</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>ctf-><span class="gmail-s2">AddRGBPoint</span>( -<span class="gmail-s3">16</span>, <span class="gmail-s3">0.73</span>, <span class="gmail-s3">0.25</span>, <span class="gmail-s3">0.30</span>, <span class="gmail-s3">0.49</span>, <span class="gmail-s3">.61</span> );</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>ctf-><span class="gmail-s2">AddRGBPoint</span>( <span class="gmail-s3">641</span>, <span class="gmail-s3">.90</span>, <span class="gmail-s3">.82</span>, <span class="gmail-s3">.56</span>, <span class="gmail-s3">.5</span>, <span class="gmail-s3">0.0</span> );</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>ctf-><span class="gmail-s2">AddRGBPoint</span>( <span class="gmail-s3">3071</span>, <span class="gmail-s3">1</span>, <span class="gmail-s3">1</span>, <span class="gmail-s3">1</span>, <span class="gmail-s3">.5</span>, <span class="gmail-s3">0.0</span> );</p>
<p class="gmail-p3" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>volumeProperty-><span class="gmail-s2">SetColor</span>(ctf);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>volumeProperty-><span class="gmail-s2">SetScalarOpacity</span>(pwf);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>volumeProperty-><span class="gmail-s2">SetShade</span>(<span class="gmail-s3">0</span>);</p>
<p class="gmail-p6" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-s1"><span class="gmail-Apple-converted-space"> </span>volumeProperty-></span>SetScalarOpacityUnitDistance<span class="gmail-s1">(</span><span class="gmail-s3">1.732</span><span class="gmail-s1">);</span></p>
<p class="gmail-p3" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-s1"> </span>vtkNew<span class="gmail-s1"><</span>vtkVolume<span class="gmail-s1">> volume;</span></p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>volume-><span class="gmail-s2">SetMapper</span>(volumeMapper);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>volume-><span class="gmail-s2">SetProperty</span>(volumeProperty);</p>
<p class="gmail-p3" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p2" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-s1"> </span>// Create the renderwindow, interactor and renderer</p>
<p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-s1"> </span>vtkNew<span class="gmail-s1"><</span>vtkRenderWindow<span class="gmail-s1">> renderWindow;</span></p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>renderWindow-><span class="gmail-s2">SetMultiSamples</span>(<span class="gmail-s3">0</span>);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>renderWindow-><span class="gmail-s2">SetSize</span>(<span class="gmail-s3">401</span>, <span class="gmail-s3">399</span>); <span class="gmail-s4">// NPOT size</span></p>
<p class="gmail-p3" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-s1"> </span>vtkNew<span class="gmail-s1"><</span>vtkRenderer<span class="gmail-s1">> renderer;</span></p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>renderer-><span class="gmail-s2">SetBackground</span>(<span class="gmail-s3">0.3</span>, <span class="gmail-s3">0.3</span>, <span class="gmail-s3">0.4</span>);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>renderWindow-><span class="gmail-s2">AddRenderer</span>(renderer);</p>
<p class="gmail-p3" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>renderer-><span class="gmail-s2">AddVolume</span>(volume);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>renderer-><span class="gmail-s2">ResetCamera</span>();</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>renderWindow-><span class="gmail-s2">Render</span>();</p>
<p class="gmail-p3" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span></p>
<p class="gmail-p2" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-s1"> </span>// Attach OSPRay render pass</p>
<p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-s1"> </span>vtkNew<span class="gmail-s1"><</span>vtkOSPRayPass<span class="gmail-s1">> osprayPass;</span></p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span><span class="gmail-s5">if</span> (useOSP)</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>{</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>renderer-><span class="gmail-s2">SetPass</span>(osprayPass);</p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>}</p><p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif"> vtkNew<span class="gmail-s1"><</span>vtkRenderWindowInteractor<span class="gmail-s1">> iren;</span></p><p class="gmail-p2" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>iren-><span class="gmail-s2">SetRenderWindow</span>(renderWindow);</p><p class="gmail-p1" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-s1"><span class="gmail-Apple-converted-space"> </span></span>vtkNew<span class="gmail-s1"><</span>vtkInteractorStyleTrackballCamera<span class="gmail-s1">> style;</span></p><p class="gmail-p3" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-s1"><span class="gmail-Apple-converted-space"> </span>iren-></span>SetInteractorStyle<span class="gmail-s1">(style);</span></p><p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif">
</p><p class="gmail-p2" style="font-family:"trebuchet ms",sans-serif"><span class="gmail-Apple-converted-space"> </span>iren-><span class="gmail-s2">Start</span>();</p><p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif">... bla bla bla</p><p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><br></p><p class="gmail-p4"><font face="trebuchet ms, sans-serif">Now, the problem is the following. If "useOSP"==FALSE, I have a certain opacity (the which one I would like to have in my results); if "useOSP"==TRUE, I have a different opacity and I'm not able to manage it as I want. </font></p><p class="gmail-p4"><font face="trebuchet ms, sans-serif">Can you please tell me what's wrong in my code?</font></p>
<p class="gmail-p4" style="font-family:"trebuchet ms",sans-serif"><br></p></div><div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Thanks to everyone!</div><br></div><br clear="all"><div><div class="gmail-m_-6751513172387578973gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><i style="font-size:12.8px;color:rgb(11,83,148)">Martina Li</i><i style="font-size:12.8px;color:rgb(11,83,148)">tterio</i><br></div></div></div></div></div></div></div>
</div>