<div dir="ltr">Yes you are correct! Later for unknow reason I changed it to [1.0,5.0]<br><br>Thanks,<br><br>Jothy<br><br><br><br><div class="gmail_quote">On Fri, Jul 9, 2010 at 4:12 PM, Eric E. Monson <span dir="ltr">&lt;<a href="mailto:emonson@cs.duke.edu">emonson@cs.duke.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;">I&#39;m glad it&#39;s working, but in your original code you had range1=[1.0,6.0] and generated three contours from that, so the middle value was 3.5<div>
<br></div><font color="#888888"><div>-Eric</div></font><div><div></div><div class="h5"><div><br><div><div>On Jul 9, 2010, at 11:08 AM, Jothy wrote:</div><br><blockquote type="cite"><div dir="ltr">Wow!<br><br>It works Eric, I thought x is the number of conotur in GetColor(x,color), but now realized it&#39;s the scalar value.<br>
<br>The values are 1,3,5 (by using ContourFilter-&gt;GetValue(0/1/2).<br><br>
Thanks very much,<br><br>Jothy<br><br><br><div class="gmail_quote">On Fri, Jul 9, 2010 at 3:58 PM, Eric E. Monson <span dir="ltr">&lt;<a href="mailto:emonson@cs.duke.edu" target="_blank">emonson@cs.duke.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;">Well, you&#39;re requesting the color for a scalar value of 2.0 and your contours are at 1.0, 3.5 and 6.0 -- if you do GetColor(3.5,cc) you get back [0.0, 1.0, 0.0], which is the color of your middle contour, right?<div>

<br></div><div>-Eric</div><div><br><div><div><div></div><div><div>On Jul 9, 2010, at 10:50 AM, Jothy wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div><div dir="ltr">But this color which translates to (242,255,0) in another RGB format doesn&#39;t match with any of the actual contour colors.<br>

<br>See the attached pic.<br><br>Thanks,<br><br>Jothy<br><br><div class="gmail_quote">
On Fri, Jul 9, 2010 at 3:44 PM, Eric E. Monson <span dir="ltr">&lt;<a href="mailto:emonson@cs.duke.edu" target="_blank">emonson@cs.duke.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


<div style="word-wrap: break-word;">I think I&#39;m just adding two lines to your code and it prints <div><br></div><div><div>[0.94509803921568625, 1.0, 0.0] color</div><div><br></div><div><div><div>import vtk</div>
<div><br></div><div>quadric =vtk.vtkQuadric()</div><div>quadric.SetCoefficients(1,2,3,0,1,0,0,0,0,0);</div><div><br></div><div>sample = vtk.vtkSampleFunction();</div><div>sample.SetSampleDimensions(40,40,40);</div><div>sample.SetImplicitFunction(quadric);</div>


<div><br></div><div>#Generate implicit surface</div><div>contour = vtk.vtkContourFilter();</div><div>contour.SetInput(sample.GetOutput());</div><div>range1=[1.0,6.0]</div><div>contour.GenerateValues(3,range1);</div><div>

<br>
</div><div># The contour lines are mapped to the graphics library.</div><div>contMapper = vtk.vtkPolyDataMapper()</div><div>contMapper.SetInputConnection(contour.GetOutputPort())</div><div>contMapper.SetScalarRange(0,7)</div>


<div><br></div><div>contActor = vtk.vtkActor()</div><div>contActor.SetMapper(contMapper)</div><div><br></div><div>mapr=contMapper.GetLookupTable()</div><div><br></div></div><div># TWO NEW LINES</div><div>mapr.SetRange(0,7)</div>


<div>mapr.Build()</div><div><div><br></div><div>cc=[0,0,0]</div><div>mapr.GetColor(2,cc)</div><div>print cc,&#39;color&#39;</div><div><br></div><div># Create the renderer, render window, and interactor.</div><div>
ren = vtk.vtkRenderer()</div><div>renWin = vtk.vtkRenderWindow()</div><div>renWin.AddRenderer(ren)</div><div>iren = vtk.vtkRenderWindowInteractor()</div><div>iren.SetRenderWindow(renWin)</div><div><br></div><div># Set the background color to white. Associate the actors with the</div>


<div># renderer.</div><div>ren.SetBackground(0,0,0)</div><div>ren.AddActor(contActor)</div><div><br></div><div># Zoom in a little bit.</div><div>ren.ResetCamera()</div><div>ren.GetActiveCamera().Zoom(1)</div><div><br></div>


<div># Initialize and start the event loop.</div><div>iren.Initialize()</div><div>renWin.Render()</div><div>iren.Start()</div></div></div><div><div></div><div><div><br></div><div><br></div><div><div>On Jul 9, 2010, at 10:40 AM, Jothy wrote:</div>


<br><blockquote type="cite"><div dir="ltr">Hi Eric,<br><br>Now I get &quot;None&quot; color<br><br>What&#39;s wrong?<br><br>Jothy<br><br><div class="gmail_quote">On Fri, Jul 9, 2010 at 3:20 PM, Eric E. Monson <span dir="ltr">&lt;<a href="mailto:emonson@cs.duke.edu" target="_blank">emonson@cs.duke.edu</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;">Hey Jothy,<div><br></div><div>If you move your GetColor() call after the first Render(), then it will get the correct value. The problem is that at the point you&#39;re trying to grab the color from the lookup table it&#39;s not really built yet (you can try GetRange() to see that it&#39;s still (0,1) when you&#39;re calling for the color at 2, for example).</div>



<div><br></div><div>So, you can either grab the color after the Render() call, or explicitly call SetRange(0,7) and then Build() on the LUT before you try to grab the color.</div><div><br></div><div>-Eric</div><div><br><div>




<span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div>



------------------------------------------------------</div><div>Eric E Monson</div><div>Duke Visualization Technology Group</div><div><br></div></span></div><br><div><div><div></div><div><div>On Jul 9, 2010, at 7:57 AM, Jothy wrote:</div>



<br></div></div><blockquote type="cite"><div><div></div><div><div dir="ltr">Hi all,<br><br>I am trying to get the color of cntours using Mapper-&gt;GetLookupTable()-&gt;GetColor(0,color)<br><br>But the color doesn&#39;t exactly matches with the actual one!<br>



<br>What the problem in this code?<br>
<br><br><b><span style="color: rgb(51, 102, 255);">import vtk</span><br style="color: rgb(51, 102, 255);"><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">quadric =vtk.vtkQuadric()</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">quadric.SetCoefficients(1,2,3,0,1,0,0,0,0,0);</span><br style="color: rgb(51, 102, 255);"><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">sample = vtk.vtkSampleFunction();</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">sample.SetSampleDimensions(40,40,40);</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">sample.SetImplicitFunction(quadric);</span><br style="color: rgb(51, 102, 255);">




<br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">#Generate implicit surface</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">contour = vtk.vtkContourFilter();</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">contour.SetInput(sample.GetOutput());</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">range1=[1.0,6.0]</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">contour.GenerateValues(3,range1);</span><br style="color: rgb(51, 102, 255);"><br style="color: rgb(51, 102, 255);"><br style="color: rgb(51, 102, 255);"><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);"># The contour lines are mapped to the graphics library.</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">contMapper = vtk.vtkPolyDataMapper()</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">contMapper.SetInputConnection(contour.GetOutputPort())</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">contMapper.SetScalarRange(0,7)</span><br style="color: rgb(51, 102, 255);">




<br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">contActor = vtk.vtkActor()</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">contActor.SetMapper(contMapper)</span><br style="color: rgb(51, 102, 255);">




<br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">mapr=contMapper.GetLookupTable()</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">cc=[0,0,0]</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">mapr.GetColor(2,cc)</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">print cc,&#39;color&#39;</span><br style="color: rgb(51, 102, 255);"><br style="color: rgb(51, 102, 255);">




<br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"># Create the renderer, render window, and interactor.</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">ren = vtk.vtkRenderer()</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">renWin = vtk.vtkRenderWindow()</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">renWin.AddRenderer(ren)</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">iren = vtk.vtkRenderWindowInteractor()</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">iren.SetRenderWindow(renWin)</span><br style="color: rgb(51, 102, 255);">




<br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"># Set the background color to white. Associate the actors with the</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"># renderer.</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">ren.SetBackground(0,0,0)</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">ren.AddActor(contActor)</span><br style="color: rgb(51, 102, 255);"><br style="color: rgb(51, 102, 255);">




<br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"># Zoom in a little bit.</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">ren.ResetCamera()</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">ren.GetActiveCamera().Zoom(1)</span><br style="color: rgb(51, 102, 255);"><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"># Initialize and start the event loop.</span><br style="color: rgb(51, 102, 255);">




<span style="color: rgb(51, 102, 255);">iren.Initialize()</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">renWin.Render()</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">iren.Start()</span></b><br>




<br>Thanks,<br>Jothy<br><br><br></div></div></div><div>
_______________________________________________<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>



</div></blockquote></div><br></div></div></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div></blockquote></div><br></div>
</div></div><span>&lt;untitled.TIF&gt;</span></blockquote></div><br></div></div></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div></blockquote></div><br></div>