[vtk-developers] How to "see" labels ("names") of points of a vtkUnstructuredGrid in a VTK window ?
houssen
houssen at ipgp.fr
Wed Apr 12 06:27:11 EDT 2017
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
More information about the vtk-developers
mailing list