# Zooming in on the surface results in stripes

**URL:** <https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133>\
**Category:** Development\
**Tags:** code\
**Created:** [August 11, 2023, 4:14am UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133 "2023-08-11T04:14:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ren](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@Ren](https://discourse.vtk.org/u/Ren)\
**Post date:** [August 11, 2023, 4:14am UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/1 "2023-08-11T04:14:10Z")

</div>

Zooming in on the surface results in stripes, see the picture, how to solve it

 ![无标题](https://discourse.vtk.org/uploads/default/original/2X/9/96cd0c34f4200297a918430fc4cfc2aeaa1cf49f.png)

---

<div class="post-metadata">

**Author:** ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)\
**Post date:** [August 11, 2023, 1:15pm UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/2 "2023-08-11T13:15:29Z")

</div>

Hello,

Please, post the code showing the entire VTK pipeline.

regards,

PC

---

<div class="post-metadata">

**Author:** ![Ren](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@Ren](https://discourse.vtk.org/u/Ren)\
**Post date:** [August 17, 2023, 3:14am UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/3 "2023-08-17T03:14:59Z")

</div>

zoom in any shading surface, SetParallelProjection(1), it will show the stripes

---

<div class="post-metadata">

**Author:** ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)\
**Post date:** [August 17, 2023, 11:17am UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/4 "2023-08-17T11:17:35Z")

</div>

That doesn’t happen to me. That’s why the code was asked. Lots of artifacts can happen due to misconfigured objects along the pipeline.

---

<div class="post-metadata">

**Author:** ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)\
**Post date:** [August 17, 2023, 1:48pm UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/5 "2023-08-17T13:48:48Z")

</div>

If you’re just visualizing a surface mesh, is it possible for you to share the data? Sometimes, the points or cell connectivity could be weird.

---

<div class="post-metadata">

**Author:** ![Ren](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@Ren](https://discourse.vtk.org/u/Ren)\
**Post date:** [August 18, 2023, 8:50am UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/6 "2023-08-18T08:50:09Z")

</div>

#include \<vtkSmartPointer.h\>  
#include \<vtkPolygon.h\>  
#include \<vtkTriangle.h\>  
#include \<vtkCellArray.h\>  
#include \<vtkPolyData.h\>  
#include \<vtkPolyDataMapper.h\>  
#include \<vtkActor.h\>  
#include \<vtkRenderWindow.h\>  
#include \<vtkRenderer.h\>  
#include \<vtkRenderWindowInteractor.h\>  
#include \<vtkProperty.h\>  
#include \<vtkTextActor.h\>  
#include \<vtkCamera.h\>  
#include \<vtkInteractorStyleTrackballCamera.h\>

#include

int main(int argc, char \*argv)  
{  
vtkSmartPointer points = vtkSmartPointer::New();  
points-\>InsertNextPoint(0.0, 0.0, 0.0);  
points-\>InsertNextPoint(1.0, 0.0, 0.0);  
points-\>InsertNextPoint(1.0, 1.0, 0.0);  
points-\>InsertNextPoint(0.0, 1.0, 0.0);  
points-\>InsertNextPoint(2.0, 0.0, 0.0);

```
vtkSmartPointer<vtkPolygon> polygon = vtkSmartPointer<vtkPolygon>::New();
polygon->GetPointIds()->SetNumberOfIds(4);
polygon->GetPointIds()->SetId(0, 0);
polygon->GetPointIds()->SetId(1, 1);
polygon->GetPointIds()->SetId(2, 2);
polygon->GetPointIds()->SetId(3, 3);

vtkSmartPointer<vtkTriangle> trianle = vtkSmartPointer<vtkTriangle>::New();
trianle->GetPointIds()->SetId(0, 1);
trianle->GetPointIds()->SetId(1, 2);
trianle->GetPointIds()->SetId(2, 4);

vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
cells->InsertNextCell(polygon);
cells->InsertNextCell(trianle);

vtkSmartPointer<vtkPolyData> polygonPolyData = vtkSmartPointer<vtkPolyData>::New();
polygonPolyData->SetPoints(points);
polygonPolyData->SetPolys(cells);

vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputData(polygonPolyData);

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);

vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
renderer->SetBackground(0.2, 0.8, 0.5);
renderer->GetActiveCamera()->SetParallelProjection(1);

vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
renderWindow->SetSize(640, 480);
renderWindow->Render();
renderWindow->SetWindowName("PolyDataNew");

vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);

vtkSmartPointer<vtkInteractorStyleTrackballCamera> style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
renderWindowInteractor->SetInteractorStyle(style);

renderWindow->Render();
renderWindowInteractor->Start();

return EXIT_SUCCESS;

```

}

---

<div class="post-metadata">

**Author:** ![Ren](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@Ren](https://discourse.vtk.org/u/Ren)\
**Post date:** [August 18, 2023, 8:51am UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/7 "2023-08-18T08:51:12Z")

</div>

zoom in，zoom in…, the stripes will be appear.

---

<div class="post-metadata">

**Author:** ![Ren](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@Ren](https://discourse.vtk.org/u/Ren)\
**Post date:** [August 22, 2023, 12:04am UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/8 "2023-08-22T00:04:38Z")

</div>

@Paulo_Carvalho @jaswantp

---

<div class="post-metadata">

**Author:** ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)\
**Post date:** [August 22, 2023, 12:50am UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/9 "2023-08-22T00:50:12Z")

</div>

It looks like you are running into this issue: [https://gitlab.kitware.com/vtk/vtk/-/issues/18423](https://gitlab.kitware.com/vtk/vtk/-/issues/18423)

If you provide or generate normals for your surface, then you shouldn’t see this artifact of unstable fragment derivatives.

---

<div class="post-metadata">

**Author:** ![whereismymoney](https://discourse.vtk.org/user_avatar/discourse.vtk.org/whereismymoney/32/6859_2.png) [@whereismymoney](https://discourse.vtk.org/u/whereismymoney)\
**Post date:** [August 29, 2023, 2:50am UTC](https://discourse.vtk.org/t/zooming-in-on-the-surface-results-in-stripes/12133/10 "2023-08-29T02:50:41Z")

</div>

It is important to compute point normals, not just cell normals.  
Without the point normals the behavior is bad and the renderer may crash on some systems.  
I provided an example here

> [@vtkPolyDataNormals appears to behave incorrectly](https://discourse.vtk.org/t/vtkpolydatanormals-appears-to-behave-incorrectly/11988):
>
> The sample code I provide here allows you to easily compare SetComputePointNormals(true) and SetComputePointNormals(false), so we can compare the correct behavior with the incorrect behavior, shown in this image: Here is the code: #include \<vtkActor.h\> #include \<vtkNew.h\> #include \<vtkRenderWindow.h\> #include \<vtkRenderWindowInteractor.h\> #include \<vtkRenderer.h\> #include \<vtkPolyDataNormals.h\> #include \<vtkPolyDataReader.h\> #include \<vtkPolyDataMapper.h\> #include \<vtkCleanPolyData.h\>…

This lets you compare SetComputePointNormals(true) and SetComputePointNormals(false).  
-Matthias
