Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rare case with touching holes (parity with earcut v2.2.1) #82

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions include/mapbox/earcut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,7 @@ Earcut<N>::findHoleBridge(Node* hole, Node* outerNode) {
// whether sector in vertex m contains sector in vertex p in the same coordinates
template <typename N>
bool Earcut<N>::sectorContainsSector(const Node* m, const Node* p) {
return (
(area(m->prev, m, p->prev) < 0 || area(p->prev, m, m->next) < 0) &&
(area(m->prev, m, p->next) < 0 || area(p->next, m, m->next) < 0)
);
return area(m->prev, m, p->prev) < 0 && area(p->next, m, m->next) < 0;
}

// interlink polygon nodes in z-order
Expand Down
3 changes: 2 additions & 1 deletion test/convert_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ fs.readdirSync(base).filter(function (name) {
"empty_square": Infinity,
"issue83": Infinity,
"issue107": Infinity,
"issue119": 0.04
"issue119": 0.04,
"touching4": 0.06
};
var expectedLibtessDeviation = libtessDeviationMap[id];
if (!expectedLibtessDeviation) expectedLibtessDeviation = 0.000001;
Expand Down
17 changes: 17 additions & 0 deletions test/fixtures/touching4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This file is auto-generated, manual changes will be lost if the code is regenerated.

#include "geometries.hpp"

namespace mapbox {
namespace fixtures {

static const Fixture<short> touching4("touching4", 20, 1e-14, 0.06, {
{{11,10},{0,10},{0,0},{11,0}},
{{7,6},{7,9},{10,9}},
{{7,5},{10,2},{10,5}},
{{6,9},{1,4},{1,9}},
{{1,1},{1,4},{4,1}},
});

}
}