Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Dane Springmeyer authored and jfirebaugh committed Oct 8, 2015
1 parent 51b80ba commit 0d7d2b9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
4 changes: 3 additions & 1 deletion include/earcut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ Earcut<Coord, N>::cureLocalIntersections(Node* start) {
Node* b = node->next->next;

// a self-intersection where edge (v[i-1],v[i]) intersects (v[i+1],v[i+2])
if (intersects(a->v, node->v, node->next->v, b->v) && locallyInside(a, b) && locallyInside(b, a)) {
if (a->v != b->v && intersects(a->v, node->v, node->next->v, b->v) &&
locallyInside(a, b) && locallyInside(b, a) &&
orient(a->v, node->v, b->v) && orient(a->v, node->next->v, b->v)) {
indices.emplace_back(a->i);
indices.emplace_back(node->i);
indices.emplace_back(b->i);
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/geometries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ extern const IntegerPolygon water3b;
extern const IntegerPolygon water4;
extern const ShortPolygon park;
extern const IntegerPolygon issue34;
extern const IntegerPolygon issue35;

}
}
40 changes: 40 additions & 0 deletions test/fixtures/issue35.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "geometries.hpp"

namespace mapbox {
namespace fixtures {

const IntegerPolygon issue35 = {
{{216,-128},{218,-98},{232,-104},{238,-98},{234,-58},{242,-32},{232,-16},{254,-2},{256,20},{268,6},{274,6},{278,20},{284,16},{284,6},{266,-4},{276,-28},{262,-64},{296,-68},{312,-60},{308,-50},{322,-46},{338,-46},{344,-52},{378,-50},{396,-16},{434,22},{446,26},{452,38},{470,42},{466,58},{450,56},{436,68},{428,102},{406,96},{408,116},{370,114},{340,96},{356,124},{358,164},{352,174},{328,186},{326,208},{342,208},{346,232},{328,232},{318,248},{306,246},{302,236},{284,238},{240,190},{218,194},{194,176},{184,124},{142,102},{134,102},{118,118},{72,118},{70,90},{52,68},{68,42},{68,24},{54,40},{36,28},{30,46},{12,48},{14,82},{30,98},{18,150},{-8,170},{-22,190},{-40,194},{-50,204},{-70,208},{-112,198},{-116,212},{-114,230},{-96,250},{-72,244},{-58,276},{-50,332},{-24,364},{-30,384},{-20,390},{-16,410},{-26,426},{-36,428},{-38,444},{-92,422},{-128,422},{-128,4224},{4224,4224},{4224,3520},{4204,3506},{4204,3498},{4212,3498},{4210,3486},{4164,3492},{4132,3478},{4104,3474},{4074,3458},{4034,3456},{3992,3428},{3928,3362},{3880,3342},{3870,3342},{3850,3360},{3814,3374},{3790,3374},{3768,3362},{3742,3360},{3706,3344},{3698,3334},{3656,3326},{3640,3314},{3592,3298},{3554,3266},{3534,3266},{3488,3252},{3464,3224},{3416,3202},{3384,3154},{3386,3142},{3398,3140},{3392,3124},{3400,3116},{3402,3094},{3392,3088},{3388,3070},{3394,3062},{3382,3052},{3378,3038},{3346,3010},{3316,2966},{3278,2938},{3278,2926},{3264,2910},{3212,2880},{3212,2866},{3220,2858},{3218,2844},{3208,2834},{3198,2836},{3184,2814},{3162,2802},{3158,2776},{3130,2768},{3090,2720},{3080,2728},{3070,2724},{3080,2698},{3044,2628},{3044,2602},{3024,2596},{3010,2580},{2992,2584},{2980,2574},{2966,2580},{2966,2608},{2972,2614},{2980,2664},{3022,2700},{3026,2718},{3056,2746},{3062,2778},{3080,2792},{3098,2824},{3112,2832},{3122,2848},{3130,2884},{3156,2922},{3156,2954},{3162,2960},{3176,2954},{3186,2960},{3202,2988},{3212,2994},{3212,3010},{3186,3026},{3170,2992},{3112,2946},{3102,2944},{3086,2926},{3090,2882},{3078,2860},{3062,2854},{3040,2832},{3018,2832},{3012,2822},{2986,2812},{2958,2782},{2960,2776},{2994,2776},{3000,2742},{2958,2696},{2928,2680},{2920,2648},{2910,2638},{2910,2624},{2900,2616},{2896,2598},{2882,2582},{2882,2566},{2862,2538},{2852,2496},{2828,2472},{2804,2464},{2796,2448},{2772,2446},{2754,2428},{2708,2424},{2702,2418},{2700,2388},{2644,2322},{2642,2304},{2648,2292},{2624,2276},{2616,2234},{2598,2224},{2590,2202},{2564,2176},{2556,2120},{2530,2086},{2542,2054},{2544,2012},{2530,1976},{2524,1928},{2542,1870},{2554,1718},{2546,1710},{2546,1668},{2540,1664},{2528,1616},{2518,1606},{2516,1576},{2524,1574},{2552,1588},{2612,1594},{2614,1588},{2606,1580},{2616,1564},{2616,1552},{2600,1528},{2586,1528},{2580,1506},{2552,1498},{2542,1480},{2534,1480},{2534,1494},{2512,1456},{2498,1452},{2498,1470},{2524,1504},{2552,1514},{2560,1520},{2564,1536},{2578,1540},{2578,1572},{2556,1576},{2498,1550},{2498,1534},{2474,1532},{2460,1514},{2434,1502},{2430,1490},{2418,1486},{2414,1472},{2402,1468},{2400,1460},{2374,1452},{2368,1428},{2350,1414},{2352,1402},{2380,1396},{2396,1412},{2418,1420},{2426,1420},{2430,1410},{2394,1396},{2378,1380},{2380,1352},{2364,1356},{2360,1350},{2360,1340},{2370,1336},{2370,1328},{2358,1328},{2356,1312},{2348,1306},{2350,1290},{2344,1284},{2332,1288},{2330,1270},{2318,1278},{2308,1264},{2314,1246},{2294,1236},{2306,1220},{2288,1220},{2278,1228},{2252,1202},{2258,1180},{2246,1174},{2246,1164},{2264,1158},{2254,1140},{2258,1112},{2232,1102},{2230,1082},{2222,1070},{2216,1070},{2220,1096},{2208,1092},{2202,1072},{2190,1068},{2196,1032},{2188,1044},{2172,1048},{2186,1068},{2182,1110},{2170,1108},{2168,1096},{2154,1084},{2144,1090},{2154,1092},{2154,1106},{2144,1108},{2130,1086},{2130,1074},{2106,1048},{2108,1042},{2122,1040},{2110,1022},{2120,1022},{2122,1014},{2102,1012},{2112,996},{2110,980},{2136,980},{2140,966},{2110,970},{2102,964},{2096,992},{2082,992},{2080,976},{2088,966},{2076,950},{2076,934},{2090,930},{2100,938},{2094,916},{2134,922},{2114,906},{2120,892},{2108,872},{2112,858},{2100,842},{2094,840},{2098,896},{2090,898},{2074,920},{2066,920},{2068,880},{2060,868},{2050,814},{2038,820},{2028,808},{2002,802},{1996,812},{1970,818},{1960,806},{1948,804},{1918,776},{1900,748},{1832,708},{1840,692},{1836,674},{1810,690},{1792,690},{1762,678},{1758,662},{1738,666},{1690,654},{1638,662},{1630,652},{1602,640},{1596,624},{1578,632},{1548,616},{1538,630},{1520,638},{1516,622},{1546,612},{1548,604},{1534,596},{1520,598},{1514,570},{1492,580},{1476,574},{1472,582},{1452,590},{1454,570},{1448,570},{1440,592},{1450,594},{1450,608},{1458,614},{1456,632},{1448,642},{1460,654},{1460,664},{1440,658},{1432,668},{1392,664},{1354,706},{1340,710},{1334,722},{1286,738},{1276,730},{1276,720},{1310,696},{1310,690},{1288,694},{1280,686},{1286,660},{1298,646},{1306,622},{1302,596},{1340,568},{1350,568},{1358,578},{1376,572},{1364,548},{1332,546},{1312,566},{1296,570},{1286,580},{1286,594},{1272,602},{1262,614},{1258,634},{1244,644},{1248,660},{1238,674},{1228,676},{1228,688},{1222,694},{1206,694},{1196,712},{1180,722},{1176,744},{1212,754},{1212,774},{1182,798},{1172,828},{1140,838},{1124,860},{1112,862},{1104,876},{1076,892},{1076,912},{1068,924},{1056,926},{1040,940},{1028,940},{1022,956},{1006,956},{1006,966},{984,970},{982,978},{990,988},{980,1002},{940,1018},{930,1034},{918,1020},{890,1044},{868,1048},{856,1058},{842,1056},{846,1040},{838,1038},{820,1078},{806,1086},{792,1082},{788,1090},{776,1090},{768,1080},{772,1092},{762,1102},{766,1108},{752,1116},{720,1118},{704,1134},{688,1132},{686,1118},{706,1092},{718,1092},{734,1082},{758,1088},{762,1076},{794,1056},{806,1030},{836,1010},{864,1008},{870,1020},{888,1016},{886,1000},{900,974},{952,938},{970,936},{976,910},{998,894},{1004,882},{1016,878},{1022,800},{1044,774},{1044,766},{1036,766},{990,786},{976,762},{970,762},{964,776},{968,800},{956,804},{928,764},{912,770},{898,760},{896,750},{888,750},{842,786},{826,786},{830,744},{820,740},{818,730},{830,704},{802,646},{794,664},{766,678},{724,678},{718,660},{702,642},{680,630},{676,616},{666,614},{682,596},{684,580},{674,574},{680,564},{674,558},{658,562},{652,544},{640,534},{644,522},{630,518},{630,510},{638,506},{634,492},{650,488},{650,460},{674,424},{688,418},{690,382},{706,354},{732,350},{756,370},{768,370},{794,346},{806,322},{818,328},{848,328},{868,310},{874,286},{866,254},{844,230},{844,220},{866,216},{872,210},{872,194},{854,182},{846,194},{814,202},{794,220},{788,236},{782,236},{778,220},{768,210},{768,230},{750,216},{710,216},{676,228},{634,216},{616,204},{618,182},{600,160},{614,150},{620,136},{570,124},{542,104},{542,96},{566,86},{570,74},{588,72},{620,38},{652,44},{644,24},{652,16},{684,8},{696,-4},{716,-10},{740,-4},{732,34},{738,48},{828,54},{840,30},{860,32},{854,18},{824,16},{826,2},{846,4},{826,-20},{826,-36},{836,-54},{820,-60},{798,-52},{748,-66},{724,-128},{216,-128}},
{{4124,4134},{4118,4136},{4120,4130},{4126,4130},{4124,4134}},
{{4086,4128},{4074,4130},{4072,4122},{4086,4118},{4086,4128}},
{{4068,4106},{4068,4112},{4060,4112},{4060,4104},{4068,4106}},
{{1032,4014},{1026,4014},{1026,4008},{1032,4014}},
{{1122,3162},{1144,3186},{1142,3198},{1124,3204},{1108,3218},{1096,3212},{1090,3176},{1098,3168},{1098,3156},{1122,3162}},
{{1088,3124},{1092,3134},{1074,3138},{1062,3126},{1064,3118},{1088,3124}},
{{1054,3114},{1038,3114},{1038,3108},{1050,3108},{1054,3114}},
{{1014,3104},{994,3102},{994,3088},{1006,3086},{1014,3104}},
{{940,3068},{934,3076},{926,3074},{922,3062},{940,3058},{940,3068}},
{{3042,2702},{3042,2710},{3034,2710},{3022,2694},{3030,2690},{3042,2702}},
{{2598,1566},{2590,1566},{2588,1558},{2594,1554},{2600,1554},{2598,1566}},
{{158,1326},{170,1326},{168,1334},{142,1342},{140,1336},{150,1318},{158,1326}},
{{100,1326},{98,1340},{90,1340},{84,1322},{100,1326}},
{{130,1336},{120,1338},{128,1326},{130,1336}},
{{-12,1318},{-14,1324},{-22,1324},{-18,1314},{-12,1318}},
{{-112,1318},{-116,1320},{-110,1312},{-112,1318}},
{{182,1314},{174,1316},{174,1310},{182,1314}},
{{272,1288},{266,1308},{234,1312},{248,1304},{260,1286},{272,1288}},
{{300,1312},{278,1308},{296,1306},{300,1312}},
{{2172,1156},{2180,1162},{2200,1160},{2188,1196},{2188,1222},{2200,1232},{2198,1260},{2208,1264},{2206,1278},{2226,1294},{2228,1310},{2208,1298},{2202,1282},{2160,1236},{2156,1210},{2142,1202},{2132,1178},{2136,1152},{2172,1156}},
{{348,1290},{346,1296},{338,1294},{342,1288},{348,1290}},
{{428,1270},{420,1272},{420,1266},{428,1270}},
{{610,1170},{626,1168},{626,1186},{616,1192},{604,1206},{588,1208},{568,1222},{552,1214},{536,1222},{518,1244},{506,1246},{512,1224},{526,1220},{532,1202},{546,1198},{554,1212},{580,1206},{590,1188},{586,1172},{596,1164},{608,1164},{610,1170}},
{{648,1152},{642,1160},{632,1158},{636,1148},{648,1152}},
{{2240,1118},{2238,1126},{2232,1124},{2234,1116},{2240,1118}},
{{806,1096},{802,1090},{808,1090},{806,1096}},
{{908,1080},{906,1076},{914,1072},{908,1080}},
{{894,1060},{884,1072},{872,1070},{876,1054},{894,1060}},
{{2024,826},{2052,836},{2048,856},{2056,876},{2054,904},{2066,948},{2062,986},{2052,980},{2044,954},{2030,938},{2028,912},{2020,922},{2010,922},{2012,894},{1976,846},{1976,834},{1988,820},{2016,816},{2024,826}}
};

}
}
1 change: 1 addition & 0 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ int main() {
areaTest<int>("water4", mapbox::fixtures::water4);
areaTest<short>("park", mapbox::fixtures::park);
areaTest<int>("issue34", mapbox::fixtures::issue34);
areaTest<int>("issue35", mapbox::fixtures::issue35);

return 0;
}
3 changes: 2 additions & 1 deletion test/viz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static bool drawMesh = true;
static bool dirty = true;

static int shapeIndex = 0;
const static int totalShapes = 13;
const static int totalShapes = 14;

static int tesselator = 0;
const static int totalTesselators = 2;
Expand Down Expand Up @@ -184,6 +184,7 @@ int main() {
case 10: drawPolygon("water3b", mapbox::fixtures::water3b); break;
case 11: drawPolygon("water4", mapbox::fixtures::water4); break;
case 12: drawPolygon("park", mapbox::fixtures::park); break;
case 13: drawPolygon("issue35", mapbox::fixtures::issue35); break;
default: assert(false); break;
}

Expand Down

0 comments on commit 0d7d2b9

Please sign in to comment.