[vtk-developers] How to "see" labels ("names") of points of a vtkUnstructuredGrid in a VTK window ?

houssen houssen at ipgp.fr
Wed Apr 12 08:49:38 EDT 2017


The answer was here : 
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/LabelPlacementMapper.

Franck

Le 2017-04-12 12:27, houssen a écrit :
> How to "see" labels (= "names") of points of a vtkUnstructuredGrid in
> a VTK window ?
>
> Is there an existing filter for that ? (looked for it but didn't find 
> it)
> Should I use vtkLabeledDataMapper: if yes, how ?
> Must I write myself a dedicated filter for that ?
>
> I have a valid vtkUnstructuredGrid (named "grid" in the following
> code snippets - points and cells have been set without problems).
>
> Now I add a string array to points (from a list called iVertexNames):
> vtkSmartPointer<vtkStringArray> ptNames =
> vtkSmartPointer<vtkStringArray>::New();
> ptNames->SetName("names");
> for (unsigned int idx = 0; idx < iVertexNames.size(); idx++)
> ptNames->SetValue(idx, iVertexNames[idx]);
> grid->GetPointData()->AddArray(ptNames);
>
> I have a VTK window in which I render the grid (works OK): now, I
> want to add point labels to the scene (does not work).
>
> I tried several things that didn't work:
> 1. grid->GetPointData()->SetActiveScalars("names")
>    => nothing change in the VTK window.
> 2. Add an (2D) actor whose mapper is a vtkLabeledDataMapper (+
> calling SetLabelModeToLabelScalars)
>    vtkSmartPointer<vtkLabeledDataMapper> lblMap =
> vtkSmartPointer<vtkLabeledDataMapper>::New();
>    lblMap->SetInputData(grid->????()); // Does NOT compile ? What to
> put here ?
>    lblMap->SetInputData(grid->GetPointData()->????()); // Does NOT
> compile ? What to put here ?
>    => Does not compile (need to use SetInputConnection ? With which
> argument ?)
> 3. Use an existing filter for that : didn't find it !
> (vtkVertexGlyphFilter seems to support only int/double/float ?)
>    => Does not exist
>
> Is there another way to do that ?
>
> Franck
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at: 
> http://markmail.org/search/?q=vtk-developers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtk-developers



More information about the vtk-developers mailing list