Skip to content

Commit 71a5be5

Browse files
committed
Update earcut.hpp to v2.2.3 (with include patch).
1 parent 8447754 commit 71a5be5

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## [Unreleased]
44

5+
## [1.0.0] - 2021-11-04
6+
7+
### Changed
8+
9+
- Update `earcut.hpp` to 2.2.3 (with fixed includes, latest version from master).
10+
- Change versioning scheme to enable semantic versioning independently from upstream versioning.
11+
512
## [0.12.11] - 2021-11-04
613

714
### Fixed

include/mapbox/earcut.hpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#include <algorithm>
44
#include <cassert>
55
#include <cmath>
6+
#include <cstddef>
67
#include <limits>
78
#include <memory>
9+
#include <utility>
810
#include <vector>
911

1012
namespace mapbox {
@@ -64,7 +66,7 @@ class Earcut {
6466
Node* cureLocalIntersections(Node* start);
6567
void splitEarcut(Node* start);
6668
template <typename Polygon> Node* eliminateHoles(const Polygon& points, Node* outerNode);
67-
void eliminateHole(Node* hole, Node* outerNode);
69+
Node* eliminateHole(Node* hole, Node* outerNode);
6870
Node* findHoleBridge(Node* hole, Node* outerNode);
6971
bool sectorContainsSector(const Node* m, const Node* p);
7072
void indexCurve(Node* start);
@@ -440,7 +442,7 @@ Earcut<N>::eliminateHoles(const Polygon& points, Node* outerNode) {
440442

441443
// process holes from left to right
442444
for (size_t i = 0; i < queue.size(); i++) {
443-
eliminateHole(queue[i], outerNode);
445+
outerNode = eliminateHole(queue[i], outerNode);
444446
outerNode = filterPoints(outerNode, outerNode->next);
445447
}
446448

@@ -449,15 +451,21 @@ Earcut<N>::eliminateHoles(const Polygon& points, Node* outerNode) {
449451

450452
// find a bridge between vertices that connects hole with an outer ring and and link it
451453
template <typename N>
452-
void Earcut<N>::eliminateHole(Node* hole, Node* outerNode) {
453-
outerNode = findHoleBridge(hole, outerNode);
454-
if (outerNode) {
455-
Node* b = splitPolygon(outerNode, hole);
456-
457-
// filter out colinear points around cuts
458-
filterPoints(outerNode, outerNode->next);
459-
filterPoints(b, b->next);
454+
typename Earcut<N>::Node*
455+
Earcut<N>::eliminateHole(Node* hole, Node* outerNode) {
456+
Node* bridge = findHoleBridge(hole, outerNode);
457+
if (!bridge) {
458+
return outerNode;
460459
}
460+
461+
Node* bridgeReverse = splitPolygon(bridge, hole);
462+
463+
// filter collinear points around the cuts
464+
Node* filteredBridge = filterPoints(bridge, bridge->next);
465+
filterPoints(bridgeReverse, bridgeReverse->next);
466+
467+
// Check if input node was removed by the filtering
468+
return outerNode == bridge ? filteredBridge : outerNode;
461469
}
462470

463471
// David Eberly's algorithm for finding a bridge between hole and outer polygon

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pybind11.setup_helpers import Pybind11Extension, build_ext
55

66
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
7-
VERSION = '0.12.11'
7+
VERSION = '1.0.0'
88

99
ext_modules = [
1010
Pybind11Extension('mapbox_earcut',

0 commit comments

Comments
 (0)