module.exports = preprocessPolygon var orient = require('robust-orientation')[3] var makeSlabs = require('slab-decomposition') var makeIntervalTree = require('interval-tree-1d') var bsearch = require('binary-search-bounds') function visitInterval() { return true } function intervalSearch(table) { return function(x, y) { var tree = table[x] if(tree) { return !!tree.queryPoint(y, visitInterval) } return false } } function buildVerticalIndex(segments) { var table = {} for(var i=0; i 0 && coordinates[bucket] === p[0]) { root = slabs[bucket-1] } else { return 1 } } var lastOrientation = 1 while(root) { var s = root.key var o = orient(p, s[0], s[1]) if(s[0][0] < s[1][0]) { if(o < 0) { root = root.left } else if(o > 0) { lastOrientation = -1 root = root.right } else { return 0 } } else { if(o > 0) { root = root.left } else if(o < 0) { lastOrientation = 1 root = root.right } else { return 0 } } } return lastOrientation } } function classifyEmpty(p) { return 1 } function createClassifyVertical(testVertical) { return function classify(p) { if(testVertical(p[0], p[1])) { return 0 } return 1 } } function createClassifyPointDegen(testVertical, testNormal) { return function classify(p) { if(testVertical(p[0], p[1])) { return 0 } return testNormal(p) } } function preprocessPolygon(loops) { //Compute number of loops var numLoops = loops.length //Unpack segments var segments = [] var vsegments = [] var ptr = 0 for(var i=0; i