[vtkusers] How can I highlight a picked cell?

David E DeMarle dave.demarle at kitware.com
Thu May 7 09:34:10 EDT 2009


ParaView uses the approach of having a separate actor that just draws
the picked cells. Picked cells are  added to a list inside a
vtkSelection data object. That selection and the original data are put
through an ExtractSelection filter which extracts just those picked
cells out into a new data set. That dataset  is given its own actor.
See selection discussions in the vtk wiki and kitware newsletter.

That being said, you could do it by changing the color of one cell.
Replace the data values in the picked cells with some flag value. Then
setup the color lookup table to draw that flag value with some color
that is not in the range of the normal transfer function.

David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109



On Thu, May 7, 2009 at 9:11 AM, Mike Taverne <mtaverne at engits.com> wrote:
> Hi,
>
> What is the best way to highlight a picked cell on a surface
> (representation of a vtkUnstructuredGrid)?
> Do I have to create a new actor or can this be done by coloring just one
> cell of the surface?
>
> Here are some excerpts from the current code:
>
>        vtkUnstructuredGrid *grid;
>
>        class vtkEgBoundaryCodesFilter : public vtkEgGridFilter
>        class vtkEgGridFilter : public vtkUnstructuredGridAlgorithm,
> public EgVtkObject
>
>        bcodes_filter = vtkEgBoundaryCodesFilter::New();
>        bcodes_filter->SetInput(grid);
>
>        surface_filter = vtkGeometryFilter::New();
>        surface_filter->SetInput(bcodes_filter->GetOutput());
>
>        boundary_pd = vtkPolyData::New();
>        boundary_pd->DeepCopy(surface_filter->GetOutput());
>
>        surface_mapper = vtkPolyDataMapper::New();
>        surface_mapper->SetInput(boundary_pd);
>
>        surface_actor = vtkActor::New();
>        surface_actor->SetBackfaceProperty(backface_property);
>        surface_actor->GetProperty()->SetColor(0.5,1,0.5);
>        surface_actor->GetBackfaceProperty()->SetColor(1,1,0.5);
>        surface_actor->SetMapper(surface_mapper);
>
> Basically, I want to highlight one cell from the grid/surface_actor (and
> more than one eventually), while still keeping global colors for the
> front and back of the surface.
>
> _______________________________________________
> 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
>



More information about the vtkusers mailing list