MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / splitEarcut

Function splitEarcut

libs/mapv/mapv.js:1831–1854  ·  view source on GitHub ↗
(start, triangles, dim, minX, minY, size)

Source from the content-addressed store, hash-verified

1829
1830// try splitting polygon into two and triangulate them independently
1831function splitEarcut(start, triangles, dim, minX, minY, size) {
1832 // look for a valid diagonal that divides the polygon into two
1833 var a = start;
1834 do {
1835 var b = a.next.next;
1836 while (b !== a.prev) {
1837 if (a.i !== b.i && isValidDiagonal(a, b)) {
1838 // split the polygon in two by the diagonal
1839 var c = splitPolygon(a, b);
1840
1841 // filter colinear points around the cuts
1842 a = filterPoints(a, a.next);
1843 c = filterPoints(c, c.next);
1844
1845 // run earcut on each half
1846 earcutLinked(a, triangles, dim, minX, minY, size);
1847 earcutLinked(c, triangles, dim, minX, minY, size);
1848 return;
1849 }
1850 b = b.next;
1851 }
1852 a = a.next;
1853 } while (a !== start);
1854}
1855
1856// link every hole into the outer loop, producing a single-ring polygon without holes
1857function eliminateHoles(data, holeIndices, outerNode, dim) {

Callers 1

earcutLinkedFunction · 0.85

Calls 4

isValidDiagonalFunction · 0.85
splitPolygonFunction · 0.85
filterPointsFunction · 0.85
earcutLinkedFunction · 0.85

Tested by

no test coverage detected