(data, holeIndices, outerNode, dim)
| 1855 | |
| 1856 | // link every hole into the outer loop, producing a single-ring polygon without holes |
| 1857 | function eliminateHoles(data, holeIndices, outerNode, dim) { |
| 1858 | var queue = [], |
| 1859 | i, |
| 1860 | len, |
| 1861 | start, |
| 1862 | end, |
| 1863 | list; |
| 1864 | |
| 1865 | for (i = 0, len = holeIndices.length; i < len; i++) { |
| 1866 | start = holeIndices[i] * dim; |
| 1867 | end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; |
| 1868 | list = linkedList(data, start, end, dim, false); |
| 1869 | if (list === list.next) list.steiner = true; |
| 1870 | queue.push(getLeftmost(list)); |
| 1871 | } |
| 1872 | |
| 1873 | queue.sort(compareX); |
| 1874 | |
| 1875 | // process holes from left to right |
| 1876 | for (i = 0; i < queue.length; i++) { |
| 1877 | eliminateHole(queue[i], outerNode); |
| 1878 | outerNode = filterPoints(outerNode, outerNode.next); |
| 1879 | } |
| 1880 | |
| 1881 | return outerNode; |
| 1882 | } |
| 1883 | |
| 1884 | function compareX(a, b) { |
| 1885 | return a.x - b.x; |
no test coverage detected