# Why dynamic drawn polygon contain triangle strips?

**URL:** <https://discourse.vtk.org/t/why-dynamic-drawn-polygon-contain-triangle-strips/11606>\
**Category:** Development\
**Tags:** code\
**Created:** [June 3, 2023, 5:54pm UTC](https://discourse.vtk.org/t/why-dynamic-drawn-polygon-contain-triangle-strips/11606 "2023-06-03T17:54:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pisces2018](https://discourse.vtk.org/user_avatar/discourse.vtk.org/pisces2018/32/7063_2.png) [@Pisces2018](https://discourse.vtk.org/u/Pisces2018)\
**Post date:** [June 3, 2023, 5:54pm UTC](https://discourse.vtk.org/t/why-dynamic-drawn-polygon-contain-triangle-strips/11606/1 "2023-06-03T17:54:59Z")

</div>

Hi,everyone,  
I want to dynamically draw a polygon in a vtkRenderWindow that contains the volume data. In this case, the polygon is closed and normal, but the drawing process will stuck because the volume data is also being rendered. Therefore, I created a new vtkRender to render the polygon. The vtkRender with the volume data is set to no render. If the rendering code is unchanged, the polygon will contain the triangle strips.  
Can anyone give me some ideas or suggestions?  
 ![WeChat Screenshot_20230604015148](https://discourse.vtk.org/uploads/default/original/2X/c/c27dadaecd9266b149be5283e6bb2d2b4c2d547d.png)  
Wanted result  
 ![WeChat Screenshot_20230604014938](https://discourse.vtk.org/uploads/default/original/2X/b/bf725323090e122240ffbecd793de427b48ea293.png)  
With triangle strips

```auto
//Points
vtkNew<vtkPoints> points1;
for (int i = 0; i < vecDisPts.size(); i++)
{
	points1->InsertNextPoint(vecDisPts[i].GetX(), vecDisPts[i].GetY(), 0.0);
}

vtkNew<vtkCellArray> polys1;
 polys1->InsertNextCell(points1->GetNumberOfPoints() + 1);
 for (int i = 0; i < points1->GetNumberOfPoints(); i++)
 {
 	polys1->InsertCellPoint(i);
 }
polys1->InsertCellPoint(0);

//Polyline
m_pClipPolylinePolyData->SetPoints(points1);
m_pClipPolylinePolyData->SetLines(polys1);

```

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [June 3, 2023, 11:13pm UTC](https://discourse.vtk.org/t/why-dynamic-drawn-polygon-contain-triangle-strips/11606/2 "2023-06-03T23:13:54Z")

</div>

Those are not triangle strips. It looks like you are not erasing the render window between renders. So every time that a line is drawn, the line stays.

It is impossible to erase just one renderer. It is only possible to erase the render window, which erases everything.

Try the following:

After you render the volume, save the rendered pixels in a vtkUnsignedCharArray (call [GetPixelData()](https://vtk.org/doc/nightly/html/classvtkWindow.html#a6da54e6ba196c5a347c82abb536a27e9) on the window). Then, when you are dynamically drawing the polygon, call [SetPixelData()](https://vtk.org/doc/nightly/html/classvtkRenderWindow.html#a6145e0967228b34f4f0d7065f9e9686c) to re-paint the volume before redrawing the lines.
