<div dir="ltr">Guys,<div>Waiting for reply!</div><div><br></div><div>Please help!</div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 5, 2018 at 2:08 PM shadab anwar <<a href="mailto:sk.shadabanwar@gmail.com">sk.shadabanwar@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hey amigos,<div><br></div><div>VTK noob here!</div><div><br></div><div>I facing a few problems while rendering vtkimagedata. The code snippet as follows, </div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">X</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(0,0,128)">4</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">Y</span>=<span style="color:rgb(0,0,128)">4</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">Z</span>=<span style="color:rgb(0,0,128)">4</span>;</pre> <pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">imageData</span>-><span style="font-style:italic;color:rgb(0,103,124)">SetDimensions</span>(<span style="color:rgb(9,46,100)">X</span>,<span style="color:rgb(9,46,100)">Y</span>,<span style="color:rgb(9,46,100)">Z</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"> imageData<span style="font-family:Arial,Helvetica,sans-serif">-></span><span style="font-family:Arial,Helvetica,sans-serif;font-style:italic;color:rgb(0,103,124)">SetSpacing</span><span style="font-family:Arial,Helvetica,sans-serif">(</span><span style="font-family:Arial,Helvetica,sans-serif;color:rgb(0,0,128)">1</span><span style="font-family:Arial,Helvetica,sans-serif">,</span><span style="font-family:Arial,Helvetica,sans-serif;color:rgb(0,0,128)">1</span><span style="font-family:Arial,Helvetica,sans-serif">,</span><span style="font-family:Arial,Helvetica,sans-serif;color:rgb(0,0,128)">1</span><span style="font-family:Arial,Helvetica,sans-serif">);</span></pre> <pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">imageData</span>-><span style="font-style:italic;color:rgb(0,103,124)">AllocateScalars</span>(<span style="color:rgb(0,0,128)">VTK_INT</span>,<span style="color:rgb(0,0,128)">1</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">k</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>;<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">k</span><span style="color:rgb(192,192,192)"> </span><<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">Z</span><span style="color:rgb(192,192,192)"> </span>;<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">k</span>++)</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>{</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">j</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>;<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">j</span><span style="color:rgb(192,192,192)"> </span><<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">Y</span><span style="color:rgb(192,192,192)"> </span>;<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">j</span>++)</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>{</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">i</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span>;<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">i</span><span style="color:rgb(192,192,192)"> </span><<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">X</span><span style="color:rgb(192,192,192)"> </span>;<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">i</span>++)</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>{</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span>*<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">voxel</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">static_cast</span><<span style="color:rgb(128,128,0)">int</span>*>(<span style="color:rgb(9,46,100)">imageData</span>-><span style="font-style:italic;color:rgb(0,103,124)">GetScalarPointer</span>(<span style="color:rgb(9,46,100)">i</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">j</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">k</span>));</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">voxel</span>[<span style="color:rgb(0,0,128)">0</span>]<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">10</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>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(192,192,192)"> </span>(<span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">i</span>=<span style="color:rgb(0,0,128)">2</span>;<span style="color:rgb(9,46,100)">i</span>!=-<span style="color:rgb(0,0,128)">1</span>;<span style="color:rgb(9,46,100)">i</span>--)</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>{</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span>*<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">voxel</span><span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">static_cast</span><<span style="color:rgb(128,128,0)">int</span>*>(<span style="color:rgb(9,46,100)">imageData</span>-><span style="font-style:italic;color:rgb(0,103,124)">GetScalarPointer</span>(<span style="color:rgb(0,0,128)">2</span>,<span style="color:rgb(9,46,100)">i</span>,<span style="color:rgb(9,46,100)">i</span>));</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">voxel</span>[<span style="color:rgb(0,0,128)">0</span>]=<span style="color:rgb(0,0,128)">0</span>;</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span>}</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">mapper</span>-><span style="color:rgb(0,103,124)">SetBlendModeToComposite</span>();</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">mapper</span>-><span style="color:rgb(0,103,124)">SetRequestedRenderModeToRayCast</span>();</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">mapper</span>-><span style="font-style:italic;color:rgb(0,103,124)">SetInputData</span>(<span style="color:rgb(9,46,100)">imageData</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">compositeOpacity</span>-><span style="color:rgb(0,103,124)">AddPoint</span>(<span style="color:rgb(0,0,128)">10</span>,<span style="color:rgb(0,0,128)">1</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">color</span>-><span style="color:rgb(0,103,124)">AddRGBPoint</span>(<span style="color:rgb(0,0,128)">10</span>,<span style="color:rgb(0,0,128)">1</span>,<span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(0,0,128)">0</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">compositeOpacity</span>-><span style="color:rgb(0,103,124)">AddPoint</span>(<span style="color:rgb(0,0,128)">0</span>,<span style="color:rgb(0,0,128)">0</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"> <span style="font-family:Arial,Helvetica,sans-serif;white-space:normal;color:rgb(9,46,100)">color</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal">-></span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal;color:rgb(0,103,124)">AddRGBPoint</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal">(</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal;color:rgb(0,0,128)">0</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal">,</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal;color:rgb(0,0,128)">0</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal">,</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal;color:rgb(0,0,128)">0</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal">,</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal;color:rgb(192,192,192)"> </span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal;color:rgb(0,0,128)">0</span><span style="font-family:Arial,Helvetica,sans-serif;white-space:normal">);</span></pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">volumeProperty</span>-><span style="color:rgb(0,103,124)">SetAmbient</span>(<span style="color:rgb(0,0,128)">0.3</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">volumeProperty</span>-><span style="color:rgb(0,103,124)">SetDiffuse</span>(<span style="color:rgb(0,0,128)">0.4</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">volumeProperty</span>-><span style="color:rgb(0,103,124)">SetSpecular</span>(<span style="color:rgb(0,0,128)">0.8</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">volumeProperty</span>-><span style="font-style:italic;color:rgb(0,103,124)">SetInterpolationType</span>(<span style="color:rgb(0,0,128)">0</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">volumeProperty</span>-><span style="color:rgb(0,103,124)">ShadeOn</span>();</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">volumeProperty</span>-><span style="color:rgb(0,103,124)">SetColor</span>(<span style="color:rgb(9,46,100)">color</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">volumeProperty</span>-><span style="color:rgb(0,103,124)">SetScalarOpacity</span>(<span style="color:rgb(9,46,100)">compositeOpacity</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(9,46,100)"> renderer</span>-><span style="font-style:italic;color:rgb(0,103,124)">SetBackground</span>(<span style="color:rgb(0,0,128)">0.5</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0.5</span>,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0.5</span>); </pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(9,46,100)"> volume</span>-><span style="color:rgb(0,103,124)">SetMapper</span>(<span style="color:rgb(9,46,100)">mapper</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">volume</span>-><span style="color:rgb(0,103,124)">SetProperty</span>(<span style="color:rgb(9,46,100)">volumeProperty</span>);</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(9,46,100)">renderer</span>-><span style="color:rgb(0,103,124)">AddViewProp</span>(<span style="color:rgb(9,46,100)">volume</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px">I am getting the below results,</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><div><img src="cid:ii_jpbjaly00" alt="image for forum.jpg" width="477" height="351" style="margin-right: 0px;"> <img src="cid:ii_jpbjduov1" alt="image for forum2.jpg" width="474" height="349" style="font-family: Arial, Helvetica, sans-serif; white-space: normal; margin-right: 0px;"><br></div><div><div><img src="cid:ii_jpbjgd0m2" alt="image for forum3.jpg" width="473" height="348" style="margin-right: 0px;"><br></div></div><div><br></div><div><br></div></pre>It can be seen that everytime I rotate my image I don't get a proper shading and color for the object. I have tried changing the lightining properties and shading properties but no sucess.</pre><pre style="margin-top:0px;margin-bottom:0px">I would be really thankful if anyone could help me.</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">Just for your information I am mechanical engineering with a bit of programming knowledge, so if my question is irrattional please forgive me.</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">Best,</pre><pre style="margin-top:0px;margin-bottom:0px">Shadab</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><br></pre></pre></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre></pre></pre></pre></div></div>
</blockquote></div>