<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">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 class="h5"><div>On Jul 9, 2010, at 7:57 AM, Jothy wrote:</div>
<br></div></div><blockquote type="cite"><div><div></div><div class="h5"><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 class="im">
_______________________________________________<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>