# How do put different labels/annotations on faces of VTKHexahedron

**URL:** https://discourse.vtk.org/t/how-do-put-different-labels-annotations-on-faces-of-vtkhexahedron/9173
**Category:** Support
**Created:** [August 18, 2022, 7:25pm UTC](https://discourse.vtk.org/t/how-do-put-different-labels-annotations-on-faces-of-vtkhexahedron/9173 "2022-08-18T19:25:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ujjwala](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/u/7feea3/32.png) [@ujjwala](https://discourse.vtk.org/u/ujjwala)
#### Post date: [August 18, 2022, 7:25pm UTC](https://discourse.vtk.org/t/how-do-put-different-labels-annotations-on-faces-of-vtkhexahedron/9173/1 "2022-08-18T19:25:21Z")

</div>

Hi VTK experts,

I’m new to VTK and I cannot seem to figure out how to put different text annotations/labels on the faces of a VTKHexahedron.

I’m displaying a thousands of cubes ( implemented using vtkhexahedrons) stacked on on each other using a singular unstructured grid and I need to label the different faces of the hexahedron with custom labels.  
For example X+ face will have text “Label1”, Y+ face will have a label “Label2”, Z+ face will have “Label3”. My question is whether this is possible ? If it is, how do I do this ? If it is not possible, what suggestions do you have on changing my implementation ( using unstructured grid and cells defining hexahedrons) ? I’m completely lost and would appreciate any pointers/suggestions.

Thanks,  
Ujjwala

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [August 18, 2022, 7:48pm UTC](https://discourse.vtk.org/t/how-do-put-different-labels-annotations-on-faces-of-vtkhexahedron/9173/2 "2022-08-18T19:48:05Z")

</div>

I would try vtkLabeledDataMapper, however I expect the display to be very busy.

---

<div class="post-metadata">

### Author: ![ujjwala](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/u/7feea3/32.png) [@ujjwala](https://discourse.vtk.org/u/ujjwala)
#### Post date: [August 18, 2022, 11:26pm UTC](https://discourse.vtk.org/t/how-do-put-different-labels-annotations-on-faces-of-vtkhexahedron/9173/3 "2022-08-18T23:26:29Z")

</div>

Thanks @danlipsa for your prompt response ! Do you think I need to reimplement my approach of displaying the cubes for a quicker rendering ?

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [August 19, 2022, 12:29pm UTC](https://discourse.vtk.org/t/how-do-put-different-labels-annotations-on-faces-of-vtkhexahedron/9173/4 "2022-08-19T12:29:08Z")

</div>

My concern was not necessarily the rendering time but rather filling up the screen with lots of labels.

---

<div class="post-metadata">

### Author: ![ujjwala](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/u/7feea3/32.png) [@ujjwala](https://discourse.vtk.org/u/ujjwala)
#### Post date: [August 22, 2022, 11:31pm UTC](https://discourse.vtk.org/t/how-do-put-different-labels-annotations-on-faces-of-vtkhexahedron/9173/5 "2022-08-22T23:31:31Z")

</div>

@danlipsa Can you please look at my code snippet and let me know what am I missing here ? I’m not getting any labels to show up at all ???

vtkNew labelPoints;  
vtkNew labels;  
labels → SetNumberOfValues(polygonList.size());  
labels → SetName(“Labels”);

for( polygon3DInfo & polyInfo : polygonList)  
{  
labelPoints-\>InsertNextPoint( polyInfo.xmin, polyInfo.ymin, polyInfo.zmin);  
labels → InsertNextValue(polyInfo.name);  
}

vtkPolyData \*polydata = vtkPolyData::New();  
polydata-\>SetPoints( labelPoints);  
polydata-\>GetPointData()-\>AddArray( labels);

```
vtkNew<vtkLabeledDataMapper> labeledDataMapper;
labeledDataMapper->SetInputData(polydata);
labeledDataMapper->SetLabelModeToLabelFieldData();
labeledDataMapper->SetFieldDataName(labels->GetName());

vtkNew<vtkActor2D> labelActor;
labelActor->SetMapper(labeledDataMapper);

```

this → renderer → AddActor2D(labelActor);

Any help/suggestion is greatly appreciated !

Thanks,  
Ujjwala
