From 04d1f5d6cadcd74ad3ea5871c4629524c00fbbc4 Mon Sep 17 00:00:00 2001 From: w8r Date: Tue, 14 Oct 2014 17:38:47 +0200 Subject: [PATCH] bump version --- dist/greiner-hormann.es5.js | 50 +++++++++++++++++---- dist/greiner-hormann.es5.min.js | 12 ++--- dist/greiner-hormann.js | 50 +++++++++++++++++---- dist/greiner-hormann.leaflet.js | 58 +++++++++++++++++++----- dist/greiner-hormann.leaflet.min.js | 14 +++--- dist/greiner-hormann.min.js | 12 ++--- package.json | 70 ++++++++++++++--------------- 7 files changed, 186 insertions(+), 80 deletions(-) diff --git a/dist/greiner-hormann.es5.js b/dist/greiner-hormann.es5.js index 3321572..98d5a86 100644 --- a/dist/greiner-hormann.es5.js +++ b/dist/greiner-hormann.es5.js @@ -179,7 +179,14 @@ var Intersection = function(s1, s2, c1, c2) { return; } + /** + * @type {Number} + */ this.toSource = ((c2.x - c1.x) * (s1.y - c1.y) - (c2.y - c1.y) * (s1.x - c1.x)) / d; + + /** + * @type {Number} + */ this.toClip = ((s2.x - s1.x) * (s1.y - c1.y) - (s2.y - s1.y) * (s1.x - c1.x)) / d; if (this.valid()) { @@ -210,6 +217,11 @@ var Polygon = function(p) { */ this.vertices = 0; + /** + * @type {Vertex} + */ + this._lastUnprocessed = null; + for (var i = 0, len = p.length; i < len; i++) { this.addVertex(new Vertex(p[i])); } @@ -280,7 +292,8 @@ Polygon.prototype.getNext = function(v) { * @return {Vertex} */ Polygon.prototype.getFirstIntersect = function() { - var v = this.first; + var v = this._firstIntersect || this.first; + do { if (v._isIntersection && !v._visited) { break; @@ -288,6 +301,8 @@ Polygon.prototype.getFirstIntersect = function() { v = v.next; } while (!v.equals(this.first)); + + this._firstIntersect = v; return v; }; @@ -296,14 +311,17 @@ Polygon.prototype.getFirstIntersect = function() { * @return {Boolean} [description] */ Polygon.prototype.hasUnprocessed = function() { - var v = this.first; + var v = this._lastUnprocessed || this.first; do { if (v._isIntersection && !v._visited) { + this._lastUnprocessed = v; return true; } v = v.next; } while (!v.equals(this.first)); + + this._lastUnprocessed = null; return false; }; @@ -314,10 +332,11 @@ Polygon.prototype.getPoints = function() { var points = [], v = this.first; - for (var i = 0; i < this.vertices; i++) { - points[i] = [v.x, v.y]; + do { + points.push([v.x, v.y]); v = v.next; - } + } while (v !== this.first); + return points; }; @@ -335,8 +354,10 @@ Polygon.prototype.getPoints = function() { */ Polygon.prototype.clip = function(clip, sourceForwards, clipForwards) { var sourceVertex = this.first, - clipVertex = clip.first; + clipVertex = clip.first, + sourceInClip, clipInSource; + // calculate and mark intersections do { if (!sourceVertex._isIntersection) { do { @@ -376,8 +397,12 @@ Polygon.prototype.clip = function(clip, sourceForwards, clipForwards) { sourceVertex = this.first; clipVertex = clip.first; - sourceForwards ^= sourceVertex.isInside(clip); - clipForwards ^= clipVertex.isInside(this); + sourceInClip = sourceVertex.isInside(clip); + clipInSource = clipVertex.isInside(this); + + sourceForwards ^= sourceInClip; + clipForwards ^= clipInSource; + do { if (sourceVertex._isIntersection) { sourceVertex._isEntry = sourceForwards; @@ -422,6 +447,15 @@ Polygon.prototype.clip = function(clip, sourceForwards, clipForwards) { list.push(clipped); } + if (list.length === 0) { + if (sourceInClip) { + list.push(this); + } + if (clipInSource) { + list.push(this); + } + } + return list; }; // Router diff --git a/dist/greiner-hormann.es5.min.js b/dist/greiner-hormann.es5.min.js index 47afe2c..71e058f 100644 --- a/dist/greiner-hormann.es5.min.js +++ b/dist/greiner-hormann.es5.min.js @@ -1,9 +1,9 @@ /* Licensed under MIT License */ -function l(){function h(a){this.first=null;for(var b=0,c=a.length;b=f||d.y=f)&&(c.x<=e||d.x<=e)&&(b^=c.x+(f-c.y)/(d.y-c.y)*(d.x-c.x)this.toSource&&0this.i};h.prototype.g=function(a){if(null==this.first)this.first=a,this.first.next=a,this.first.c=a;else{var b=this.first,c=b.c;b.c=a;a.next=b;a.c=c;c.next=a}};h.prototype.l=function(a,b,c){for(;!b.b(c)&&b.j=g||d.y=g)&&(c.x<=e||d.x<=e)&&(b^=c.x+(g-c.y)/(d.y-c.y)*(d.x-c.x)this.toSource&&0this.i};k.prototype.g=function(a){if(null==this.first)this.first=a,this.first.next=a,this.first.c=a;else{var b=this.first,c=b.c;b.c=a;a.next=b;a.c=c;c.next=a}};k.prototype.m=function(a,b,c){for(;!b.b(c)&&b.j=f||e.y=f)&&(c.x<=d||e.x<=d)&&(b^=c.x+(f-c.y)/(e.y-c.y)*(e.x-c.x)this.toSource&&0this.i};h.prototype.g=function(a){if(null==this.first)this.first=a,this.first.next=a,this.first.c=a;else{var b=this.first,c=b.c;b.c=a;a.next=b;a.c=c;c.next=a}this.j++};h.prototype.m=function(a,b,c){for(;!b.b(c)&&b.k=f||e.y=f)&&(c.x<=d||e.x<=d)&&(b^=c.x+(f-c.y)/(e.y-c.y)*(e.x-c.x)this.toSource&&0this.i};k.prototype.g=function(a){if(null==this.first)this.first=a,this.first.next=a,this.first.c=a;else{var b=this.first,c=b.c;b.c=a;a.next=b;a.c=c;c.next=a}};k.prototype.m=function(a,b,c){for(;!b.b(c)&&b.j=f||d.y< -f&&c.y>=f)&&(c.x<=e||d.x<=e)&&(b^=c.x+(f-c.y)/(d.y-c.y)*(d.x-c.x)this.toSource&&0this.i};h.prototype.g=function(a){if(null==this.first)this.first=a,this.first.next=a,this.first.c=a;else{var b=this.first,c=b.c;b.c=a;a.next=b;a.c=c;c.next=a}};h.prototype.l=function(a,b,c){for(;!b.b(c)&&b.j= +g||d.y=g)&&(c.x<=e||d.x<=e)&&(b^=c.x+(g-c.y)/(d.y-c.y)*(d.x-c.x)this.toSource&&0this.i};k.prototype.g=function(a){if(null==this.first)this.first=a,this.first.next=a,this.first.c=a;else{var b=this.first,c=b.c;b.c=a;a.next=b;a.c=c;c.next=a}};k.prototype.m=function(a,b,c){for(;!b.b(c)&&b.j