From 4ffe77446b96efd2488d4134970994d88db945c6 Mon Sep 17 00:00:00 2001 From: oeh-rowanwinsemius Date: Thu, 18 Jan 2018 15:10:19 +1100 Subject: [PATCH 1/4] Add test for multipoly --- demo/js/bundle.js | 2930 +++++++++++++++--------------- demo/js/index.js | 5 +- test/fixtures/multipolys.geojson | 147 ++ 3 files changed, 1620 insertions(+), 1462 deletions(-) create mode 100644 test/fixtures/multipolys.geojson diff --git a/demo/js/bundle.js b/demo/js/bundle.js index adca98e..500d537 100644 --- a/demo/js/bundle.js +++ b/demo/js/bundle.js @@ -1,347 +1,347 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o', - '', - '', '', - ''].join(''); - var form = container.querySelector('form'); - L.DomEvent - .on(form, 'submit', function (evt) { - L.DomEvent.stop(evt); - var radios = Array.prototype.slice.call( - form.querySelectorAll('input[type=radio]')); - for (var i = 0, len = radios.length; i < len; i++) { - if (radios[i].checked) { - this.options.callback(parseInt(radios[i].value)); - break; - } - } - }, this) - .on(form['clear'], 'click', function(evt) { - L.DomEvent.stop(evt); - this.options.clear(); - }, this); - - L.DomEvent - .disableClickPropagation(this._container) - .disableScrollPropagation(this._container); - return this._container; - } - -}); +L.BooleanControl = L.Control.extend({ + options: { + position: 'topright' + }, + + onAdd: function(map) { + var container = this._container = L.DomUtil.create('div', 'leaflet-bar'); + this._container.style.background = '#ffffff'; + this._container.style.padding = '10px'; + container.innerHTML = [ + '
', + '
    ', + '
  • ','', '
  • ', + '
  • ','', '
  • ', + '
  • ','', '
  • ', + '
  • ','', '
  • ', + '
  • ','', '
  • ', + '
