Skip to content

Commit

Permalink
Update earcut.hpp to v2.2.3 (with include patch).
Browse files Browse the repository at this point in the history
  • Loading branch information
skogler committed Nov 4, 2021
1 parent 8447754 commit 71a5be5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## [Unreleased]

## [1.0.0] - 2021-11-04

### Changed

- Update `earcut.hpp` to 2.2.3 (with fixed includes, latest version from master).
- Change versioning scheme to enable semantic versioning independently from upstream versioning.

## [0.12.11] - 2021-11-04

### Fixed
Expand Down
28 changes: 18 additions & 10 deletions include/mapbox/earcut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <limits>
#include <memory>
#include <utility>
#include <vector>

namespace mapbox {
Expand Down Expand Up @@ -64,7 +66,7 @@ class Earcut {
Node* cureLocalIntersections(Node* start);
void splitEarcut(Node* start);
template <typename Polygon> Node* eliminateHoles(const Polygon& points, Node* outerNode);
void eliminateHole(Node* hole, Node* outerNode);
Node* eliminateHole(Node* hole, Node* outerNode);
Node* findHoleBridge(Node* hole, Node* outerNode);
bool sectorContainsSector(const Node* m, const Node* p);
void indexCurve(Node* start);
Expand Down Expand Up @@ -440,7 +442,7 @@ Earcut<N>::eliminateHoles(const Polygon& points, Node* outerNode) {

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

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

// find a bridge between vertices that connects hole with an outer ring and and link it
template <typename N>
void Earcut<N>::eliminateHole(Node* hole, Node* outerNode) {
outerNode = findHoleBridge(hole, outerNode);
if (outerNode) {
Node* b = splitPolygon(outerNode, hole);

// filter out colinear points around cuts
filterPoints(outerNode, outerNode->next);
filterPoints(b, b->next);
typename Earcut<N>::Node*
Earcut<N>::eliminateHole(Node* hole, Node* outerNode) {
Node* bridge = findHoleBridge(hole, outerNode);
if (!bridge) {
return outerNode;
}

Node* bridgeReverse = splitPolygon(bridge, hole);

// filter collinear points around the cuts
Node* filteredBridge = filterPoints(bridge, bridge->next);
filterPoints(bridgeReverse, bridgeReverse->next);

// Check if input node was removed by the filtering
return outerNode == bridge ? filteredBridge : outerNode;
}

// David Eberly's algorithm for finding a bridge between hole and outer polygon
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pybind11.setup_helpers import Pybind11Extension, build_ext

FILE_DIR = os.path.dirname(os.path.abspath(__file__))
VERSION = '0.12.11'
VERSION = '1.0.0'

ext_modules = [
Pybind11Extension('mapbox_earcut',
Expand Down

0 comments on commit 71a5be5

Please sign in to comment.