Merge connected coplanar faces

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.

Thanks,

Tim

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

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.

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.

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