diff --git a/CHANGELOG.md b/CHANGELOG.md index 5de9953..5cc1820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed point welding bug in map_mesh function. - Changed example_isolines to work with the new compas_viewer. - GA for cibuildwheel, bring back the tessagon test. +- Fixed planarize method to handle triangles. ### Removed diff --git a/src/compas_libigl/planarize.py b/src/compas_libigl/planarize.py index c4a35d0..f607124 100644 --- a/src/compas_libigl/planarize.py +++ b/src/compas_libigl/planarize.py @@ -30,10 +30,24 @@ def quadmesh_planarize(M, kmax=500, maxdev=0.005): Notes ----- - The input mesh should consist primarily of quad faces for best results. - Non-quad faces may produce unexpected results. + The input mesh should consist of quad and triangle faces, else ValueError is raised. + + + Raises + ----- + ValueError + If the input mesh contains faces other than quads or triangles. + """ + V, F = M + + for f in F: + if len(f) == 3: + f.append(f[0]) + elif len(f) != 4: + raise ValueError("All faces must be quads for planarization.") + V = np.asarray(V, dtype=np.float64) F = np.asarray(F, dtype=np.int32) return _planarize.planarize_quads(V, F, kmax, maxdev)