', + '', '', + '
'].join(''); + var form = container.querySelector('form'); + L.DomEvent + .on(form, 'submit', function (evt) { + L.DomEvent.stop(evt); + var radios = Array.prototype.slice.call( + form.querySelectorAll('input[type=radio]')); + for (var i = 0, len = radios.length; i < len; i++) { + if (radios[i].checked) { + this.options.callback(parseInt(radios[i].value)); + break; + } + } + }, this) + .on(form['clear'], 'click', function(evt) { + L.DomEvent.stop(evt); + this.options.clear(); + }, this); + + L.DomEvent + .disableClickPropagation(this._container) + .disableScrollPropagation(this._container); + return this._container; + } + +}); },{}],2:[function(require,module,exports){ -L.Coordinates = L.Control.extend({ - options: { - position: 'bottomright' - }, - - onAdd: function(map) { - this._container = L.DomUtil.create('div', 'leaflet-bar'); - this._container.style.background = '#ffffff'; - map.on('mousemove', this._onMouseMove, this); - return this._container; - }, - - _onMouseMove: function(e) { - this._container.innerHTML = '' + - e.latlng.lng.toFixed(3) + ', ' + e.latlng.lat.toFixed(3) + ''; - } - +L.Coordinates = L.Control.extend({ + options: { + position: 'bottomright' + }, + + onAdd: function(map) { + this._container = L.DomUtil.create('div', 'leaflet-bar'); + this._container.style.background = '#ffffff'; + map.on('mousemove', this._onMouseMove, this); + return this._container; + }, + + _onMouseMove: function(e) { + this._container.innerHTML = '' + + e.latlng.lng.toFixed(3) + ', ' + e.latlng.lat.toFixed(3) + ''; + } + }); },{}],3:[function(require,module,exports){ -require('./coordinates'); -require('./polygoncontrol'); -require('./booleanopcontrol'); -var martinez = window.martinez = require('../../'); -//var martinez = require('../../dist/martinez.min'); -var xhr = require('superagent'); -var mode = window.location.hash.substring(1); -var path = '../test/fixtures/'; -var ext = '.geojson'; -var file; - -var files = [ - 'asia', 'trapezoid-box', 'canada', 'horseshoe', 'hourglasses', 'overlap_y', - 'polygon_trapezoid_edge_overlap', 'touching_boxes', 'two_pointed_triangles', - 'hole_cut', 'overlapping_segments', 'overlap_loop', 'disjoint_boxes' -]; - -switch (mode) { - case 'geo': - file = 'asia.geojson'; - break; - case 'states': - file = 'states_source.geojson'; - break; - case 'trapezoid': - file = 'trapezoid-box.geojson'; - break; - case 'canada': - file = 'canada.geojson'; - break; - case 'horseshoe': - file = 'horseshoe.geojson'; - break; - case 'hourglasses': - file = 'hourglasses.geojson'; - break; - case 'edge_overlap': - file = 'polygon_trapezoid_edge_overlap.geojson'; - break; - case 'touching_boxes': - file = 'touching_boxes.geojson'; - break; - case 'triangles': - file = 'two_pointed_triangles.geojson'; - break; - case 'holecut': - file = 'hole_cut.geojson'; - break; - case 'overlapping_segments': - file = 'overlapping_segments.geojson'; - break; - case 'overlap_loop': - file = 'overlap_loop.geojson'; - break; - case 'overlap_y': - file = 'overlap_y.geojson'; - break; - case 'overlap_two': - file = 'overlap_two.geojson'; - break; - case 'disjoint_boxes': - file = 'disjoint_boxes.geojson'; - break; - case 'polygons_edge_overlap': - file = 'polygons_edge_overlap.geojson'; - break; - case 'collapsed': - file = 'collapsed.geojson'; - break; - default: - file = 'hole_hole.geojson'; - break; -} - -console.log(mode); - - -var OPERATIONS = { - INTERSECTION: 0, - UNION: 1, - DIFFERENCE: 2, - XOR: 3 -}; - -var div = document.createElement('div'); -div.id = 'image-map'; -div.style.width = div.style.height = '100%'; -document.body.appendChild(div); - -// create the slippy map -var map = window.map = L.map('image-map', { - minZoom: 1, - maxZoom: 20, - center: [0, 0], - zoom: 2, - crs: mode === 'geo' ? L.CRS.EPSG4326 : L.extend({}, L.CRS.Simple, { - transformation: new L.Transformation(1/8, 0, -1/8, 0) - }), - editable: true -}); - -map.addControl(new L.NewPolygonControl({ - callback: map.editTools.startPolygon -})); -map.addControl(new L.Coordinates()); -map.addControl(new L.BooleanControl({ - callback: run, - clear: clear -})); - -var drawnItems = window.drawnItems = L.geoJson().addTo(map); - -function loadData(path) { - console.log(path); - xhr - .get(path) - .accept('json') - .end(function(e, r) { - if (!e) { - drawnItems.addData(JSON.parse(r.text)); - map.fitBounds(drawnItems.getBounds().pad(0.05), { animate: false }); - } - }); -} - -function clear() { - drawnItems.clearLayers(); - results.clearLayers(); -} - -var reader = new jsts.io.GeoJSONReader(); -var writer = new jsts.io.GeoJSONWriter(); - -function run (op) { - var layers = drawnItems.getLayers(); - if (layers.length < 2) return; - var subject = layers[0].toGeoJSON(); - var clipping = layers[1].toGeoJSON(); - - //console.log('input', subject, clipping, op); - - subject = JSON.parse(JSON.stringify(subject)); - clipping = JSON.parse(JSON.stringify(clipping)); - - var operation; - if (op === OPERATIONS.INTERSECTION) { - operation = martinez.intersection; - } else if (op === OPERATIONS.UNION) { - operation = martinez.union; - } else if (op === OPERATIONS.DIFFERENCE) { - operation = martinez.diff; - } else if (op === 5) { // B - A - operation = martinez.diff; - - var temp = subject; - subject = clipping; - clipping = temp; - } else { - operation = martinez.xor; - } - - console.time('martinez'); - var result = operation(subject.geometry.coordinates, clipping.geometry.coordinates); - console.timeEnd('martinez'); - - //if (op === OPERATIONS.UNION) result = result[0]; - console.log('result', result); - // console.log(JSON.stringify(result)) - results.clearLayers(); - - if (result !== null) { - results.addData({ - 'type': 'Feature', - 'geometry': { - 'type': 'MultiPolygon', - 'coordinates': result - } - }); - - setTimeout(function() { - console.time('jsts'); - var s = reader.read(subject); - var c = reader.read(clipping); - var res; - if (op === OPERATIONS.INTERSECTION) { - res = s.geometry.intersection(c.geometry); - } else if (op === OPERATIONS.UNION) { - res = s.geometry.union(c.geometry); - } else if (op === OPERATIONS.DIFFERENCE) { - res = s.geometry.difference(c.geometry); - } else { - res = s.geometry.symDifference(c.geometry); - } - res = writer.write(res); - console.timeEnd('jsts'); - console.log(res); - }, 500); - } -} - -//drawnItems.addData(oneInside); -//drawnItems.addData(twoPointedTriangles); -//drawnItems.addData(selfIntersecting); -//drawnItems.addData(holes); -//drawnItems.addData(data); - -map.on('editable:created', function(evt) { - drawnItems.addLayer(evt.layer); - evt.layer.on('click', function(e) { - if ((e.originalEvent.ctrlKey || e.originalEvent.metaKey) && this.editEnabled()) { - this.editor.newHole(e.latlng); - } - }); -}); - -var results = window.results = L.geoJson(null, { - style: function(feature) { - return { - color: 'red', - weight: 1 - }; - } -}).addTo(map); - -loadData(path + file); - -},{"../../":5,"./booleanopcontrol":1,"./coordinates":2,"./polygoncontrol":4,"superagent":8}],4:[function(require,module,exports){ -L.EditControl = L.Control.extend({ - - options: { - position: 'topleft', - callback: null, - kind: '', - html: '' - }, - - onAdd: function (map) { - var container = L.DomUtil.create('div', 'leaflet-control leaflet-bar'), - link = L.DomUtil.create('a', '', container); - - link.href = '#'; - link.title = 'Create a new ' + this.options.kind; - link.innerHTML = this.options.html; - L.DomEvent.on(link, 'click', L.DomEvent.stop) - .on(link, 'click', function () { - window.LAYER = this.options.callback.call(map.editTools); - }, this); - - return container; - } - -}); +require('./coordinates'); +require('./polygoncontrol'); +require('./booleanopcontrol'); +var martinez = window.martinez = require('../../src/index'); +//var martinez = require('../../dist/martinez.min'); +var xhr = require('superagent'); +var mode = window.location.hash.substring(1); +var path = '../test/fixtures/'; +var ext = '.geojson'; +var file; + +var files = [ + 'asia', 'trapezoid-box', 'canada', 'horseshoe', 'hourglasses', 'overlap_y', + 'polygon_trapezoid_edge_overlap', 'touching_boxes', 'two_pointed_triangles', + 'hole_cut', 'overlapping_segments', 'overlap_loop', 'disjoint_boxes' +]; + +switch (mode) { + case 'multi': + file = 'multipolys.geojson'; + break; + case 'geo': + file = 'asia.geojson'; + break; + case 'states': + file = 'states_source.geojson'; + break; + case 'trapezoid': + file = 'trapezoid-box.geojson'; + break; + case 'canada': + file = 'canada.geojson'; + break; + case 'horseshoe': + file = 'horseshoe.geojson'; + break; + case 'hourglasses': + file = 'hourglasses.geojson'; + break; + case 'edge_overlap': + file = 'polygon_trapezoid_edge_overlap.geojson'; + break; + case 'touching_boxes': + file = 'touching_boxes.geojson'; + break; + case 'triangles': + file = 'two_pointed_triangles.geojson'; + break; + case 'holecut': + file = 'hole_cut.geojson'; + break; + case 'overlapping_segments': + file = 'overlapping_segments.geojson'; + break; + case 'overlap_loop': + file = 'overlap_loop.geojson'; + break; + case 'overlap_y': + file = 'overlap_y.geojson'; + break; + case 'overlap_two': + file = 'overlap_two.geojson'; + break; + case 'disjoint_boxes': + file = 'disjoint_boxes.geojson'; + break; + case 'polygons_edge_overlap': + file = 'polygons_edge_overlap.geojson'; + break; + case 'collapsed': + file = 'collapsed.geojson'; + break; + default: + file = 'hole_hole.geojson'; + break; +} + +console.log(mode); + + +var OPERATIONS = { + INTERSECTION: 0, + UNION: 1, + DIFFERENCE: 2, + XOR: 3 +}; + +var div = document.createElement('div'); +div.id = 'image-map'; +div.style.width = div.style.height = '100%'; +document.body.appendChild(div); + +// create the slippy map +var map = window.map = L.map('image-map', { + minZoom: 1, + maxZoom: 20, + center: [0, 0], + zoom: 2, + crs: mode === 'geo' ? L.CRS.EPSG4326 : L.extend({}, L.CRS.Simple, { + transformation: new L.Transformation(1/8, 0, -1/8, 0) + }), + editable: true +}); + +map.addControl(new L.NewPolygonControl({ + callback: map.editTools.startPolygon +})); +map.addControl(new L.Coordinates()); +map.addControl(new L.BooleanControl({ + callback: run, + clear: clear +})); + +var drawnItems = window.drawnItems = L.geoJson().addTo(map); + +function loadData(path) { + console.log(path); + xhr + .get(path) + .accept('json') + .end(function(e, r) { + if (!e) { + drawnItems.addData(JSON.parse(r.text)); + map.fitBounds(drawnItems.getBounds().pad(0.05), { animate: false }); + } + }); +} + +function clear() { + drawnItems.clearLayers(); + results.clearLayers(); +} + +var reader = new jsts.io.GeoJSONReader(); +var writer = new jsts.io.GeoJSONWriter(); + +function run (op) { + var layers = drawnItems.getLayers(); + if (layers.length < 2) return; + var subject = layers[0].toGeoJSON(); + var clipping = layers[1].toGeoJSON(); + + //console.log('input', subject, clipping, op); + + subject = JSON.parse(JSON.stringify(subject)); + clipping = JSON.parse(JSON.stringify(clipping)); + + var operation; + if (op === OPERATIONS.INTERSECTION) { + operation = martinez.intersection; + } else if (op === OPERATIONS.UNION) { + operation = martinez.union; + } else if (op === OPERATIONS.DIFFERENCE) { + operation = martinez.diff; + } else if (op === 5) { // B - A + operation = martinez.diff; + + var temp = subject; + subject = clipping; + clipping = temp; + } else { + operation = martinez.xor; + } + + console.time('martinez'); + var result = operation(subject.geometry.coordinates, clipping.geometry.coordinates); + console.timeEnd('martinez'); + + //if (op === OPERATIONS.UNION) result = result[0]; + console.log('result', result); + // console.log(JSON.stringify(result)) + results.clearLayers(); + + if (result !== null) { + results.addData({ + 'type': 'Feature', + 'geometry': { + 'type': 'MultiPolygon', + 'coordinates': result + } + }); + + setTimeout(function() { + console.time('jsts'); + var s = reader.read(subject); + var c = reader.read(clipping); + var res; + if (op === OPERATIONS.INTERSECTION) { + res = s.geometry.intersection(c.geometry); + } else if (op === OPERATIONS.UNION) { + res = s.geometry.union(c.geometry); + } else if (op === OPERATIONS.DIFFERENCE) { + res = s.geometry.difference(c.geometry); + } else { + res = s.geometry.symDifference(c.geometry); + } + res = writer.write(res); + console.timeEnd('jsts'); + console.log(res); + }, 500); + } +} + +//drawnItems.addData(oneInside); +//drawnItems.addData(twoPointedTriangles); +//drawnItems.addData(selfIntersecting); +//drawnItems.addData(holes); +//drawnItems.addData(data); + +map.on('editable:created', function(evt) { + drawnItems.addLayer(evt.layer); + evt.layer.on('click', function(e) { + if ((e.originalEvent.ctrlKey || e.originalEvent.metaKey) && this.editEnabled()) { + this.editor.newHole(e.latlng); + } + }); +}); + +var results = window.results = L.geoJson(null, { + style: function(feature) { + return { + color: 'red', + weight: 1 + }; + } +}).addTo(map); + +loadData(path + file); -L.NewPolygonControl = L.EditControl.extend({ - options: { - position: 'topleft', - kind: 'polygon', - html: '▰' - } +},{"../../src/index":20,"./booleanopcontrol":1,"./coordinates":2,"./polygoncontrol":4,"superagent":7}],4:[function(require,module,exports){ +L.EditControl = L.Control.extend({ + + options: { + position: 'topleft', + callback: null, + kind: '', + html: '' + }, + + onAdd: function (map) { + var container = L.DomUtil.create('div', 'leaflet-control leaflet-bar'), + link = L.DomUtil.create('a', '', container); + + link.href = '#'; + link.title = 'Create a new ' + this.options.kind; + link.innerHTML = this.options.html; + L.DomEvent.on(link, 'click', L.DomEvent.stop) + .on(link, 'click', function () { + window.LAYER = this.options.callback.call(map.editTools); + }, this); + + return container; + } + +}); + +L.NewPolygonControl = L.EditControl.extend({ + options: { + position: 'topleft', + kind: 'polygon', + html: '▰' + } }); },{}],5:[function(require,module,exports){ -'use strict'; - -var martinez = require('./src/index'); - -module.exports = { - union: martinez.union, - diff: martinez.diff, - xor: martinez.xor, - intersection: martinez.intersection -}; +/** + * avl v1.4.1 + * Fast AVL tree for Node and browser + * + * @author Alexander Milevski + * @license MIT + * @preserve + */ -},{"./src/index":21}],6:[function(require,module,exports){ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - (global.avl = factory()); + (global.AVLTree = factory()); }(this, (function () { 'use strict'; /** @@ -960,7 +960,7 @@ AVLTree.prototype.remove = function remove (key) { while (min.left || min.right) { while (min.left) { min = min.left; } - node.key = min.key; + node.key= min.key; node.data = min.data; if (min.right) { node = min; @@ -968,22 +968,20 @@ AVLTree.prototype.remove = function remove (key) { } } - node.key = min.key; + node.key= min.key; node.data = min.data; node = min; } var parent = node.parent; - var pp = node; + var pp = node; var newRoot; while (parent) { if (parent.left === pp) { parent.balanceFactor -= 1; } - else { parent.balanceFactor += 1; } + else { parent.balanceFactor += 1; } - - if (parent.balanceFactor === -2) { - if (!parent.right) { parent.balanceFactor += 1; break; } + if (parent.balanceFactor < -1) { // inlined //var newRoot = rightBalance(parent); if (parent.right.balanceFactor === 1) { rotateRight(parent.right); } @@ -991,8 +989,7 @@ AVLTree.prototype.remove = function remove (key) { if (parent === this$1._root) { this$1._root = newRoot; } parent = newRoot; - } else if (parent.balanceFactor === 2) { - if (!parent.right) { parent.balanceFactor += 1; break; } + } else if (parent.balanceFactor > 1) { // inlined // var newRoot = leftBalance(parent); if (parent.left.balanceFactor === -1) { rotateLeft(parent.left); } @@ -1060,12 +1057,14 @@ AVLTree.prototype.toString = function toString (printNode) { Object.defineProperties( AVLTree.prototype, prototypeAccessors ); +AVLTree.default = AVLTree; + return AVLTree; }))); -},{}],7:[function(require,module,exports){ +},{}],6:[function(require,module,exports){ /** * Expose `Emitter`. @@ -1230,7 +1229,7 @@ Emitter.prototype.hasListeners = function(event){ return !! this.listeners(event).length; }; -},{}],8:[function(require,module,exports){ +},{}],7:[function(require,module,exports){ /** * Root reference for iframes. */ @@ -2208,7 +2207,7 @@ request.put = function(url, data, fn){ return req; }; -},{"./is-object":9,"./request":11,"./request-base":10,"emitter":7}],9:[function(require,module,exports){ +},{"./is-object":8,"./request":10,"./request-base":9,"emitter":6}],8:[function(require,module,exports){ /** * Check if `obj` is an object. * @@ -2223,7 +2222,7 @@ function isObject(obj) { module.exports = isObject; -},{}],10:[function(require,module,exports){ +},{}],9:[function(require,module,exports){ /** * Module of mixed-in functions shared between node and client code */ @@ -2597,7 +2596,7 @@ exports.send = function(data){ return this; }; -},{"./is-object":9}],11:[function(require,module,exports){ +},{"./is-object":8}],10:[function(require,module,exports){ // The node and browser modules expose versions of this with the // appropriate constructor function bound as first argument /** @@ -2631,10 +2630,11 @@ function request(RequestConstructor, method, url) { module.exports = request; -},{}],12:[function(require,module,exports){ +},{}],11:[function(require,module,exports){ 'use strict'; module.exports = TinyQueue; +module.exports.default = TinyQueue; function TinyQueue(data, compare) { if (!(this instanceof TinyQueue)) return new TinyQueue(data, compare); @@ -2643,7 +2643,9 @@ function TinyQueue(data, compare) { this.length = this.data.length; this.compare = compare || defaultCompare; - if (data) for (var i = Math.floor(this.length / 2); i >= 0; i--) this._down(i); + if (this.length > 0) { + for (var i = (this.length >> 1) - 1; i >= 0; i--) this._down(i); + } } function defaultCompare(a, b) { @@ -2659,11 +2661,17 @@ TinyQueue.prototype = { }, pop: function () { + if (this.length === 0) return undefined; + var top = this.data[0]; - this.data[0] = this.data[this.length - 1]; this.length--; + + if (this.length > 0) { + this.data[0] = this.data[this.length]; + this._down(0); + } this.data.pop(); - this._down(0); + return top; }, @@ -2672,1139 +2680,1139 @@ TinyQueue.prototype = { }, _up: function (pos) { - var data = this.data, - compare = this.compare; + var data = this.data; + var compare = this.compare; + var item = data[pos]; while (pos > 0) { - var parent = Math.floor((pos - 1) / 2); - if (compare(data[pos], data[parent]) < 0) { - swap(data, parent, pos); - pos = parent; - - } else break; + var parent = (pos - 1) >> 1; + var current = data[parent]; + if (compare(item, current) >= 0) break; + data[pos] = current; + pos = parent; } + + data[pos] = item; }, _down: function (pos) { - var data = this.data, - compare = this.compare, - len = this.length; - - while (true) { - var left = 2 * pos + 1, - right = left + 1, - min = pos; - - if (left < len && compare(data[left], data[min]) < 0) min = left; - if (right < len && compare(data[right], data[min]) < 0) min = right; - - if (min === pos) return; - - swap(data, min, pos); - pos = min; + var data = this.data; + var compare = this.compare; + var halfLength = this.length >> 1; + var item = data[pos]; + + while (pos < halfLength) { + var left = (pos << 1) + 1; + var right = left + 1; + var best = data[left]; + + if (right < this.length && compare(data[right], best) < 0) { + left = right; + best = data[right]; + } + if (compare(best, item) >= 0) break; + + data[pos] = best; + pos = left; } + + data[pos] = item; } }; -function swap(data, i, j) { - var tmp = data[i]; - data[i] = data[j]; - data[j] = tmp; -} +},{}],12:[function(require,module,exports){ +'use strict'; + +var signedArea = require('./signed_area'); +// var equals = require('./equals'); + +/** + * @param {SweepEvent} e1 + * @param {SweepEvent} e2 + * @return {Number} + */ +module.exports = function compareEvents(e1, e2) { + var p1 = e1.point; + var p2 = e2.point; + + // Different x-coordinate + if (p1[0] > p2[0]) return 1; + if (p1[0] < p2[0]) return -1; + + // Different points, but same x-coordinate + // Event with lower y-coordinate is processed first + if (p1[1] !== p2[1]) return p1[1] > p2[1] ? 1 : -1; + + return specialCases(e1, e2, p1, p2); +}; + + +/* eslint-disable no-unused-vars */ +function specialCases(e1, e2, p1, p2) { + // Same coordinates, but one is a left endpoint and the other is + // a right endpoint. The right endpoint is processed first + if (e1.left !== e2.left) + return e1.left ? 1 : -1; + + // var p2 = e1.otherEvent.point, p3 = e2.otherEvent.point; + // var sa = (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1]) + // Same coordinates, both events + // are left endpoints or right endpoints. + // not collinear + if (signedArea(p1, e1.otherEvent.point, e2.otherEvent.point) !== 0) { + // the event associate to the bottom segment is processed first + return (!e1.isBelow(e2.otherEvent.point)) ? 1 : -1; + } + + return (!e1.isSubject && e2.isSubject) ? 1 : -1; +} +/* eslint-enable no-unused-vars */ -},{}],13:[function(require,module,exports){ -'use strict'; +},{"./signed_area":24}],13:[function(require,module,exports){ +'use strict'; + +var signedArea = require('./signed_area'); +var compareEvents = require('./compare_events'); +var equals = require('./equals'); + + +/** + * @param {SweepEvent} le1 + * @param {SweepEvent} le2 + * @return {Number} + */ +module.exports = function compareSegments(le1, le2) { + if (le1 === le2) return 0; + + // Segments are not collinear + if (signedArea(le1.point, le1.otherEvent.point, le2.point) !== 0 || + signedArea(le1.point, le1.otherEvent.point, le2.otherEvent.point) !== 0) { + + // If they share their left endpoint use the right endpoint to sort + if (equals(le1.point, le2.point)) return le1.isBelow(le2.otherEvent.point) ? -1 : 1; + + // Different left endpoint: use the left endpoint to sort + if (le1.point[0] === le2.point[0]) return le1.point[1] < le2.point[1] ? -1 : 1; + + // has the line segment associated to e1 been inserted + // into S after the line segment associated to e2 ? + if (compareEvents(le1, le2) === 1) return le2.isAbove(le1.point) ? -1 : 1; + + // The line segment associated to e2 has been inserted + // into S after the line segment associated to e1 + return le1.isBelow(le2.point) ? -1 : 1; + } + + if (le1.isSubject === le2.isSubject) { // same polygon + var p1 = le1.point, p2 = le2.point; + if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) { + p1 = le1.otherEvent.point; p2 = le2.otherEvent.point; + if (p1[0] === p2[0] && p1[1] === p2[1]) return 0; + else return le1.contourId > le2.contourId ? 1 : -1; + } + } else { // Segments are collinear, but belong to separate polygons + return le1.isSubject ? -1 : 1; + } + + return compareEvents(le1, le2) === 1 ? 1 : -1; +}; -var signedArea = require('./signed_area'); -// var equals = require('./equals'); +},{"./compare_events":12,"./equals":18,"./signed_area":24}],14:[function(require,module,exports){ +'use strict'; + +var edgeType = require('./edge_type'); +var operationType = require('./operation'); + +var INTERSECTION = operationType.INTERSECTION; +var UNION = operationType.UNION; +var DIFFERENCE = operationType.DIFFERENCE; +var XOR = operationType.XOR; + +/** + * @param {SweepEvent} event + * @param {SweepEvent} prev + * @param {Operation} operation + */ +module.exports = function computeFields(event, prev, operation) { + // compute inOut and otherInOut fields + if (prev === null) { + event.inOut = false; + event.otherInOut = true; + + // previous line segment in sweepline belongs to the same polygon + } else { + if (event.isSubject === prev.isSubject) { + event.inOut = !prev.inOut; + event.otherInOut = prev.otherInOut; + + // previous line segment in sweepline belongs to the clipping polygon + } else { + event.inOut = !prev.otherInOut; + event.otherInOut = prev.isVertical() ? !prev.inOut : prev.inOut; + } + + // compute prevInResult field + if (prev) { + event.prevInResult = (!inResult(prev, operation) || prev.isVertical()) ? + prev.prevInResult : prev; + } + } + + // check if the line segment belongs to the Boolean operation + event.inResult = inResult(event, operation); +}; + + +/* eslint-disable indent */ +function inResult(event, operation) { + switch (event.type) { + case edgeType.NORMAL: + switch (operation) { + case INTERSECTION: + return !event.otherInOut; + case UNION: + return event.otherInOut; + case DIFFERENCE: + // return (event.isSubject && !event.otherInOut) || + // (!event.isSubject && event.otherInOut); + return (event.isSubject && event.otherInOut) || + (!event.isSubject && !event.otherInOut); + case XOR: + return true; + } + break; + case edgeType.SAME_TRANSITION: + return operation === INTERSECTION || operation === UNION; + case edgeType.DIFFERENT_TRANSITION: + return operation === DIFFERENCE; + case edgeType.NON_CONTRIBUTING: + return false; + } + return false; +} +/* eslint-enable indent */ -/** - * @param {SweepEvent} e1 - * @param {SweepEvent} e2 - * @return {Number} - */ -module.exports = function compareEvents(e1, e2) { - var p1 = e1.point; - var p2 = e2.point; +},{"./edge_type":17,"./operation":21}],15:[function(require,module,exports){ +'use strict'; + +// var equals = require('./equals'); +var compareEvents = require('./compare_events'); +var operationType = require('./operation'); + +/** + * @param {Array.} sortedEvents + * @return {Array.} + */ +function orderEvents(sortedEvents) { + var event, i, len, tmp; + var resultEvents = []; + for (i = 0, len = sortedEvents.length; i < len; i++) { + event = sortedEvents[i]; + if ((event.left && event.inResult) || + (!event.left && event.otherEvent.inResult)) { + resultEvents.push(event); + } + } + // Due to overlapping edges the resultEvents array can be not wholly sorted + var sorted = false; + while (!sorted) { + sorted = true; + for (i = 0, len = resultEvents.length; i < len; i++) { + if ((i + 1) < len && + compareEvents(resultEvents[i], resultEvents[i + 1]) === 1) { + tmp = resultEvents[i]; + resultEvents[i] = resultEvents[i + 1]; + resultEvents[i + 1] = tmp; + sorted = false; + } + } + } + + for (i = 0, len = resultEvents.length; i < len; i++) { + event = resultEvents[i]; + event.pos = i; + + if (!event.left) { + tmp = event.pos; + event.pos = event.otherEvent.pos; + event.otherEvent.pos = tmp; + } + } + + return resultEvents; +} + + +/** + * @param {Number} pos + * @param {Array.} resultEvents + * @param {Object>} processed + * @return {Number} + */ +function nextPos(pos, resultEvents, processed, origIndex) { + var newPos = pos + 1; + var length = resultEvents.length; + if (newPos > length - 1) return pos - 1; + var p = resultEvents[pos].point; + var p1 = resultEvents[newPos].point; + + + // while in range and not the current one by value + while (newPos < length && p1[0] === p[0] && p1[1] === p[1]) { + if (!processed[newPos]) { + return newPos; + } else { + newPos++; + } + p1 = resultEvents[newPos].point; + } + + newPos = pos - 1; + + while (processed[newPos] && newPos >= origIndex) { + newPos--; + } + return newPos; +} + + +/** + * @param {Array.} sortedEvents + * @return {Array.<*>} polygons + */ +module.exports = function connectEdges(sortedEvents, operation) { + var i, len; + var resultEvents = orderEvents(sortedEvents); + + // "false"-filled array + var processed = {}; + var result = []; + var event; + + for (i = 0, len = resultEvents.length; i < len; i++) { + if (processed[i]) continue; + var contour = [[]]; + + if (!resultEvents[i].isExteriorRing) { + if (result.length === 0) { + result.push([[contour]]); + } else { + result[result.length - 1].push(contour[0]); + } + } else if (operation === operationType.DIFFERENCE && !resultEvents[i].isSubject && result.length > 1) { + result[result.length - 1].push(contour[0]); + } else { + result.push(contour); + } + + var ringId = result.length - 1; + var pos = i; + + var initial = resultEvents[i].point; + contour[0].push(initial); + + while (pos >= i) { + event = resultEvents[pos]; + processed[pos] = true; + + if (event.left) { + event.resultInOut = false; + event.contourId = ringId; + } else { + event.otherEvent.resultInOut = true; + event.otherEvent.contourId = ringId; + } + + pos = event.pos; + processed[pos] = true; + contour[0].push(resultEvents[pos].point); + pos = nextPos(pos, resultEvents, processed, i); + } + + pos = pos === -1 ? i : pos; + + event = resultEvents[pos]; + processed[pos] = processed[event.pos] = true; + event.otherEvent.resultInOut = true; + event.otherEvent.contourId = ringId; + } + + // for (i = 0, len = result.length; i < len; i++) { + // var polygon = result[i]; + // for (var j = 0, jj = polygon.length; j < jj; j++) { + // var polygonContour = polygon[j]; + // for (var k = 0, kk = polygonContour.length; k < kk; k++) { + // var coords = polygonContour[k]; + // if (typeof coords[0] !== 'number') { + // polygon.splice(j, 1); + // polygon.push(coords); + // } + // } + // } + // } + + // Handle if the result is a polygon (eg not multipoly) + // Commented it again, let's see what do we mean by that + // if (result.length === 1) result = result[0]; + return result; +}; - // Different x-coordinate - if (p1[0] > p2[0]) return 1; - if (p1[0] < p2[0]) return -1; +},{"./compare_events":12,"./operation":21}],16:[function(require,module,exports){ +'use strict'; + +var SweepEvent = require('./sweep_event'); +var equals = require('./equals'); +var compareEvents = require('./compare_events'); + +/** + * @param {SweepEvent} se + * @param {Array.} p + * @param {Queue} queue + * @return {Queue} + */ +module.exports = function divideSegment(se, p, queue) { + var r = new SweepEvent(p, false, se, se.isSubject); + var l = new SweepEvent(p, true, se.otherEvent, se.isSubject); + + if (equals(se.point, se.otherEvent.point)) { + console.warn('what is that, a collapsed segment?', se); + } + + r.contourId = l.contourId = se.contourId; + + // avoid a rounding error. The left event would be processed after the right event + if (compareEvents(l, se.otherEvent) > 0) { + se.otherEvent.left = true; + l.left = false; + } + + // avoid a rounding error. The left event would be processed after the right event + // if (compareEvents(se, r) > 0) {} + + se.otherEvent.otherEvent = l; + se.otherEvent = r; + + queue.push(l); + queue.push(r); + + return queue; +}; - // Different points, but same x-coordinate - // Event with lower y-coordinate is processed first - if (p1[1] !== p2[1]) return p1[1] > p2[1] ? 1 : -1; - - return specialCases(e1, e2, p1, p2); -}; - - -/* eslint-disable no-unused-vars */ -function specialCases(e1, e2, p1, p2) { - // Same coordinates, but one is a left endpoint and the other is - // a right endpoint. The right endpoint is processed first - if (e1.left !== e2.left) - return e1.left ? 1 : -1; - - // var p2 = e1.otherEvent.point, p3 = e2.otherEvent.point; - // var sa = (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1]) - // Same coordinates, both events - // are left endpoints or right endpoints. - // not collinear - if (signedArea(p1, e1.otherEvent.point, e2.otherEvent.point) !== 0) { - // the event associate to the bottom segment is processed first - return (!e1.isBelow(e2.otherEvent.point)) ? 1 : -1; - } - - return (!e1.isSubject && e2.isSubject) ? 1 : -1; -} -/* eslint-enable no-unused-vars */ - -},{"./signed_area":25}],14:[function(require,module,exports){ -'use strict'; - -var signedArea = require('./signed_area'); -var compareEvents = require('./compare_events'); -var equals = require('./equals'); - - -/** - * @param {SweepEvent} le1 - * @param {SweepEvent} le2 - * @return {Number} - */ -module.exports = function compareSegments(le1, le2) { - if (le1 === le2) return 0; - - // Segments are not collinear - if (signedArea(le1.point, le1.otherEvent.point, le2.point) !== 0 || - signedArea(le1.point, le1.otherEvent.point, le2.otherEvent.point) !== 0) { - - // If they share their left endpoint use the right endpoint to sort - if (equals(le1.point, le2.point)) return le1.isBelow(le2.otherEvent.point) ? -1 : 1; - - // Different left endpoint: use the left endpoint to sort - if (le1.point[0] === le2.point[0]) return le1.point[1] < le2.point[1] ? -1 : 1; - - // has the line segment associated to e1 been inserted - // into S after the line segment associated to e2 ? - if (compareEvents(le1, le2) === 1) return le2.isAbove(le1.point) ? -1 : 1; - - // The line segment associated to e2 has been inserted - // into S after the line segment associated to e1 - return le1.isBelow(le2.point) ? -1 : 1; - } - - if (le1.isSubject === le2.isSubject) { // same polygon - var p1 = le1.point, p2 = le2.point; - if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) { - p1 = le1.otherEvent.point; p2 = le2.otherEvent.point; - if (p1[0] === p2[0] && p1[1] === p2[1]) return 0; - else return le1.contourId > le2.contourId ? 1 : -1; - } - } else { // Segments are collinear, but belong to separate polygons - return le1.isSubject ? -1 : 1; - } - - return compareEvents(le1, le2) === 1 ? 1 : -1; -}; - -},{"./compare_events":13,"./equals":19,"./signed_area":25}],15:[function(require,module,exports){ -'use strict'; - -var edgeType = require('./edge_type'); -var operationType = require('./operation'); - -var INTERSECTION = operationType.INTERSECTION; -var UNION = operationType.UNION; -var DIFFERENCE = operationType.DIFFERENCE; -var XOR = operationType.XOR; - -/** - * @param {SweepEvent} event - * @param {SweepEvent} prev - * @param {Operation} operation - */ -module.exports = function computeFields(event, prev, operation) { - // compute inOut and otherInOut fields - if (prev === null) { - event.inOut = false; - event.otherInOut = true; - - // previous line segment in sweepline belongs to the same polygon - } else { - if (event.isSubject === prev.isSubject) { - event.inOut = !prev.inOut; - event.otherInOut = prev.otherInOut; - - // previous line segment in sweepline belongs to the clipping polygon - } else { - event.inOut = !prev.otherInOut; - event.otherInOut = prev.isVertical() ? !prev.inOut : prev.inOut; - } - - // compute prevInResult field - if (prev) { - event.prevInResult = (!inResult(prev, operation) || prev.isVertical()) ? - prev.prevInResult : prev; - } - } - - // check if the line segment belongs to the Boolean operation - event.inResult = inResult(event, operation); -}; - - -/* eslint-disable indent */ -function inResult(event, operation) { - switch (event.type) { - case edgeType.NORMAL: - switch (operation) { - case INTERSECTION: - return !event.otherInOut; - case UNION: - return event.otherInOut; - case DIFFERENCE: - // return (event.isSubject && !event.otherInOut) || - // (!event.isSubject && event.otherInOut); - return (event.isSubject && event.otherInOut) || - (!event.isSubject && !event.otherInOut); - case XOR: - return true; - } - break; - case edgeType.SAME_TRANSITION: - return operation === INTERSECTION || operation === UNION; - case edgeType.DIFFERENT_TRANSITION: - return operation === DIFFERENCE; - case edgeType.NON_CONTRIBUTING: - return false; - } - return false; -} -/* eslint-enable indent */ - -},{"./edge_type":18,"./operation":22}],16:[function(require,module,exports){ -'use strict'; - -// var equals = require('./equals'); -var compareEvents = require('./compare_events'); -var operationType = require('./operation'); - -/** - * @param {Array.} sortedEvents - * @return {Array.} - */ -function orderEvents(sortedEvents) { - var event, i, len, tmp; - var resultEvents = []; - for (i = 0, len = sortedEvents.length; i < len; i++) { - event = sortedEvents[i]; - if ((event.left && event.inResult) || - (!event.left && event.otherEvent.inResult)) { - resultEvents.push(event); - } - } - // Due to overlapping edges the resultEvents array can be not wholly sorted - var sorted = false; - while (!sorted) { - sorted = true; - for (i = 0, len = resultEvents.length; i < len; i++) { - if ((i + 1) < len && - compareEvents(resultEvents[i], resultEvents[i + 1]) === 1) { - tmp = resultEvents[i]; - resultEvents[i] = resultEvents[i + 1]; - resultEvents[i + 1] = tmp; - sorted = false; - } - } - } - - for (i = 0, len = resultEvents.length; i < len; i++) { - event = resultEvents[i]; - event.pos = i; - - if (!event.left) { - tmp = event.pos; - event.pos = event.otherEvent.pos; - event.otherEvent.pos = tmp; - } - } - - return resultEvents; -} - - -/** - * @param {Number} pos - * @param {Array.} resultEvents - * @param {Object>} processed - * @return {Number} - */ -function nextPos(pos, resultEvents, processed, origIndex) { - var newPos = pos + 1; - var length = resultEvents.length; - if (newPos > length - 1) return pos - 1; - var p = resultEvents[pos].point; - var p1 = resultEvents[newPos].point; - - - // while in range and not the current one by value - while (newPos < length && p1[0] === p[0] && p1[1] === p[1]) { - if (!processed[newPos]) { - return newPos; - } else { - newPos++; - } - p1 = resultEvents[newPos].point; - } - - newPos = pos - 1; - - while (processed[newPos] && newPos >= origIndex) { - newPos--; - } - return newPos; -} - - -/** - * @param {Array.} sortedEvents - * @return {Array.<*>} polygons - */ -module.exports = function connectEdges(sortedEvents, operation) { - var i, len; - var resultEvents = orderEvents(sortedEvents); - - // "false"-filled array - var processed = {}; - var result = []; - var event; - - for (i = 0, len = resultEvents.length; i < len; i++) { - if (processed[i]) continue; - var contour = [[]]; - - if (!resultEvents[i].isExteriorRing) { - if (result.length === 0) { - result.push([[contour]]); - } else { - result[result.length - 1].push(contour[0]); - } - } else if (operation === operationType.DIFFERENCE && !resultEvents[i].isSubject && result.length > 1) { - result[result.length - 1].push(contour[0]); - } else { - result.push(contour); - } - - var ringId = result.length - 1; - var pos = i; - - var initial = resultEvents[i].point; - contour[0].push(initial); - - while (pos >= i) { - event = resultEvents[pos]; - processed[pos] = true; - - if (event.left) { - event.resultInOut = false; - event.contourId = ringId; - } else { - event.otherEvent.resultInOut = true; - event.otherEvent.contourId = ringId; - } - - pos = event.pos; - processed[pos] = true; - contour[0].push(resultEvents[pos].point); - pos = nextPos(pos, resultEvents, processed, i); - } - - pos = pos === -1 ? i : pos; - - event = resultEvents[pos]; - processed[pos] = processed[event.pos] = true; - event.otherEvent.resultInOut = true; - event.otherEvent.contourId = ringId; - } - - // for (i = 0, len = result.length; i < len; i++) { - // var polygon = result[i]; - // for (var j = 0, jj = polygon.length; j < jj; j++) { - // var polygonContour = polygon[j]; - // for (var k = 0, kk = polygonContour.length; k < kk; k++) { - // var coords = polygonContour[k]; - // if (typeof coords[0] !== 'number') { - // polygon.splice(j, 1); - // polygon.push(coords); - // } - // } - // } - // } - - // Handle if the result is a polygon (eg not multipoly) - // Commented it again, let's see what do we mean by that - // if (result.length === 1) result = result[0]; - return result; -}; - -},{"./compare_events":13,"./operation":22}],17:[function(require,module,exports){ -'use strict'; - -var SweepEvent = require('./sweep_event'); -var equals = require('./equals'); -var compareEvents = require('./compare_events'); - -/** - * @param {SweepEvent} se - * @param {Array.} p - * @param {Queue} queue - * @return {Queue} - */ -module.exports = function divideSegment(se, p, queue) { - var r = new SweepEvent(p, false, se, se.isSubject); - var l = new SweepEvent(p, true, se.otherEvent, se.isSubject); - - if (equals(se.point, se.otherEvent.point)) { - console.warn('what is that, a collapsed segment?', se); - } - - r.contourId = l.contourId = se.contourId; - - // avoid a rounding error. The left event would be processed after the right event - if (compareEvents(l, se.otherEvent) > 0) { - se.otherEvent.left = true; - l.left = false; - } - - // avoid a rounding error. The left event would be processed after the right event - // if (compareEvents(se, r) > 0) {} - - se.otherEvent.otherEvent = l; - se.otherEvent = r; - - queue.push(l); - queue.push(r); - - return queue; -}; - -},{"./compare_events":13,"./equals":19,"./sweep_event":27}],18:[function(require,module,exports){ -'use strict'; - -module.exports = { - NORMAL: 0, - NON_CONTRIBUTING: 1, - SAME_TRANSITION: 2, - DIFFERENT_TRANSITION: 3 -}; - -},{}],19:[function(require,module,exports){ -'use strict'; - -// var EPSILON = 1e-9; -// var abs = Math.abs; - -module.exports = function equals(p1, p2) { - if (p1[0] === p2[0]) { - if (p1[1] === p2[1]) { - return true; - } else { - return false; - } - } - return false; -}; - -// TODO https://github.com/w8r/martinez/issues/6#issuecomment-262847164 -// Precision problem. -// -// module.exports = function equals(p1, p2) { -// return abs(p1[0] - p2[0]) <= EPSILON && abs(p1[1] - p2[1]) <= EPSILON; -// }; - -},{}],20:[function(require,module,exports){ -'use strict'; - -var Queue = require('tinyqueue'); -var SweepEvent = require('./sweep_event'); -var compareEvents = require('./compare_events'); - -var max = Math.max; -var min = Math.min; - -var contourId = 0; - - -function processPolygon(contourOrHole, isSubject, depth, Q, bbox, isExteriorRing) { - var i, len, s1, s2, e1, e2; - for (i = 0, len = contourOrHole.length - 1; i < len; i++) { - s1 = contourOrHole[i]; - s2 = contourOrHole[i + 1]; - e1 = new SweepEvent(s1, false, undefined, isSubject); - e2 = new SweepEvent(s2, false, e1, isSubject); - e1.otherEvent = e2; - - if (s1[0] === s2[0] && s1[1] === s2[1]) { - continue; // skip collapsed edges, or it breaks - } - - e1.contourId = e2.contourId = depth; - if (!isExteriorRing) { - e1.isExteriorRing = false; - e2.isExteriorRing = false; - } - if (compareEvents(e1, e2) > 0) { - e2.left = true; - } else { - e1.left = true; - } - - var x = s1[0], y = s1[1]; - bbox[0] = min(bbox[0], x); - bbox[1] = min(bbox[1], y); - bbox[2] = max(bbox[2], x); - bbox[3] = max(bbox[3], y); - - // Pushing it so the queue is sorted from left to right, - // with object on the left having the highest priority. - Q.push(e1); - Q.push(e2); - } -} - - -module.exports = function fillQueue(subject, clipping, sbbox, cbbox) { - var eventQueue = new Queue(null, compareEvents); - var polygonSet, isExteriorRing, i, ii, j, jj; //, k, kk; - - for (i = 0, ii = subject.length; i < ii; i++) { - polygonSet = subject[i]; - for (j = 0, jj = polygonSet.length; j < jj; j++) { - isExteriorRing = j === 0; - if (isExteriorRing) contourId++; - processPolygon(polygonSet[j], true, contourId, eventQueue, sbbox, isExteriorRing); - } - } - - for (i = 0, ii = clipping.length; i < ii; i++) { - polygonSet = clipping[i]; - for (j = 0, jj = polygonSet.length; j < jj; j++) { - isExteriorRing = j === 0; - if (isExteriorRing) contourId++; - processPolygon(polygonSet[j], false, contourId, eventQueue, cbbox, isExteriorRing); - } - } - - return eventQueue; -}; - -},{"./compare_events":13,"./sweep_event":27,"tinyqueue":12}],21:[function(require,module,exports){ -'use strict'; - -var subdivideSegments = require('./subdivide_segments'); -var connectEdges = require('./connect_edges'); -var fillQueue = require('./fill_queue'); -var operations = require('./operation'); - -var EMPTY = []; - - -function trivialOperation(subject, clipping, operation) { - var result = null; - if (subject.length * clipping.length === 0) { - if (operation === operations.INTERSECTION) { - result = EMPTY; - } else if (operation === operations.DIFFERENCE) { - result = subject; - } else if (operation === operations.UNION || - operation === operations.XOR) { - result = (subject.length === 0) ? clipping : subject; - } - } - return result; -} - - -function compareBBoxes(subject, clipping, sbbox, cbbox, operation) { - var result = null; - if (sbbox[0] > cbbox[2] || - cbbox[0] > sbbox[2] || - sbbox[1] > cbbox[3] || - cbbox[1] > sbbox[3]) { - if (operation === operations.INTERSECTION) { - result = EMPTY; - } else if (operation === operations.DIFFERENCE) { - result = subject; - } else if (operation === operations.UNION || - operation === operations.XOR) { - result = subject.concat(clipping); - } - } - return result; -} - - -function boolean(subject, clipping, operation) { - if (typeof subject[0][0][0] === 'number') { - subject = [subject]; - } - if (typeof clipping[0][0][0] === 'number') { - clipping = [clipping]; - } - var trivial = trivialOperation(subject, clipping, operation); - if (trivial) { - return trivial === EMPTY ? null : trivial; - } - var sbbox = [Infinity, Infinity, -Infinity, -Infinity]; - var cbbox = [Infinity, Infinity, -Infinity, -Infinity]; - - //console.time('fill queue'); - var eventQueue = fillQueue(subject, clipping, sbbox, cbbox); - //console.timeEnd('fill queue'); - - trivial = compareBBoxes(subject, clipping, sbbox, cbbox, operation); - if (trivial) { - return trivial === EMPTY ? null : trivial; - } - //console.time('subdivide edges'); - var sortedEvents = subdivideSegments(eventQueue, subject, clipping, sbbox, cbbox, operation); - //console.timeEnd('subdivide edges'); - - //console.time('connect vertices'); - var result = connectEdges(sortedEvents, operation); - //console.timeEnd('connect vertices'); - return result; -} - -boolean.union = function (subject, clipping) { - return boolean(subject, clipping, operations.UNION); -}; - - -boolean.diff = function (subject, clipping) { - return boolean(subject, clipping, operations.DIFFERENCE); -}; - - -boolean.xor = function (subject, clipping) { - return boolean(subject, clipping, operations.XOR); -}; - - -boolean.intersection = function (subject, clipping) { - return boolean(subject, clipping, operations.INTERSECTION); -}; - - -/** - * @enum {Number} - */ -boolean.operations = operations; - - -module.exports = boolean; -module.exports.default = boolean; - -},{"./connect_edges":16,"./fill_queue":20,"./operation":22,"./subdivide_segments":26}],22:[function(require,module,exports){ -'use strict'; - -module.exports = { - INTERSECTION: 0, - UNION: 1, - DIFFERENCE: 2, - XOR: 3 -}; - -},{}],23:[function(require,module,exports){ -'use strict'; - -var divideSegment = require('./divide_segment'); -var intersection = require('./segment_intersection'); -var equals = require('./equals'); -var compareEvents = require('./compare_events'); -var edgeType = require('./edge_type'); - -/** - * @param {SweepEvent} se1 - * @param {SweepEvent} se2 - * @param {Queue} queue - * @return {Number} - */ -module.exports = function possibleIntersection(se1, se2, queue) { - // that disallows self-intersecting polygons, - // did cost us half a day, so I'll leave it - // out of respect - // if (se1.isSubject === se2.isSubject) return; - var inter = intersection( - se1.point, se1.otherEvent.point, - se2.point, se2.otherEvent.point - ); - - var nintersections = inter ? inter.length : 0; - if (nintersections === 0) return 0; // no intersection - - // the line segments intersect at an endpoint of both line segments - if ((nintersections === 1) && - (equals(se1.point, se2.point) || - equals(se1.otherEvent.point, se2.otherEvent.point))) { - return 0; - } - - if (nintersections === 2 && se1.isSubject === se2.isSubject) { - // if(se1.contourId === se2.contourId){ - // console.warn('Edges of the same polygon overlap', - // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point); - // } - //throw new Error('Edges of the same polygon overlap'); - return 0; - } - - // The line segments associated to se1 and se2 intersect - if (nintersections === 1) { - - // if the intersection point is not an endpoint of se1 - if (!equals(se1.point, inter[0]) && !equals(se1.otherEvent.point, inter[0])) { - divideSegment(se1, inter[0], queue); - } - - // if the intersection point is not an endpoint of se2 - if (!equals(se2.point, inter[0]) && !equals(se2.otherEvent.point, inter[0])) { - divideSegment(se2, inter[0], queue); - } - return 1; - } - - // The line segments associated to se1 and se2 overlap - var events = []; - var leftCoincide = false; - var rightCoincide = false; - - if (equals(se1.point, se2.point)) { - leftCoincide = true; // linked - } else if (compareEvents(se1, se2) === 1) { - events.push(se2, se1); - } else { - events.push(se1, se2); - } - - if (equals(se1.otherEvent.point, se2.otherEvent.point)) { - rightCoincide = true; - } else if (compareEvents(se1.otherEvent, se2.otherEvent) === 1) { - events.push(se2.otherEvent, se1.otherEvent); - } else { - events.push(se1.otherEvent, se2.otherEvent); - } - - if ((leftCoincide && rightCoincide) || leftCoincide) { - // both line segments are equal or share the left endpoint - se2.type = edgeType.NON_CONTRIBUTING; - se1.type = (se2.inOut === se1.inOut) ? - edgeType.SAME_TRANSITION : - edgeType.DIFFERENT_TRANSITION; - - if (leftCoincide && !rightCoincide) { - // honestly no idea, but changing events selection from [2, 1] - // to [0, 1] fixes the overlapping self-intersecting polygons issue - divideSegment(events[1].otherEvent, events[0].point, queue); - } - return 2; - } - - // the line segments share the right endpoint - if (rightCoincide) { - divideSegment(events[0], events[1].point, queue); - return 3; - } - - // no line segment includes totally the other one - if (events[0] !== events[3].otherEvent) { - divideSegment(events[0], events[1].point, queue); - divideSegment(events[1], events[2].point, queue); - return 3; - } - - // one line segment includes the other one - divideSegment(events[0], events[1].point, queue); - divideSegment(events[3].otherEvent, events[2].point, queue); - - return 3; -}; - -},{"./compare_events":13,"./divide_segment":17,"./edge_type":18,"./equals":19,"./segment_intersection":24}],24:[function(require,module,exports){ -'use strict'; - -var EPSILON = 1e-9; - -/** - * Finds the magnitude of the cross product of two vectors (if we pretend - * they're in three dimensions) - * - * @param {Object} a First vector - * @param {Object} b Second vector - * @private - * @returns {Number} The magnitude of the cross product - */ -function crossProduct(a, b) { - return a[0] * b[1] - a[1] * b[0]; -} - -/** - * Finds the dot product of two vectors. - * - * @param {Object} a First vector - * @param {Object} b Second vector - * @private - * @returns {Number} The dot product - */ -function dotProduct(a, b) { - return a[0] * b[0] + a[1] * b[1]; -} - -/** - * Finds the intersection (if any) between two line segments a and b, given the - * line segments' end points a1, a2 and b1, b2. - * - * This algorithm is based on Schneider and Eberly. - * http://www.cimec.org.ar/~ncalvo/Schneider_Eberly.pdf - * Page 244. - * - * @param {Array.} a1 point of first line - * @param {Array.} a2 point of first line - * @param {Array.} b1 point of second line - * @param {Array.} b2 point of second line - * @param {Boolean=} noEndpointTouch whether to skip single touchpoints - * (meaning connected segments) as - * intersections - * @returns {Array.>|Null} If the lines intersect, the point of - * intersection. If they overlap, the two end points of the overlapping segment. - * Otherwise, null. - */ -module.exports = function (a1, a2, b1, b2, noEndpointTouch) { - // The algorithm expects our lines in the form P + sd, where P is a point, - // s is on the interval [0, 1], and d is a vector. - // We are passed two points. P can be the first point of each pair. The - // vector, then, could be thought of as the distance (in x and y components) - // from the first point to the second point. - // So first, let's make our vectors: - var va = [a2[0] - a1[0], a2[1] - a1[1]]; - var vb = [b2[0] - b1[0], b2[1] - b1[1]]; - // We also define a function to convert back to regular point form: - - /* eslint-disable arrow-body-style */ - - function toPoint(p, s, d) { - return [ - p[0] + s * d[0], - p[1] + s * d[1] - ]; - } - - /* eslint-enable arrow-body-style */ - - // The rest is pretty much a straight port of the algorithm. - var e = [b1[0] - a1[0], b1[1] - a1[1]]; - var kross = crossProduct(va, vb); - var sqrKross = kross * kross; - var sqrLenA = dotProduct(va, va); - var sqrLenB = dotProduct(vb, vb); - - // Check for line intersection. This works because of the properties of the - // cross product -- specifically, two vectors are parallel if and only if the - // cross product is the 0 vector. The full calculation involves relative error - // to account for possible very small line segments. See Schneider & Eberly - // for details. - if (sqrKross > EPSILON * sqrLenA * sqrLenB) { - // If they're not parallel, then (because these are line segments) they - // still might not actually intersect. This code checks that the - // intersection point of the lines is actually on both line segments. - var s = crossProduct(e, vb) / kross; - if (s < 0 || s > 1) { - // not on line segment a - return null; - } - var t = crossProduct(e, va) / kross; - if (t < 0 || t > 1) { - // not on line segment b - return null; - } - return noEndpointTouch ? null : [toPoint(a1, s, va)]; - } - - // If we've reached this point, then the lines are either parallel or the - // same, but the segments could overlap partially or fully, or not at all. - // So we need to find the overlap, if any. To do that, we can use e, which is - // the (vector) difference between the two initial points. If this is parallel - // with the line itself, then the two lines are the same line, and there will - // be overlap. - var sqrLenE = dotProduct(e, e); - kross = crossProduct(e, va); - sqrKross = kross * kross; - - if (sqrKross > EPSILON * sqrLenA * sqrLenE) { - // Lines are just parallel, not the same. No overlap. - return null; - } - - var sa = dotProduct(va, e) / sqrLenA; - var sb = sa + dotProduct(va, vb) / sqrLenA; - var smin = Math.min(sa, sb); - var smax = Math.max(sa, sb); - - // this is, essentially, the FindIntersection acting on floats from - // Schneider & Eberly, just inlined into this function. - if (smin <= 1 && smax >= 0) { - - // overlap on an end point - if (smin === 1) { - return noEndpointTouch ? null : [toPoint(a1, smin > 0 ? smin : 0, va)]; - } - - if (smax === 0) { - return noEndpointTouch ? null : [toPoint(a1, smax < 1 ? smax : 1, va)]; - } - - if (noEndpointTouch && smin === 0 && smax === 1) return null; - - // There's overlap on a segment -- two points of intersection. Return both. - return [ - toPoint(a1, smin > 0 ? smin : 0, va), - toPoint(a1, smax < 1 ? smax : 1, va), - ]; - } - - return null; -}; - -},{}],25:[function(require,module,exports){ -'use strict'; - -/** - * Signed area of the triangle (p0, p1, p2) - * @param {Array.} p0 - * @param {Array.} p1 - * @param {Array.} p2 - * @return {Number} - */ -module.exports = function signedArea(p0, p1, p2) { - return (p0[0] - p2[0]) * (p1[1] - p2[1]) - (p1[0] - p2[0]) * (p0[1] - p2[1]); -}; - -},{}],26:[function(require,module,exports){ -'use strict'; - -var Tree = require('avl'); -var computeFields = require('./compute_fields'); -var possibleIntersection = require('./possible_intersection'); -var compareSegments = require('./compare_segments'); -var operations = require('./operation'); - - -module.exports = function subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation) { - var sweepLine = new Tree(compareSegments); - var sortedEvents = []; - - var rightbound = Math.min(sbbox[2], cbbox[2]); - - var prev, next, begin; - - var INTERSECTION = operations.INTERSECTION; - var DIFFERENCE = operations.DIFFERENCE; - - while (eventQueue.length) { - var event = eventQueue.pop(); - sortedEvents.push(event); - - // optimization by bboxes for intersection and difference goes here - if ((operation === INTERSECTION && event.point[0] > rightbound) || - (operation === DIFFERENCE && event.point[0] > sbbox[2])) { - break; - } - - if (event.left) { - next = prev = sweepLine.insert(event); - begin = sweepLine.minNode(); - - if (prev !== begin) prev = sweepLine.prev(prev); - else prev = null; - - next = sweepLine.next(next); - - var prevEvent = prev ? prev.key : null; - var prevprevEvent; - computeFields(event, prevEvent, operation); - if (next) { - if (possibleIntersection(event, next.key, eventQueue) === 2) { - computeFields(event, prevEvent, operation); - computeFields(event, next.key, operation); - } - } - - if (prev) { - if (possibleIntersection(prev.key, event, eventQueue) === 2) { - var prevprev = prev; - if (prevprev !== begin) prevprev = sweepLine.prev(prevprev); - else prevprev = null; - - prevprevEvent = prevprev ? prevprev.key : null; - computeFields(prevEvent, prevprevEvent, operation); - computeFields(event, prevEvent, operation); - } - } - } else { - event = event.otherEvent; - next = prev = sweepLine.find(event); - - if (prev && next) { - - if (prev !== begin) prev = sweepLine.prev(prev); - else prev = null; - - next = sweepLine.next(next); - sweepLine.remove(event); - - if (next && prev) { - possibleIntersection(prev.key, next.key, eventQueue); - } - } - } - } - return sortedEvents; -}; - -},{"./compare_segments":14,"./compute_fields":15,"./operation":22,"./possible_intersection":23,"avl":6}],27:[function(require,module,exports){ -'use strict'; - -//var signedArea = require('./signed_area'); -var EdgeType = require('./edge_type'); - -/** - * Sweepline event - * - * @class {SweepEvent} - * @param {Array.} point - * @param {Boolean} left - * @param {SweepEvent=} otherEvent - * @param {Boolean} isSubject - * @param {Number} edgeType - */ -function SweepEvent(point, left, otherEvent, isSubject, edgeType) { - - /** - * Is left endpoint? - * @type {Boolean} - */ - this.left = left; - - /** - * @type {Array.} - */ - this.point = point; - - /** - * Other edge reference - * @type {SweepEvent} - */ - this.otherEvent = otherEvent; - - /** - * Belongs to source or clipping polygon - * @type {Boolean} - */ - this.isSubject = isSubject; - - /** - * Edge contribution type - * @type {Number} - */ - this.type = edgeType || EdgeType.NORMAL; - - - /** - * In-out transition for the sweepline crossing polygon - * @type {Boolean} - */ - this.inOut = false; - - - /** - * @type {Boolean} - */ - this.otherInOut = false; - - /** - * Previous event in result? - * @type {SweepEvent} - */ - this.prevInResult = null; - - /** - * Does event belong to result? - * @type {Boolean} - */ - this.inResult = false; - - - // connection step - - /** - * @type {Boolean} - */ - this.resultInOut = false; - - this.isExteriorRing = true; -} - - -SweepEvent.prototype = { - - /** - * @param {Array.} p - * @return {Boolean} - */ - isBelow: function (p) { - var p0 = this.point, p1 = this.otherEvent.point; - return this.left ? - (p0[0] - p[0]) * (p1[1] - p[1]) - (p1[0] - p[0]) * (p0[1] - p[1]) > 0 : - // signedArea(this.point, this.otherEvent.point, p) > 0 : - (p1[0] - p[0]) * (p0[1] - p[1]) - (p0[0] - p[0]) * (p1[1] - p[1]) > 0; - //signedArea(this.otherEvent.point, this.point, p) > 0; - }, +},{"./compare_events":12,"./equals":18,"./sweep_event":26}],17:[function(require,module,exports){ +'use strict'; + +module.exports = { + NORMAL: 0, + NON_CONTRIBUTING: 1, + SAME_TRANSITION: 2, + DIFFERENT_TRANSITION: 3 +}; +},{}],18:[function(require,module,exports){ +'use strict'; + +// var EPSILON = 1e-9; +// var abs = Math.abs; + +module.exports = function equals(p1, p2) { + if (p1[0] === p2[0]) { + if (p1[1] === p2[1]) { + return true; + } else { + return false; + } + } + return false; +}; + +// TODO https://github.com/w8r/martinez/issues/6#issuecomment-262847164 +// Precision problem. +// +// module.exports = function equals(p1, p2) { +// return abs(p1[0] - p2[0]) <= EPSILON && abs(p1[1] - p2[1]) <= EPSILON; +// }; - /** - * @param {Array.} p - * @return {Boolean} - */ - isAbove: function (p) { - return !this.isBelow(p); - }, +},{}],19:[function(require,module,exports){ +'use strict'; + +var Queue = require('tinyqueue'); +var SweepEvent = require('./sweep_event'); +var compareEvents = require('./compare_events'); + +var max = Math.max; +var min = Math.min; + +var contourId = 0; + + +function processPolygon(contourOrHole, isSubject, depth, Q, bbox, isExteriorRing) { + var i, len, s1, s2, e1, e2; + for (i = 0, len = contourOrHole.length - 1; i < len; i++) { + s1 = contourOrHole[i]; + s2 = contourOrHole[i + 1]; + e1 = new SweepEvent(s1, false, undefined, isSubject); + e2 = new SweepEvent(s2, false, e1, isSubject); + e1.otherEvent = e2; + + if (s1[0] === s2[0] && s1[1] === s2[1]) { + continue; // skip collapsed edges, or it breaks + } + + e1.contourId = e2.contourId = depth; + if (!isExteriorRing) { + e1.isExteriorRing = false; + e2.isExteriorRing = false; + } + if (compareEvents(e1, e2) > 0) { + e2.left = true; + } else { + e1.left = true; + } + + var x = s1[0], y = s1[1]; + bbox[0] = min(bbox[0], x); + bbox[1] = min(bbox[1], y); + bbox[2] = max(bbox[2], x); + bbox[3] = max(bbox[3], y); + + // Pushing it so the queue is sorted from left to right, + // with object on the left having the highest priority. + Q.push(e1); + Q.push(e2); + } +} + + +module.exports = function fillQueue(subject, clipping, sbbox, cbbox) { + var eventQueue = new Queue(null, compareEvents); + var polygonSet, isExteriorRing, i, ii, j, jj; //, k, kk; + + for (i = 0, ii = subject.length; i < ii; i++) { + polygonSet = subject[i]; + for (j = 0, jj = polygonSet.length; j < jj; j++) { + isExteriorRing = j === 0; + if (isExteriorRing) contourId++; + processPolygon(polygonSet[j], true, contourId, eventQueue, sbbox, isExteriorRing); + } + } + + for (i = 0, ii = clipping.length; i < ii; i++) { + polygonSet = clipping[i]; + for (j = 0, jj = polygonSet.length; j < jj; j++) { + isExteriorRing = j === 0; + if (isExteriorRing) contourId++; + processPolygon(polygonSet[j], false, contourId, eventQueue, cbbox, isExteriorRing); + } + } + + return eventQueue; +}; +},{"./compare_events":12,"./sweep_event":26,"tinyqueue":11}],20:[function(require,module,exports){ +'use strict'; + +var subdivideSegments = require('./subdivide_segments'); +var connectEdges = require('./connect_edges'); +var fillQueue = require('./fill_queue'); +var operations = require('./operation'); + +var EMPTY = []; + + +function trivialOperation(subject, clipping, operation) { + var result = null; + if (subject.length * clipping.length === 0) { + if (operation === operations.INTERSECTION) { + result = EMPTY; + } else if (operation === operations.DIFFERENCE) { + result = subject; + } else if (operation === operations.UNION || + operation === operations.XOR) { + result = (subject.length === 0) ? clipping : subject; + } + } + return result; +} + + +function compareBBoxes(subject, clipping, sbbox, cbbox, operation) { + var result = null; + if (sbbox[0] > cbbox[2] || + cbbox[0] > sbbox[2] || + sbbox[1] > cbbox[3] || + cbbox[1] > sbbox[3]) { + if (operation === operations.INTERSECTION) { + result = EMPTY; + } else if (operation === operations.DIFFERENCE) { + result = subject; + } else if (operation === operations.UNION || + operation === operations.XOR) { + result = subject.concat(clipping); + } + } + return result; +} + + +function boolean(subject, clipping, operation) { + if (typeof subject[0][0][0] === 'number') { + subject = [subject]; + } + if (typeof clipping[0][0][0] === 'number') { + clipping = [clipping]; + } + var trivial = trivialOperation(subject, clipping, operation); + if (trivial) { + return trivial === EMPTY ? null : trivial; + } + var sbbox = [Infinity, Infinity, -Infinity, -Infinity]; + var cbbox = [Infinity, Infinity, -Infinity, -Infinity]; + + //console.time('fill queue'); + var eventQueue = fillQueue(subject, clipping, sbbox, cbbox); + //console.timeEnd('fill queue'); + + trivial = compareBBoxes(subject, clipping, sbbox, cbbox, operation); + if (trivial) { + return trivial === EMPTY ? null : trivial; + } + //console.time('subdivide edges'); + var sortedEvents = subdivideSegments(eventQueue, subject, clipping, sbbox, cbbox, operation); + //console.timeEnd('subdivide edges'); + + //console.time('connect vertices'); + var result = connectEdges(sortedEvents, operation); + //console.timeEnd('connect vertices'); + return result; +} + +boolean.union = function (subject, clipping) { + return boolean(subject, clipping, operations.UNION); +}; + + +boolean.diff = function (subject, clipping) { + return boolean(subject, clipping, operations.DIFFERENCE); +}; + + +boolean.xor = function (subject, clipping) { + return boolean(subject, clipping, operations.XOR); +}; + + +boolean.intersection = function (subject, clipping) { + return boolean(subject, clipping, operations.INTERSECTION); +}; + + +/** + * @enum {Number} + */ +boolean.operations = operations; + + +module.exports = boolean; +module.exports.default = boolean; - /** - * @return {Boolean} - */ - isVertical: function () { - return this.point[0] === this.otherEvent.point[0]; - }, +},{"./connect_edges":15,"./fill_queue":19,"./operation":21,"./subdivide_segments":25}],21:[function(require,module,exports){ +'use strict'; + +module.exports = { + INTERSECTION: 0, + UNION: 1, + DIFFERENCE: 2, + XOR: 3 +}; +},{}],22:[function(require,module,exports){ +'use strict'; + +var divideSegment = require('./divide_segment'); +var intersection = require('./segment_intersection'); +var equals = require('./equals'); +var compareEvents = require('./compare_events'); +var edgeType = require('./edge_type'); + +/** + * @param {SweepEvent} se1 + * @param {SweepEvent} se2 + * @param {Queue} queue + * @return {Number} + */ +module.exports = function possibleIntersection(se1, se2, queue) { + // that disallows self-intersecting polygons, + // did cost us half a day, so I'll leave it + // out of respect + // if (se1.isSubject === se2.isSubject) return; + var inter = intersection( + se1.point, se1.otherEvent.point, + se2.point, se2.otherEvent.point + ); + + var nintersections = inter ? inter.length : 0; + if (nintersections === 0) return 0; // no intersection + + // the line segments intersect at an endpoint of both line segments + if ((nintersections === 1) && + (equals(se1.point, se2.point) || + equals(se1.otherEvent.point, se2.otherEvent.point))) { + return 0; + } + + if (nintersections === 2 && se1.isSubject === se2.isSubject) { + // if(se1.contourId === se2.contourId){ + // console.warn('Edges of the same polygon overlap', + // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point); + // } + //throw new Error('Edges of the same polygon overlap'); + return 0; + } + + // The line segments associated to se1 and se2 intersect + if (nintersections === 1) { + + // if the intersection point is not an endpoint of se1 + if (!equals(se1.point, inter[0]) && !equals(se1.otherEvent.point, inter[0])) { + divideSegment(se1, inter[0], queue); + } + + // if the intersection point is not an endpoint of se2 + if (!equals(se2.point, inter[0]) && !equals(se2.otherEvent.point, inter[0])) { + divideSegment(se2, inter[0], queue); + } + return 1; + } + + // The line segments associated to se1 and se2 overlap + var events = []; + var leftCoincide = false; + var rightCoincide = false; + + if (equals(se1.point, se2.point)) { + leftCoincide = true; // linked + } else if (compareEvents(se1, se2) === 1) { + events.push(se2, se1); + } else { + events.push(se1, se2); + } + + if (equals(se1.otherEvent.point, se2.otherEvent.point)) { + rightCoincide = true; + } else if (compareEvents(se1.otherEvent, se2.otherEvent) === 1) { + events.push(se2.otherEvent, se1.otherEvent); + } else { + events.push(se1.otherEvent, se2.otherEvent); + } + + if ((leftCoincide && rightCoincide) || leftCoincide) { + // both line segments are equal or share the left endpoint + se2.type = edgeType.NON_CONTRIBUTING; + se1.type = (se2.inOut === se1.inOut) ? + edgeType.SAME_TRANSITION : + edgeType.DIFFERENT_TRANSITION; + + if (leftCoincide && !rightCoincide) { + // honestly no idea, but changing events selection from [2, 1] + // to [0, 1] fixes the overlapping self-intersecting polygons issue + divideSegment(events[1].otherEvent, events[0].point, queue); + } + return 2; + } + + // the line segments share the right endpoint + if (rightCoincide) { + divideSegment(events[0], events[1].point, queue); + return 3; + } + + // no line segment includes totally the other one + if (events[0] !== events[3].otherEvent) { + divideSegment(events[0], events[1].point, queue); + divideSegment(events[1], events[2].point, queue); + return 3; + } + + // one line segment includes the other one + divideSegment(events[0], events[1].point, queue); + divideSegment(events[3].otherEvent, events[2].point, queue); + + return 3; +}; - clone: function () { - var copy = new SweepEvent( - this.point, this.left, this.otherEvent, this.isSubject, this.type); +},{"./compare_events":12,"./divide_segment":16,"./edge_type":17,"./equals":18,"./segment_intersection":23}],23:[function(require,module,exports){ +'use strict'; + +var EPSILON = 1e-9; + +/** + * Finds the magnitude of the cross product of two vectors (if we pretend + * they're in three dimensions) + * + * @param {Object} a First vector + * @param {Object} b Second vector + * @private + * @returns {Number} The magnitude of the cross product + */ +function crossProduct(a, b) { + return a[0] * b[1] - a[1] * b[0]; +} + +/** + * Finds the dot product of two vectors. + * + * @param {Object} a First vector + * @param {Object} b Second vector + * @private + * @returns {Number} The dot product + */ +function dotProduct(a, b) { + return a[0] * b[0] + a[1] * b[1]; +} + +/** + * Finds the intersection (if any) between two line segments a and b, given the + * line segments' end points a1, a2 and b1, b2. + * + * This algorithm is based on Schneider and Eberly. + * http://www.cimec.org.ar/~ncalvo/Schneider_Eberly.pdf + * Page 244. + * + * @param {Array.} a1 point of first line + * @param {Array.} a2 point of first line + * @param {Array.} b1 point of second line + * @param {Array.} b2 point of second line + * @param {Boolean=} noEndpointTouch whether to skip single touchpoints + * (meaning connected segments) as + * intersections + * @returns {Array.>|Null} If the lines intersect, the point of + * intersection. If they overlap, the two end points of the overlapping segment. + * Otherwise, null. + */ +module.exports = function (a1, a2, b1, b2, noEndpointTouch) { + // The algorithm expects our lines in the form P + sd, where P is a point, + // s is on the interval [0, 1], and d is a vector. + // We are passed two points. P can be the first point of each pair. The + // vector, then, could be thought of as the distance (in x and y components) + // from the first point to the second point. + // So first, let's make our vectors: + var va = [a2[0] - a1[0], a2[1] - a1[1]]; + var vb = [b2[0] - b1[0], b2[1] - b1[1]]; + // We also define a function to convert back to regular point form: + + /* eslint-disable arrow-body-style */ + + function toPoint(p, s, d) { + return [ + p[0] + s * d[0], + p[1] + s * d[1] + ]; + } + + /* eslint-enable arrow-body-style */ + + // The rest is pretty much a straight port of the algorithm. + var e = [b1[0] - a1[0], b1[1] - a1[1]]; + var kross = crossProduct(va, vb); + var sqrKross = kross * kross; + var sqrLenA = dotProduct(va, va); + var sqrLenB = dotProduct(vb, vb); + + // Check for line intersection. This works because of the properties of the + // cross product -- specifically, two vectors are parallel if and only if the + // cross product is the 0 vector. The full calculation involves relative error + // to account for possible very small line segments. See Schneider & Eberly + // for details. + if (sqrKross > EPSILON * sqrLenA * sqrLenB) { + // If they're not parallel, then (because these are line segments) they + // still might not actually intersect. This code checks that the + // intersection point of the lines is actually on both line segments. + var s = crossProduct(e, vb) / kross; + if (s < 0 || s > 1) { + // not on line segment a + return null; + } + var t = crossProduct(e, va) / kross; + if (t < 0 || t > 1) { + // not on line segment b + return null; + } + return noEndpointTouch ? null : [toPoint(a1, s, va)]; + } + + // If we've reached this point, then the lines are either parallel or the + // same, but the segments could overlap partially or fully, or not at all. + // So we need to find the overlap, if any. To do that, we can use e, which is + // the (vector) difference between the two initial points. If this is parallel + // with the line itself, then the two lines are the same line, and there will + // be overlap. + var sqrLenE = dotProduct(e, e); + kross = crossProduct(e, va); + sqrKross = kross * kross; + + if (sqrKross > EPSILON * sqrLenA * sqrLenE) { + // Lines are just parallel, not the same. No overlap. + return null; + } + + var sa = dotProduct(va, e) / sqrLenA; + var sb = sa + dotProduct(va, vb) / sqrLenA; + var smin = Math.min(sa, sb); + var smax = Math.max(sa, sb); + + // this is, essentially, the FindIntersection acting on floats from + // Schneider & Eberly, just inlined into this function. + if (smin <= 1 && smax >= 0) { + + // overlap on an end point + if (smin === 1) { + return noEndpointTouch ? null : [toPoint(a1, smin > 0 ? smin : 0, va)]; + } + + if (smax === 0) { + return noEndpointTouch ? null : [toPoint(a1, smax < 1 ? smax : 1, va)]; + } + + if (noEndpointTouch && smin === 0 && smax === 1) return null; + + // There's overlap on a segment -- two points of intersection. Return both. + return [ + toPoint(a1, smin > 0 ? smin : 0, va), + toPoint(a1, smax < 1 ? smax : 1, va), + ]; + } + + return null; +}; - copy.inResult = this.inResult; - copy.prevInResult = this.prevInResult; - copy.isExteriorRing = this.isExteriorRing; - copy.inOut = this.inOut; - copy.otherInOut = this.otherInOut; +},{}],24:[function(require,module,exports){ +'use strict'; + +/** + * Signed area of the triangle (p0, p1, p2) + * @param {Array.} p0 + * @param {Array.} p1 + * @param {Array.} p2 + * @return {Number} + */ +module.exports = function signedArea(p0, p1, p2) { + return (p0[0] - p2[0]) * (p1[1] - p2[1]) - (p1[0] - p2[0]) * (p0[1] - p2[1]); +}; - return copy; - } -}; +},{}],25:[function(require,module,exports){ +'use strict'; + +var Tree = require('avl'); +var computeFields = require('./compute_fields'); +var possibleIntersection = require('./possible_intersection'); +var compareSegments = require('./compare_segments'); +var operations = require('./operation'); + + +module.exports = function subdivide(eventQueue, subject, clipping, sbbox, cbbox, operation) { + var sweepLine = new Tree(compareSegments); + var sortedEvents = []; + + var rightbound = Math.min(sbbox[2], cbbox[2]); + + var prev, next, begin; + + var INTERSECTION = operations.INTERSECTION; + var DIFFERENCE = operations.DIFFERENCE; + + while (eventQueue.length) { + var event = eventQueue.pop(); + sortedEvents.push(event); + + // optimization by bboxes for intersection and difference goes here + if ((operation === INTERSECTION && event.point[0] > rightbound) || + (operation === DIFFERENCE && event.point[0] > sbbox[2])) { + break; + } + + if (event.left) { + next = prev = sweepLine.insert(event); + begin = sweepLine.minNode(); + + if (prev !== begin) prev = sweepLine.prev(prev); + else prev = null; + + next = sweepLine.next(next); + + var prevEvent = prev ? prev.key : null; + var prevprevEvent; + computeFields(event, prevEvent, operation); + if (next) { + if (possibleIntersection(event, next.key, eventQueue) === 2) { + computeFields(event, prevEvent, operation); + computeFields(event, next.key, operation); + } + } + + if (prev) { + if (possibleIntersection(prev.key, event, eventQueue) === 2) { + var prevprev = prev; + if (prevprev !== begin) prevprev = sweepLine.prev(prevprev); + else prevprev = null; + + prevprevEvent = prevprev ? prevprev.key : null; + computeFields(prevEvent, prevprevEvent, operation); + computeFields(event, prevEvent, operation); + } + } + } else { + event = event.otherEvent; + next = prev = sweepLine.find(event); + + if (prev && next) { + + if (prev !== begin) prev = sweepLine.prev(prev); + else prev = null; + + next = sweepLine.next(next); + sweepLine.remove(event); + + if (next && prev) { + possibleIntersection(prev.key, next.key, eventQueue); + } + } + } + } + return sortedEvents; +}; -module.exports = SweepEvent; +},{"./compare_segments":13,"./compute_fields":14,"./operation":21,"./possible_intersection":22,"avl":5}],26:[function(require,module,exports){ +'use strict'; + +//var signedArea = require('./signed_area'); +var EdgeType = require('./edge_type'); + +/** + * Sweepline event + * + * @class {SweepEvent} + * @param {Array.} point + * @param {Boolean} left + * @param {SweepEvent=} otherEvent + * @param {Boolean} isSubject + * @param {Number} edgeType + */ +function SweepEvent(point, left, otherEvent, isSubject, edgeType) { + + /** + * Is left endpoint? + * @type {Boolean} + */ + this.left = left; + + /** + * @type {Array.} + */ + this.point = point; + + /** + * Other edge reference + * @type {SweepEvent} + */ + this.otherEvent = otherEvent; + + /** + * Belongs to source or clipping polygon + * @type {Boolean} + */ + this.isSubject = isSubject; + + /** + * Edge contribution type + * @type {Number} + */ + this.type = edgeType || EdgeType.NORMAL; + + + /** + * In-out transition for the sweepline crossing polygon + * @type {Boolean} + */ + this.inOut = false; + + + /** + * @type {Boolean} + */ + this.otherInOut = false; + + /** + * Previous event in result? + * @type {SweepEvent} + */ + this.prevInResult = null; + + /** + * Does event belong to result? + * @type {Boolean} + */ + this.inResult = false; + + + // connection step + + /** + * @type {Boolean} + */ + this.resultInOut = false; + + this.isExteriorRing = true; +} + + +SweepEvent.prototype = { + + /** + * @param {Array.} p + * @return {Boolean} + */ + isBelow: function (p) { + var p0 = this.point, p1 = this.otherEvent.point; + return this.left ? + (p0[0] - p[0]) * (p1[1] - p[1]) - (p1[0] - p[0]) * (p0[1] - p[1]) > 0 : + // signedArea(this.point, this.otherEvent.point, p) > 0 : + (p1[0] - p[0]) * (p0[1] - p[1]) - (p0[0] - p[0]) * (p1[1] - p[1]) > 0; + //signedArea(this.otherEvent.point, this.point, p) > 0; + }, + + + /** + * @param {Array.} p + * @return {Boolean} + */ + isAbove: function (p) { + return !this.isBelow(p); + }, + + + /** + * @return {Boolean} + */ + isVertical: function () { + return this.point[0] === this.otherEvent.point[0]; + }, + + + clone: function () { + var copy = new SweepEvent( + this.point, this.left, this.otherEvent, this.isSubject, this.type); + + copy.inResult = this.inResult; + copy.prevInResult = this.prevInResult; + copy.isExteriorRing = this.isExteriorRing; + copy.inOut = this.inOut; + copy.otherInOut = this.otherInOut; + + return copy; + } +}; + +module.exports = SweepEvent; -},{"./edge_type":18}]},{},[3]) -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJkZW1vL2pzL2Jvb2xlYW5vcGNvbnRyb2wuanMiLCJkZW1vL2pzL2Nvb3JkaW5hdGVzLmpzIiwiZGVtby9qcy9pbmRleC5qcyIsImRlbW8vanMvcG9seWdvbmNvbnRyb2wuanMiLCJpbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9hdmwvZGlzdC9hdmwuanMiLCJub2RlX21vZHVsZXMvY29tcG9uZW50LWVtaXR0ZXIvaW5kZXguanMiLCJub2RlX21vZHVsZXMvc3VwZXJhZ2VudC9saWIvY2xpZW50LmpzIiwibm9kZV9tb2R1bGVzL3N1cGVyYWdlbnQvbGliL2lzLW9iamVjdC5qcyIsIm5vZGVfbW9kdWxlcy9zdXBlcmFnZW50L2xpYi9yZXF1ZXN0LWJhc2UuanMiLCJub2RlX21vZHVsZXMvc3VwZXJhZ2VudC9saWIvcmVxdWVzdC5qcyIsIm5vZGVfbW9kdWxlcy90aW55cXVldWUvaW5kZXguanMiLCJzcmMvY29tcGFyZV9ldmVudH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h0LmtleSwgZXZlbnRRdWV1ZSkgPT09IDIpIHtcbiAgICAgICAgICBjb21wdXRlRmllbGRzKGV2ZW50LCBwcmV2RXZlbnQsIG9wZXJhdGlvbik7XG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgbmV4dC5rZXksIG9wZXJhdGlvbik7XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgaWYgKHByZXYpIHtcbiAgICAgICAgaWYgKHBvc3NpYmxlSW50ZXJzZWN0aW9uKHByZXYua2V5LCBldmVudCwgZXZlbnRRdWV1ZSkgPT09IDIpIHtcbiAgICAgICAgICB2YXIgcHJldnByZXYgPSBwcmV2O1xuICAgICAgICAgIGlmIChwcmV2cHJldiAhPT0gYmVnaW4pIHByZXZwcmV2ID0gc3dlZXBMaW5lLnByZXYocHJldnByZXYpO1xuICAgICAgICAgIGVsc2UgICAgICAgICAgICAgICAgICAgIHByZXZwcmV2ID0gbnVsbDtcblxuICAgICAgICAgIHByZXZwcmV2RXZlbnQgPSBwcmV2cHJldiA/IHByZXZwcmV2LmtleSA6IG51bGw7XG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhwcmV2RXZlbnQsIHByZXZwcmV2RXZlbnQsIG9wZXJhdGlvbik7XG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgICAgIHByZXZFdmVudCwgICAgIG9wZXJhdGlvbik7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9IGVsc2Uge1xuICAgICAgZXZlbnQgPSBldmVudC5vdGhlckV2ZW50O1xuICAgICAgbmV4dCA9IHByZXYgPSBzd2VlcExpbmUuZmluZChldmVudCk7XG5cbiAgICAgIGlmIChwcmV2ICYmIG5leHQpIHtcblxuICAgICAgICBpZiAocHJldiAhPT0gYmVnaW4pIHByZXYgPSBzd2VlcExpbmUucHJldihwcmV2KTtcbiAgICAgICAgZWxzZSAgICAgICAgICAgICAgICBwcmV2ID0gbnVsbDtcblxuICAgICAgICBuZXh0ID0gc3dl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CwgdGhpcy5sZWZ0LCB0aGlzLm90aGVyRXZlbnQsIHRoaXMuaXNTdWJqZWN0LCB0aGlzLnR5cGUpO1xuXG4gICAgY29weS5pblJlc3VsdCAgICAgICA9IHRoaXMuaW5SZXN1bHQ7XG4gICAgY29weS5wcmV2SW5SZXN1bHQgICA9IHRoaXMucHJldkluUmVzdWx0O1xuICAgIGNvcHkuaXNFeHRlcmlvclJpbmcgPSB0aGlzLmlzRXh0ZXJpb3JSaW5nO1xuICAgIGNvcHkuaW5PdXQgICAgICAgICAgPSB0aGlzLmluT3V0O1xuICAgIGNvcHkub3RoZXJJbk91dCAgICAgPSB0aGlzLm90aGVySW5PdXQ7XG5cbiAgICByZXR1cm4gY29weTtcbiAgfVxufTtcblxubW9kdWxlLmV4cG9ydHMgPSBTd2VlcEV2ZW50O1xuIl19 +},{"./edge_type":17}]},{},[3]) +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJkZW1vL2pzL2Jvb2xlYW5vcGNvbnRyb2wuanMiLCJkZW1vL2pzL2Nvb3JkaW5hdGVzLmpzIiwiZGVtby9qcy9pbmRleC5qcyIsImRlbW8vanMvcG9seWdvbmNvbnRyb2wuanMiLCJub2RlX21vZHVsZXMvYXZsL2Rpc3QvYXZsLmpzIiwibm9kZV9tb2R1bGVzL2NvbXBvbmVudC1lbWl0dGVyL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL3N1cGVyYWdlbnQvbGliL2NsaWVudC5qcyIsIm5vZGVfbW9kdWxlcy9zdXBlcmFnZW50L2xpYi9pcy1vYmplY3QuanMiLCJub2RlX21vZHVsZXMvc3VwZXJhZ2VudC9saWIvcmVxdWVzdC1iYXNlLmpzIiwibm9kZV9tb2R1bGVzL3N1cGVyYWdlbnQvbGliL3JlcXVlc3QuanMiLCJub2RlX21vZHVsZXMvdGlueXF1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9XG5cbiAgICAgICAgZGF0YVtwb3NdID0gaXRlbTtcbiAgICB9LFxuXG4gICAgX2Rvd246IGZ1bmN0aW9uIChwb3MpIHtcbiAgICAgICAgdmFyIGRhdGEgPSB0aGlzLmRhdGE7XG4gICAgICAgIHZhciBjb21wYXJlID0gdGhpcy5jb21wYXJlO1xuICAgICAgICB2YXIgaGFsZkxlbmd0aCA9IHRoaXMubGVuZ3RoID4+IDE7XG4gICAgICAgIHZhciBpdGVtID0gZGF0YVtwb3NdO1xuXG4gICAgICAgIHdoaWxlIChwb3MgPCBoYWxmTGVuZ3RoKSB7XG4gICAgICAgICAgICB2YXIgbGVmdCA9IChwb3MgPDwgMSkgKyAxO1xuICAgICAgICAgICAgdmFyIHJpZ2h0ID0gbGVmdCArIDE7XG4gICAgICAgICAgICB2YXIgYmVzdCA9IGRhdGFbbGVmdF07XG5cbiAgICAgICAgICAgIGlmIChyaWdodCA8IHRoaXMubGVuZ3RoICYmIGNvbXBhcmUoZGF0YVtyaWdodF0sIGJlc3QpIDwgMCkge1xuICAgICAgICAgICAgICAgIGxlZnQgPSByaWdodDtcbiAgICAgICAgICAgICAgICBiZXN0ID0gZGF0YVtyaWdodF07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoY29tcGFyZShiZXN0LCBpdGVtKSA+PSAwKSBicmVhaztcblxuICAgICAgICAgICAgZGF0YVtwb3NdID0gYmVzdDtcbiAgICAgICAgICAgIHBvcyA9IGxlZnQ7XG4gICAgICAgIH1cblxuICAgICAgICBkYXRhW3Bvc10gPSBpdGVtO1xuICAgIH1cbn07XG4iLCIndXNlIHN0cmljdCc7XHJcblxyXG52YXIgc2lnbmVkQXJlYSA9IHJlcXVpcmUoJy4vc2lnbmVkX2FyZWEnKTtcclxuLy8gdmFyIGVxdWFscyA9IHJlcXVpcmUoJy4vZXF1YWxzJyk7XHJcblxyXG4vKipcclxuICogQHBhcmFtICB7U3dlZXBFdmVudH0gZTFcclxuICogQHBhcmFtICB7U3dl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mllbGRzKGV2ZW50LCBuZXh0LmtleSwgb3BlcmF0aW9uKTtcclxuICAgICAgICB9XHJcbiAgICAgIH1cclxuXHJcbiAgICAgIGlmIChwcmV2KSB7XHJcbiAgICAgICAgaWYgKHBvc3NpYmxlSW50ZXJzZWN0aW9uKHByZXYua2V5LCBldmVudCwgZXZlbnRRdWV1ZSkgPT09IDIpIHtcclxuICAgICAgICAgIHZhciBwcmV2cHJldiA9IHByZXY7XHJcbiAgICAgICAgICBpZiAocHJldnByZXYgIT09IGJlZ2luKSBwcmV2cHJldiA9IHN3ZWVwTGluZS5wcmV2KHByZXZwcmV2KTtcclxuICAgICAgICAgIGVsc2UgICAgICAgICAgICAgICAgICAgIHByZXZwcmV2ID0gbnVsbDtcclxuXHJcbiAgICAgICAgICBwcmV2cHJldkV2ZW50ID0gcHJldnByZXYgPyBwcmV2cHJldi5rZXkgOiBudWxsO1xyXG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhwcmV2RXZlbnQsIHByZXZwcmV2RXZlbnQsIG9wZXJhdGlvbik7XHJcbiAgICAgICAgICBjb21wdXRlRmllbGRzKGV2ZW50LCAgICAgcHJldkV2ZW50LCAgICAgb3BlcmF0aW9uKTtcclxuICAgICAgICB9XHJcbiAgICAgIH1cclxuICAgIH0gZWxzZSB7XHJcbiAgICAgIGV2ZW50ID0gZXZlbnQub3RoZXJFdmVudDtcclxuICAgICAgbmV4dCA9IHByZXYgPSBzd2VlcExpbmUuZmluZChldmVudCk7XHJcblxyXG4gICAgICBpZiAocHJldiAmJiBuZXh0KSB7XHJcblxyXG4gICAgICAgIGlmIChwcmV2ICE9PSBiZWdpbikgcHJldiA9IHN3ZWVwTGluZS5wcmV2KHByZXYpO1xyXG4gICAgICAgIGVsc2UgICAgICAgICAgICAgICAgcHJldiA9IG51bGw7XHJcblxyXG4gICAgICAgIG5leHQgPSBzd2VlcExpbmUubmV4dChuZXh0KTtcclxuICAgICAgICBzd2VlcExpbmUucmVtb3ZlKGV2ZW50KT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Cb29sZWFufVxyXG4gICAqL1xyXG4gIGlzVmVydGljYWw6IGZ1bmN0aW9uICgpIHtcclxuICAgIHJldHVybiB0aGlzLnBvaW50WzBdID09PSB0aGlzLm90aGVyRXZlbnQucG9pbnRbMF07XHJcbiAgfSxcclxuXHJcblxyXG4gIGNsb25lOiBmdW5jdGlvbiAoKSB7XHJcbiAgICB2YXIgY29weSA9IG5ldyBTd2VlcEV2ZW50KFxyXG4gICAgICB0aGlzLnBvaW50LCB0aGlzLmxlZnQsIHRoaXMub3RoZXJFdmVudCwgdGhpcy5pc1N1YmplY3QsIHRoaXMudHlwZSk7XHJcblxyXG4gICAgY29weS5pblJlc3VsdCAgICAgICA9IHRoaXMuaW5SZXN1bHQ7XHJcbiAgICBjb3B5LnByZXZJblJlc3VsdCAgID0gdGhpcy5wcmV2SW5SZXN1bHQ7XHJcbiAgICBjb3B5LmlzRXh0ZXJpb3JSaW5nID0gdGhpcy5pc0V4dGVyaW9yUmluZztcclxuICAgIGNvcHkuaW5PdXQgICAgICAgICAgPSB0aGlzLmluT3V0O1xyXG4gICAgY29weS5vdGhlckluT3V0ICAgICA9IHRoaXMub3RoZXJJbk91dDtcclxuXHJcbiAgICByZXR1cm4gY29weTtcclxuICB9XHJcbn07XHJcblxyXG5tb2R1bGUuZXhwb3J0cyA9IFN3ZWVwRXZlbnQ7XHJcbiJdfQ== diff --git a/demo/js/index.js b/demo/js/index.js index 87b0a63..6bf44ec 100644 --- a/demo/js/index.js +++ b/demo/js/index.js @@ -1,7 +1,7 @@ require('./coordinates'); require('./polygoncontrol'); require('./booleanopcontrol'); -var martinez = window.martinez = require('../../'); +var martinez = window.martinez = require('../../src/index'); //var martinez = require('../../dist/martinez.min'); var xhr = require('superagent'); var mode = window.location.hash.substring(1); @@ -16,6 +16,9 @@ var files = [ ]; switch (mode) { + case 'multi': + file = 'multipolys.geojson'; + break; case 'geo': file = 'asia.geojson'; break; diff --git a/test/fixtures/multipolys.geojson b/test/fixtures/multipolys.geojson new file mode 100644 index 0000000..a4fc267 --- /dev/null +++ b/test/fixtures/multipolys.geojson @@ -0,0 +1,147 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": { + "collectedProperties": [ + {}, + {}, + {} + ] + }, + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [ + -79.92141723632812, + 32.953944317478246 + ], + [ + -79.97428894042969, + 32.83690450361482 + ], + [ + -79.97360229492188, + 32.76071688548088 + ], + [ + -79.93034362792969, + 32.76475877693074 + ], + [ + -79.93789672851562, + 32.74108223150125 + ], + [ + -79.80537414550781, + 32.7231762754146 + ], + [ + -79.81773376464844, + 32.923402043498875 + ], + [ + -79.92141723632812, + 32.953944317478246 + ] + ] + ], + [ + [ + [ + -80.10543823242188, + 32.94760622243483 + ], + [ + -80.14389038085938, + 32.8149783969858 + ], + [ + -80.07453918457031, + 32.85536439443039 + ], + [ + -79.99351501464844, + 32.84440429734253 + ], + [ + -79.98184204101562, + 32.90495631913751 + ], + [ + -80.10543823242188, + 32.94760622243483 + ] + ] + ], + [ + [ + [ + -79.9200439453125, + 32.9372338139709 + ], + [ + -80.03128051757812, + 32.936657533381286 + ], + [ + -79.99008178710938, + 32.77226465992344 + ], + [ + -79.90219116210938, + 32.8432505241666 + ], + [ + -79.96604919433594, + 32.87497382061986 + ], + [ + -79.9200439453125, + 32.9372338139709 + ] + ] + ] + ] + } + }, + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -79.95025634765625, + 32.97007559940924 + ], + [ + -80.00175476074217, + 32.732418508353746 + ], + [ + -79.84725952148438, + 32.753210028851896 + ], + [ + -79.82048034667969, + 32.848442385344136 + ], + [ + -79.85481262207031, + 32.923402043498875 + ], + [ + -79.95025634765625, + 32.97007559940924 + ] + ] + ] + } + } + ] +} \ No newline at end of file From 00c0545a9586ab2aac176c2a1a2f890ea37317ac Mon Sep 17 00:00:00 2001 From: oeh-rowanwinsemius Date: Thu, 18 Jan 2018 15:53:20 +1100 Subject: [PATCH 2/4] Add contour equality test --- demo/js/bundle.js | 95 ++++++++++++++++++++++++++++-------- src/compare_segments.js | 2 +- src/compute_fields.js | 2 +- src/connect_edges.js | 3 +- src/possible_intersection.js | 2 +- 5 files changed, 79 insertions(+), 25 deletions(-) diff --git a/demo/js/bundle.js b/demo/js/bundle.js index 500d537..b14a3ab 100644 --- a/demo/js/bundle.js +++ b/demo/js/bundle.js @@ -294,7 +294,7 @@ var results = window.results = L.geoJson(null, { loadData(path + file); -},{"../../src/index":20,"./booleanopcontrol":1,"./coordinates":2,"./polygoncontrol":4,"superagent":7}],4:[function(require,module,exports){ +},{"../../src/index":21,"./booleanopcontrol":1,"./coordinates":2,"./polygoncontrol":4,"superagent":7}],4:[function(require,module,exports){ L.EditControl = L.Control.extend({ options: { @@ -2768,7 +2768,7 @@ function specialCases(e1, e2, p1, p2) { } /* eslint-enable no-unused-vars */ -},{"./signed_area":24}],13:[function(require,module,exports){ +},{"./signed_area":25}],13:[function(require,module,exports){ 'use strict'; var signedArea = require('./signed_area'); @@ -2803,7 +2803,7 @@ module.exports = function compareSegments(le1, le2) { return le1.isBelow(le2.point) ? -1 : 1; } - if (le1.isSubject === le2.isSubject) { // same polygon + if (le1.isSubject === le2.isSubject || le1.contourId === le2.contourId) { // same polygon var p1 = le1.point, p2 = le2.point; if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) { p1 = le1.otherEvent.point; p2 = le2.otherEvent.point; @@ -2817,7 +2817,7 @@ module.exports = function compareSegments(le1, le2) { return compareEvents(le1, le2) === 1 ? 1 : -1; }; -},{"./compare_events":12,"./equals":18,"./signed_area":24}],14:[function(require,module,exports){ +},{"./compare_events":12,"./equals":19,"./signed_area":25}],14:[function(require,module,exports){ 'use strict'; var edgeType = require('./edge_type'); @@ -2841,7 +2841,7 @@ module.exports = function computeFields(event, prev, operation) { // previous line segment in sweepline belongs to the same polygon } else { - if (event.isSubject === prev.isSubject) { + if (event.isSubject === prev.isSubject || event.contourId === prev.contourId) { event.inOut = !prev.inOut; event.otherInOut = prev.otherInOut; @@ -2892,12 +2892,13 @@ function inResult(event, operation) { } /* eslint-enable indent */ -},{"./edge_type":17,"./operation":21}],15:[function(require,module,exports){ +},{"./edge_type":18,"./operation":22}],15:[function(require,module,exports){ 'use strict'; // var equals = require('./equals'); var compareEvents = require('./compare_events'); var operationType = require('./operation'); +var debug = require('./debug_utils'); /** * @param {Array.} sortedEvents @@ -2983,7 +2984,7 @@ function nextPos(pos, resultEvents, processed, origIndex) { module.exports = function connectEdges(sortedEvents, operation) { var i, len; var resultEvents = orderEvents(sortedEvents); - + // debug.renderPoints(resultEvents); // "false"-filled array var processed = {}; var result = []; @@ -3057,7 +3058,59 @@ module.exports = function connectEdges(sortedEvents, operation) { return result; }; -},{"./compare_events":12,"./operation":21}],16:[function(require,module,exports){ +},{"./compare_events":12,"./debug_utils":16,"./operation":22}],16:[function(require,module,exports){ +/* eslint-disable no-unused-vars, no-debugger, no-undef, no-use-before-define */ +module.exports.renderPoints = function renderPoints(possiblePoints, prop) { + var map = window.map; + var points = window.points; + if (!map) return; + if (points !== undefined) points.clearLayers(); + + points = window.points = L.layerGroup([]).addTo(map); + possiblePoints.forEach(function (e) { + var point = L.circleMarker([e.point[1], e.point[0]], { + radius: Math.floor(5 + Math.random() * 10), + color: e[prop] ? 'green' : 'gray', + opacity: e[prop] ? 0.5 : 0.1, + weight: 1 + }).addTo(points); + }); +} + +module.exports.renderSweepLine = function renderSweepLine(sweepLine, pos, event) { + var map = window.map; + if (!map) return; + if (window.sws) window.sws.forEach(function (p) { + map.removeLayer(p); + }); + window.sws = []; + sweepLine.forEach(function (e) { + var poly = L.polyline([ + e.key.point.slice().reverse(), + e.key.otherEvent.point.slice().reverse() + ], {color: 'green'}).addTo(map); + window.sws.push(poly); + }); + + if (window.vt) map.removeLayer(window.vt); + var v = pos.slice(); + var b = map.getBounds(); + window.vt = L.polyline([ + [b.getNorth(), v[0]], + [b.getSouth(), v[0]] + ], {color: 'green', weight: 1}).addTo(map); + + if (window.ps) map.removeLayer(window.ps); + window.ps = L.polyline([ + event.point.slice().reverse(), + event.otherEvent.point.slice().reverse() + ], {color: 'black', weight: 9, opacity: 0.4}).addTo(map); + debugger; +} + +/* eslint-enable no-unused-vars, no-debugger, no-undef, no-use-before-define */ + +},{}],17:[function(require,module,exports){ 'use strict'; var SweepEvent = require('./sweep_event'); @@ -3098,7 +3151,7 @@ module.exports = function divideSegment(se, p, queue) { return queue; }; -},{"./compare_events":12,"./equals":18,"./sweep_event":26}],17:[function(require,module,exports){ +},{"./compare_events":12,"./equals":19,"./sweep_event":27}],18:[function(require,module,exports){ 'use strict'; module.exports = { @@ -3108,7 +3161,7 @@ module.exports = { DIFFERENT_TRANSITION: 3 }; -},{}],18:[function(require,module,exports){ +},{}],19:[function(require,module,exports){ 'use strict'; // var EPSILON = 1e-9; @@ -3132,7 +3185,7 @@ module.exports = function equals(p1, p2) { // return abs(p1[0] - p2[0]) <= EPSILON && abs(p1[1] - p2[1]) <= EPSILON; // }; -},{}],19:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ 'use strict'; var Queue = require('tinyqueue'); @@ -3208,7 +3261,7 @@ module.exports = function fillQueue(subject, clipping, sbbox, cbbox) { return eventQueue; }; -},{"./compare_events":12,"./sweep_event":26,"tinyqueue":11}],20:[function(require,module,exports){ +},{"./compare_events":12,"./sweep_event":27,"tinyqueue":11}],21:[function(require,module,exports){ 'use strict'; var subdivideSegments = require('./subdivide_segments'); @@ -3315,7 +3368,7 @@ boolean.operations = operations; module.exports = boolean; module.exports.default = boolean; -},{"./connect_edges":15,"./fill_queue":19,"./operation":21,"./subdivide_segments":25}],21:[function(require,module,exports){ +},{"./connect_edges":15,"./fill_queue":20,"./operation":22,"./subdivide_segments":26}],22:[function(require,module,exports){ 'use strict'; module.exports = { @@ -3325,7 +3378,7 @@ module.exports = { XOR: 3 }; -},{}],22:[function(require,module,exports){ +},{}],23:[function(require,module,exports){ 'use strict'; var divideSegment = require('./divide_segment'); @@ -3360,7 +3413,7 @@ module.exports = function possibleIntersection(se1, se2, queue) { return 0; } - if (nintersections === 2 && se1.isSubject === se2.isSubject) { + if (nintersections === 2 && (se1.isSubject === se2.isSubject || se1.contourId === se2.contourId)) { // if(se1.contourId === se2.contourId){ // console.warn('Edges of the same polygon overlap', // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point); @@ -3440,7 +3493,7 @@ module.exports = function possibleIntersection(se1, se2, queue) { return 3; }; -},{"./compare_events":12,"./divide_segment":16,"./edge_type":17,"./equals":18,"./segment_intersection":23}],23:[function(require,module,exports){ +},{"./compare_events":12,"./divide_segment":17,"./edge_type":18,"./equals":19,"./segment_intersection":24}],24:[function(require,module,exports){ 'use strict'; var EPSILON = 1e-9; @@ -3585,7 +3638,7 @@ module.exports = function (a1, a2, b1, b2, noEndpointTouch) { return null; }; -},{}],24:[function(require,module,exports){ +},{}],25:[function(require,module,exports){ 'use strict'; /** @@ -3599,7 +3652,7 @@ module.exports = function signedArea(p0, p1, p2) { return (p0[0] - p2[0]) * (p1[1] - p2[1]) - (p1[0] - p2[0]) * (p0[1] - p2[1]); }; -},{}],25:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ 'use strict'; var Tree = require('avl'); @@ -3681,7 +3734,7 @@ module.exports = function subdivide(eventQueue, subject, clipping, sbbox, cbbox, return sortedEvents; }; -},{"./compare_segments":13,"./compute_fields":14,"./operation":21,"./possible_intersection":22,"avl":5}],26:[function(require,module,exports){ +},{"./compare_segments":13,"./compute_fields":14,"./operation":22,"./possible_intersection":23,"avl":5}],27:[function(require,module,exports){ 'use strict'; //var signedArea = require('./signed_area'); @@ -3814,5 +3867,5 @@ SweepEvent.prototype = { module.exports = SweepEvent; -},{"./edge_type":17}]},{},[3]) -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2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yXG4vKiBlc2xpbnQtZGlzYWJsZSBpbmRlbnQgKi9cclxuZnVuY3Rpb24gaW5SZXN1bHQoZXZlbnQsIG9wZXJhdGlvbikge1xyXG4gIHN3aXRjaCAoZXZlbnQudHlwZSkge1xyXG4gICAgY2FzZSBlZGdlVHlwZS5OT1JNQUw6XHJcbiAgICAgIHN3aXRjaCAob3BlcmF0aW9uKSB7XHJcbiAgICAgICAgY2FzZSBJTlRFUlNFQ1RJT046XHJcbiAgICAgICAgICByZXR1cm4gIWV2ZW50Lm90aGVySW5PdXQ7XHJcbiAgICAgICAgY2FzZSBVTklPTjpcclxuICAgICAgICAgIHJldHVybiBldmVudC5vdGhlckluT3V0O1xyXG4gICAgICAgIGNhc2UgRElGRkVSRU5DRTpcclxuICAgICAgICAgIC8vIHJldHVybiAoZXZlbnQuaXNTdWJqZWN0ICYmICFldmVudC5vdGhlckluT3V0KSB8fFxyXG4gICAgICAgICAgLy8gICAgICAgICAoIWV2ZW50LmlzU3ViamVjdCAmJiBldmVudC5vdGhlckluT3V0KTtcclxuICAgICAgICAgIHJldHVybiAoZXZlbnQuaXNTdWJqZWN0ICYmIGV2ZW50Lm90aGVySW5PdXQpIHx8XHJcbiAgICAgICAgICAgICAgICAgICghZXZlbnQuaXNTdWJqZWN0ICYmICFldmVudC5vdGhlckluT3V0KTtcclxuICAgICAgICBjYXNlIFhPUjpcclxuICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICB9XHJcbiAgICAgIGJyZWFrO1xyXG4gICAgY2FzZSBlZGdlVHlwZS5TQU1FX1RSQU5TSVRJT046XHJcbiAgICAgIHJldHVybiBvcGVyYXRpb24gPT09IElOVEVSU0VDVElPTiB8fCBvcGVyYXRpb24gPT09IFVOSU9OO1xyXG4gICAgY2FzZSBlZGdlVHlwZS5ESUZGRVJFTlRfVFJBTlNJVElPTjpcclxuICAgICAgcmV0dXJuIG9wZXJhdGlvbiA9PT0gRElGRkVSRU5DRTtcclxuICAgIGNhc2UgZWRn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bmUucHJldihwcmV2KTtcclxuICAgICAgZWxzZSAgICAgICAgICAgICAgICBwcmV2ID0gbnVsbDtcclxuXHJcbiAgICAgIG5leHQgPSBzd2VlcExpbmUubmV4dChuZXh0KTtcclxuXHJcbiAgICAgIHZhciBwcmV2RXZlbnQgPSBwcmV2ID8gcHJldi5rZXkgOiBudWxsO1xyXG4gICAgICB2YXIgcHJldnByZXZFdmVudDtcclxuICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgcHJldkV2ZW50LCBvcGVyYXRpb24pO1xyXG4gICAgICBpZiAobmV4dCkge1xyXG4gICAgICAgIGlmIChwb3NzaWJsZUludGVyc2VjdGlvbihldmVudCwgbmV4dC5rZXksIGV2ZW50UXVldWUpID09PSAyKSB7XHJcbiAgICAgICAgICBjb21wdXRlRmllbGRzKGV2ZW50LCBwcmV2RXZlbnQsIG9wZXJhdGlvbik7XHJcbiAgICAgICAgICBjb21wdXRlRmllbGRzKGV2ZW50LCBuZXh0LmtleSwgb3BlcmF0aW9uKTtcclxuICAgICAgICB9XHJcbiAgICAgIH1cclxuXHJcbiAgICAgIGlmIChwcmV2KSB7XHJcbiAgICAgICAgaWYgKHBvc3NpYmxlSW50ZXJzZWN0aW9uKHByZXYua2V5LCBldmVudCwgZXZlbnRRdWV1ZSkgPT09IDIpIHtcclxuICAgICAgICAgIHZhciBwcmV2cHJldiA9IHByZXY7XHJcbiAgICAgICAgICBpZiAocHJldnByZXYgIT09IGJlZ2luKSBwcmV2cHJldiA9IHN3ZWVwTGluZS5wcmV2KHByZXZwcmV2KTtcclxuICAgICAgICAgIGVsc2UgICAgICAgICAgICAgICAgICAgIHByZXZwcmV2ID0gbnVsbDtcclxuXHJcbiAgICAgICAgICBwcmV2cHJldkV2ZW50ID0gcHJldnByZXYgPyBwcmV2cHJldi5rZXkgOiBudWxsO1xyXG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhwcmV2RXZlbnQsIHByZXZwcmV2RXZlbnQsIG9wZXJhdGlvbik7X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T3V0O1xyXG4gICAgY29weS5vdGhlckluT3V0ICAgICA9IHRoaXMub3RoZXJJbk91dDtcclxuXHJcbiAgICByZXR1cm4gY29weTtcclxuICB9XHJcbn07XHJcblxyXG5tb2R1bGUuZXhwb3J0cyA9IFN3ZWVwRXZlbnQ7XHJcbiJdfQ== +},{"./edge_type":18}]},{},[3]) +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJkZW1vL2pzL2Jvb2xlYW5vcGNvbnRyb2wuanMiLCJkZW1vL2pzL2Nvb3JkaW5hdGVzLmpzIiwiZGVtby9qcy9pbmRleC5qcyIsImRlbW8vanMvcG9seWdvbmNvbnRyb2wuanMiLCJub2RlX21vZHVsZXMvYXZsL2Rpc3QvYXZsLmpzIiwibm9kZV9tb2R1bGVzL2NvbXBvbmVudC1lbWl0dGVyL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL3N1cGVyYWdlbnQvbGliL2NsaWVudC5qcyIsIm5vZGVfbW9kdWxlcy9zdXBlcmFnZW50L2xpYi9pcy1vYmplY3QuanMiLCJub2RlX21vZHVsZXMvc3VwZXJhZ2VudC9saWIvcmVxdWVzdC1iYXNlLmpzIiwibm9kZV9tb2R1bGVzL3N1cGVyYWdlbnQvbGliL3JlcXVlc3QuanMiLCJub2RlX21vZHVsZXMvdGlueXF1ZXVlL2luZGV4LmpzIiwic3JjL2NvbXBhcmVfZXZlbnRzLmpzIiwic3JjL2NvbXBhcmVfc2VnbWVudHMuanMiLCJzcmMvY29tcHV0ZV9maWVsZHMuanMiLCJzcmMvY29ubmVjdF9lZGdlcy5qcyIsInNyYy9kZWJ1Z191dGlscy5qcyIsInNyYy9kaXZpZGVfc2VnbWVudC5qcyIsInNyYy9lZGdlX3R5cGUuanMiLCJzcmMvZXF1YWxzLmpzIiwic3JjL2ZpbGxfcXVldWUuanMiLCJ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cclxuICAgICAgZXZlbnQuaW5PdXQgICAgICA9ICFwcmV2LmluT3V0O1xyXG4gICAgICBldmVudC5vdGhlckluT3V0ID0gcHJldi5vdGhlckluT3V0O1xyXG5cclxuICAgIC8vIHByZXZpb3VzIGxpbmUgc2VnbWVudCBpbiBzd2VlcGxpbmUgYmVsb25ncyB0byB0aGUgY2xpcHBpbmcgcG9seWdvblxyXG4gICAgfSBlbHNlIHtcclxuICAgICAgZXZlbnQuaW5PdXQgICAgICA9ICFwcmV2Lm90aGVySW5PdXQ7XHJcbiAgICAgIGV2ZW50Lm90aGVySW5PdXQgPSBwcmV2LmlzVmVydGljYWwoKSA/ICFwcmV2LmluT3V0IDogcHJldi5pbk91dDtcclxuICAgIH1cclxuXHJcbiAgICAvLyBjb21wdXRlIHByZXZJblJlc3VsdCBmaWVsZFxyXG4gICAgaWYgKHByZXYpIHtcclxuICAgICAgZXZlbnQucHJldkluUmVzdWx0ID0gKCFpblJlc3VsdChwcmV2LCBvcGVyYXRpb24pIHx8IHByZXYuaXNWZXJ0aWNhbCgpKSA/XHJcbiAgICAgICAgIHByZXYucHJldkluUmVzdWx0IDogcHJldjtcclxuICAgIH1cclxuICB9XHJcblxyXG4gIC8vIGNoZWNrIGlmIHRoZSBsaW5lIHNlZ21lbnQgYmVsb25ncyB0byB0aGUgQm9vbGVhbiBvcGVyYXRpb25cclxuICBldmVudC5pblJlc3VsdCA9IGluUmVzdWx0KGV2ZW50LCBvcGVyYXRpb24pO1xyXG59O1xyXG5cclxuXHJcbi8qIGVzbGludC1kaXNhYmxlIGluZGVudCAqL1xyXG5mdW5jdGlvbiBpblJlc3VsdChldmVudCwgb3BlcmF0aW9uKSB7XHJcbiAgc3dpdGNoIChldmVudC50eXBlKSB7XHJcbiAgICBjYXNlIGVkZ2VUeXBlLk5PUk1BTDpcclxuICAgICAgc3dpdGNoIChvcGVyYXRpb24pIHtcclxuICAgICAgICBjYXNlIElOVEVSU0VDVElPTjpcclxuICAgICAgICAgIHJldHV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KSBwcmV2ID0gc3dlZXBMaW5lLnByZXYocHJldik7XHJcbiAgICAgIGVsc2UgICAgICAgICAgICAgICAgcHJldiA9IG51bGw7XHJcblxyXG4gICAgICBuZXh0ID0gc3dlZXBMaW5lLm5leHQobmV4dCk7XHJcblxyXG4gICAgICB2YXIgcHJldkV2ZW50ID0gcHJldiA/IHByZXYua2V5IDogbnVsbDtcclxuICAgICAgdmFyIHByZXZwcmV2RXZlbnQ7XHJcbiAgICAgIGNvbXB1dGVGaWVsZHMoZXZlbnQsIHByZXZFdmVudCwgb3BlcmF0aW9uKTtcclxuICAgICAgaWYgKG5leHQpIHtcclxuICAgICAgICBpZiAocG9zc2libGVJbnRlcnNlY3Rpb24oZXZlbnQsIG5leHQua2V5LCBldmVudFF1ZXVlKSA9PT0gMikge1xyXG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgcHJldkV2ZW50LCBvcGVyYXRpb24pO1xyXG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgbmV4dC5rZXksIG9wZXJhdGlvbik7XHJcbiAgICAgICAgfVxyXG4gICAgICB9XHJcblxyXG4gICAgICBpZiAocHJldikge1xyXG4gICAgICAgIGlmIChwb3NzaWJsZUludGVyc2VjdGlvbihwcmV2LmtleSwgZXZlbnQsIGV2ZW50UXVldWUpID09PSAyKSB7XHJcbiAgICAgICAgICB2YXIgcHJldnByZXYgPSBwcmV2O1xyXG4gICAgICAgICAgaWYgKHByZXZwcmV2ICE9PSBiZWdpbikgcHJldnByZXYgPSBzd2VlcExpbmUucHJldihwcmV2cHJldik7XHJcbiAgICAgICAgICBlbHNlICAgICAgICAgICAgICAgICAgICBwcmV2cHJldiA9IG51bGw7XHJcblxyXG4gICAgICAgICAgcHJldnByZXZFdmVudCA9IHByZXZwcmV2ID8gcHJldnByZXYua2V5IDogbnVsbDtcclxuICAgICAgICAgIGNvbXB1dGVGaWVsZHMocHJldkV2ZW50LCBwcmV2cHJldkV2ZW50LCBvcGVyYXR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bk91dDtcclxuICAgIGNvcHkub3RoZXJJbk91dCAgICAgPSB0aGlzLm90aGVySW5PdXQ7XHJcblxyXG4gICAgcmV0dXJuIGNvcHk7XHJcbiAgfVxyXG59O1xyXG5cclxubW9kdWxlLmV4cG9ydHMgPSBTd2VlcEV2ZW50O1xyXG4iXX0= diff --git a/src/compare_segments.js b/src/compare_segments.js index 6d7a8e2..76f59ca 100644 --- a/src/compare_segments.js +++ b/src/compare_segments.js @@ -32,7 +32,7 @@ module.exports = function compareSegments(le1, le2) { return le1.isBelow(le2.point) ? -1 : 1; } - if (le1.isSubject === le2.isSubject) { // same polygon + if (le1.isSubject === le2.isSubject || le1.contourId === le2.contourId) { // same polygon var p1 = le1.point, p2 = le2.point; if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) { p1 = le1.otherEvent.point; p2 = le2.otherEvent.point; diff --git a/src/compute_fields.js b/src/compute_fields.js index 844be70..85ba993 100644 --- a/src/compute_fields.js +++ b/src/compute_fields.js @@ -21,7 +21,7 @@ module.exports = function computeFields(event, prev, operation) { // previous line segment in sweepline belongs to the same polygon } else { - if (event.isSubject === prev.isSubject) { + if (event.isSubject === prev.isSubject || event.contourId === prev.contourId) { event.inOut = !prev.inOut; event.otherInOut = prev.otherInOut; diff --git a/src/connect_edges.js b/src/connect_edges.js index 8c9953a..798b143 100644 --- a/src/connect_edges.js +++ b/src/connect_edges.js @@ -3,6 +3,7 @@ // var equals = require('./equals'); var compareEvents = require('./compare_events'); var operationType = require('./operation'); +var debug = require('./debug_utils'); /** * @param {Array.} sortedEvents @@ -88,7 +89,7 @@ function nextPos(pos, resultEvents, processed, origIndex) { module.exports = function connectEdges(sortedEvents, operation) { var i, len; var resultEvents = orderEvents(sortedEvents); - + // debug.renderPoints(resultEvents); // "false"-filled array var processed = {}; var result = []; diff --git a/src/possible_intersection.js b/src/possible_intersection.js index 8b92486..792d256 100644 --- a/src/possible_intersection.js +++ b/src/possible_intersection.js @@ -32,7 +32,7 @@ module.exports = function possibleIntersection(se1, se2, queue) { return 0; } - if (nintersections === 2 && se1.isSubject === se2.isSubject) { + if (nintersections === 2 && (se1.isSubject === se2.isSubject || se1.contourId === se2.contourId)) { // if(se1.contourId === se2.contourId){ // console.warn('Edges of the same polygon overlap', // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point); From e7e90861bbd595a40fd31bf60be9c35c301b2b90 Mon Sep 17 00:00:00 2001 From: oeh-rowanwinsemius Date: Thu, 18 Jan 2018 16:05:00 +1100 Subject: [PATCH 3/4] Minor tweak --- demo/js/bundle.js | 6 +++--- src/compare_segments.js | 2 +- src/possible_intersection.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/demo/js/bundle.js b/demo/js/bundle.js index b14a3ab..c0d16ce 100644 --- a/demo/js/bundle.js +++ b/demo/js/bundle.js @@ -2803,7 +2803,7 @@ module.exports = function compareSegments(le1, le2) { return le1.isBelow(le2.point) ? -1 : 1; } - if (le1.isSubject === le2.isSubject || le1.contourId === le2.contourId) { // same polygon + if (le1.contourId === le2.contourId) { // same polygon var p1 = le1.point, p2 = le2.point; if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) { p1 = le1.otherEvent.point; p2 = le2.otherEvent.point; @@ -3413,7 +3413,7 @@ module.exports = function possibleIntersection(se1, se2, queue) { return 0; } - if (nintersections === 2 && (se1.isSubject === se2.isSubject || se1.contourId === se2.contourId)) { + if (nintersections === 2 && (se1.isSubject === se2.isSubject && se1.contourId === se2.contourId)) { // if(se1.contourId === se2.contourId){ // console.warn('Edges of the same polygon overlap', // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point); @@ -3868,4 +3868,4 @@ SweepEvent.prototype = { module.exports = SweepEvent; },{"./edge_type":18}]},{},[3]) -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1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bb2JqZWN0IEJsb2JdJzpcbiAgICBjYXNlICdbb2JqZWN0IEZvcm1EYXRhXSc6XG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICBkZWZhdWx0OlxuICAgICAgcmV0dXJuIGZhbHNlO1xuICB9XG59XG5cbi8qKlxuICogU2VuZCBgZGF0YWAgYXMgdGhlIHJlcXVlc3QgYm9keSwgZGVmYXVsdGluZyB0aGUgYC50eXBlKClgIHRvIFwianNvblwiIHdoZW5cbiAqIGFuIG9iamVjdCBpcyBnaXZlbi5cbiAqXG4gKiBFeGFtcGxlczpcbiAqXG4gKiAgICAgICAvLyBtYW51YWwganNvblxuICogICAgICAgcmVxdWVzdC5wb3N0KCcvdXNlcicpXG4gKiAgICAgICAgIC50eXBlKCdqc29uJylcbiAqICAgICAgICAgLnNlbmQoJ3tcIm5hbWVcIjpcInRqXCJ9JylcbiAqICAgICAgICAgLmVuZChjYWxsYmFjaylcbiAqXG4gKiAgICAgICAvLyBhdXRvIGpzb25cbiAqICAgICAgIHJlcXVlc3QucG9zdCgnL3VzZXInKVxuICogICAgICAgICAuc2VuZCh7IG5hbWU6ICd0aicgfSlcbiAqICAgICAgICAgLmVuZChjYWxsYmFjaylcbiAqXG4gKiAgICAgICAvLyBtYW51YWwgeC13d3ctZm9ybS11cmxlbmNvZGVkXG4gKiAgICAgICByZXF1ZXN0LnBvc3QoJy91c2VyJylcbiAqICAgICAgICAgLnR5cGUoJ2Zvcm0nKVxuICogICAgICAgICAuc2VuZCgnbmFtZT10aicpXG4gKiAgICAgICAgIC5lbmQoY2FsbGJhY2spXG4gKlxuICogICAgICAgLy8gYXV0byB4LXd3dy1mb3JtLXVybGVuY29kZWRcbiAqICAgICAgIHJlcXVlc3QucG9zdCgnL3VzZXInKVxuICogICAgICAgICAudHlwZSgnZm9ybScpXG4gKiAgICAgICAgIC5zZW5kKHsgbmFtZTogJ3RqJyB9KVxuICogICAgICAgICAuZW5kKGNhbGxiYWNrKVxuICpcbiAqICAgICAgIC8v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LFxuXG4gICAgcG9wOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIGlmICh0aGlzLmxlbmd0aCA9PT0gMCkgcmV0dXJuIHVuZGVmaW5lZDtcblxuICAgICAgICB2YXIgdG9wID0gdGhpcy5kYXRhWzBdO1xuICAgICAgICB0aGlzLmxlbmd0aC0tO1xuXG4gICAgICAgIGlmICh0aGlzLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIHRoaXMuZGF0YVswXSA9IHRoaXMuZGF0YVt0aGlzLmxlbmd0aF07XG4gICAgICAgICAgICB0aGlzLl9kb3duKDApO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGF0YS5wb3AoKTtcblxuICAgICAgICByZXR1cm4gdG9wO1xuICAgIH0sXG5cbiAgICBwZWVrOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmRhdGFbMF07XG4gICAgfSxcblxuICAgIF91cDogZnVuY3Rpb24gKHBvcykge1xuICAgICAgICB2YXIgZGF0YSA9IHRoaXMuZGF0YTtcbiAgICAgICAgdmFyIGNvbXBhcmUgPSB0aGlzLmNvbXBhcmU7XG4gICAgICAgIHZhciBpdGVtID0gZGF0YVtwb3NdO1xuXG4gICAgICAgIHdoaWxlIChwb3MgPiAwKSB7XG4gICAgICAgICAgICB2YXIgcGFyZW50ID0gKHBvcyAtIDEpID4+IDE7XG4gICAgICAgICAgICB2YXIgY3VycmVudCA9IGRhdGFbcGFyZW50XTtcbiAgICAgICAgICAgIGlmIChjb21wYXJlKGl0ZW0sIGN1cnJlbnQpID49IDApIGJyZWFrO1xuICAgICAgICAgICAgZGF0YVtwb3NdID0gY3VycmVudDtcbiAgICAgICAgICAgIHBvcyA9IHBhcmVudDtcbiAgICAgICAgfVxuXG4gICAgICAgIGRhdGFbcG9zXSA9IGl0ZW07XG4gICAgfSxcblxuICAgIF9kb3duOiBmdW5jdGlvbiAocG9zKSB7XG4gICAgICAgIHZhciBkYXRhID0gdGhpcy5kYXRhO1x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AgIGV2ZW50Lm90aGVySW5PdXQgPSBwcmV2LmlzVmVydGljYWwoKSA/ICFwcmV2LmluT3V0IDogcHJldi5pbk91dDtcclxuICAgIH1cclxuXHJcbiAgICAvLyBjb21wdXRlIHByZXZJblJlc3VsdCBmaWVsZFxyXG4gICAgaWYgKHByZXYpIHtcclxuICAgICAgZXZlbnQucHJldkluUmVzdWx0ID0gKCFpblJlc3VsdChwcmV2LCBvcGVyYXRpb24pIHx8IHByZXYuaXNWZXJ0aWNhbCgpKSA/XHJcbiAgICAgICAgIHByZXYucHJldkluUmVzdWx0IDogcHJldjtcclxuICAgIH1cclxuICB9XHJcblxyXG4gIC8vIGNoZWNrIGlmIHRoZSBsaW5lIHNlZ21lbnQgYmVsb25ncyB0byB0aGUgQm9vbGVhbiBvcGVyYXRpb25cclxuICBldmVudC5pblJlc3VsdCA9IGluUmVzdWx0KGV2ZW50LCBvcGVyYXRpb24pO1xyXG59O1xyXG5cclxuXHJcbi8qIGVzbGludC1kaXNhYmxlIGluZGVudCAqL1xyXG5mdW5jdGlvbiBpblJlc3VsdChldmVudCwgb3BlcmF0aW9uKSB7XHJcbiAgc3dpdGNoIChldmVudC50eXBlKSB7XHJcbiAgICBjYXNlIGVkZ2VUeXBlLk5PUk1BTDpcclxuICAgICAgc3dpdGNoIChvcGVyYXRpb24pIHtcclxuICAgICAgICBjYXNlIElOVEVSU0VDVElPTjpcclxuICAgICAgICAgIHJldHVybiAhZXZlbnQub3RoZXJJbk91dDtcclxuICAgICAgICBjYXNlIFVOSU9OOlxyXG4gICAgICAgICAgcmV0dXJuIGV2ZW50Lm90aGVySW5PdXQ7XHJcbiAgICAgICAgY2FzZSBESUZGRVJFTkNFOlxyXG4gICAgICAgICAgLy8gcmV0dXJuIChldmVudC5pc1N1YmplY3QgJiYgIWV2ZW50Lm90aGVySW5PdXQpIHx8XHJcbiAgICAgICAgICAvLyAgICAgICAgICghZXZlbnQuaXNTdWJqZWN0ICYmIGV2ZW50Lm90aGVySW5Pd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b3BlcmF0aW9uKTtcclxuICAgICAgaWYgKG5leHQpIHtcclxuICAgICAgICBpZiAocG9zc2libGVJbnRlcnNlY3Rpb24oZXZlbnQsIG5leHQua2V5LCBldmVudFF1ZXVlKSA9PT0gMikge1xyXG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgcHJldkV2ZW50LCBvcGVyYXRpb24pO1xyXG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgbmV4dC5rZXksIG9wZXJhdGlvbik7XHJcbiAgICAgICAgfVxyXG4gICAgICB9XHJcblxyXG4gICAgICBpZiAocHJldikge1xyXG4gICAgICAgIGlmIChwb3NzaWJsZUludGVyc2VjdGlvbihwcmV2LmtleSwgZXZlbnQsIGV2ZW50UXVldWUpID09PSAyKSB7XHJcbiAgICAgICAgICB2YXIgcHJldnByZXYgPSBwcmV2O1xyXG4gICAgICAgICAgaWYgKHByZXZwcmV2ICE9PSBiZWdpbikgcHJldnByZXYgPSBzd2VlcExpbmUucHJldihwcmV2cHJldik7XHJcbiAgICAgICAgICBlbHNlICAgICAgICAgICAgICAgICAgICBwcmV2cHJldiA9IG51bGw7XHJcblxyXG4gICAgICAgICAgcHJldnByZXZFdmVudCA9IHByZXZwcmV2ID8gcHJldnByZXYua2V5IDogbnVsbDtcclxuICAgICAgICAgIGNvbXB1dGVGaWVsZHMocHJldkV2ZW50LCBwcmV2cHJldkV2ZW50LCBvcGVyYXRpb24pO1xyXG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgICAgIHByZXZFdmVudCwgICAgIG9wZXJhdGlvbik7XHJcbiAgICAgICAgfVxyXG4gICAgICB9XHJcbiAgICB9IGVsc2Uge1xyXG4gICAgICBldmVudCA9IGV2ZW50Lm90aGVyRXZlbnQ7XHJcbiAgICAgIG5leHQgPSBwcmV2ID0gc3dlZXBMaW5lLmZpbmQoZXZlbnQpO1xyXG5cclxuICAgICAgaWYgKHByZXYgJiYgbmV4dCkge1xyXG5cclxuICAg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BcnJheS48TnVtYmVyPn0gIHBcclxuICAgKiBAcmV0dXJuIHtCb29sZWFufVxyXG4gICAqL1xyXG4gIGlzQWJvdmU6IGZ1bmN0aW9uIChwKSB7XHJcbiAgICByZXR1cm4gIXRoaXMuaXNCZWxvdyhwKTtcclxuICB9LFxyXG5cclxuXHJcbiAgLyoqXHJcbiAgICogQHJldHVybiB7Qm9vbGVhbn1cclxuICAgKi9cclxuICBpc1ZlcnRpY2FsOiBmdW5jdGlvbiAoKSB7XHJcbiAgICByZXR1cm4gdGhpcy5wb2ludFswXSA9PT0gdGhpcy5vdGhlckV2ZW50LnBvaW50WzBdO1xyXG4gIH0sXHJcblxyXG5cclxuICBjbG9uZTogZnVuY3Rpb24gKCkge1xyXG4gICAgdmFyIGNvcHkgPSBuZXcgU3dlZXBFdmVudChcclxuICAgICAgdGhpcy5wb2ludCwgdGhpcy5sZWZ0LCB0aGlzLm90aGVyRXZlbnQsIHRoaXMuaXNTdWJqZWN0LCB0aGlzLnR5cGUpO1xyXG5cclxuICAgIGNvcHkuaW5SZXN1bHQgICAgICAgPSB0aGlzLmluUmVzdWx0O1xyXG4gICAgY29weS5wcmV2SW5SZXN1bHQgICA9IHRoaXMucHJldkluUmVzdWx0O1xyXG4gICAgY29weS5pc0V4dGVyaW9yUmluZyA9IHRoaXMuaXNFeHRlcmlvclJpbmc7XHJcbiAgICBjb3B5LmluT3V0ICAgICAgICAgID0gdGhpcy5pbk91dDtcclxuICAgIGNvcHkub3RoZXJJbk91dCAgICAgPSB0aGlzLm90aGVySW5PdXQ7XHJcblxyXG4gICAgcmV0dXJuIGNvcHk7XHJcbiAgfVxyXG59O1xyXG5cclxubW9kdWxlLmV4cG9ydHMgPSBTd2VlcEV2ZW50O1xyXG4iXX0= +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJkZW1vL2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JzpcbiAgICBjYXNlICdbb2JqZWN0IEZvcm1EYXRhXSc6XG4gICAgICByZXR1cm4gdHJ1ZTtcbiAgICBkZWZhdWx0OlxuICAgICAgcmV0dXJuIGZhbHNlO1xuICB9XG59XG5cbi8qKlxuICogU2VuZCBgZGF0YWAgYXMgdGhlIHJlcXVlc3QgYm9keSwgZGVmYXVsdGluZyB0aGUgYC50eXBlKClgIHRvIFwianNvblwiIHdoZW5cbiAqIGFuIG9iamVjdCBpcyBnaXZlbi5cbiAqXG4gKiBFeGFtcGxlczpcbiAqXG4gKiAgICAgICAvLyBtYW51YWwganNvblxuICogICAgICAgcmVxdWVzdC5wb3N0KCcvdXNlcicpXG4gKiAgICAgICAgIC50eXBlKCdqc29uJylcbiAqICAgICAgICAgLnNlbmQoJ3tcIm5hbWVcIjpcInRqXCJ9JylcbiAqICAgICAgICAgLmVuZChjYWxsYmFjaylcbiAqXG4gKiAgICAgICAvLyBhdXRvIGpzb25cbiAqICAgICAgIHJlcXVlc3QucG9zdCgnL3VzZXInKVxuICogICAgICAgICAuc2VuZCh7IG5hbWU6ICd0aicgfSlcbiAqICAgICAgICAgLmVuZChjYWxsYmFjaylcbiAqXG4gKiAgICAgICAvLyBtYW51YWwgeC13d3ctZm9ybS11cmxlbmNvZGVkXG4gKiAgICAgICByZXF1ZXN0LnBvc3QoJy91c2VyJylcbiAqICAgICAgICAgLnR5cGUoJ2Zvcm0nKVxuICogICAgICAgICAuc2VuZCgnbmFtZT10aicpXG4gKiAgICAgICAgIC5lbmQoY2FsbGJhY2spXG4gKlxuICogICAgICAgLy8gYXV0byB4LXd3dy1mb3JtLXVybGVuY29kZWRcbiAqICAgICAgIHJlcXVlc3QucG9zdCgnL3VzZXInKVxuICogICAgICAgICAudHlwZSgnZm9ybScpXG4gKiAgICAgICAgIC5zZW5kKHsgbmFtZTogJ3RqJyB9KVxuICogICAgICAgICAuZW5kKGNhbGxiYWNrKVxuICpcbiAqICAgICAgIC8vIGRlZmF1bHRzIHRvI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BmdW5jdGlvbiAoKSB7XG4gICAgICAgIGlmICh0aGlzLmxlbmd0aCA9PT0gMCkgcmV0dXJuIHVuZGVmaW5lZDtcblxuICAgICAgICB2YXIgdG9wID0gdGhpcy5kYXRhWzBdO1xuICAgICAgICB0aGlzLmxlbmd0aC0tO1xuXG4gICAgICAgIGlmICh0aGlzLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIHRoaXMuZGF0YVswXSA9IHRoaXMuZGF0YVt0aGlzLmxlbmd0aF07XG4gICAgICAgICAgICB0aGlzLl9kb3duKDApO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMuZGF0YS5wb3AoKTtcblxuICAgICAgICByZXR1cm4gdG9wO1xuICAgIH0sXG5cbiAgICBwZWVrOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmRhdGFbMF07XG4gICAgfSxcblxuICAgIF91cDogZnVuY3Rpb24gKHBvcykge1xuICAgICAgICB2YXIgZGF0YSA9IHRoaXMuZGF0YTtcbiAgICAgICAgdmFyIGNvbXBhcmUgPSB0aGlzLmNvbXBhcmU7XG4gICAgICAgIHZhciBpdGVtID0gZGF0YVtwb3NdO1xuXG4gICAgICAgIHdoaWxlIChwb3MgPiAwKSB7XG4gICAgICAgICAgICB2YXIgcGFyZW50ID0gKHBvcyAtIDEpID4+IDE7XG4gICAgICAgICAgICB2YXIgY3VycmVudCA9IGRhdGFbcGFyZW50XTtcbiAgICAgICAgICAgIGlmIChjb21wYXJlKGl0ZW0sIGN1cnJlbnQpID49IDApIGJyZWFrO1xuICAgICAgICAgICAgZGF0YVtwb3NdID0gY3VycmVudDtcbiAgICAgICAgICAgIHBvcyA9IHBhcmVudDtcbiAgICAgICAgfVxuXG4gICAgICAgIGRhdGFbcG9zXSA9IGl0ZW07XG4gICAgfSxcblxuICAgIF9kb3duOiBmdW5jdGlvbiAocG9zKSB7XG4gICAgICAgIHZhciBkYXRhID0gdGhpcy5kYXRhO1xuICAgICAgICB2YXIgY29t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bik7XHJcbiAgICAgIGlmIChuZXh0KSB7XHJcbiAgICAgICAgaWYgKHBvc3NpYmxlSW50ZXJzZWN0aW9uKGV2ZW50LCBuZXh0LmtleSwgZXZlbnRRdWV1ZSkgPT09IDIpIHtcclxuICAgICAgICAgIGNvbXB1dGVGaWVsZHMoZXZlbnQsIHByZXZFdmVudCwgb3BlcmF0aW9uKTtcclxuICAgICAgICAgIGNvbXB1dGVGaWVsZHMoZXZlbnQsIG5leHQua2V5LCBvcGVyYXRpb24pO1xyXG4gICAgICAgIH1cclxuICAgICAgfVxyXG5cclxuICAgICAgaWYgKHByZXYpIHtcclxuICAgICAgICBpZiAocG9zc2libGVJbnRlcnNlY3Rpb24ocHJldi5rZXksIGV2ZW50LCBldmVudFF1ZXVlKSA9PT0gMikge1xyXG4gICAgICAgICAgdmFyIHByZXZwcmV2ID0gcHJldjtcclxuICAgICAgICAgIGlmIChwcmV2cHJldiAhPT0gYmVnaW4pIHByZXZwcmV2ID0gc3dlZXBMaW5lLnByZXYocHJldnByZXYpO1xyXG4gICAgICAgICAgZWxzZSAgICAgICAgICAgICAgICAgICAgcHJldnByZXYgPSBudWxsO1xyXG5cclxuICAgICAgICAgIHByZXZwcmV2RXZlbnQgPSBwcmV2cHJldiA/IHByZXZwcmV2LmtleSA6IG51bGw7XHJcbiAgICAgICAgICBjb21wdXRlRmllbGRzKHByZXZFdmVudCwgcHJldnByZXZFdmVudCwgb3BlcmF0aW9uKTtcclxuICAgICAgICAgIGNvbXB1dGVGaWVsZHMoZXZlbnQsICAgICBwcmV2RXZlbnQsICAgICBvcGVyYXRpb24pO1xyXG4gICAgICAgIH1cclxuICAgICAgfVxyXG4gICAgfSBlbHNlIHtcclxuICAgICAgZXZlbnQgPSBldmVudC5vdGhlckV2ZW50O1xyXG4gICAgICBuZXh0ID0gcHJldiA9IHN3ZWVwTGluZS5maW5kKGV2ZW50KTtcclxuXHJcbiAgICAgIGlmIChwcmV2ICYmIG5leHQpIHtcclxuXHJcbiAgIC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yoqXHJcbiAgICogQHBhcmFtICB7QXJyYXkuPE51bWJlcj59ICBwXHJcbiAgICogQHJldHVybiB7Qm9vbGVhbn1cclxuICAgKi9cclxuICBpc0Fib3ZlOiBmdW5jdGlvbiAocCkge1xyXG4gICAgcmV0dXJuICF0aGlzLmlzQmVsb3cocCk7XHJcbiAgfSxcclxuXHJcblxyXG4gIC8qKlxyXG4gICAqIEByZXR1cm4ge0Jvb2xlYW59XHJcbiAgICovXHJcbiAgaXNWZXJ0aWNhbDogZnVuY3Rpb24gKCkge1xyXG4gICAgcmV0dXJuIHRoaXMucG9pbnRbMF0gPT09IHRoaXMub3RoZXJFdmVudC5wb2ludFswXTtcclxuICB9LFxyXG5cclxuXHJcbiAgY2xvbmU6IGZ1bmN0aW9uICgpIHtcclxuICAgIHZhciBjb3B5ID0gbmV3IFN3ZWVwRXZlbnQoXHJcbiAgICAgIHRoaXMucG9pbnQsIHRoaXMubGVmdCwgdGhpcy5vdGhlckV2ZW50LCB0aGlzLmlzU3ViamVjdCwgdGhpcy50eXBlKTtcclxuXHJcbiAgICBjb3B5LmluUmVzdWx0ICAgICAgID0gdGhpcy5pblJlc3VsdDtcclxuICAgIGNvcHkucHJldkluUmVzdWx0ICAgPSB0aGlzLnByZXZJblJlc3VsdDtcclxuICAgIGNvcHkuaXNFeHRlcmlvclJpbmcgPSB0aGlzLmlzRXh0ZXJpb3JSaW5nO1xyXG4gICAgY29weS5pbk91dCAgICAgICAgICA9IHRoaXMuaW5PdXQ7XHJcbiAgICBjb3B5Lm90aGVySW5PdXQgICAgID0gdGhpcy5vdGhlckluT3V0O1xyXG5cclxuICAgIHJldHVybiBjb3B5O1xyXG4gIH1cclxufTtcclxuXHJcbm1vZHVsZS5leHBvcnRzID0gU3dlZXBFdmVudDtcclxuIl19 diff --git a/src/compare_segments.js b/src/compare_segments.js index 76f59ca..f09db62 100644 --- a/src/compare_segments.js +++ b/src/compare_segments.js @@ -32,7 +32,7 @@ module.exports = function compareSegments(le1, le2) { return le1.isBelow(le2.point) ? -1 : 1; } - if (le1.isSubject === le2.isSubject || le1.contourId === le2.contourId) { // same polygon + if (le1.contourId === le2.contourId) { // same polygon var p1 = le1.point, p2 = le2.point; if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) { p1 = le1.otherEvent.point; p2 = le2.otherEvent.point; diff --git a/src/possible_intersection.js b/src/possible_intersection.js index 792d256..c14ce85 100644 --- a/src/possible_intersection.js +++ b/src/possible_intersection.js @@ -32,7 +32,7 @@ module.exports = function possibleIntersection(se1, se2, queue) { return 0; } - if (nintersections === 2 && (se1.isSubject === se2.isSubject || se1.contourId === se2.contourId)) { + if (nintersections === 2 && (se1.isSubject === se2.isSubject && se1.contourId === se2.contourId)) { // if(se1.contourId === se2.contourId){ // console.warn('Edges of the same polygon overlap', // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point); From 89049947eec150f4d6d56fdc6f4692b046117891 Mon Sep 17 00:00:00 2001 From: oeh-rowanwinsemius Date: Thu, 18 Jan 2018 16:24:52 +1100 Subject: [PATCH 4/4] Passing tests --- demo/js/bundle.js | 8 ++++---- src/compare_segments.js | 2 +- src/compute_fields.js | 2 +- src/possible_intersection.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/demo/js/bundle.js b/demo/js/bundle.js index c0d16ce..d208d4b 100644 --- a/demo/js/bundle.js +++ b/demo/js/bundle.js @@ -2803,7 +2803,7 @@ module.exports = function compareSegments(le1, le2) { return le1.isBelow(le2.point) ? -1 : 1; } - if (le1.contourId === le2.contourId) { // same polygon + if (le1.isSubject === le2.isSubject || le1.contourId === le2.contourId) { // same polygon var p1 = le1.point, p2 = le2.point; if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) { p1 = le1.otherEvent.point; p2 = le2.otherEvent.point; @@ -2841,7 +2841,7 @@ module.exports = function computeFields(event, prev, operation) { // previous line segment in sweepline belongs to the same polygon } else { - if (event.isSubject === prev.isSubject || event.contourId === prev.contourId) { + if (event.contourId === prev.contourId) { event.inOut = !prev.inOut; event.otherInOut = prev.otherInOut; @@ -3413,7 +3413,7 @@ module.exports = function possibleIntersection(se1, se2, queue) { return 0; } - if (nintersections === 2 && (se1.isSubject === se2.isSubject && se1.contourId === se2.contourId)) { + if (nintersections === 2 && se1.contourId === se2.contourId) { // if(se1.contourId === se2.contourId){ // console.warn('Edges of the same polygon overlap', // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point); @@ -3868,4 +3868,4 @@ SweepEvent.prototype = { module.exports = SweepEvent; },{"./edge_type":18}]},{},[3]) -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJkZW1vL2pzL2Jvb2xlYW5vcGNvbnRyb2wuanMiLCJkZW1vL2pzL2Nvb3JkaW5hdGVzLmpzIiwiZGVtby9qcy9pbmRleC5qcyIsImRlbW8vanMvcG9seWdvbmNvbnRyb2wuanMiLCJub2RlX21vZHVsZXMvYXZsL2Rpc3QvYXZsLmpzIiwibm9kZV9tb2R1bGVzL2NvbXBvbmVudC1lbWl0dGVyL2luZGV4LmpzIiwibm9kZV9tb2R1bGVzL3N1cGVyYWdlbnQvbGliL2NsaWVudC5qcyIsIm5vZGVfbW9kdWxlcy9zdXBlcmFnZW50L2xpYi9pcy1vYmplY3QuanMiLCJub2RlX21vZHVsZXMvc3VwZXJhZ2VudC9saWIvcmVxdWVzdC1iYXNlLmpzIiwibm9kZV9tb2R1bGVzL3N1cGVyYWdlbnQvbGliL3JlcXVlc3QuanMiLCJub2RlX21vZHVsZXMvdGlueXF1ZXVlL2luZGV4LmpzIiwic3JjL2NvbXBhcmVfZXZlbnRzLmpzIiwic3JjL2NvbXBhcmVfc2VnbWVudHMuanMiLCJzcmMvY29tcHV0ZV9maWVsZHMuanMiLCJzcmMvY29ubmVjdF9lZGdlcy5qcyI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0YVtwb3NdO1xuXG4gICAgICAgIHdoaWxlIChwb3MgPiAwKSB7XG4gICAgICAgICAgICB2YXIgcGFyZW50ID0gKHBvcyAtIDEpID4+IDE7XG4gICAgICAgICAgICB2YXIgY3VycmVudCA9IGRhdGFbcGFyZW50XTtcbiAgICAgICAgICAgIGlmIChjb21wYXJlKGl0ZW0sIGN1cnJlbnQpID49IDApIGJyZWFrO1xuICAgICAgICAgICAgZGF0YVtwb3NdID0gY3VycmVudDtcbiAgICAgICAgICAgIHBvcyA9IHBhcmVudDtcbiAgICAgICAgfVxuXG4gICAgICAgIGRhdGFbcG9zXSA9IGl0ZW07XG4gICAgfSxcblxuICAgIF9kb3duOiBmdW5jdGlvbiAocG9zKSB7XG4gICAgICAgIHZhciBkYXRhID0gdGhpcy5kYXRhO1xuICAgICAgICB2YXIgY29tcGFyZSA9IHRoaXMuY29tcGFyZTtcbiAgICAgICAgdmFyIGhhbGZMZW5ndGggPSB0aGlzLmxlbmd0aCA+PiAxO1xuICAgICAgICB2YXIgaXRlbSA9IGRhdGFbcG9zXTtcblxuICAgICAgICB3aGlsZSAocG9zIDwgaGFsZkxlbmd0aCkge1xuICAgICAgICAgICAgdmFyIGxlZnQgPSAocG9zIDw8IDEpICsgMTtcbiAgICAgICAgICAgIHZhciByaWdodCA9IGxlZnQgKyAxO1xuICAgICAgICAgICAgdmFyIGJlc3QgPSBkYXRhW2xlZnRdO1xuXG4gICAgICAgICAgICBpZiAocmlnaHQgPCB0aGlzLmxlbmd0aCAmJiBjb21wYXJlKGRhdGFbcmlnaHRdLCBiZXN0KSA8IDApIHtcbiAgICAgICAgICAgICAgICBsZWZ0ID0gcmlnaHQ7XG4gICAgICAgICAgICAgICAgYmVzdCA9IGRhdGFbcmlnaHRdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGNvbXBhcmUoYmVzdCwgaXRlbSkgPj0gMCkgYnJlYWs7XG5cbiAgICAgICAgICAgIGRhdGFbcG9zXSA9IGJlc3Q7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ZXZlbnQudHlwZSkge1xyXG4gICAgY2FzZSBlZGdlVHlwZS5OT1JNQUw6XHJcbiAgICAgIHN3aXRjaCAob3BlcmF0aW9uKSB7XHJcbiAgICAgICAgY2FzZSBJTlRFUlNFQ1RJT046XHJcbiAgICAgICAgICByZXR1cm4gIWV2ZW50Lm90aGVySW5PdXQ7XHJcbiAgICAgICAgY2FzZSBVTklPTjpcclxuICAgICAgICAgIHJldHVybiBldmVudC5vdGhlckluT3V0O1xyXG4gICAgICAgIGNhc2UgRElGRkVSRU5DRTpcclxuICAgICAgICAgIC8vIHJldHVybiAoZXZlbnQuaXNTdWJqZWN0ICYmICFldmVudC5vdGhlckluT3V0KSB8fFxyXG4gICAgICAgICAgLy8gICAgICAgICAoIWV2ZW50LmlzU3ViamVjdCAmJiBldmVudC5vdGhlckluT3V0KTtcclxuICAgICAgICAgIHJldHVybiAoZXZlbnQuaXNTdWJqZWN0ICYmIGV2ZW50Lm90aGVySW5PdXQpIHx8XHJcbiAgICAgICAgICAgICAgICAgICghZXZlbnQuaXNTdWJqZWN0ICYmICFldmVudC5vdGhlckluT3V0KTtcclxuICAgICAgICBjYXNlIFhPUjpcclxuICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICB9XHJcbiAgICAgIGJyZWFrO1xyXG4gICAgY2FzZSBlZGdlVHlwZS5TQU1FX1RSQU5TSVRJT046XHJcbiAgICAgIHJldHVybiBvcGVyYXRpb24gPT09IElOVEVSU0VDVElPTiB8fCBvcGVyYXRpb24gPT09IFVOSU9OO1xyXG4gICAgY2FzZSBlZGdlVHlwZS5ESUZGRVJFTlRfVFJBTlNJVElPTjpcclxuICAgICAgcmV0dXJuIG9wZXJhdGlvbiA9PT0gRElGRkVSRU5DRTtcclxuICAgIGNhc2UgZWRnZVR5cGUuTk9OX0NPTlRSSUJVVElORzpcclxuICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gIH1cclxuICByZXR1cm4gZmFsc2U7XHJcbn1cclxuLyogZXNsaW50L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mV4dCAgPSBwcmV2ID0gc3dlZXBMaW5lLmluc2VydChldmVudCk7XHJcbiAgICAgIGJlZ2luID0gc3dlZXBMaW5lLm1pbk5vZGUoKTtcclxuXHJcbiAgICAgIGlmIChwcmV2ICE9PSBiZWdpbikgcHJldiA9IHN3ZWVwTGluZS5wcmV2KHByZXYpO1xyXG4gICAgICBlbHNlICAgICAgICAgICAgICAgIHByZXYgPSBudWxsO1xyXG5cclxuICAgICAgbmV4dCA9IHN3ZWVwTGluZS5uZXh0KG5leHQpO1xyXG5cclxuICAgICAgdmFyIHByZXZFdmVudCA9IHByZXYgPyBwcmV2LmtleSA6IG51bGw7XHJcbiAgICAgIHZhciBwcmV2cHJldkV2ZW50O1xyXG4gICAgICBjb21wdXRlRmllbGRzKGV2ZW50LCBwcmV2RXZlbnQsIG9wZXJhdGlvbik7XHJcbiAgICAgIGlmIChuZXh0KSB7XHJcbiAgICAgICAgaWYgKHBvc3NpYmxlSW50ZXJzZWN0aW9uKGV2ZW50LCBuZXh0LmtleSwgZXZlbnRRdWV1ZSkgPT09IDIpIHtcclxuICAgICAgICAgIGNvbXB1dGVGaWVsZHMoZXZlbnQsIHByZXZFdmVudCwgb3BlcmF0aW9uKTtcclxuICAgICAgICAgIGNvbXB1dGVGaWVsZHMoZXZlbnQsIG5leHQua2V5LCBvcGVyYXRpb24pO1xyXG4gICAgICAgIH1cclxuICAgICAgfVxyXG5cclxuICAgICAgaWYgKHByZXYpIHtcclxuICAgICAgICBpZiAocG9zc2libGVJbnRlcnNlY3Rpb24ocHJldi5rZXksIGV2ZW50LCBldmVudFF1ZXVlKSA9PT0gMikge1xyXG4gICAgICAgICAgdmFyIHByZXZwcmV2ID0gcHJldjtcclxuICAgICAgICAgIGlmIChwcmV2cHJldiAhPT0gYmVnaW4pIHByZXZwcmV2ID0gc3dlZXBMaW5lLnByZXYocHJldnByZXYpO1xyXG4gICAgICAgICAgZWxzZSAgICAgICAgICAgICAgICAgICAgcHJldnByZXYgPSBudWxsO1xyXG5cclxuICAgICAgICAgIHByZXZwcmV2RXZlbnQgPSBwcmV2cHJldiA/IHByZXZwcmV2LmtleSA6IG51bGw7XHJcbiAgICAgICAgICBjb21wdXRlRmllbGRzKHByZXZFdmVudCwgcHJldnByZXZFdmVudCwgb3BlcmF0aW9uKTtcclxuICAgICAgICAgIGNvbXB1dGVGaWVsZHMoZXZlbnQsICAgICBwcmV2RXZlbnQsICAgICBvcGVyYXRpb24pO1xyXG4gICAgICAgIH1cclxuICAgICAgfVxyXG4gICAgfSBlbHNlIHtcclxuICAgICAgZXZlbnQgPSBldmVudC5vdGhlckV2ZW50O1xyXG4gICAgICBuZXh0ID0gcHJldiA9IHN3ZWVwTGluZS5maW5kKGV2ZW50KTtcclxuXHJcbiAgICAgIGlmIChwcmV2ICYmIG5leHQpIHtcclxuXHJcbiAgICAgICAgaWYgKHByZXYgIT09IGJlZ2luKSBwcmV2ID0gc3dlZXBMaW5lLnByZXYocHJldik7XHJcbiAgICAgICAgZWxzZSAgICAgICAgICAgICAgICBwcmV2ID0gbnVsbDtcclxuXHJcbiAgICAgICAgbmV4dCA9IHN3ZWVwTGluZS5uZXh0KG5leHQpO1xyXG4gICAgICAgIHN3ZWVwTGluZS5yZW1vdmUoZXZlbnQpO1xyXG5cclxuICAgICAgICBpZiAobmV4dCAmJiBwcmV2KSB7XHJcbiAgICAgICAgICBwb3NzaWJsZUludGVyc2VjdGlvbihwcmV2LmtleSwgbmV4dC5rZXksIGV2ZW50UXVldWUpO1xyXG4gICAgICAgIH1cclxuICAgICAgfVxyXG4gICAgfVxyXG4gIH1cclxuICByZXR1cm4gc29ydGVkRXZlbnRzO1xyXG59O1xyXG4iLCIndXNlIHN0cmljdCc7XHJcblxyXG4vL3ZhciBzaWduZWRBcmVhID0gcmVxdWlyZSgnLi9zaWduZWRfYXJlYScpO1xyXG52YXIgRWRnZVR5cGUgICA9IHJlcXVpcmUoJy4vZWRnZV90eXBlJyk7XHJcblxyXG4vKipcclxuICogU3dlZXBs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IHZhciBpdGVtID0gZGF0YVtwb3NdO1xuXG4gICAgICAgIHdoaWxlIChwb3MgPiAwKSB7XG4gICAgICAgICAgICB2YXIgcGFyZW50ID0gKHBvcyAtIDEpID4+IDE7XG4gICAgICAgICAgICB2YXIgY3VycmVudCA9IGRhdGFbcGFyZW50XTtcbiAgICAgICAgICAgIGlmIChjb21wYXJlKGl0ZW0sIGN1cnJlbnQpID49IDApIGJyZWFrO1xuICAgICAgICAgICAgZGF0YVtwb3NdID0gY3VycmVudDtcbiAgICAgICAgICAgIHBvcyA9IHBhcmVudDtcbiAgICAgICAgfVxuXG4gICAgICAgIGRhdGFbcG9zXSA9IGl0ZW07XG4gICAgfSxcblxuICAgIF9kb3duOiBmdW5jdGlvbiAocG9zKSB7XG4gICAgICAgIHZhciBkYXRhID0gdGhpcy5kYXRhO1xuICAgICAgICB2YXIgY29tcGFyZSA9IHRoaXMuY29tcGFyZTtcbiAgICAgICAgdmFyIGhhbGZMZW5ndGggPSB0aGlzLmxlbmd0aCA+PiAxO1xuICAgICAgICB2YXIgaXRlbSA9IGRhdGFbcG9zXTtcblxuICAgICAgICB3aGlsZSAocG9zIDwgaGFsZkxlbmd0aCkge1xuICAgICAgICAgICAgdmFyIGxlZnQgPSAocG9zIDw8IDEpICsgMTtcbiAgICAgICAgICAgIHZhciByaWdodCA9IGxlZnQgKyAxO1xuICAgICAgICAgICAgdmFyIGJlc3QgPSBkYXRhW2xlZnRdO1xuXG4gICAgICAgICAgICBpZiAocmlnaHQgPCB0aGlzLmxlbmd0aCAmJiBjb21wYXJlKGRhdGFbcmlnaHRdLCBiZXN0KSA8IDApIHtcbiAgICAgICAgICAgICAgICBsZWZ0ID0gcmlnaHQ7XG4gICAgICAgICAgICAgICAgYmVzdCA9IGRhdGFbcmlnaHRdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKGNvbXBhcmUoYmVzdCwgaXRlbSkgPj0gMCkgYnJlYWs7XG5cbiAgICAgICAgICAgIGRhdGFb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ZSBlZGdlVHlwZS5OT1JNQUw6XHJcbiAgICAgIHN3aXRjaCAob3BlcmF0aW9uKSB7XHJcbiAgICAgICAgY2FzZSBJTlRFUlNFQ1RJT046XHJcbiAgICAgICAgICByZXR1cm4gIWV2ZW50Lm90aGVySW5PdXQ7XHJcbiAgICAgICAgY2FzZSBVTklPTjpcclxuICAgICAgICAgIHJldHVybiBldmVudC5vdGhlckluT3V0O1xyXG4gICAgICAgIGNhc2UgRElGRkVSRU5DRTpcclxuICAgICAgICAgIC8vIHJldHVybiAoZXZlbnQuaXNTdWJqZWN0ICYmICFldmVudC5vdGhlckluT3V0KSB8fFxyXG4gICAgICAgICAgLy8gICAgICAgICAoIWV2ZW50LmlzU3ViamVjdCAmJiBldmVudC5vdGhlckluT3V0KTtcclxuICAgICAgICAgIHJldHVybiAoZXZlbnQuaXNTdWJqZWN0ICYmIGV2ZW50Lm90aGVySW5PdXQpIHx8XHJcbiAgICAgICAgICAgICAgICAgICghZXZlbnQuaXNTdWJqZWN0ICYmICFldmVudC5vdGhlckluT3V0KTtcclxuICAgICAgICBjYXNlIFhPUjpcclxuICAgICAgICAgIHJldHVybiB0cnVlO1xyXG4gICAgICB9XHJcbiAgICAgIGJyZWFrO1xyXG4gICAgY2FzZSBlZGdlVHlwZS5TQU1FX1RSQU5TSVRJT046XHJcbiAgICAgIHJldHVybiBvcGVyYXRpb24gPT09IElOVEVSU0VDVElPTiB8fCBvcGVyYXRpb24gPT09IFVOSU9OO1xyXG4gICAgY2FzZSBlZGdlVHlwZS5ESUZGRVJFTlRfVFJBTlNJVElPTjpcclxuICAgICAgcmV0dXJuIG9wZXJhdGlvbiA9PT0gRElGRkVSRU5DRTtcclxuICAgIGNhc2UgZWRnZVR5cGUuTk9OX0NPTlRSSUJVVElORzpcclxuICAgICAgcmV0dXJuIGZhbHNlO1xyXG4gIH1cclxuICByZXR1cm4gZmFsc2U7XHJcbn1cclxuLyogZXNsaW50LWVuYWJsZSBpbmRlbnQgKi9cclxuIiw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gICAgYmVnaW4gPSBzd2VlcExpbmUubWluTm9kZSgpO1xyXG5cclxuICAgICAgaWYgKHByZXYgIT09IGJlZ2luKSBwcmV2ID0gc3dlZXBMaW5lLnByZXYocHJldik7XHJcbiAgICAgIGVsc2UgICAgICAgICAgICAgICAgcHJldiA9IG51bGw7XHJcblxyXG4gICAgICBuZXh0ID0gc3dlZXBMaW5lLm5leHQobmV4dCk7XHJcblxyXG4gICAgICB2YXIgcHJldkV2ZW50ID0gcHJldiA/IHByZXYua2V5IDogbnVsbDtcclxuICAgICAgdmFyIHByZXZwcmV2RXZlbnQ7XHJcbiAgICAgIGNvbXB1dGVGaWVsZHMoZXZlbnQsIHByZXZFdmVudCwgb3BlcmF0aW9uKTtcclxuICAgICAgaWYgKG5leHQpIHtcclxuICAgICAgICBpZiAocG9zc2libGVJbnRlcnNlY3Rpb24oZXZlbnQsIG5leHQua2V5LCBldmVudFF1ZXVlKSA9PT0gMikge1xyXG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgcHJldkV2ZW50LCBvcGVyYXRpb24pO1xyXG4gICAgICAgICAgY29tcHV0ZUZpZWxkcyhldmVudCwgbmV4dC5rZXksIG9wZXJhdGlvbik7XHJcbiAgICAgICAgfVxyXG4gICAgICB9XHJcblxyXG4gICAgICBpZiAocHJldikge1xyXG4gICAgICAgIGlmIChwb3NzaWJsZUludGVyc2VjdGlvbihwcmV2LmtleSwgZXZlbnQsIGV2ZW50UXVldWUpID09PSAyKSB7XHJcbiAgICAgICAgICB2YXIgcHJldnByZXYgPSBwcmV2O1xyXG4gICAgICAgICAgaWYgKHByZXZwcmV2ICE9PSBiZWdpbikgcHJldnByZXYgPSBzd2VlcExpbmUucHJldihwcmV2cHJldik7XHJcbiAgICAgICAgICBlbHNlICAgICAgICAgICAgICAgICAgICBwcmV2cHJldiA9IG51bGw7XHJcblxyXG4gICAgICAgICAgcHJldnByZXZFdmVudCA9IHByZXZwcmV2ID8gcHJldnByZXYua2V5IDogbnVs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mluZyA9IHRoaXMuaXNFeHRlcmlvclJpbmc7XHJcbiAgICBjb3B5LmluT3V0ICAgICAgICAgID0gdGhpcy5pbk91dDtcclxuICAgIGNvcHkub3RoZXJJbk91dCAgICAgPSB0aGlzLm90aGVySW5PdXQ7XHJcblxyXG4gICAgcmV0dXJuIGNvcHk7XHJcbiAgfVxyXG59O1xyXG5cclxubW9kdWxlLmV4cG9ydHMgPSBTd2VlcEV2ZW50O1xyXG4iXX0= diff --git a/src/compare_segments.js b/src/compare_segments.js index f09db62..76f59ca 100644 --- a/src/compare_segments.js +++ b/src/compare_segments.js @@ -32,7 +32,7 @@ module.exports = function compareSegments(le1, le2) { return le1.isBelow(le2.point) ? -1 : 1; } - if (le1.contourId === le2.contourId) { // same polygon + if (le1.isSubject === le2.isSubject || le1.contourId === le2.contourId) { // same polygon var p1 = le1.point, p2 = le2.point; if (p1[0] === p2[0] && p1[1] === p2[1]/*equals(le1.point, le2.point)*/) { p1 = le1.otherEvent.point; p2 = le2.otherEvent.point; diff --git a/src/compute_fields.js b/src/compute_fields.js index 85ba993..c9e590d 100644 --- a/src/compute_fields.js +++ b/src/compute_fields.js @@ -21,7 +21,7 @@ module.exports = function computeFields(event, prev, operation) { // previous line segment in sweepline belongs to the same polygon } else { - if (event.isSubject === prev.isSubject || event.contourId === prev.contourId) { + if (event.contourId === prev.contourId) { event.inOut = !prev.inOut; event.otherInOut = prev.otherInOut; diff --git a/src/possible_intersection.js b/src/possible_intersection.js index c14ce85..1c4683e 100644 --- a/src/possible_intersection.js +++ b/src/possible_intersection.js @@ -32,7 +32,7 @@ module.exports = function possibleIntersection(se1, se2, queue) { return 0; } - if (nintersections === 2 && (se1.isSubject === se2.isSubject && se1.contourId === se2.contourId)) { + if (nintersections === 2 && se1.contourId === se2.contourId) { // if(se1.contourId === se2.contourId){ // console.warn('Edges of the same polygon overlap', // se1.point, se1.otherEvent.point, se2.point, se2.otherEvent.point);