<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>