diff options
| author | Arne Dußin | 2020-11-26 14:57:39 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-11-26 14:57:39 +0100 |
| commit | 19a1221c4bb9df34bb0c14746fc5372d07d1c771 (patch) | |
| tree | 486c8b22ddf5e639db3e02d8fb7c48d52dedf6df /src/math | |
| parent | 9d469c353eb179a35fad6d42fa3f6fc985b49188 (diff) | |
| download | graf_karto-19a1221c4bb9df34bb0c14746fc5372d07d1c771.tar.gz graf_karto-19a1221c4bb9df34bb0c14746fc5372d07d1c771.zip | |
Print polygon that makes the earcutting algo panic
Diffstat (limited to 'src/math')
| -rw-r--r-- | src/math/polygon/triangulate.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/math/polygon/triangulate.rs b/src/math/polygon/triangulate.rs index 4c7d952..8a18cd7 100644 --- a/src/math/polygon/triangulate.rs +++ b/src/math/polygon/triangulate.rs @@ -75,10 +75,13 @@ where */ while polygon.corners.len() > 3 { // Find the ear with the highest index. - let ear = flags - .iter() - .rposition(|&x| (x & FLAG_EAR) != 0) - .expect("Polygon has more than three vertices, but no ear."); + let ear = match flags.iter().rposition(|&x| (x & FLAG_EAR) != 0) { + Some(pos) => pos, + None => panic!( + "Polygon has more than three vertices, but no ear: {:?}", + polygon + ), + }; // Add the ear's triangle to the list. { |
