!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.rastertools=e.rastertools||{})}(this,function(e){"use strict";function t(e,t,o){return(e-t)/(o-t)}function o(e){for(var t=[],o=e.rows,r=e.cols,l=[],h=0;h0){var n=e.cells[h][a],f=(n.cval,p(n)),i=null,c=a,b=h;null!==f&&l.push([f.p[0]+c,f.p[1]+b]);do{if(i=u(e.cells[b][c],f.x,f.y,f.o),null===i)break;if(l.push([i.p[0]+c,i.p[1]+b]),c+=i.x,b+=i.y,f=i,b<0||b>=o||c<0||c>=r||"undefined"==typeof e.cells[b][c]){c-=i.x,b-=i.y;var g=s(e,c,b,i.x,i.y,i.o);if(null===g)break;g.path.forEach(function(e){l.push(e)}),c=g.i,b=g.j,f=g}}while("undefined"!=typeof e.cells[b][c]&&e.cells[b][c].edges.length>0);t.push(l),l=[],e.cells[h][a].edges.length>0&&a--}return t}function s(e,t,o,s,r,p){for(var u=e.cells[o][t],l=u.cval_real,h=t+s,a=o+r,n=[],f=(e.rows,e.cols,!1);!f;){if("undefined"==typeof e.cells[a]||"undefined"==typeof e.cells[a][h])if(a-=r,h-=s,u=e.cells[a][h],l=u.cval_real,r===-1)if(0===p)if(l&w)n.push([h,a]),s=-1,r=0,p=0;else{if(!(l&x)){n.push([h+u.bottomright,a]),s=0,r=1,p=1,f=!0;break}n.push([h+1,a]),s=1,r=0,p=0}else{if(!(l&w)){if(l&x){n.push([h+u.bottomright,a]),s=0,r=1,p=1,f=!0;break}n.push([h+u.bottomleft,a]),s=0,r=1,p=0,f=!0;break}n.push([h,a]),s=-1,r=0,p=0}else if(1===r)if(0===p){if(!(l&k)){if(l&v){n.push([h+u.topleft,a+1]),s=0,r=-1,p=0,f=!0;break}n.push([h+u.topright,a+1]),s=0,r=-1,p=1,f=!0;break}n.push([h+1,a+1]),s=1,r=0,p=1}else l&k?(n.push([h+1,a+1]),s=1,r=0,p=1):(n.push([h+1,a+1]),s=1,r=0,p=1);else if(s===-1)if(0===p){if(!(l&v)){if(l&w){n.push([h,a+u.leftbottom]),s=1,r=0,p=0,f=!0;break}n.push([h,a+u.lefttop]),s=1,r=0,p=1,f=!0;break}n.push([h,a+1]),s=0,r=1,p=0}else{if(!(l&v)){console.log("wtf");break}n.push([h,a+1]),s=0,r=1,p=0}else{if(1!==s){console.log("we came from nowhere!");break}if(0===p){if(!(l&x)){n.push([h+1,a+u.rightbottom]),s=-1,r=0,p=0,f=!0;break}n.push([h+1,a]),s=0,r=-1,p=1}else{if(!(l&x)){if(l&k){n.push([h+1,a+u.righttop]),s=-1,r=0,p=1;break}n.push([h+1,a+u.rightbottom]),s=-1,r=0,p=0,f=!0;break}n.push([h+1,a]),s=0,r=-1,p=1}}else if(u=e.cells[a][h],l=u.cval_real,s===-1)if(0===p)if("undefined"!=typeof e.cells[a-1]&&"undefined"!=typeof e.cells[a-1][h])s=0,r=-1,p=1;else{if(!(l&w)){n.push([h+u.bottomright,a]),s=0,r=1,p=1,f=!0;break}n.push([h,a])}else{if(!(l&v)){console.log("found entry from top at "+h+","+a);break}console.log("proceeding in x-direction!")}else if(1===s){if(0===p){console.log("wtf");break}if("undefined"!=typeof e.cells[a+1]&&"undefined"!=typeof e.cells[a+1][h])s=0,r=1,p=0;else{if(!(l&k)){n.push([h+u.topleft,a+1]),s=0,r=-1,p=0,f=!0;break}n.push([h+1,a+1]),s=1,r=0,p=1}}else if(r===-1){if(1!==p){console.log("wtf");break}if("undefined"!=typeof e.cells[a][h+1])s=1,r=0,p=1;else{if(!(l&x)){n.push([h+1,a+u.righttop]),s=-1,r=0,p=1,f=!0;break}n.push([h+1,a]),s=0,r=-1,p=1}}else{if(1!==r){console.log("where did we came from???");break}if(0!==p){console.log("wtf");break}if("undefined"!=typeof e.cells[a][h-1])s=-1,r=0,p=0;else{if(!(l&v)){n.push([h,a+u.leftbottom]),s=1,r=0,p=0,f=!0;break}n.push([h,a+1]),s=0,r=1,p=0}}if(h+=s,a+=r,h===t&&a===o)break}return{path:n,i:h,j:a,x:s,y:r,o:p}}function r(e,t){delete e.edges[t];for(var o=t+1;o0){var t=e.edges[e.edges.length-1],o=e.cval_real;switch(t){case 0:return o&k?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[e.topleft,1],x:0,y:-1,o:0};case 1:return o&x?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 2:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[e.topleft,1],x:0,y:-1,o:0};case 3:return o&w?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 4:return o&k?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[e.topright,1],x:0,y:-1,o:1};case 5:return o&x?{p:[e.topright,1],x:0,y:-1,o:1}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 6:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[e.topright,1],x:0,y:-1,o:1};case 7:return o&w?{p:[e.topright,1],x:0,y:-1,o:1}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 8:return o&x?{p:[e.bottomright],x:0,y:1,o:1}:{p:[1,e.righttop],x:-1,y:0,o:1};case 9:return o&w?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 10:return o&w?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[1,e.righttop],x:-1,y:0,o:1};case 11:return o&v?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[0,e.lefttop],x:1,y:0,o:1};case 12:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 13:return o&w?{p:[1,e.rightbottom],x:-1,y:0,o:0}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 14:return o&w?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 15:return o&v?{p:[1,e.rightbottom],x:-1,y:0,o:0}:{p:[0,e.lefttop],x:1,y:0,o:1};case 16:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[0,e.leftbottom],x:1,y:0,o:0};case 17:return o&v?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[0,e.lefttop],x:1,y:0,o:1};case 18:return o&w?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 19:return o&v?{p:[e.bottomleft,0],x:0,y:1,o:0}:{p:[0,e.lefttop],x:1,y:0,o:1};case 20:return o&v?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[0,e.leftbottom],x:1,y:0,o:0};case 21:return o&k?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[e.topright,1],x:0,y:-1,o:1};case 22:return o&v?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[0,e.lefttop],x:1,y:0,o:1};case 23:return o&k?{p:[0,e.lefttop],x:1,y:0,o:1}:{p:[e.topright,1],x:0,y:-1,o:1};default:console.log("edge index out of range!"),console.log(e)}}return null}function u(e,t,o,s){var p,u,t,o,l,h,a,n=e.cval;switch(t){case-1:switch(s){case 0:p=U[n],l=A[n],h=G[n],a=P[n];break;default:p=R[n],l=F[n],h=O[n],a=I[n]}break;case 1:switch(s){case 0:p=Y[n],l=J[n],h=K[n],a=Q[n];break;default:p=Z[n],l=B[n],h=D[n],a=H[n]}break;default:switch(o){case-1:switch(s){case 0:p=$[n],l=N[n],h=C[n],a=j[n];break;default:p=ee[n],l=_[n],h=E[n],a=M[n]}break;case 1:switch(s){case 0:p=X[n],l=T[n],h=V[n],a=L[n];break;default:p=W[n],l=S[n],h=q[n],a=z[n]}}}if(u=e.edges.indexOf(p),"undefined"==typeof e.edges[u])return null;switch(r(e,u),n=e.cval_real,p){case 0:n&k?(t=e.topleft,o=1):(t=1,o=e.righttop);break;case 1:n&x?(t=1,o=e.rightbottom):(t=e.topleft,o=1);break;case 2:n&x?(t=e.topleft,o=1):(t=e.bottomright,o=0);break;case 3:n&w?(t=e.bottomleft,o=0):(t=e.topleft,o=1);break;case 4:n&k?(t=e.topright,o=1):(t=1,o=e.righttop);break;case 5:n&x?(t=1,o=e.rightbottom):(t=e.topright,o=1);break;case 6:n&x?(t=e.topright,o=1):(t=e.bottomright,o=0);break;case 7:n&w?(t=e.bottomleft,o=0):(t=e.topright,o=1);break;case 8:n&x?(t=1,o=e.righttop):(t=e.bottomright,o=0);break;case 9:n&w?(t=e.bottomleft,o=0):(t=1,o=e.righttop);break;case 10:n&w?(t=1,o=e.righttop):(t=0,o=e.leftbottom);break;case 11:n&v?(t=0,o=e.lefttop):(t=1,o=e.righttop);break;case 12:n&x?(t=1,o=e.rightbottom):(t=e.bottomright,o=0);break;case 13:n&w?(t=e.bottomleft,o=0):(t=1,o=e.rightbottom);break;case 14:n&w?(t=1,o=e.rightbottom):(t=0,o=e.leftbottom);break;case 15:n&v?(t=0,o=e.lefttop):(t=1,o=e.rightbottom);break;case 16:n&x?(t=0,o=e.leftbottom):(t=e.bottomright,o=0);break;case 17:n&v?(t=0,o=e.lefttop):(t=e.bottomright,o=0);break;case 18:n&w?(t=e.bottomleft,o=0):(t=0,o=e.leftbottom);break;case 19:n&v?(t=0,o=e.lefttop):(t=e.bottomleft,o=0);break;case 20:n&v?(t=0,o=e.leftbottom):(t=e.topleft,o=1);break;case 21:n&k?(t=e.topright,o=1):(t=0,o=e.leftbottom);break;case 22:n&v?(t=0,o=e.lefttop):(t=e.topleft,o=1);break;case 23:n&k?(t=e.topright,o=1):(t=0,o=e.lefttop);break;default:return console.log("edge index out of range!"),console.log(e),null}return"undefined"!=typeof t&&"undefined"!=typeof o&&"undefined"!=typeof l&&"undefined"!=typeof h&&"undefined"!=typeof a||(console.log("undefined value!"),console.log(e),console.log(t+" "+o+" "+l+" "+h+" "+a)),{p:[t,o],x:l,y:h,o:a}}function l(e,t,o){return(e-t)/(o-t)}function h(e,t){for(var o=e.length-1,s=e[0].length-1,r={rows:o,cols:s,cells:[]},p=0;p=t?8:0,h|=n>=t?4:0,h|=f>=t?2:0,h|=i>=t?1:0;var c=!1;if(5==h||10==h){var b=(a+n+f+i)/4;5==h&&b=0;c--)if(Math.abs(t[c][0][0]-f)<=s&&Math.abs(t[c][0][1]-i)<=s){for(var g=l.path.length-2;g>=0;--g)t[c].unshift(l.path[g]);h=!0;break}h||(t[o++]=l.path)}})}),t}function b(e,t,o){var s,r,p,u=e.length,l=[],h=[0,0,1,1,0,0,0,0,-1,0,1,1,-1,0,-1,0],a=[0,-1,0,0,1,1,1,1,0,-1,0,0,0,-1,0,0],n=["none","left","bottom","left","right","none","bottom","left","top","top","none","top","right","right","bottom","none"],c=["none","bottom","right","right","top","top","top","top","left","bottom","right","right","left","bottom","left","none"],b=(e[t][o],e[t][o]),g=b.cval,p=n[g],d=i(b,p);l.push([o+d[0],t+d[1]]),p=c[g],d=i(b,p),l.push([o+d[0],t+d[1]]),f(b);for(var y=o+h[g],m=t+a[g],v=g;y>=0&&m>=0&&ml?128:64,n|=il?32:16,n|=cl?8:4,n|=bl?2:1;var g=+n,d=0;if(17==n||18==n||33==n||34==n||38==n||68==n||72==n||98==n||102==n||132==n||136==n||137==n||152==n||153==n){var y=(f+i+c+b)/4;d=y>l?2:y0?(n=156,d=4):n=152:33===n?d>0?(n=139,d=4):n=137:72===n?d>0?(n=99,d=4):n=98:132===n&&(d>0?(n=39,d=4):n=38)}if(0!=n&&170!=n){var m,v,k,x,w,N,C,j;m=v=k=x=w=N=C=j=.5;var _=[];1===n?(k=1-t(o,c,b),j=1-t(o,f,b),_.push(X[n])):169===n?(k=t(l,b,c),j=t(l,b,f),_.push(X[n])):4===n?(N=1-t(o,i,c),x=t(o,b,c),_.push(U[n])):166===n?(N=t(l,c,i),x=1-t(l,c,b),_.push(U[n])):16===n?(w=t(o,c,i),v=t(o,f,i),_.push(R[n])):154===n?(w=1-t(l,i,c),v=1-t(l,i,f),_.push(R[n])):64===n?(C=t(o,b,f),m=1-t(o,i,f),_.push(Z[n])):106===n?(C=1-t(l,f,b),m=t(l,f,i),_.push(Z[n])):168===n?(x=t(l,b,c),k=t(o,b,c),j=t(o,b,f),C=t(l,b,f),_.push(W[n]),_.push(X[n])):2===n?(x=1-t(o,c,b),k=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),_.push(W[n]),_.push(X[n])):162===n?(w=t(l,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),_.push(W[n]),_.push(X[n])):8===n?(w=1-t(o,i,c),N=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),_.push(R[n]),_.push(U[n])):138===n?(w=1-t(o,i,c),N=1-t(l,i,c),m=1-t(l,i,f),v=1-t(o,i,f),_.push(R[n]),_.push(U[n])):32===n?(w=t(l,c,i),N=t(o,c,i),m=t(o,f,i),v=t(l,f,i),_.push(R[n]),_.push(U[n])):42===n?(j=1-t(l,f,b),C=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i),_.push(Y[n]),_.push(Z[n])):128===n&&(j=t(o,b,f),C=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f),_.push(Y[n]),_.push(Z[n])),5===n?(N=1-t(o,i,c),j=1-t(o,f,b),_.push(U[n])):165===n?(N=t(l,c,i),j=t(l,b,f),_.push(U[n])):20===n?(x=t(o,b,c),v=t(o,f,i),_.push(W[n])):150===n?(x=1-t(l,c,b),v=1-t(l,i,f),_.push(W[n])):80===n?(w=t(o,c,i),C=t(o,b,f),_.push(R[n])):90===n?(w=1-t(l,i,c),C=1-t(l,f,b),_.push(R[n])):65===n?(k=1-t(o,c,b),m=1-t(o,i,f),_.push(X[n])):105===n?(k=t(l,b,c),m=t(l,f,i),_.push(X[n])):160===n?(w=t(l,c,i),N=t(o,c,i),j=t(o,b,f),C=t(l,b,f),_.push(R[n]),_.push(U[n])):10===n?(w=1-t(o,i,c),N=1-t(l,i,c),j=1-t(l,f,b),C=1-t(o,f,b),_.push(R[n]),_.push(U[n])):130===n?(x=1-t(o,c,b),k=1-t(l,c,b),m=1-t(l,i,f),v=1-t(o,i,f),_.push(W[n]),_.push(X[n])):40===n?(x=t(l,b,c),k=t(o,b,c),m=t(o,f,i),v=t(l,f,i),_.push(W[n]),_.push(X[n])):101===n?(N=t(l,c,i),m=t(l,f,i),_.push(U[n])):69===n?(N=1-t(o,i,c),m=1-t(o,i,f),_.push(U[n])):149===n?(j=t(l,b,f),v=1-t(l,i,f),_.push(Y[n])):21===n?(j=1-t(o,f,b),v=t(o,f,i),_.push(Y[n])):86===n?(x=1-t(l,c,b),C=1-t(l,f,b),_.push(W[n])):84===n?(x=t(o,b,c),C=t(o,b,f),_.push(W[n])):89===n?(w=1-t(l,i,c),k=t(l,b,c),_.push(X[n])):81===n?(w=t(o,c,i),k=1-t(o,c,b),_.push(X[n])):96===n?(w=t(l,c,i),N=t(o,c,i),C=t(o,b,f),m=t(l,f,i),_.push(R[n]),_.push(U[n])):74===n?(w=1-t(o,i,c),N=1-t(l,i,c),C=1-t(l,f,b),m=1-t(o,i,f),_.push(R[n]),_.push(U[n])):24===n?(w=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),v=t(o,f,i),_.push(R[n]),_.push(X[n])):146===n?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),v=1-t(l,i,f),_.push(R[n]),_.push(X[n])):6===n?(N=1-t(o,i,c),x=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),_.push(U[n]),_.push(W[n])):164===n?(N=t(l,c,i),x=t(o,b,c),j=t(o,b,f),C=t(l,b,f),_.push(U[n]),_.push(W[n])):129===n?(k=1-t(o,c,b),j=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f),_.push(X[n]),_.push(Y[n])):41===n?(k=t(l,b,c),j=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i),_.push(X[n]),_.push(Y[n])):66===n?(x=1-t(o,c,b),k=1-t(l,c,b),C=1-t(l,f,b),m=1-t(o,i,f),_.push(W[n]),_.push(X[n])):104===n?(x=t(l,b,c),k=t(o,b,c),C=t(o,b,f),m=t(l,f,i),_.push(X[n]),_.push($[n])):144===n?(w=t(o,c,i),j=t(o,b,f),C=t(l,b,f),v=1-t(l,i,f),_.push(R[n]),_.push(Z[n])):26===n?(w=1-t(l,i,c),j=1-t(l,f,b),C=1-t(o,f,b),v=t(o,f,i),_.push(R[n]),_.push(Z[n])):36===n?(N=t(l,c,i),x=t(o,b,c),m=t(o,f,i),v=t(l,f,i),_.push(U[n]),_.push(W[n])):134===n?(N=1-t(o,i,c),x=1-t(l,c,b),m=1-t(l,i,f),v=1-t(o,i,f),_.push(U[n]),_.push(W[n])):9===n?(w=1-t(o,i,c),N=1-t(l,i,c),k=t(l,b,c),j=1-t(o,f,b),_.push(R[n]),_.push(U[n])):161===n?(w=t(l,c,i),N=t(o,c,i),k=1-t(o,c,b),j=t(l,b,f),_.push(R[n]),_.push(U[n])):37===n?(N=t(l,c,i),j=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i),_.push(U[n]),_.push(Y[n])):133===n?(N=1-t(o,i,c),j=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f),_.push(U[n]),_.push(Y[n])):148===n?(x=t(o,b,c),j=t(o,b,f),C=t(l,b,f),v=1-t(l,i,f),_.push(W[n]),_.push(Z[n])):22===n?(x=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),v=t(o,f,i),_.push(W[n]),_.push(Z[n])):82===n?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),C=1-t(l,f,b),_.push(R[n]),_.push(X[n])):88===n?(w=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),C=t(o,b,f),_.push(R[n]),_.push(X[n])):73===n?(w=1-t(o,i,c),N=1-t(l,i,c),k=t(l,b,c),m=1-t(o,i,f),_.push(R[n]),_.push(U[n])):97===n?(w=t(l,c,i),N=t(o,c,i),k=1-t(o,c,b),m=t(l,f,i),_.push(R[n]),_.push(U[n])):145===n?(w=t(o,c,i),k=1-t(o,c,b),j=t(l,b,f),v=1-t(l,i,f),_.push(R[n]),_.push(Y[n])):25===n?(w=1-t(l,i,c),k=t(l,b,c),j=1-t(o,f,b),v=t(o,f,i),_.push(R[n]),_.push(Y[n])):70===n?(N=1-t(o,i,c),x=1-t(l,c,b),C=1-t(l,f,b),m=1-t(o,i,f),_.push(U[n]),_.push(W[n])):100===n?(N=t(l,c,i),x=t(o,b,c),C=t(o,b,f),m=t(l,f,i),_.push(U[n]),_.push(W[n])):34===n?(0===d?(w=1-t(o,i,c),N=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),j=t(o,b,f),C=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f)):(w=t(l,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i)),_.push(R[n]),_.push(U[n]),_.push(Y[n]),_.push(Z[n])):35===n?(4===d?(w=1-t(o,i,c),N=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),j=t(o,b,f),C=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f)):(w=t(l,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i)),_.push(R[n]),_.push(U[n]),_.push(X[n]),_.push(Z[n])):136===n?(0===d?(w=t(l,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i)):(w=1-t(o,i,c),N=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),j=t(o,b,f),C=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f)),_.push(R[n]),_.push(U[n]),_.push(Y[n]),_.push(Z[n])):153===n?(0===d?(w=t(o,c,i),k=1-t(o,c,b),j=1-t(o,f,b),v=t(o,f,i)):(w=1-t(l,i,c),k=t(l,b,c),j=t(l,b,f),v=1-t(l,i,f)),_.push(R[n]),_.push(X[n])):102===n?(0===d?(N=1-t(o,i,c),x=t(o,b,c),C=t(o,b,f),m=1-t(o,i,f)):(N=t(l,c,i),x=1-t(l,c,b),C=1-t(l,f,b),m=t(l,f,i)),_.push(U[n]),_.push(Z[n])):155===n?(4===d?(w=t(o,c,i),k=1-t(o,c,b),j=1-t(o,f,b),v=t(o,f,i)):(w=1-t(l,i,c),k=t(l,b,c),j=t(l,b,f),v=1-t(l,i,f)),_.push(R[n]),_.push(Y[n])):103===n?(4===d?(N=1-t(o,i,c),x=t(o,b,c),C=t(o,b,f),m=1-t(o,i,f)):(N=t(l,c,i),x=1-t(l,c,b),C=1-t(l,f,b),m=t(l,f,i)),_.push(U[n]),_.push(W[n])):152===n?(0===d?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),v=t(o,f,i)):(w=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),j=t(o,b,f),C=t(l,b,f),v=1-t(l,i,f)),_.push(R[n]),_.push(W[n]),_.push(X[n])):156===n?(4===d?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),v=t(o,f,i)):(w=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),j=t(o,b,f),C=t(l,b,f),v=1-t(l,i,f)),_.push(R[n]),_.push(X[n]),_.push(Z[n])):137===n?(0===d?(w=t(l,c,i),N=t(o,c,i),k=1-t(o,c,b),j=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i)):(w=1-t(o,i,c),N=1-t(l,i,c),k=t(l,b,c),j=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f)),_.push(R[n]),_.push(U[n]),_.push(X[n])):139===n?(4===d?(w=t(l,c,i),N=t(o,c,i),k=1-t(o,c,b),j=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i)):(w=1-t(o,i,c),N=1-t(l,i,c),k=t(l,b,c),j=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f)),_.push(R[n]),_.push(U[n]),_.push(Y[n])):98===n?(0===d?(w=1-t(o,i,c),N=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),C=t(o,b,f),m=1-t(o,i,f)):(w=t(l,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),C=1-t(l,f,b),m=t(l,f,i)),_.push(R[n]),_.push(U[n]),_.push(Z[n])):99===n?(4===d?(w=1-t(o,i,c),N=1-t(l,i,c),x=t(l,b,c),k=t(o,b,c),C=t(o,b,f),m=1-t(o,i,f)):(w=t(l,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(l,c,b),C=1-t(l,f,b),m=t(l,f,i)),_.push(R[n]),_.push(U[n]),_.push(X[n])):38===n?(0===d?(N=1-t(o,i,c),x=t(o,b,c),j=t(o,b,f),C=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f)):(N=t(l,c,i),x=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i)),_.push(U[n]),_.push(Y[n]),_.push(Z[n])):39===n?(4===d?(N=1-t(o,i,c),x=t(o,b,c),j=t(o,b,f),C=t(l,b,f),m=1-t(l,i,f),v=1-t(o,i,f)):(N=t(l,c,i),x=1-t(l,c,b),j=1-t(l,f,b),C=1-t(o,f,b),m=t(o,f,i),v=t(l,f,i)),_.push(U[n]),_.push(W[n]),_.push(Z[n])):85===n&&(w=1,N=0,x=1,k=0,j=0,C=1,m=0,v=1),(m<0||m>1||v<0||v>1||w<0||w>1||x<0||x>1||j<0||j>1||C<0||C>1)&&console.log(n+" "+g+" "+f+","+i+","+c+","+b+" "+d+" "+m+" "+v+" "+w+" "+N+" "+x+" "+k+" "+j+" "+C),u.cells[h][a]={cval:n,cval_real:g,flipped:d,topleft:m,topright:v,righttop:w,rightbottom:N,bottomright:x,bottomleft:k,leftbottom:j,lefttop:C,edges:_}}}}}return u},oe=function(e,t,o){for(var s={type:"FeatureCollection",features:[]},r=0;r