# Merge connected coplanar faces

**URL:** https://discourse.vtk.org/t/merge-connected-coplanar-faces/10196
**Category:** Support
**Created:** [December 14, 2022, 8:01pm UTC](https://discourse.vtk.org/t/merge-connected-coplanar-faces/10196 "2022-12-14T20:01:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Tim\_Hutton](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tim_hutton/32/1204_2.png) [@Tim\_Hutton](https://discourse.vtk.org/u/Tim_Hutton)
#### Post date: [December 14, 2022, 8:01pm UTC](https://discourse.vtk.org/t/merge-connected-coplanar-faces/10196/1 "2022-12-14T20:01:38Z")

</div>

Is there a filter in VTK to merge connected coplanar faces?

Example image showing a case where a cube has triangulated faces. The desired output has square faces.

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

Thanks,

Tim

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dcthomp/32/60_2.png) [@dcthomp](https://discourse.vtk.org/u/dcthomp)
#### Post date: [December 15, 2022, 3:58am UTC](https://discourse.vtk.org/t/merge-connected-coplanar-faces/10196/2 "2022-12-15T03:58:11Z")

</div>

There’s a quadric decimation filter that will merge all faces, preferring coplanar ones first. But I’m not sure there is an option to specify a maximum dihedral angle for merging; instead it targets a percent reduction in the number of faces. You would probably have to modify it to use a different termination criterion.

[https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/Core/vtkQuadricDecimation.h](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/Core/vtkQuadricDecimation.h)

---

<div class="post-metadata">

### Author: ![Tim\_Hutton](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tim_hutton/32/1204_2.png) [@Tim\_Hutton](https://discourse.vtk.org/u/Tim_Hutton)
#### Post date: [December 15, 2022, 3:02pm UTC](https://discourse.vtk.org/t/merge-connected-coplanar-faces/10196/3 "2022-12-15T15:02:30Z")

</div>

vtkQuadricDecimation and vtkDecimatePro both seem to work by finding vertices to delete, to reduce the number of triangles. I can’t find any combination of parameters that reduces the triangle count while keeping all the vertices.

I can write code to iterate over neighboring faces and merge them but I’m surprised if VTK can’t already do this.

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dcthomp/32/60_2.png) [@dcthomp](https://discourse.vtk.org/u/dcthomp)
#### Post date: [December 15, 2022, 4:01pm UTC](https://discourse.vtk.org/t/merge-connected-coplanar-faces/10196/4 "2022-12-15T16:01:29Z")

</div>

I’m not sure I understand why or how you would keep vertices common only to coplanar faces. Without incident faces, they would just be dangling with no cells attached.

---

<div class="post-metadata">

### Author: ![Tim\_Hutton](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tim_hutton/32/1204_2.png) [@Tim\_Hutton](https://discourse.vtk.org/u/Tim_Hutton)
#### Post date: [December 15, 2022, 5:05pm UTC](https://discourse.vtk.org/t/merge-connected-coplanar-faces/10196/5 "2022-12-15T17:05:16Z")

</div>

I have found that what I really want is vtkFeatureEdges, to be able to show clean wireframes without all the extra edges.
