Skip to content

Commit c55d78b

Browse files
Merge pull request #30 from compas-dev/planarize
Planarize
2 parents 12987e9 + bcb12ba commit c55d78b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
- Fixed point welding bug in map_mesh function.
2727
- Changed example_isolines to work with the new compas_viewer.
2828
- GA for cibuildwheel, bring back the tessagon test.
29+
- Fixed planarize method to handle triangles.
2930

3031
### Removed
3132

src/compas_libigl/planarize.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,24 @@ def quadmesh_planarize(M, kmax=500, maxdev=0.005):
3030
3131
Notes
3232
-----
33-
The input mesh should consist primarily of quad faces for best results.
34-
Non-quad faces may produce unexpected results.
33+
The input mesh should consist of quad and triangle faces, else ValueError is raised.
34+
35+
36+
Raises
37+
-----
38+
ValueError
39+
If the input mesh contains faces other than quads or triangles.
40+
3541
"""
42+
3643
V, F = M
44+
45+
for f in F:
46+
if len(f) == 3:
47+
f.append(f[0])
48+
elif len(f) != 4:
49+
raise ValueError("All faces must be quads for planarization.")
50+
3751
V = np.asarray(V, dtype=np.float64)
3852
F = np.asarray(F, dtype=np.int32)
3953
return _planarize.planarize_quads(V, F, kmax, maxdev)

0 commit comments

Comments
 (0)