[vtkusers] GetColor from vtkLookupTable problem

Jothy jothybasu at gmail.com
Fri Jul 9 10:40:16 EDT 2010


Hi Eric,

Now I get "None" color

What's wrong?

Jothy

On Fri, Jul 9, 2010 at 3:20 PM, Eric E. Monson <emonson at cs.duke.edu> wrote:

> Hey Jothy,
>
> 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're trying to grab
> the color from the lookup table it's not really built yet (you can try
> GetRange() to see that it's still (0,1) when you're calling for the color at
> 2, for example).
>
> 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.
>
> -Eric
>
> ------------------------------------------------------
> Eric E Monson
> Duke Visualization Technology Group
>
>
> On Jul 9, 2010, at 7:57 AM, Jothy wrote:
>
> Hi all,
>
> I am trying to get the color of cntours using
> Mapper->GetLookupTable()->GetColor(0,color)
>
> But the color doesn't exactly matches with the actual one!
>
> What the problem in this code?
>
>
> *import vtk
>
> quadric =vtk.vtkQuadric()
> quadric.SetCoefficients(1,2,3,0,1,0,0,0,0,0);
>
> sample = vtk.vtkSampleFunction();
> sample.SetSampleDimensions(40,40,40);
> sample.SetImplicitFunction(quadric);
>
> #Generate implicit surface
> contour = vtk.vtkContourFilter();
> contour.SetInput(sample.GetOutput());
> range1=[1.0,6.0]
> contour.GenerateValues(3,range1);
>
>
>
> # The contour lines are mapped to the graphics library.
> contMapper = vtk.vtkPolyDataMapper()
> contMapper.SetInputConnection(contour.GetOutputPort())
> contMapper.SetScalarRange(0,7)
>
> contActor = vtk.vtkActor()
> contActor.SetMapper(contMapper)
>
> mapr=contMapper.GetLookupTable()
> cc=[0,0,0]
> mapr.GetColor(2,cc)
> print cc,'color'
>
>
> # Create the renderer, render window, and interactor.
> ren = vtk.vtkRenderer()
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(ren)
> iren = vtk.vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
>
> # Set the background color to white. Associate the actors with the
> # renderer.
> ren.SetBackground(0,0,0)
> ren.AddActor(contActor)
>
>
> # Zoom in a little bit.
> ren.ResetCamera()
> ren.GetActiveCamera().Zoom(1)
>
> # Initialize and start the event loop.
> iren.Initialize()
> renWin.Render()
> iren.Start()*
>
> Thanks,
> Jothy
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100709/bae804f6/attachment.htm>


More information about the vtkusers mailing list