# How to mark some area of an object with specific color in vtkPolyData?

**URL:** https://discourse.vtk.org/t/how-to-mark-some-area-of-an-object-with-specific-color-in-vtkpolydata/11868
**Category:** Support
**Created:** [July 3, 2023, 8:56am UTC](https://discourse.vtk.org/t/how-to-mark-some-area-of-an-object-with-specific-color-in-vtkpolydata/11868 "2023-07-03T08:56:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![yen](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@yen](https://discourse.vtk.org/u/yen)
#### Post date: [July 3, 2023, 8:56am UTC](https://discourse.vtk.org/t/how-to-mark-some-area-of-an-object-with-specific-color-in-vtkpolydata/11868/1 "2023-07-03T08:56:12Z")

</div>

![image](https://discourse.vtk.org/uploads/default/original/2X/d/d47ebe3e9ff5ffe0a0d68cb042ac4bd0a4001a73.png)

Hello, the picture above is an object that I display with vtkPolyData. I want to make the protrusion parts in this object become red to show the position of defects. However, I fail serveral times. The class I use is pcl::PointXYZRGB to color the point.

Here are codes:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/9/9538ea7efe8e2ee4428385b0cd17ba325ffa2617.png)  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/a/aec50e48d9510c85f982d94b54a3fc91bbcc651b.png)  
Can someone help me?

---

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [July 3, 2023, 5:12pm UTC](https://discourse.vtk.org/t/how-to-mark-some-area-of-an-object-with-specific-color-in-vtkpolydata/11868/2 "2023-07-03T17:12:14Z")

</div>

I tried your approach and indeed it doesn’t work.

If you individual colors, you need to set the following on the mapper  
`mapper->ScalarVisibilityOn()`  
or a single color can be set on the actor,  
`actor->GetProperty()->SetColor(255,0,0);`

---

<div class="post-metadata">

### Author: ![yen](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/50afbb/32.png) [@yen](https://discourse.vtk.org/u/yen)
#### Post date: [July 4, 2023, 12:55am UTC](https://discourse.vtk.org/t/how-to-mark-some-area-of-an-object-with-specific-color-in-vtkpolydata/11868/3 "2023-07-04T00:55:31Z")

</div>

![image](https://discourse.vtk.org/uploads/default/original/2X/d/df9581b121aeb9017694737b5481f932e06e04e5.png)  
Now there is red in the object. However, why the shape is so strange? When I connect the points with CellArrays, the object will be quite normal. In contrary, the vtkGlyphfilter resulted in this abnormal problem.

---

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [July 4, 2023, 1:36am UTC](https://discourse.vtk.org/t/how-to-mark-some-area-of-an-object-with-specific-color-in-vtkpolydata/11868/4 "2023-07-04T01:36:34Z")

</div>

Your points may be wrong. I cannot say without having a more complere example
