markuno_lib 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/markcad.js +15 -6
- package/package.json +1 -1
- package/types/markcad.d.ts +22 -12
package/bin/markcad.js
CHANGED
|
@@ -164,6 +164,14 @@ constructor(p1,p2,x2=null,y2=null){"number"==typeof p1&&"number"==typeof p2&&nul
|
|
|
164
164
|
* semplificazione radiale e usa solo Douglas–Peucker per massima qualità.
|
|
165
165
|
* @returns {Array<{x:number,y:number}>} Nuovo array di punti semplificato.
|
|
166
166
|
*/
|
|
167
|
+
/**
|
|
168
|
+
* Calcola i punti di un arco DXF dato p1, p2, bulge e n punti intermedi.
|
|
169
|
+
* p1, p2: oggetti {x, y}
|
|
170
|
+
* bulge: valore DXF tra p1 e p2
|
|
171
|
+
* n: numero di punti INTERMEDI da inserire tra p1 e p2 (n=0 -> solo estremi)
|
|
172
|
+
* Return: array di punti [{x, y}, ..., {x, y}]
|
|
173
|
+
*/
|
|
174
|
+
function dxfbulge(p1,p2,bulge,n=0){const points=[];if(!bulge||Math.abs(bulge)<1e-10||0===n)return points;const theta=4*Math.atan(bulge);if(theta<0)return dxfbulge(p2,p1,-bulge,n).reverse();const dx=p2.x-p1.x,dy=p2.y-p1.y,chord=Math.hypot(dx,dy),r=chord/(2*Math.sin(theta/2)),mx=(p1.x+p2.x)/2,my=(p1.y+p2.y)/2,nx=-dy/chord,ny=dx/chord,d=r*Math.cos(theta/2),sign=bulge>=0?1:-1,cx=mx+sign*nx*d,cy=my+sign*ny*d;let a1=Math.atan2(p1.y-cy,p1.x-cx);for(let i=1;i<=n;i++){const a=a1+i/(n+1)*theta,x=cx+r*Math.cos(a),y=cy+r*Math.sin(a);points.push({x:x,y:y})}return points}
|
|
167
175
|
/**
|
|
168
176
|
* Crea una curva di Bézier quadratica tra due segmenti di linea.
|
|
169
177
|
* @param {Object} a1 - Punto iniziale del primo segmento {x,y}
|
|
@@ -230,6 +238,7 @@ function raccordabezier(a1,a2,b1,b2,subdivisions=10){const intersection=function
|
|
|
230
238
|
* @method fromclip(vv) - Inizializza da punti in formato clipper
|
|
231
239
|
* @method fromvec(aa) - Inizializza da array di coordinate [x1,y1,x2,y2,...]
|
|
232
240
|
* @method frompt(pts) - Inizializza da array di punti [{x,y},...]
|
|
241
|
+
* @method fromdxfvec(verts) - vertici nel formato DXF LWPOLYLINE con bulge per i raccordi:
|
|
233
242
|
* @method fromstr(str) - Inizializza da stringa con sintassi speciale
|
|
234
243
|
* @method addpt(pts) - Aggiunge punti alla forma
|
|
235
244
|
* @method addracc(v1,v2,suddivisioni,addv1v2) - Aggiunge raccordo tra punti
|
|
@@ -266,7 +275,7 @@ function _addvec(aa){for(let i=0;i<aa.length;i+=2)pt.push({x:aa[i],y:aa[i+1]})}f
|
|
|
266
275
|
* @param {number} thresholdDeg - Angolo in gradi.
|
|
267
276
|
* @returns {Array<{ index: number, point: {x:number,y:number}, angle: number }>}
|
|
268
277
|
*/
|
|
269
|
-
function sharpCorners(path,thresholdDeg=45){const result=[],n=path.length;if(n<3)return result;for(let i=0;i<n;i++){const prev=path[(i-1+n)%n],curr=path[i],next=path[(i+1)%n],ux=curr.x-prev.x,uy=curr.y-prev.y,vx=next.x-curr.x,vy=next.y-curr.y,magU=Math.hypot(ux,uy),magV=Math.hypot(vx,vy);if(0===magU||0===magV)continue;let cosTheta=(ux*vx+uy*vy)/(magU*magV);cosTheta=Math.max(-1,Math.min(1,cosTheta));const angleDeg=180*Math.acos(cosTheta)/Math.PI;angleDeg>thresholdDeg&&result.push({i:i,x:curr.x,y:curr.y,a:angleDeg})}return result}(pt,45),clone:()=>getshape().frompt(pt),dims:()=>dims(pt),alignline(p1,p2){return pt=function stretchShapeToLine(shapePts,p1,p2){if(!shapePts?.length||!p1||!p2)return[];const first=shapePts[0],last=shapePts[shapePts.length-1],dx=last.x-first.x,dy=last.y-first.y,ang=Math.atan2(dy,dx);let pts0=shapePts.map((p=>({x:p.x-first.x,y:p.y-first.y}))),pts1=pts0.map((p=>({x:p.x*Math.cos(-ang)-p.y*Math.sin(-ang),y:p.x*Math.sin(-ang)+p.y*Math.cos(-ang)})));const linea={dx:p2.x-p1.x,dy:p2.y-p1.y},scaleX=Math.sqrt(linea.dx*linea.dx+linea.dy*linea.dy)/(pts1[pts1.length-1].x||1e-8);let pts2=pts1.map((p=>({x:p.x*scaleX,y:p.y})));const angDest=Math.atan2(linea.dy,linea.dx);let pts3=pts2.map((p=>({x:p.x*Math.cos(angDest)-p.y*Math.sin(angDest),y:p.x*Math.sin(angDest)+p.y*Math.cos(angDest)}))),ptsFinal=pts3.map((p=>({x:p.x+p1.x,y:p.y+p1.y})));return ptsFinal}(pt,p1,p2),this},rotate(deg){if(!deg)return this;const r=deg*Math.PI/180,cosTheta=Math.cos(r),sinTheta=Math.sin(r);for(let p of pt){const xNew=p.x*cosTheta-p.y*sinTheta,yNew=p.x*sinTheta+p.y*cosTheta;p.x=xNew,p.y=yNew}return this},selezionaprimo:selezionaprimo,
|
|
278
|
+
function sharpCorners(path,thresholdDeg=45){const result=[],n=path.length;if(n<3)return result;for(let i=0;i<n;i++){const prev=path[(i-1+n)%n],curr=path[i],next=path[(i+1)%n],ux=curr.x-prev.x,uy=curr.y-prev.y,vx=next.x-curr.x,vy=next.y-curr.y,magU=Math.hypot(ux,uy),magV=Math.hypot(vx,vy);if(0===magU||0===magV)continue;let cosTheta=(ux*vx+uy*vy)/(magU*magV);cosTheta=Math.max(-1,Math.min(1,cosTheta));const angleDeg=180*Math.acos(cosTheta)/Math.PI;angleDeg>thresholdDeg&&result.push({i:i,x:curr.x,y:curr.y,a:angleDeg})}return result}(pt,45),clone:()=>getshape().frompt(pt),dims:()=>dims(pt),get area(){return Math.abs(pt.reduce(((acc,curr,i)=>{const next=pt[(i+1)%pt.length];return acc+(curr.x*next.y-next.x*curr.y)}),0)/2)},alignline(p1,p2){return pt=function stretchShapeToLine(shapePts,p1,p2){if(!shapePts?.length||!p1||!p2)return[];const first=shapePts[0],last=shapePts[shapePts.length-1],dx=last.x-first.x,dy=last.y-first.y,ang=Math.atan2(dy,dx);let pts0=shapePts.map((p=>({x:p.x-first.x,y:p.y-first.y}))),pts1=pts0.map((p=>({x:p.x*Math.cos(-ang)-p.y*Math.sin(-ang),y:p.x*Math.sin(-ang)+p.y*Math.cos(-ang)})));const linea={dx:p2.x-p1.x,dy:p2.y-p1.y},scaleX=Math.sqrt(linea.dx*linea.dx+linea.dy*linea.dy)/(pts1[pts1.length-1].x||1e-8);let pts2=pts1.map((p=>({x:p.x*scaleX,y:p.y})));const angDest=Math.atan2(linea.dy,linea.dx);let pts3=pts2.map((p=>({x:p.x*Math.cos(angDest)-p.y*Math.sin(angDest),y:p.x*Math.sin(angDest)+p.y*Math.cos(angDest)}))),ptsFinal=pts3.map((p=>({x:p.x+p1.x,y:p.y+p1.y})));return ptsFinal}(pt,p1,p2),this},rotate(deg){if(!deg)return this;const r=deg*Math.PI/180,cosTheta=Math.cos(r),sinTheta=Math.sin(r);for(let p of pt){const xNew=p.x*cosTheta-p.y*sinTheta,yNew=p.x*sinTheta+p.y*cosTheta;p.x=xNew,p.y=yNew}return this},selezionaprimo:selezionaprimo,
|
|
270
279
|
/**
|
|
271
280
|
* Trova i punti in cui l’angolo interno è maggiore di `thresholdDeg`.
|
|
272
281
|
*
|
|
@@ -274,7 +283,7 @@ function sharpCorners(path,thresholdDeg=45){const result=[],n=path.length;if(n<3
|
|
|
274
283
|
* @param {number} thresholdDeg - Angolo in gradi.
|
|
275
284
|
* @returns {Array<{ index: number, point: {x:number,y:number}, angle: number }>}
|
|
276
285
|
*/
|
|
277
|
-
segment(i,inverse=!1){let n=pt.length;return i<0&&(i+=n),new Linea2(pt[i%n],pt[(i+(inverse?-1:1))%n])},lineoffset(i1,i2,offset){if((i1=(i1||0)%pt.length)!=(i2=(i2||0)%pt.length)){let l2=new Linea2(pt[i1],pt[i2]);if(l2){return l2=l2.offsetline(-offset),this.intersectline(l2)}}},orientasplitter(){-1!=orientation()&&pt.reverse();let np=pt.length;for(let i=0;i<np;i++){let lt=new Linea2(pt[(np+i-1)%np],pt[i]);if(Math.abs(Math.abs(lt.angle)-Math.PI)<.001){i&&selezionaprimo(i);break}}return this},move(x=0,y=0){"object"==typeof x&&x.x&&(y=x.y||0,x=x.x);for(let p of pt)p.x+=x,p.y+=y;return this},mirrorx(value=0){for(let p of pt)p.x=2*value-p.x;return this},mirrory(value=0){for(let p of pt)p.y=2*value-p.y;return this},simplify(tolerance,hq){return pt=function simplify(points,tolerance,highestQuality){if(points.length<=2)return points;var sqTolerance=void 0!==tolerance?tolerance*tolerance:1;return simplifyDouglasPeucker(points=highestQuality?points:function simplifyRadialDist(points,sqTolerance){for(var point,p1,p2,dx,dy,prevPoint=points[0],newPoints=[prevPoint],i=1,len=points.length;i<len;i++)p2=prevPoint,dx=void 0,dy=void 0,(dx=(p1=point=points[i]).x-p2.x)*dx+(dy=p1.y-p2.y)*dy>sqTolerance&&(newPoints.push(point),prevPoint=point);return prevPoint!==point&&newPoints.push(point),newPoints}(points,sqTolerance),sqTolerance)}(pt,tolerance,hq),this},fromclip(vv){pt=[];for(let p of vv)pt.push({x:p.x/1e3,y:p.y/1e3});return this},infosegmento(i,open=!1){const n=pt.length;function clampIndex(idx){return(idx+n)%n}function angle(p1,p2){return Math.atan2(p2.y-p1.y,p2.x-p1.x)}function angleDiff(a,b){let diff=a-b;for(;diff>Math.PI;)diff-=2*Math.PI;for(;diff<-Math.PI;)diff+=2*Math.PI;return diff}const p1=pt[i];let p0,p2,p3;if(open)if(0===i){const dx=pt[1].x-pt[0].x,dy=pt[1].y-pt[0].y;p0={x:pt[0].x-dx,y:pt[0].y-dy},p2=pt[1],p3=pt[2]}else if(i===n-1){const dx=pt[n-1].x-pt[n-2].x,dy=pt[n-1].y-pt[n-2].y;p0=pt[n-2],p2={x:pt[n-1].x+dx,y:pt[n-1].y+dy},p3={x:p2.x+dx,y:p2.y+dy}}else p0=pt[i-1],p2=pt[i+1],p3=i+2<n?pt[i+2]:{x:pt[i+1].x+(pt[i+1].x-pt[i].x),y:pt[i+1].y+(pt[i+1].y-pt[i].y)};else{const i0=clampIndex(i-1),i2=clampIndex(i+1),i3=clampIndex(i+2);p0=pt[i0],p2=pt[i2],p3=pt[i3]}const ang12=angle(p1,p2),ang01=angle(p0,p1),ang23=angle(p2,p3);return{x:p1.x,y:p1.y,l:function length(p1,p2){const dx=p2.x-p1.x,dy=p2.y-p1.y;return Math.sqrt(dx*dx+dy*dy)}(p1,p2),ang:ang12/PIF,a1:angleDiff(ang12,ang01)/PIF,a2:angleDiff(ang23,ang12)/PIF}},swapxy(){for(let i=0;i<pt.length;i++){let q=pt[i].x;pt[i].x=-pt[i].y,pt[i].y=-q}return this},fromvec(aa){return pt=[],_addvec(aa),this},addvec(vec){return _addvec(vec),this},frompt(pts){return pt=[...pts],pt=removeduplicate(pt),this},fromstr(str){return pt=removeduplicate(function processTokens(tokens){const points=[];for(let i=0;i<tokens.length;i++){const token=tokens[i];if("point"===token.type)points.push(token.point);else if("command"===token.type)switch(token.cmd){case"b":{if(points.length<2)continue;const npt=parseInt(token.params[0])||5,p1=points[points.length-2],p2=points[points.length-1];let p3="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p4="point"===tokens[i+2]?.type?tokens[i+2].point:void 0;p3?p4||(p4=points[0]):(p3=points[0],p4=points[1]);const raccordo=raccordabezier(p1,p2,p3,p4,npt);points.push(...raccordo),i+=1;break}case"r":{if(points.length<1)continue;const dist=parseFloat(token.params[0])||5,npt=parseInt(token.params[1])||10,p1=points[points.length-1];let p2="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p3="point"===tokens[i+2]?.type?tokens[i+2].point:"point"===tokens[i+3]?.type?tokens[i+3].point:void 0;p2?p3||(p3=points[0]):(p2=points[0],p3=points[1],points.splice(0,1));const raccordo=raccordabezier3(p1,p2,p3,dist,npt);points.push(...raccordo),i+=1;break}case"c":{const radius=parseFloat(token.params[0])||50,segments=parseInt(token.params[1])||12,center="point"===tokens[i+1]?.type?tokens[i+1].point:new Punto2(0,0);for(let j=0;j<segments;j++)points.push(new Punto2(center.x+radius*Math.cos(j/segments*Math.PI*2),center.y+radius*Math.sin(j/segments*Math.PI*2)));i+=1;break}case"a":{let npt,p1="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p2="point"===tokens[i+2]?.type?tokens[i+2].point:void 0,p3="point"===tokens[i+3]?.type?tokens[i+3].point:void 0;if(!p1||!p3)continue;if(p2)if(token.params[0])npt=clamp(parseInt(token.params[0]),1,24);else{const chord=Math.hypot(p3.x-p1.x,p3.y-p1.y),sagitta=Math.abs((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))/(2*chord);npt=Math.round(chord*Math.sqrt(sagitta/(chord+.1))*10),npt=clamp(npt,1,24),npt=1}else p2=p3,npt=0;const arcoPoints=arcfrom3point(npt,p1,p2,p3);points.push(...arcoPoints),i+=3;break}}}return points}(function tokenize(str){const tokens=[],values=str.toLowerCase().replace(/[\n\s]+/gm," ").split(/[,;]/).map((s=>s.trim()));for(let i=0;i<values.length;){const current=values[i];["b","r","c","a"].includes(current[0])?(tokens.push({type:"command",cmd:current[0],params:current.slice(1).split(":")}),i++):/[a-zA-Z]/.test(current[0])||(i<values.length-1?(tokens.push({type:"point",point:new Punto2(parseFloat(values[i]),parseFloat(values[i+1]))}),i+=2):i++)}return tokens}(str))),this},fromrect(w,h,sx,sy,bordo){w||(w=10),h||(h=10),bordo||(bordo=0),bordo=Math.min(Math.abs(bordo),Math.abs(.4*w),Math.abs(.4*h));let b1=w>0?bordo:-bordo,b2=h>0?bordo:-bordo;return pt=bordo?[{x:b1,y:0},{x:w-b1,y:0},{x:w,y:b2},{x:w,y:h-b2},{x:w-b1,y:h},{x:b1,y:h},{x:0,y:h-b2},{x:0,y:b2}]:[{x:0,y:0},{x:w,y:0},{x:w,y:h},{x:0,y:h}],this},intersectline:l=>function _intersectline(shape,p3,p4){let n=shape.length,l=new Linea2(p3,p4);const intersezioni=[];for(let i=0;i<shape.length;i++){let l2=new Linea2(shape[i],shape[(i+1)%n]),p=l2.interseca(l);p&&l2.onsegment(p)&&intersezioni.push(p)}if(intersezioni.length<2)return null;const{dx:dx,dy:dy}=l;intersezioni.sort(((a,b)=>(a.x-p3.x)*dx+(a.y-p3.y)*dy-((b.x-p3.x)*dx+(b.y-p3.y)*dy)));let pstart=new Punto2(intersezioni[0].x,intersezioni[0].y),pend=new Punto2(intersezioni[intersezioni.length-1].x,intersezioni[intersezioni.length-1].y);const vx1=pend.x-pstart.x,vy1=pend.y-pstart.y;return vx1*dx+vy1*dy<0&&([pstart,pend]=[pend,pstart]),new Linea2(pstart,pend)}(pt,l.p1,l.p2),tostr(dec=2){let dd=10**dec,pstr=x=>String(Math.round(x*dd)/dd)
|
|
286
|
+
segment(i,inverse=!1){let n=pt.length;return i<0&&(i+=n),new Linea2(pt[i%n],pt[(i+(inverse?-1:1))%n])},lineoffset(i1,i2,offset){if((i1=(i1||0)%pt.length)!=(i2=(i2||0)%pt.length)){let l2=new Linea2(pt[i1],pt[i2]);if(l2){return l2=l2.offsetline(-offset),this.intersectline(l2)}}},orientasplitter(){-1!=orientation()&&pt.reverse();let np=pt.length;for(let i=0;i<np;i++){let lt=new Linea2(pt[(np+i-1)%np],pt[i]);if(Math.abs(Math.abs(lt.angle)-Math.PI)<.001){i&&selezionaprimo(i);break}}return this},move(x=0,y=0){"object"==typeof x&&x.x&&(y=x.y||0,x=x.x);for(let p of pt)p.x+=x,p.y+=y;return this},mirrorx(value=0){for(let p of pt)p.x=2*value-p.x;return this},mirrory(value=0){for(let p of pt)p.y=2*value-p.y;return this},simplify(tolerance,hq){return pt=function simplify(points,tolerance,highestQuality){if(points.length<=2)return points;var sqTolerance=void 0!==tolerance?tolerance*tolerance:1;return simplifyDouglasPeucker(points=highestQuality?points:function simplifyRadialDist(points,sqTolerance){for(var point,p1,p2,dx,dy,prevPoint=points[0],newPoints=[prevPoint],i=1,len=points.length;i<len;i++)p2=prevPoint,dx=void 0,dy=void 0,(dx=(p1=point=points[i]).x-p2.x)*dx+(dy=p1.y-p2.y)*dy>sqTolerance&&(newPoints.push(point),prevPoint=point);return prevPoint!==point&&newPoints.push(point),newPoints}(points,sqTolerance),sqTolerance)}(pt,tolerance,hq),this},fromclip(vv){pt=[];for(let p of vv)pt.push({x:p.x/1e3,y:p.y/1e3});return this},infosegmento(i,open=!1){const n=pt.length;function clampIndex(idx){return(idx+n)%n}function angle(p1,p2){return Math.atan2(p2.y-p1.y,p2.x-p1.x)}function angleDiff(a,b){let diff=a-b;for(;diff>Math.PI;)diff-=2*Math.PI;for(;diff<-Math.PI;)diff+=2*Math.PI;return diff}const p1=pt[i];let p0,p2,p3;if(open)if(0===i){const dx=pt[1].x-pt[0].x,dy=pt[1].y-pt[0].y;p0={x:pt[0].x-dx,y:pt[0].y-dy},p2=pt[1],p3=pt[2]}else if(i===n-1){const dx=pt[n-1].x-pt[n-2].x,dy=pt[n-1].y-pt[n-2].y;p0=pt[n-2],p2={x:pt[n-1].x+dx,y:pt[n-1].y+dy},p3={x:p2.x+dx,y:p2.y+dy}}else p0=pt[i-1],p2=pt[i+1],p3=i+2<n?pt[i+2]:{x:pt[i+1].x+(pt[i+1].x-pt[i].x),y:pt[i+1].y+(pt[i+1].y-pt[i].y)};else{const i0=clampIndex(i-1),i2=clampIndex(i+1),i3=clampIndex(i+2);p0=pt[i0],p2=pt[i2],p3=pt[i3]}const ang12=angle(p1,p2),ang01=angle(p0,p1),ang23=angle(p2,p3);return{x:p1.x,y:p1.y,l:function length(p1,p2){const dx=p2.x-p1.x,dy=p2.y-p1.y;return Math.sqrt(dx*dx+dy*dy)}(p1,p2),ang:ang12/PIF,a1:angleDiff(ang12,ang01)/PIF,a2:angleDiff(ang23,ang12)/PIF}},swapxy(){for(let i=0;i<pt.length;i++){let q=pt[i].x;pt[i].x=-pt[i].y,pt[i].y=-q}return this},fromvec(aa){return pt=[],_addvec(aa),this},addvec(vec){return _addvec(vec),this},frompt(pts){return pt=[...pts],pt=removeduplicate(pt),this},fromdxfvec(verts){let points=[];if(verts&&verts.length)for(let i=0;i<verts.length;i++){let{x:x,y:y,bulge:bulge}=verts[i];if(points.push({x:x,y:y}),bulge){const step=1;let p1={x:x,y:y},p2=verts[(i+1)%verts.length],dx=p2.x-p1.x,dy=p2.y-p1.y,dist=Math.hypot(dx,dy);dist>step&&points.push(...dxfbulge(p1,p2,bulge,Math.floor((dist-step)/step)+1))}}return pt=points.map((e=>({x:Math.round(10*e.x)/10,y:Math.round(10*e.y)/10}))),pt=removeduplicate(pt),this},fromstr(str){return pt=removeduplicate(function processTokens(tokens){const points=[];for(let i=0;i<tokens.length;i++){const token=tokens[i];if("point"===token.type)points.push(token.point);else if("command"===token.type)switch(token.cmd){case"x":{const p1=points[points.length-1],p2="point"===tokens[i+1]?.type?tokens[i+1].point:points[0],bulge=parseFloat(token.params[0])||5;{const STEP=1;let dx=p2.x-p1.x,dy=p2.y-p1.y,dist=Math.hypot(dx,dy);dist>1&&points.push(...dxfbulge(p1,p2,bulge,Math.floor((dist-STEP)/(STEP+2))+1))}break}case"b":{if(points.length<2)continue;const npt=parseInt(token.params[0])||5,p1=points[points.length-2],p2=points[points.length-1];let p3="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p4="point"===tokens[i+2]?.type?tokens[i+2].point:void 0;p3?p4||(p4=points[0]):(p3=points[0],p4=points[1]);const raccordo=raccordabezier(p1,p2,p3,p4,npt);points.push(...raccordo),i+=1;break}case"r":{if(points.length<1)continue;const dist=parseFloat(token.params[0])||5,npt=parseInt(token.params[1])||10,p1=points[points.length-1];let p2="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p3="point"===tokens[i+2]?.type?tokens[i+2].point:"point"===tokens[i+3]?.type?tokens[i+3].point:void 0;p2?p3||(p3=points[0]):(p2=points[0],p3=points[1],points.splice(0,1));const raccordo=raccordabezier3(p1,p2,p3,dist,npt);points.push(...raccordo),i+=1;break}case"c":{const radius=parseFloat(token.params[0])||50,segments=parseInt(token.params[1])||12,center="point"===tokens[i+1]?.type?tokens[i+1].point:new Punto2(0,0);for(let j=0;j<segments;j++)points.push(new Punto2(center.x+radius*Math.cos(j/segments*Math.PI*2),center.y+radius*Math.sin(j/segments*Math.PI*2)));i+=1;break}case"a":{let npt,p1="point"===tokens[i+1]?.type?tokens[i+1].point:void 0,p2="point"===tokens[i+2]?.type?tokens[i+2].point:void 0,p3="point"===tokens[i+3]?.type?tokens[i+3].point:void 0;if(!p1||!p3)continue;if(p2)if(token.params[0])npt=clamp(parseInt(token.params[0]),1,24);else{const chord=Math.hypot(p3.x-p1.x,p3.y-p1.y),sagitta=Math.abs((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))/(2*chord);npt=Math.round(chord*Math.sqrt(sagitta/(chord+.1))*10),npt=clamp(npt,1,24),npt=1}else p2=p3,npt=0;const arcoPoints=arcfrom3point(npt,p1,p2,p3);points.push(...arcoPoints),i+=3;break}}}return points}(function tokenize(str){const tokens=[],values=str.toLowerCase().replace(/[\n\s]+/gm," ").split(/[,;]/).map((s=>s.trim()));for(let i=0;i<values.length;){const current=values[i];["b","r","c","a","x"].includes(current[0])?(tokens.push({type:"command",cmd:current[0],params:current.slice(1).split(":")}),i++):/[a-zA-Z]/.test(current[0])||(i<values.length-1?(tokens.push({type:"point",point:new Punto2(parseFloat(values[i]),parseFloat(values[i+1]))}),i+=2):i++)}return tokens}(str))),this},fromrect(w,h,sx,sy,bordo){w||(w=10),h||(h=10),bordo||(bordo=0),bordo=Math.min(Math.abs(bordo),Math.abs(.4*w),Math.abs(.4*h));let b1=w>0?bordo:-bordo,b2=h>0?bordo:-bordo;return pt=bordo?[{x:b1,y:0},{x:w-b1,y:0},{x:w,y:b2},{x:w,y:h-b2},{x:w-b1,y:h},{x:b1,y:h},{x:0,y:h-b2},{x:0,y:b2}]:[{x:0,y:0},{x:w,y:0},{x:w,y:h},{x:0,y:h}],this},intersectline:l=>function _intersectline(shape,p3,p4){let n=shape.length,l=new Linea2(p3,p4);const intersezioni=[];for(let i=0;i<shape.length;i++){let l2=new Linea2(shape[i],shape[(i+1)%n]),p=l2.interseca(l);p&&l2.onsegment(p)&&intersezioni.push(p)}if(intersezioni.length<2)return null;const{dx:dx,dy:dy}=l;intersezioni.sort(((a,b)=>(a.x-p3.x)*dx+(a.y-p3.y)*dy-((b.x-p3.x)*dx+(b.y-p3.y)*dy)));let pstart=new Punto2(intersezioni[0].x,intersezioni[0].y),pend=new Punto2(intersezioni[intersezioni.length-1].x,intersezioni[intersezioni.length-1].y);const vx1=pend.x-pstart.x,vy1=pend.y-pstart.y;return vx1*dx+vy1*dy<0&&([pstart,pend]=[pend,pstart]),new Linea2(pstart,pend)}(pt,l.p1,l.p2),tostr(dec=2){let dd=10**dec,pstr=x=>String(Math.round(x*dd)/dd),cl=pt.map((e=>`${pstr(e.x)};${pstr(e.y)};`)).join("");return cl&&cl.length?cl.slice(0,-1).match(/.{1,80}(;|$)/g).map((s=>s.trim())).join("\n"):""},addpt(pts){return pts?(Array.isArray(pts)||(pts=[pts]),pt=removeduplicate([...pt,...pts]),this):this},addracc(v1,v2,suddivisioni=2,addv1v2=!0){if(Array.isArray(v1)&&(v2={x:v1[2]||0,y:v1[3]||0},v1={x:v1[0]||0,y:v1[1]||0}),pt.length>=2){let tm=raccordabezier(pt[pt.length-2],pt[pt.length-1],v1,v2,suddivisioni);pt=[...pt,...tm],addv1v2&&(pt.push(v1),pt.push(v2))}return pt=removeduplicate(pt),this},setorient(mode){let p=orientation();return(1==p&&-1==mode||-1==p&&1==mode)&&pt.reverse(),this},reverse(){return pt.reverse(),this},pointinshape:p=>function isPointInPolygon(P){let x=P.x,y=P.y,inside=!1;for(let i=0,j=pt.length-1;i<pt.length;j=i++){let xi=pt[i].x,yi=pt[i].y,xj=pt[j].x,yj=pt[j].y;yi>y!=yj>y&&x<(xj-xi)*(y-yi)/(yj-yi)+xi&&(inside=!inside)}return inside}(p),azzera(){return pt=[],this},removeduplicate(delta=.005){return pt=removeduplicate(pt,delta),this},to3d(u0,alt=0,coeffa=0,coeffb=0,open=!1){pt=removeduplicate(pt);let tm=function genuvnormal(path,options){let{currentU:currentU=0,c:c=0,a:a=0,b:b=0,anglemin:anglemin=30,open:open=!1}=options;const pointsWithNormals=[],n=path.length;for(let i=0;i<n;i++){const prev=path[(i-1+n)%n],current=path[i],next=path[(i+1)%n],vPrev={x:current.x-prev.x,y:current.y-prev.y},vNext={x:next.x-current.x,y:next.y-current.y},normalPrev=normal2(prev,current),normalNext=normal2(current,next),angle=angle2vec(vPrev,vNext);let z=a*current.x+b*current.y+c;Math.abs(angle-180)<=anglemin?(normalPrev.nx,normalNext.nx,normalPrev.ny,normalNext.ny,pointsWithNormals.push({x:current.x,y:-current.y,z:z,u:currentU,v:z})):(pointsWithNormals.push({x:current.x,y:-current.y,z:z,u:currentU,v:z}),pointsWithNormals.push({x:current.x,y:-current.y,z:z,u:currentU,v:z}));const dx=next.x-current.x,dy=next.y-current.y;currentU+=Math.sqrt(dx*dx+dy*dy)}if(!open){let p=pointsWithNormals[0],pf=pointsWithNormals[pointsWithNormals.length-1];p.x==pf.x&&p.y==pf.y||pointsWithNormals.push({x:p.x,y:p.y,z:p.z,nx:p.nx,ny:p.ny,nz:p.nz,u:currentU,v:p.z})}return pointsWithNormals}(pt,{open:open,currentU:u0,c:alt,a:coeffa,b:coeffb,anglemin:30});return tm},getboundbox:()=>pt.length?pt.reduce(((box,p)=>(box.p1.x=Math.min(box.p1.x,p.x),box.p1.y=Math.min(box.p1.y,p.y),box.p2.x=Math.max(box.p2.x,p.x),box.p2.y=Math.max(box.p2.y,p.y),box)),{p1:new Punto2(1/0,1/0),p2:new Punto2(-1/0,-1/0)}):{p1:new Punto2(0,0),p2:new Punto2(0,0)},fittobox(p1,p2){if(!pt.length)return this;const currentBox=this.getboundbox(),currentWidth=currentBox.p2.x-currentBox.p1.x,currentHeight=currentBox.p2.y-currentBox.p1.y,targetWidth=p2.x-p1.x,targetHeight=p2.y-p1.y,scale=Math.min(targetWidth/(currentWidth||1),targetHeight/(currentHeight||1));for(let p of pt)p.x=(p.x-currentBox.p1.x)*scale,p.y=(p.y-currentBox.p1.y)*scale,p.x+=p1.x,p.y+=p1.y;return this}}}
|
|
278
287
|
/**
|
|
279
288
|
* Calcola i punti di un arco passante per tre punti
|
|
280
289
|
* @param {number} segments - Numero di segmenti (punti-1)
|
|
@@ -500,7 +509,7 @@ function shapeclip(){function toclipformat(pts){let tm=pts.map((e=>({X:Math.roun
|
|
|
500
509
|
* @param {boolean} [interna=false] - Se true, usa i bordi interni degli intervalli
|
|
501
510
|
* @param {boolean} [allbreak=false] - Se true, considera ogni punto degli intervalli come una rottura
|
|
502
511
|
* @returns {Array<{a: number, b: number}>} Array di segmenti generati
|
|
503
|
-
*/const tipi={i:"inclinato",a:"arco",d:"diagonali",s:"smussato",x:"normale"},tagli={dd:"diagonale",vv:"verticale",oo:"orizzontale",vo:"verticale+orizzontale",vd:"verticale+diagonale",ov:"orizzontale+verticale",od:"orizzontale+diagonale"},tipocut={d:"dist. positiva","d-":"dist. negativa",p:"perc. positiva","p-":"perc negativa"},tipoalign={l:"sinistra",c:"centro",r:"destra"};function findareacod(areacodes,x,y){let mindist=1/0,minkey="";for(let k of areacodes){let dist=(k.x-x)**2+(k.y-y)**2;dist<mindist&&(mindist=dist,minkey=k.k)}return minkey}function generatesegments(t1,t2,interna=!1,allbreak=!1){let t3=[];if(t1?.length>=2){if(allbreak){let tm=[];for(let t of t1)tm.push({a:t.a,b:t.a}),t.a!=t.b&&tm.push({a:t.b,b:t.b});t1=tm}if(t1=t1.sort(((a,b)=>a.a-b.a)),t2?.length){let j=0;for(let i=1;i<t1.length;i++){const ε=1e-6;t2.find((e=>e>t1[i-1].b+ε&&e<t1[i].a-ε))&&(i-1>j&&(interna?t3.push({a:t1[j].b,b:t1[i-1].a}):t3.push({a:t1[j].a,b:t1[i-1].b})),j=i)}j<t1.length-1&&(interna?t3.push({a:t1[j].b,b:t1[t1.length-1].a}):t3.push({a:t1[j].a,b:t1[t1.length-1].b}))}else t3.push({a:t1[0].b,b:t1[t1.length-1].a})}return t3}function makedivisions(ff,shape2,oggetti){let draws=[],areas=[],dati=[],lines=[],{x:dx,y:dy,oriz:oriz,vert:vert,tipo:tipo,minvano:minvano,minvanox:minvanox,minvanoy:minvanoy}=ff,{bb:bb,bt:bt,bl:bl,br:br}=getbordi(oggetti,ff.bordo);minvanox=minvanox||minvano||50,minvanoy=minvanoy||minvano||50;let{dati:h1,punti:ph}=ordinabase(oggetti,"o",oriz,dy,minvanoy,bb,bt,tipo),{dati:v1,punti:pv}=ordinabase(oggetti,"v",vert,dx,minvanox,bl,br),shapecontorno=shape2.clone();function adddatilin(type,cod,l0,l1,sp,id){if("l"==type)areas.push([l0.p1,l0.p2]);else{let ptx=[l0.p1,l0.p2,l1.p2,l1.p1];areas.push(ptx);let s1=getshape().frompt(ptx);if(shapecontorno?.pt&&(s1.orient!=shapecontorno.orient&&s1.reverse(),s1=shapeclip().intersecasplitter(shapecontorno,s1)),s1){s1.pt.length>=4&&(l0.p1=s1.pt[0],l0.p2=s1.pt[1],l1.p1=s1.pt[s1.pt.length-1],l1.p2=s1.pt[s1.pt.length-2]),lines.push([l0.p1.x+("v"==type?sp:0),l0.p1.y+("v"!=type?sp:0),l0.p2.x+("v"==type?sp:0),l0.p2.y+("v"!=type?sp:0)]);let info=l0.infoquad(l1);if(info&&info.distanza){let s2=s1.clone(),c2=checkoggetto(oggetti,type,cod);(info.sx||info.sy)&&s2.move(-info.sx||0,-info.sy||0),info.angle&&s2.rotate(-info.angle||0);let tm={id:id,type:type,cod:cod,c2:c2,shape:s2.pt,info:info};dati.push(tm),tm?.shape&&draws.push({type:type,sx:tm.info.sx,sy:tm.info.sy,rot:tm.info.angle,pt:tm.shape})}}}}function isinseg(segs,v){
|
|
512
|
+
*/const tipi={i:"inclinato",a:"arco",d:"diagonali",s:"smussato",x:"normale"},tagli={dd:"diagonale",vv:"verticale",oo:"orizzontale",vo:"verticale+orizzontale",vd:"verticale+diagonale",ov:"orizzontale+verticale",od:"orizzontale+diagonale"},tipocut={d:"dist. positiva","d-":"dist. negativa",p:"perc. positiva","p-":"perc negativa"},tipoalign={l:"sinistra",c:"centro",r:"destra"};function findareacod(areacodes,x,y){let mindist=1/0,minkey="";for(let k of areacodes){let dist=(k.x-x)**2+(k.y-y)**2;dist<mindist&&(mindist=dist,minkey=k.k)}return minkey}function generatesegments(t1,t2,interna=!1,allbreak=!1){let t3=[];if(t1?.length>=2){if(allbreak){let tm=[];for(let t of t1)tm.push({a:t.a,b:t.a}),t.a!=t.b&&tm.push({a:t.b,b:t.b});t1=tm}if(t1=t1.sort(((a,b)=>a.a-b.a)),t2?.length){let j=0;for(let i=1;i<t1.length;i++){const ε=1e-6;let f=t2.find((e=>e>t1[i-1].b+ε&&e<t1[i].a-ε));f&&(i-1>j&&(interna?t3.push({a:t1[j].b,b:t1[i-1].a}):t3.push({a:t1[j].a,b:t1[i-1].b})),j=i)}j<t1.length-1&&(interna?t3.push({a:t1[j].b,b:t1[t1.length-1].a}):t3.push({a:t1[j].a,b:t1[t1.length-1].b}))}else t3.push({a:t1[0].b,b:t1[t1.length-1].a})}return t3}function makedivisions(ff,shape2,oggetti){let draws=[],areas=[],dati=[],lines=[],{x:dx,y:dy,oriz:oriz,vert:vert,tipo:tipo,minvano:minvano,minvanox:minvanox,minvanoy:minvanoy}=ff,{bb:bb,bt:bt,bl:bl,br:br}=getbordi(oggetti,ff.bordo);minvanox=minvanox||minvano||50,minvanoy=minvanoy||minvano||50;let{dati:h1,punti:ph}=ordinabase(oggetti,"o",oriz,dy,minvanoy,bb,bt,tipo),{dati:v1,punti:pv}=ordinabase(oggetti,"v",vert,dx,minvanox,bl,br),shapecontorno=shape2.clone();function adddatilin(type,cod,l0,l1,sp,id){if("l"==type)areas.push([l0.p1,l0.p2]);else{let ptx=[l0.p1,l0.p2,l1.p2,l1.p1];areas.push(ptx);let s1=getshape().frompt(ptx);if(shapecontorno?.pt&&(s1.orient!=shapecontorno.orient&&s1.reverse(),s1=shapeclip().intersecasplitter(shapecontorno,s1)),s1){s1.pt.length>=4&&(l0.p1=s1.pt[0],l0.p2=s1.pt[1],l1.p1=s1.pt[s1.pt.length-1],l1.p2=s1.pt[s1.pt.length-2]),lines.push([l0.p1.x+("v"==type?sp:0),l0.p1.y+("v"!=type?sp:0),l0.p2.x+("v"==type?sp:0),l0.p2.y+("v"!=type?sp:0)]);let info=l0.infoquad(l1);if(info&&info.distanza){let s2=s1.clone(),c2=checkoggetto(oggetti,type,cod);(info.sx||info.sy)&&s2.move(-info.sx||0,-info.sy||0),info.angle&&s2.rotate(-info.angle||0);let tm={id:id,type:type,cod:cod,c2:c2,shape:s2.pt,info:info};dati.push(tm),tm?.shape&&draws.push({type:type,sx:tm.info.sx,sy:tm.info.sy,rot:tm.info.angle,pt:tm.shape})}}}}function isinseg(segs,v){let f=segs.find((e=>e.a<=v&&e.b>=v));return!!f}for(var h of(v1.forEach(((v,i)=>{v.segs=generatesegments(ph,v.cuts,!0),v.segs.forEach(((s,j)=>{let l0=new Linea2({x:v.x,y:s.a},{x:v.x,y:s.b}),l1=new Linea2({x:v.x+v.sp,y:s.a},{x:v.x+v.sp,y:s.b});adddatilin(v.sp?"v":"l",v.cod,l0,l1,v.sp/2,v.id)}))})),h1)){let cuts=[...h.cuts],pv1=[...pv];for(var v of v1)pv1.push({a:v.x,b:v.x+v.sp}),isinseg(v.segs,h.x+h.sp/2)&&cuts.push(v.x+v.sp/2);h.segs=generatesegments(pv1,cuts,!0,!0);for(let s of h.segs){let l1=new Linea2({x:s.b,y:h.x+h.sp},{x:s.a,y:h.x+h.sp}),l0=new Linea2({x:s.b,y:h.x},{x:s.a,y:h.x});adddatilin(h.sp?"o":"l",h.cod,l0,l1,h.sp,h.id)}}let res=shapeclip().areesplitter(shape2.pt,areas),areacodes=function getareacodes(ff){let k1,x1,k2,x2,out=[];for(let i=0;i<=ff.vert.length;i++){if(0==i)k1="v0",x1=0;else{let t=ff.vert[i-1];k1=`${t.dir}${t.id}`,x1=t._v}for(let j=0;j<=ff.oriz.length;j++){if(0==j)k2="o0",x2=0;else{let t=ff.oriz[j-1];k2=`${t.dir}${t.id}`,x2=t._v}out.push({k:k1+k2,x:x1,y:x2})}}return out}(ff);for(let d of res){let s=getshape().frompt(d),{p1:p1,width:width,height:height,isrect:isrect}=s.dims(),ix=s.pt.findIndex((p=>Math.abs(p.x-p1.x)<.001&&Math.abs(p.y-p1.y)<.001));ix>0&&s.selezionaprimo(ix),s.pt.length&&(s.move(-p1.x,-p1.y),1==s.orient&&s.reverse());let k=findareacod(areacodes,p1.x,p1.y),cod=ff.aree[k]||ff.area||"",c2=checkoggetto(oggetti,"a",cod);dati.push({id:k,cod:cod,c2:c2,type:"a",shape:isrect?null:s.pt,info:{isrect:isrect?1:0,sx:p1.x,sy:p1.y,rot:0,width:width,height:height}}),draws.push({type:isrect?"a":"as",sx:p1.x,sy:p1.y,dx:width,dy:height,id:k,cod:cod,rot:0,pt:s.pt,color:c2.color})}return{ff:ff,h1:h1,ph:ph,v1:v1,pv:pv,draws:draws,lines:lines,dati:dati}}function ordinabase(oggetti,dir,hh,dd,minvano,b1,b2,tipo){let d1=[];if(hh){for(var h of hh){let sp=checkoggetto(oggetti,dir,h.cod).sps||0,x=0;switch(h.tipo){case"d-":x=dd-h.v;break;case"p":x=dd*h.v/100;break;case"p-":x=dd*(100-h.v)/100;break;default:x=h.v}if(sp&&"c"==h.align?x-=sp/2:sp&&"r"==h.align&&(x-=sp),x=Math.round(10*x)/10,h._x0=x,h._x1=x+sp,h._v=x+sp/2,h._valid=x>0&&x<dd,x>b1&&x<dd-b2){let cuts=[];h.cuts&&h.cuts.length&&h.cuts.forEach((c=>{cuts.push(c<0?dd+c:c)})),d1.push({id:h.id,x:x,sp:sp,cuts:cuts,cod:h.cod})}}d1.sort(((a,b)=>a.x-b.x))}let d2=[],p0=b1;"a"==tipo&&(dd*=1.3);for(let i=0;i<d1.length;i++){let d=d1[i];d.x>=p0+minvano&&d.x+d.sp<=dd-b2-minvano&&(d.min=p0+minvano,d.max=dd-b2-minvano,d2.length>0&&(d2[d2.length-1].max=d.x-minvano),d2.push(d),p0=d.x+d.sp)}let d3=[];d3.push({a:b1,b:b1});for(let d of d2)d3.push({a:d.x,b:d.x+d.sp});return d3.push({a:dd-b2,b:dd-b2}),{dati:d2,punti:d3}}function check(ff){let{x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2,vert:vert,oriz:oriz,aree:aree,forma:forma,countid:countid}=ff;return x=x||1e3,x<200&&(x=200),y=y||1e3,y<200&&(y=200),h1=h1||y1||0,h2=h2||y2||0,l1=l1||d1||x1||0,l2=l2||d2||x2||0,h1<0&&h1>y-100&&(h1=0),h2<0&&h2>y-100&&(h2=0),(l2<0||l2>x-l1)&&(l2=0),(l1<0||l1>x-l2)&&(l1=0),minvano=minvano||50,forma&&(tipo="a"),area=area||"__",bordo=bordo||"__",priority=priority||"v",taglio=tagli[taglio]?taglio:"dd",tipo=tipi[tipo]?tipo:"x",vert=vert||[],oriz=oriz||[],aree=aree||{},goriz=goriz||void 0,gvert=gvert||void 0,countid=countid||1,{x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,vert:vert,oriz:oriz,aree:aree,countid:countid}}function newcount(ff){return ff.countid++,ff.countid}function addtaglio(ff,dir,tipodim,dim,cod,align="c",cuts=[]){return{dir:dir,id:newcount(ff),tipo:tipocut[tipodim]?tipodim:"d",align:tipoalign[align]?align:"c",v:dim,cod:cod,cuts:cuts||[]}}function addoriz(ff,tipodim,dim,cod,align,cuts){let x=Array.isArray(ff.bordo)?ff.bordo[0]:ff.bordo;cod||(cod=ff.goriz||x||"__"),Array.isArray(align)&&(cuts=align,align="c");let tm=addtaglio(ff,"o",tipodim,dim,cod,align,cuts);return ff.oriz||(ff.oriz=[]),ff.oriz.push(tm),ff}var SP=Object.freeze({__proto__:null,addhoriz:function addhoriz(ff,tipodim,dim,cod,align,cuts){return addoriz(ff,tipodim,dim,cod,align,cuts)},addoriz:addoriz,addvert:function addvert(ff,tipodim,dim,cod,align,cuts){let x=Array.isArray(ff.bordo)?ff.bordo[0]:ff.bordo;cod||(cod=ff.gvert||x||"__"),Array.isArray(align)&&(cuts=align,align="c");let tm=addtaglio(ff,"v",tipodim,dim,cod,align,cuts);return ff.vert||(ff.vert=[]),ff.vert.push(tm),ff},calcoladivisioni:
|
|
504
513
|
/**
|
|
505
514
|
* Ordina e calcola le posizioni di taglio lungo una dimensione, gestendo bordi e spazi minimi
|
|
506
515
|
* @param {Array<Object>} hh - Array di oggetti che definiscono i tagli
|
|
@@ -511,7 +520,7 @@ function shapeclip(){function toclipformat(pts){let tm=pts.map((e=>({X:Math.roun
|
|
|
511
520
|
* - dati: Array di oggetti con le posizioni elaborate dei tagli
|
|
512
521
|
* - punti: Array di oggetti {a,b} che definiscono inizio e fine di ogni segmento
|
|
513
522
|
*/
|
|
514
|
-
function calcoladivisioni(ff,notused,shape2,oggetti){return makedivisions(ff,shape2,oggetti)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(x,y,bordo,options){options||(options={});let{minvano:minvano,priority:priority,taglio:taglio,tipo:tipo,h1:h1,h2:h2,d1:d1,d2:d2,l1:l1,l2:l2,x1:x1,x2:x2,y1:y1,y2:y2,gvert:gvert,goriz:goriz,forma:forma,area:area}=options,ff=check({x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2});return ff.forma=forma,ff},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(ff,oggetti){return creaprofiloesterno(ff,oggetti)},priorita:{v:"verticale",h:"orizzontale"},tagli:tagli,tipi:tipi,tipoalign:tipoalign,tipocut:tipocut});async function valutagrafica(amb,startmacro,rulespec,progetto,fnreload){let{getcolonne:getcolonne,muCalc:muCalc,muEval:muEval,tipifree:tipifree}=amb.muvalutatore;rulespec||(rulespec={});for(let x of["l","a","p"]){!amb.vari.var(x)&&startmacro.dims&&amb.vari.add(x,String(startmacro.dims[x].val||100))}let fnlist=new Set;const PARSGLOBAL=["sl","sa","sp","ul","ua","up","ax","ay","az","scx","scy","scz","scale"];let isdimreload,isfnreload=!1,oo=await muEval(amb,startmacro,startmacro.codice,{leveleval:0,checkheader:op=>{let{variante:variante}=op;if(Array.isArray(startmacro.head)){let ff=startmacro.head.find((e=>e.cod==variante));isfnreload=!!ff}},grafica:async _op=>{let p2,cadv,iscad,des,fatti,{id:id,pars:pars,parametri:parametri,macro:macro,options:options,vari:vari}=_op,isheader=!!(macro&¯o.head&¯o.head.length),sv={l:amb.vari.var("l"),a:amb.vari.var("a"),p:amb.vari.var("p")};const varcad=["l","a","p","#d",...PARSGLOBAL];for(let x of varcad){let tm=amb.vari.dictionary[x];tm&&(sv[x]=tm)}async function _parsepars(x,head){let k,v,r9=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(x);if(r9)k="#d",v=await amb.vari.valuta(r9[2]);else{let result=await vari.parametrokeyval(x);k=result.k,v=result.v}k&&!fatti[k]&&(fatti[k]=!0,varcad.includes(k)?"#d"==k?des=v:("string"==typeof v&&(v=muCalc(v)),["l","a","p"].includes(k)&&amb.vari.add(k,String(v)),cadv[k]=v,iscad=!0):"string"==typeof v?p2.push(`${k}=${v}`):amb.vari.add(k,v))}if(p2=[],cadv={},iscad=!1,des="",fatti={},progetto&&progetto.keys&&progetto.keys[id]){let px=progetto.keys[id].pars;if(px)for(let t in px){let t1=amb.vari.dictionary[t];t1&&(sv[t]=t1),await _parsepars(`${t}=${px[t]}`)}}if(pars&&pars.length)for(const par of pars)await _parsepars(par);if(parametri&¶metri.length)for(const param of parametri)await _parsepars(param);if(macro&¯o.head&¯o.head.length){let tm=macro.head.filter((e=>!["g"].includes(e.t)));for(const h of tm)await _parsepars(h.cod)}let out={iscad:iscad,isheader:isheader,name:macro.name,des:des,leveleval:options.leveleval};isheader&&id&&(out.id=id),iscad&&(cadv.l?amb.vari.add("l",String(cadv.l)):cadv.l=muCalc(amb.vari.var("l")),cadv.a?amb.vari.add("a",String(cadv.a)):cadv.a=muCalc(amb.vari.var("a")),cadv.p?amb.vari.add("p",String(cadv.p)):cadv.p=muCalc(amb.vari.var("p")),out.cadv=cadv),await macro.impostaparametri(parametri,p2,!0);let ruleid=rulespec[id];if(id&&isheader&&ruleid&&ruleid.pars&&(out.pars=ruleid.pars,options.leveleval++,await macro.setparametri(ruleid.pars)),out.rows=await muEval(amb,macro,macro.codice,options),id&&isheader&&(out.spars=macro.getparametri()),iscad)for(let x in sv)amb.vari.dictionary[x]=sv[x];return out},parsefnpunto:async _op=>{let{dati:dati,vari:vari,id:id,output:output}=_op;dati=dati.trim();let q=dati.indexOf(" "),q2=dati.indexOf(",");q2>0&&q>0&&q2<q&&(q=q2);let fn,pp,pars={},p2={};q>1?(fn=dati.slice(1,q),pp=getcolonne(dati.slice(q+1))):(fn=dati.slice(1),pp=[]),fnlist.has(fn)||fnlist.add(fn);for(let p of pp){let{k:k,v:v}=await vari.parametrokeyval(p);k&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)&&(pars[k]=v||"")}for(let l of["l","a","p"])pars[l]||(pars[l]=vari.var(l));let tm=Object.keys(pars);for(let l of PARSGLOBAL)tm.includes(l)&&(p2[l]=muCalc(pars[l]),delete pars[l]);output.push({t:"fn",fn:fn,id:id,pars:pars,p2:p2})}});for(let x of["l","a","p"])if(startmacro.dims&&startmacro.dims[x].val!=parseFloat(amb.vari.var(x))){isdimreload=!0;break}return(isfnreload||isdimreload&&"function"==typeof fnreload)&&await fnreload(isdimreload,isfnreload),{oo:oo,vari:amb.vari.dump(!0),fnlist:[...fnlist]}}function ismacro(row){return"object"==typeof row&&row?.name&&row.rows}function isfn(row){return"object"==typeof row&&"fn"==row?.t}function getnodebyid(id,nodocorrente){let res;return nodocorrente&&nodocorrente.rows&&function _getnode(rows){for(let x of rows){if(ismacro(x)){if(x.id==id)return void(res=x);x.rows&&_getnode(x.rows)}if(res)return}}(nodocorrente.rows),res}function getsubrules(nodocorrente){let res=[];return res.push({id:"",level:0,name:"home"}),function _xfiltrati(rr,level){if(rr.rows&&rr.rows.length)for(let x of rr.rows)ismacro(x)&&(x.id&&x.isheader?(res.push({id:x.id,name:x.name,des:x.des||"",spec:x.pars?1:0,level:level}),_xfiltrati(x,level+1)):_xfiltrati(x,level))}(nodocorrente,1),res}function getprojectkeys(project){return project.keys={},function _getkeys(node){if(node.rows&&node.rows.length)for(let x of node.rows)ismacro(x)&&(x.id&&x.isheader&&x.pars&&(project.keys[x.id]={name:x.name,des:x.des||"",pars:x.pars}),_getkeys(x))}(project),project}function getdumpmacro(nodo){let cl=[];return function _dumpnodo(node){if(node.rows&&node.rows.length)for(let x of node.rows)if(ismacro(x)){x.name;let c=[];if(x.iscad&&x.cadv)for(let k in x.cadv){let t=x.cadv[k];"number"==typeof t&&t&&c.push(`${k}=${t}`)}if(x.pars)for(let k in x.pars){let t=x.pars[k];c.push(`${k}=${t}`)}c.length&&cl.push(`--\x3e ${x.name} ${c.join(",")}`),_dumpnodo(x),c.length&&cl.push("<--")}else isfn(x)?cl.push(`FN: ${x.fn} ${JSON.stringify(x.pars)}`):"string"==typeof x&&x.length&&cl.push(x)}(nodo),cl.join("\n")}const mgreen$1=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:THREE.DoubleSide});function getorientate(ori,x,y,z){switch(x=x||0,y=y||0,z=z||0,ori.trim().toLowerCase()){case"alp":return{x:y,y:x,z:z};case"apl":return{x:y,y:z,z:x};case"pla":return{x:z,y:x,z:y};case"pal":return{x:z,y:y,z:x};case"lpa":return{x:x,y:z,z:y};default:return{x:x,y:y,z:z}}}function parselavs(ori,id,x=0,y=0,z=0,lavorazioni="",facce="",def=""){let lavcods=function muClComments(codice,tienivuoti){const righe=(code=codice,code.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((match,quoted)=>quoted||""))).split(/\r?\n/);var code;const tm=[];let rigaContinua="";for(const riga of righe){let rigaTrim=riga.trim();if(rigaTrim.includes("//")&&(rigaTrim=rigaTrim.split("//")[0].trim()),0!==rigaTrim.length)if(rigaContinua.length>0&&(rigaTrim=rigaContinua+" "+rigaTrim,rigaContinua=""),rigaTrim.endsWith("\\")){rigaTrim=rigaTrim.slice(0,-1);const indiceCommento=rigaTrim.lastIndexOf("//");-1!==indiceCommento&&(rigaTrim=rigaTrim.slice(0,indiceCommento).trim()),rigaContinua=rigaTrim}else tm.push(rigaTrim)}return tm}(lavorazioni),rets=[];for(let lavcod of lavcods){var rr=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(lavcod);if(rr&&rr[1]){let lav={name:rr[1].trim().toLowerCase(),...getorientate(ori,x,y,z),id:id,facce:facce};if(rr[2]){let aa=getcolonne(rr[2]);for(let a of aa){let i=a.indexOf("=");i>0&&(lav[a.slice(0,i).trim()]=a.slice(i+1).trim())}}rets.push(lav)}}return!rets.length&&def&&rets.push({name:def,...getorientate(ori,x,y,z),id:id,facce:facce}),rets}function getemitter(data){let{d:d,name:name,x:x,y:y,z:z,lavs:lavs="",ids:ids="",faces:faces=null,size:size=5}=data;ids=getcolonne(clean(ids,!0));const emitter=new THREE.Object3D;if(emitter.position.set(x,y,z),emitter.userData={emitter:!0,lavs:lavs,ids:ids,faces:faces,size:size,name:name},d){const geometry=new THREE.SphereGeometry(size||5,8,8),material=new THREE.MeshBasicMaterial({color:16711680}),mesh=new THREE.Mesh(geometry,material);emitter.add(mesh)}return emitter}function getreceiver(gcad,data){gcad.gmats.__istask=1;let{d:d,ori:ori="LAP",x:x=0,y:y=0,z:z=0,tipo:tipo="",start:start="",end:end=""}=data;tipo=clean(tipo,!0);const receiver=new THREE.Object3D;if(receiver.position.set(x/2,y/2,z/2),receiver.userData={receiver:!0,ori:(ori||"").trim().toLowerCase(),x:x,y:y,z:z,tipo:tipo,start:start,end:end},d){const geometry=new THREE.BoxGeometry(x,y,z),mesh=new THREE.Mesh(geometry,mgreen$1);mesh.position.set(0,0,0),receiver.add(mesh)}return receiver}function calcolatasks(scena){const emitterWorldPosition=new WeakMap,receiverWorldMatrixInverse=new WeakMap;function boxBoxIntersects(pos,l,x,y,z){return pos.x+l>0&&pos.x-l<x&&pos.y+l>0&&pos.y-l<y&&pos.z+l>0&&pos.z-l<z}function getFacceToccate(pos,sogliafaccia,x,y,z,filtra){const facce=[];function addfaccia(f){filtra&&!filtra.includes(f)||facce.push(f)}return Math.abs(pos.x-0)<sogliafaccia&&addfaccia("s"),Math.abs(pos.x-x)<sogliafaccia&&addfaccia("d"),Math.abs(pos.y-0)<sogliafaccia&&addfaccia("b"),Math.abs(pos.y-y)<sogliafaccia&&addfaccia("a"),Math.abs(pos.z-0)<sogliafaccia&&addfaccia("z"),Math.abs(pos.z-z)<sogliafaccia&&addfaccia("f"),facce.join("")}function getEmitterWorldPosition(emitter){if(!emitterWorldPosition.has(emitter)){const pos=new THREE.Vector3;emitter.getWorldPosition(pos),emitterWorldPosition.set(emitter,pos)}return emitterWorldPosition.get(emitter)}function getReceiverWorldMatrixInverse(receiver){if(!receiverWorldMatrixInverse.has(receiver)){const inv=receiver.matrixWorld.clone().invert();receiverWorldMatrixInverse.set(receiver,inv)}return receiverWorldMatrixInverse.get(receiver)}scena.updateMatrixWorld(!0);const receivers=[],emitters=[];!function scan(obj){obj.userData?.receiver&&receivers.push(obj),obj.userData?.emitter&&emitters.push(obj),obj.children&&obj.children.forEach(scan)}(scena);let tasks=[];for(const receiver of receivers){const{mat:mat,ori:ori,x:x,y:y,z:z,start:start,end:end,tipo:tipo,size:size}=receiver.userData;let singletask={id:mat,...getorientate(ori,x,y,z),tipo:tipo,ori:ori,lavs:[]};start&&singletask.lavs.push(...parselavs(ori,"_start",0,0,0,start,"",""));const matrixInverse=getReceiverWorldMatrixInverse(receiver);for(const emitter of emitters){if("string"==typeof tipo&&""!==tipo){const idx=emitter.userData.ids;if(Array.isArray(idx)&&idx.length>0&&!idx.includes("*")&&!idx.includes(tipo))continue}const posLocalAdj=getEmitterWorldPosition(emitter).clone().applyMatrix4(matrixInverse).clone().add(new THREE.Vector3(x/2,y/2,z/2));if(!boxBoxIntersects(posLocalAdj,emitter.userData.size??0,x,y,z))continue;const facceToccate=getFacceToccate(posLocalAdj,emitter.userData.soglia??2,x,y,z,emitter.userData.faces);facceToccate&&facceToccate.length&&singletask.lavs.push(...parselavs(ori,emitter.userData.name,posLocalAdj.x,posLocalAdj.y,posLocalAdj.z,emitter.userData.lavs,facceToccate,"nd"))}end&&singletask.lavs.push(...parselavs(ori,"_end",0,0,0,end,"","")),singletask.lavs.length&&tasks.push(singletask)}return tasks}const SIDE=THREE.DoubleSide;let materialline1=new THREE.LineBasicMaterial({color:3158064}),materialline2=new THREE.LineBasicMaterial({color:5263440});const mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgray1=new THREE.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:SIDE}),mgray2=new THREE.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:SIDE}),mred=new THREE.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:SIDE}),mblue=new THREE.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE}),mblack=new THREE.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:SIDE}),scaleunit=.001;function groupfromgeometry(geometry,material,x,y,z,name,layer){let child=new THREE.Group;child.position.set(x,y,z),child.name=name;const mesh=new THREE.Mesh(geometry,material);mesh.name=name,mesh.castShadow=!0,mesh.receiveShadow=!0,mesh.layers.set(layer);const edges=new THREE.EdgesGeometry(geometry),lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(30),child.add(mesh),child.add(lineSegments),child}function posiziona(grp,pos={}){let tm=new THREE.Group;if(grp){let g2=grp.clone(),tm2=g2,{sl:sl=0,sa:sa=0,sp:sp=0,ax:ax=0,ay:ay=0,az:az=0,ul:ul=0,ua:ua=0,up:up=0,scale:scale=1,scx:scx=scale,scy:scy=scale,scz:scz=scale,emitters:emitters,emittersname:emittersname}=pos;if(tm.position.set(sl,sa,sp),tm.rotation.set(ax*PIF,ay*PIF,az*PIF),(ul||ua||up)&&(tm2=new THREE.Group,tm2.add(g2),tm2.position.set(ul,ua,up)),tm.scale.set(scx,scy,scz),tm.add(tm2),emitters&&emitters.length)for(let e of emitters)e.name=e.name||emittersname,tm.add(getemitter(e))}return tm}function edgesfromgeometry(g1,layer=30){return getlinesgeom(new THREE.EdgesGeometry(g1,40),layer)}function getlinesgeom(edges,layer=30){const lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(layer),lineSegments}function getmesh(geom,material,layer=1,clone=!1){let m=new THREE.Mesh(geom,clone?material.clone():material);return m.castShadow=!0,m.receiveShadow=!0,m.layers.set(layer),m}function get3dshape(punti,material,layer){if(!punti||punti.length<3)return new THREE.BufferGeometry;const vertices=[];for(let i=0;i<punti.length;i++){const p1=punti[i],p2=punti[(i+1)%punti.length];vertices.push(p1.x,0,p1.y),vertices.push(p2.x,0,p2.y)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3));let m=new THREE.LineSegments(geometry,material);return m.layers.set(layer),m}function creategroup(name){let g=new THREE.Group;return g.name=name||"$$",g}function svuotanodo(n){!function _dispose(node){if(node.children.length){[...node.children].forEach((child=>{_dispose(child),node.remove(child)}))}node.geometry&&node.geometry.dispose(),node.material&&(Array.isArray(node.material)?node.material.forEach((m=>m.dispose())):node.material.dispose())}(n)}function deletegroup(grpbase,name){if(!grpbase?.children)return;let gr=grpbase.children.find((e=>e.name==name));if(gr){for(;gr.children.length>0;){const child=gr.children[0];gr.remove(child)}gr.parent&&gr.parent.remove(gr),gr=null}}function randombasemat(){const material=new THREE.LineBasicMaterial,color=new THREE.Color;return color.setHSL(Math.random(),.7,.4),material.color=color,material}
|
|
523
|
+
function calcoladivisioni(ff,notused,shape2,oggetti){return makedivisions(ff,shape2,oggetti)},check:check,checkoggetto:checkoggetto,creaprofiloesterno:creaprofiloesterno,create:function create(x,y,bordo,options){options||(options={});let{minvano:minvano,priority:priority,taglio:taglio,tipo:tipo,h1:h1,h2:h2,d1:d1,d2:d2,l1:l1,l2:l2,x1:x1,x2:x2,y1:y1,y2:y2,gvert:gvert,goriz:goriz,forma:forma,area:area}=options,ff=check({x:x,y:y,area:area,bordo:bordo,gvert:gvert,goriz:goriz,priority:priority,minvano:minvano,taglio:taglio,tipo:tipo,h1:h1,h2:h2,l1:l1,l2:l2,d1:d1,x1:x1,y1:y1,d2:d2,x2:x2,y2:y2});return ff.forma=forma,ff},elaborapercorso:elaborapercorso,getbordi:getbordi,makedivisions:makedivisions,makeshape:function makeshape(ff,oggetti){return creaprofiloesterno(ff,oggetti)},priorita:{v:"verticale",h:"orizzontale"},tagli:tagli,tipi:tipi,tipoalign:tipoalign,tipocut:tipocut});async function valutagrafica(amb,startmacro,rulespec,progetto,fnreload){let{getcolonne:getcolonne,muCalc:muCalc,muEval:muEval,tipifree:tipifree}=amb.muvalutatore;rulespec||(rulespec={});for(let x of["l","a","p"]){!amb.vari.var(x)&&startmacro.dims&&amb.vari.add(x,String(startmacro.dims[x].val||100))}let fnlist=new Set;const PARSGLOBAL=["sl","sa","sp","ul","ua","up","ax","ay","az","scx","scy","scz","scale"];let isdimreload,isfnreload=!1,oo=await muEval(amb,startmacro,startmacro.codice,{leveleval:0,checkheader:op=>{let{variante:variante}=op;if(Array.isArray(startmacro.head)){let ff=startmacro.head.find((e=>e.cod==variante));isfnreload=!!ff}},grafica:async _op=>{let p2,cadv,iscad,des,fatti,{id:id,pars:pars,parametri:parametri,macro:macro,options:options,vari:vari}=_op,isheader=!!(macro&¯o.head&¯o.head.length),sv={l:amb.vari.var("l"),a:amb.vari.var("a"),p:amb.vari.var("p")};const varcad=["l","a","p","#d",...PARSGLOBAL];for(let x of varcad){let tm=amb.vari.dictionary[x];tm&&(sv[x]=tm)}async function _parsepars(x,head){let k,v,r9=/^#(d|des|descrizione)\s*=\s*(.*)\s*$/im.exec(x);if(r9)k="#d",v=await amb.vari.valuta(r9[2]);else{let result=await vari.parametrokeyval(x);k=result.k,v=result.v}k&&!fatti[k]&&(fatti[k]=!0,varcad.includes(k)?"#d"==k?des=v:("string"==typeof v&&(v=muCalc(v)),["l","a","p"].includes(k)&&amb.vari.add(k,String(v)),cadv[k]=v,iscad=!0):"string"==typeof v?p2.push(`${k}=${v}`):amb.vari.add(k,v))}if(p2=[],cadv={},iscad=!1,des="",fatti={},progetto&&progetto.keys&&progetto.keys[id]){let px=progetto.keys[id].pars;if(px)for(let t in px){let t1=amb.vari.dictionary[t];t1&&(sv[t]=t1),await _parsepars(`${t}=${px[t]}`)}}if(pars&&pars.length)for(const par of pars)await _parsepars(par);if(parametri&¶metri.length)for(const param of parametri)await _parsepars(param);if(macro&¯o.head&¯o.head.length){let tm=macro.head.filter((e=>!["g"].includes(e.t)));for(const h of tm)await _parsepars(h.cod)}let out={iscad:iscad,isheader:isheader,name:macro.name,des:des,leveleval:options.leveleval};isheader&&id&&(out.id=id),iscad&&(cadv.l?amb.vari.add("l",String(cadv.l)):cadv.l=muCalc(amb.vari.var("l")),cadv.a?amb.vari.add("a",String(cadv.a)):cadv.a=muCalc(amb.vari.var("a")),cadv.p?amb.vari.add("p",String(cadv.p)):cadv.p=muCalc(amb.vari.var("p")),out.cadv=cadv),await macro.impostaparametri(parametri,p2,!0);let ruleid=rulespec[id];if(id&&isheader&&ruleid&&ruleid.pars&&(out.pars=ruleid.pars,options.leveleval++,await macro.setparametri(ruleid.pars)),out.rows=await muEval(amb,macro,macro.codice,options),id&&isheader&&(out.spars=macro.getparametri()),iscad)for(let x in sv)amb.vari.dictionary[x]=sv[x];return out},parsefnpunto:async _op=>{let{dati:dati,vari:vari,id:id,output:output}=_op;dati=dati.trim();let q=dati.indexOf(" "),q2=dati.indexOf(",");q2>0&&q>0&&q2<q&&(q=q2);let fn,pp,pars={},p2={};q>1?(fn=dati.slice(1,q),pp=getcolonne(dati.slice(q+1))):(fn=dati.slice(1),pp=[]),fnlist.has(fn)||fnlist.add(fn);for(let p of pp){let{k:k,v:v}=await vari.parametrokeyval(p);k&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(k)&&(pars[k]=v||"")}for(let l of["l","a","p"])pars[l]||(pars[l]=vari.var(l));let tm=Object.keys(pars);for(let l of PARSGLOBAL)tm.includes(l)&&(p2[l]=muCalc(pars[l]),delete pars[l]);output.push({t:"fn",fn:fn,id:id,pars:pars,p2:p2})}});for(let x of["l","a","p"])if(startmacro.dims&&startmacro.dims[x].val!=parseFloat(amb.vari.var(x))){isdimreload=!0;break}return(isfnreload||isdimreload&&"function"==typeof fnreload)&&await fnreload(isdimreload,isfnreload),{oo:oo,vari:amb.vari.dump(!0),fnlist:[...fnlist]}}function ismacro(row){return"object"==typeof row&&row?.name&&row.rows}function isfn(row){return"object"==typeof row&&"fn"==row?.t}function getnodebyid(id,nodocorrente){let res;return nodocorrente&&nodocorrente.rows&&function _getnode(rows){for(let x of rows){if(ismacro(x)){if(x.id==id)return void(res=x);x.rows&&_getnode(x.rows)}if(res)return}}(nodocorrente.rows),res}function getsubrules(nodocorrente){let res=[];return res.push({id:"",level:0,name:"home"}),function _xfiltrati(rr,level){if(rr.rows&&rr.rows.length)for(let x of rr.rows)ismacro(x)&&(x.id&&x.isheader?(res.push({id:x.id,name:x.name,des:x.des||"",spec:x.pars?1:0,level:level}),_xfiltrati(x,level+1)):_xfiltrati(x,level))}(nodocorrente,1),res}function getprojectkeys(project){return project.keys={},function _getkeys(node){if(node.rows&&node.rows.length)for(let x of node.rows)ismacro(x)&&(x.id&&x.isheader&&x.pars&&(project.keys[x.id]={name:x.name,des:x.des||"",pars:x.pars}),_getkeys(x))}(project),project}function getdumpmacro(nodo){let cl=[];return function _dumpnodo(node){if(node.rows&&node.rows.length)for(let x of node.rows)if(ismacro(x)){x.name;let c=[];if(x.iscad&&x.cadv)for(let k in x.cadv){let t=x.cadv[k];"number"==typeof t&&t&&c.push(`${k}=${t}`)}if(x.pars)for(let k in x.pars){let t=x.pars[k];c.push(`${k}=${t}`)}c.length&&cl.push(`--\x3e ${x.name} ${c.join(",")}`),_dumpnodo(x),c.length&&cl.push("<--")}else isfn(x)?cl.push(`FN: ${x.fn} ${JSON.stringify(x.pars)}`):"string"==typeof x&&x.length&&cl.push(x)}(nodo),cl.join("\n")}function t$1(e,t,s){return{x:null!=e?e:0,y:null!=t?t:0,z:null!=s?s:0}}function s(e,t){return{x:null!=e?e:0,y:null!=t?t:0}}class h{static next(){return(++h.seed).toString(16).toUpperCase()}static peek(){return(h.seed+1).toString(16).toUpperCase()}static clear(){h.seed=0}}h.seed=0;class o{constructor(){this.handle=h.next()}dxfy(e){e.type("ENDBLK"),e.handle(this.handle),e.push(330,this.ownerObjectHandle),e.subclassMarker("AcDbEntity"),e.layerName("0"),e.subclassMarker("AcDbBlockEnd")}}const d=(e,t)=>({tl:e,br:t});class a{static centerRadiusBBox(e,s){return d(t$1(e.x-s,e.y+s),t$1(e.x+s,e.y-s))}static pointBBox(e){return d(t$1(e.x-100,e.y+100),t$1(e.x+100,e.y-100))}static lineBBox(e,s){const n=e.x>s.x?e.x:s.x,i=e.x<s.x?e.x:s.x,h=e.y>s.y?e.y:s.y,o=e.y<s.y?e.y:s.y,a=e.z>s.z?e.z:s.z,l=e.z<s.z?e.z:s.z;return d(t$1(i,h,l),t$1(n,o,a))}static verticesBBox(e){let s=-1/0,n=-1/0,i=1/0,h=1/0;for(let t=0;t<e.length;t++){const{x:o,y:d}=e[t];s<o&&(s=o),n<d&&(n=d),i>o&&(i=o),h>d&&(h=d)}return d(t$1(i,n),t$1(s,h))}static boundingBox(e){if(0===e.length)return a.pointBBox(t$1());const s=[];for(let t=0;t<e.length;t++){const n=e[t];s.push(n.tl,n.br)}return a.verticesBBox(s)}static boundingBoxCenter(e){return t$1(e.tl.x+(e.br.x-e.tl.x)/2,e.br.y+(e.tl.y-e.br.y)/2,0)}static boundingBoxHeight(e){return e.tl.y-e.br.y}}var l,r,f;!function(e){e[e.None=0]="None",e[e.Frozen=1]="Frozen",e[e.FrozenInNewViewports=2]="FrozenInNewViewports",e[e.Locked=4]="Locked",e[e.XRefDependent=16]="XRefDependent",e[e.XRefResolved=32]="XRefResolved"}(l||(l={})),function(e){e[e.None=0]="None",e[e.DescribeShape=1]="DescribeShape",e[e.VerticalText=4]="VerticalText",e[e.XRefDependent=16]="XRefDependent",e[e.XRefResolved=32]="XRefResolved"}(r||(r={})),function(e){e[e.None=0]="None",e[e.PaperSpace=1]="PaperSpace",e[e.XRefDependent=16]="XRefDependent",e[e.XRefResolved=32]="XRefResolved"}(f||(f={}));class u{constructor(e){this.type=e,this.handle=h.next()}dxfy(e){e.type(this.type),e.handle(this.handle),e.push(330,this.ownerObjectHandle),e.subclassMarker("AcDbSymbolTableRecord")}}class c extends u{constructor(e,t,s,n){super("LAYER"),this.name=e,this.colorNumber=t,this.lineType=s,this.flags=null!=n?n:l.None}dxfy(e){super.dxfy(e),e.subclassMarker("AcDbLayerTableRecord"),e.name(this.name),e.push(70,this.flags),e.colorNumber(this.colorNumber),e.push(420,this.trueColor),e.lineType(this.lineType),e.push(370,0),e.push(390,0),e.push(347,this.materialObject)}}c.layerZeroName="0";const g$1=[[["00","00","00"],0,["0","0","0"]],[["FF","00","00"],1,["255","0","0"]],[["FF","FF","00"],2,["255","255","0"]],[["00","FF","00"],3,["0","255","0"]],[["00","FF","FF"],4,["0","255","255"]],[["00","00","FF"],5,["0","0","255"]],[["FF","00","FF"],6,["255","0","255"]],[["FF","FF","FF"],7,["255","255","255"]],[["41","41","41"],8,["65","65","65"]],[["80","80","80"],9,["128","128","128"]],[["FF","00","00"],10,["255","0","0"]],[["FF","AA","AA"],11,["255","170","170"]],[["BD","00","00"],12,["189","0","0"]],[["BD","7E","7E"],13,["189","126","126"]],[["81","00","00"],14,["129","0","0"]],[["81","56","56"],15,["129","86","86"]],[["68","00","00"],16,["104","0","0"]],[["68","45","45"],17,["104","69","69"]],[["4F","00","00"],18,["79","0","0"]],[["4F","35","35"],19,["79","53","53"]],[["FF","3F","00"],20,["255","63","0"]],[["FF","BF","AA"],21,["255","191","170"]],[["BD","2E","00"],22,["189","46","0"]],[["BD","8D","7E"],23,["189","141","126"]],[["81","1F","00"],24,["129","31","0"]],[["81","60","56"],25,["129","96","86"]],[["68","19","00"],26,["104","25","0"]],[["68","4E","45"],27,["104","78","69"]],[["4F","13","00"],28,["79","19","0"]],[["4F","3B","35"],29,["79","59","53"]],[["FF","7F","00"],30,["255","127","0"]],[["FF","D4","AA"],31,["255","212","170"]],[["BD","5E","00"],32,["189","94","0"]],[["BD","9D","7E"],33,["189","157","126"]],[["81","40","00"],34,["129","64","0"]],[["81","6B","56"],35,["129","107","86"]],[["68","34","00"],36,["104","52","0"]],[["68","56","45"],37,["104","86","69"]],[["4F","27","00"],38,["79","39","0"]],[["4F","42","35"],39,["79","66","53"]],[["FF","BF","00"],40,["255","191","0"]],[["FF","EA","AA"],41,["255","234","170"]],[["BD","8D","00"],42,["189","141","0"]],[["BD","AD","7E"],43,["189","173","126"]],[["81","60","00"],44,["129","96","0"]],[["81","76","56"],45,["129","118","86"]],[["68","4E","00"],46,["104","78","0"]],[["68","5F","45"],47,["104","95","69"]],[["4F","3B","00"],48,["79","59","0"]],[["4F","49","35"],49,["79","73","53"]],[["FF","FF","00"],50,["255","255","0"]],[["FF","FF","AA"],51,["255","255","170"]],[["BD","BD","00"],52,["189","189","0"]],[["BD","BD","7E"],53,["189","189","126"]],[["81","81","00"],54,["129","129","0"]],[["81","81","56"],55,["129","129","86"]],[["68","68","00"],56,["104","104","0"]],[["68","68","45"],57,["104","104","69"]],[["4F","4F","00"],58,["79","79","0"]],[["4F","4F","35"],59,["79","79","53"]],[["BF","FF","00"],60,["191","255","0"]],[["EA","FF","AA"],61,["234","255","170"]],[["8D","BD","00"],62,["141","189","0"]],[["AD","BD","7E"],63,["173","189","126"]],[["60","81","00"],64,["96","129","0"]],[["76","81","56"],65,["118","129","86"]],[["4E","68","00"],66,["78","104","0"]],[["5F","68","45"],67,["95","104","69"]],[["3B","4F","00"],68,["59","79","0"]],[["49","4F","35"],69,["73","79","53"]],[["7F","FF","00"],70,["127","255","0"]],[["D4","FF","AA"],71,["212","255","170"]],[["5E","BD","00"],72,["94","189","0"]],[["9D","BD","7E"],73,["157","189","126"]],[["40","81","00"],74,["64","129","0"]],[["6B","81","56"],75,["107","129","86"]],[["34","68","00"],76,["52","104","0"]],[["56","68","45"],77,["86","104","69"]],[["27","4F","00"],78,["39","79","0"]],[["42","4F","35"],79,["66","79","53"]],[["3F","FF","00"],80,["63","255","0"]],[["BF","FF","AA"],81,["191","255","170"]],[["2E","BD","00"],82,["46","189","0"]],[["8D","BD","7E"],83,["141","189","126"]],[["1F","81","00"],84,["31","129","0"]],[["60","81","56"],85,["96","129","86"]],[["19","68","00"],86,["25","104","0"]],[["4E","68","45"],87,["78","104","69"]],[["13","4F","00"],88,["19","79","0"]],[["3B","4F","35"],89,["59","79","53"]],[["00","FF","00"],90,["0","255","0"]],[["AA","FF","AA"],91,["170","255","170"]],[["00","BD","00"],92,["0","189","0"]],[["7E","BD","7E"],93,["126","189","126"]],[["00","81","00"],94,["0","129","0"]],[["56","81","56"],95,["86","129","86"]],[["00","68","00"],96,["0","104","0"]],[["45","68","45"],97,["69","104","69"]],[["00","4F","00"],98,["0","79","0"]],[["35","4F","35"],99,["53","79","53"]],[["00","FF","3F"],100,["0","255","63"]],[["AA","FF","BF"],101,["170","255","191"]],[["00","BD","2E"],102,["0","189","46"]],[["7E","BD","8D"],103,["126","189","141"]],[["00","81","1F"],104,["0","129","31"]],[["56","81","60"],105,["86","129","96"]],[["00","68","19"],106,["0","104","25"]],[["45","68","4E"],107,["69","104","78"]],[["00","4F","13"],108,["0","79","19"]],[["35","4F","3B"],109,["53","79","59"]],[["00","FF","7F"],110,["0","255","127"]],[["AA","FF","D4"],111,["170","255","212"]],[["00","BD","5E"],112,["0","189","94"]],[["7E","BD","9D"],113,["126","189","157"]],[["00","81","40"],114,["0","129","64"]],[["56","81","6B"],115,["86","129","107"]],[["00","68","34"],116,["0","104","52"]],[["45","68","56"],117,["69","104","86"]],[["00","4F","27"],118,["0","79","39"]],[["35","4F","42"],119,["53","79","66"]],[["00","FF","BF"],120,["0","255","191"]],[["AA","FF","EA"],121,["170","255","234"]],[["00","BD","8D"],122,["0","189","141"]],[["7E","BD","AD"],123,["126","189","173"]],[["00","81","60"],124,["0","129","96"]],[["56","81","76"],125,["86","129","118"]],[["00","68","4E"],126,["0","104","78"]],[["45","68","5F"],127,["69","104","95"]],[["00","4F","3B"],128,["0","79","59"]],[["35","4F","49"],129,["53","79","73"]],[["00","FF","FF"],130,["0","255","255"]],[["AA","FF","FF"],131,["170","255","255"]],[["00","BD","BD"],132,["0","189","189"]],[["7E","BD","BD"],133,["126","189","189"]],[["00","81","81"],134,["0","129","129"]],[["56","81","81"],135,["86","129","129"]],[["00","68","68"],136,["0","104","104"]],[["45","68","68"],137,["69","104","104"]],[["00","4F","4F"],138,["0","79","79"]],[["35","4F","4F"],139,["53","79","79"]],[["00","BF","FF"],140,["0","191","255"]],[["AA","EA","FF"],141,["170","234","255"]],[["00","8D","BD"],142,["0","141","189"]],[["7E","AD","BD"],143,["126","173","189"]],[["00","60","81"],144,["0","96","129"]],[["56","76","81"],145,["86","118","129"]],[["00","4E","68"],146,["0","78","104"]],[["45","5F","68"],147,["69","95","104"]],[["00","3B","4F"],148,["0","59","79"]],[["35","49","4F"],149,["53","73","79"]],[["00","7F","FF"],150,["0","127","255"]],[["AA","D4","FF"],151,["170","212","255"]],[["00","5E","BD"],152,["0","94","189"]],[["7E","9D","BD"],153,["126","157","189"]],[["00","40","81"],154,["0","64","129"]],[["56","6B","81"],155,["86","107","129"]],[["00","34","68"],156,["0","52","104"]],[["45","56","68"],157,["69","86","104"]],[["00","27","4F"],158,["0","39","79"]],[["35","42","4F"],159,["53","66","79"]],[["00","3F","FF"],160,["0","63","255"]],[["AA","BF","FF"],161,["170","191","255"]],[["00","2E","BD"],162,["0","46","189"]],[["7E","8D","BD"],163,["126","141","189"]],[["00","1F","81"],164,["0","31","129"]],[["56","60","81"],165,["86","96","129"]],[["00","19","68"],166,["0","25","104"]],[["45","4E","68"],167,["69","78","104"]],[["00","13","4F"],168,["0","19","79"]],[["35","3B","4F"],169,["53","59","79"]],[["00","00","FF"],170,["0","0","255"]],[["AA","AA","FF"],171,["170","170","255"]],[["00","00","BD"],172,["0","0","189"]],[["7E","7E","BD"],173,["126","126","189"]],[["00","00","81"],174,["0","0","129"]],[["56","56","81"],175,["86","86","129"]],[["00","00","68"],176,["0","0","104"]],[["45","45","68"],177,["69","69","104"]],[["00","00","4F"],178,["0","0","79"]],[["35","35","4F"],179,["53","53","79"]],[["3F","00","FF"],180,["63","0","255"]],[["BF","AA","FF"],181,["191","170","255"]],[["2E","00","BD"],182,["46","0","189"]],[["8D","7E","BD"],183,["141","126","189"]],[["1F","00","81"],184,["31","0","129"]],[["60","56","81"],185,["96","86","129"]],[["19","00","68"],186,["25","0","104"]],[["4E","45","68"],187,["78","69","104"]],[["13","00","4F"],188,["19","0","79"]],[["3B","35","4F"],189,["59","53","79"]],[["7F","00","FF"],190,["127","0","255"]],[["D4","AA","FF"],191,["212","170","255"]],[["5E","00","BD"],192,["94","0","189"]],[["9D","7E","BD"],193,["157","126","189"]],[["40","00","81"],194,["64","0","129"]],[["6B","56","81"],195,["107","86","129"]],[["34","00","68"],196,["52","0","104"]],[["56","45","68"],197,["86","69","104"]],[["27","00","4F"],198,["39","0","79"]],[["42","35","4F"],199,["66","53","79"]],[["BF","00","FF"],200,["191","0","255"]],[["EA","AA","FF"],201,["234","170","255"]],[["8D","00","BD"],202,["141","0","189"]],[["AD","7E","BD"],203,["173","126","189"]],[["60","00","81"],204,["96","0","129"]],[["76","56","81"],205,["118","86","129"]],[["4E","00","68"],206,["78","0","104"]],[["5F","45","68"],207,["95","69","104"]],[["3B","00","4F"],208,["59","0","79"]],[["49","35","4F"],209,["73","53","79"]],[["FF","00","FF"],210,["255","0","255"]],[["FF","AA","FF"],211,["255","170","255"]],[["BD","00","BD"],212,["189","0","189"]],[["BD","7E","BD"],213,["189","126","189"]],[["81","00","81"],214,["129","0","129"]],[["81","56","81"],215,["129","86","129"]],[["68","00","68"],216,["104","0","104"]],[["68","45","68"],217,["104","69","104"]],[["4F","00","4F"],218,["79","0","79"]],[["4F","35","4F"],219,["79","53","79"]],[["FF","00","BF"],220,["255","0","191"]],[["FF","AA","EA"],221,["255","170","234"]],[["BD","00","8D"],222,["189","0","141"]],[["BD","7E","AD"],223,["189","126","173"]],[["81","00","60"],224,["129","0","96"]],[["81","56","76"],225,["129","86","118"]],[["68","00","4E"],226,["104","0","78"]],[["68","45","5F"],227,["104","69","95"]],[["4F","00","3B"],228,["79","0","59"]],[["4F","35","49"],229,["79","53","73"]],[["FF","00","7F"],230,["255","0","127"]],[["FF","AA","D4"],231,["255","170","212"]],[["BD","00","5E"],232,["189","0","94"]],[["BD","7E","9D"],233,["189","126","157"]],[["81","00","40"],234,["129","0","64"]],[["81","56","6B"],235,["129","86","107"]],[["68","00","34"],236,["104","0","52"]],[["68","45","56"],237,["104","69","86"]],[["4F","00","27"],238,["79","0","39"]],[["4F","35","42"],239,["79","53","66"]],[["FF","00","3F"],240,["255","0","63"]],[["FF","AA","BF"],241,["255","170","191"]],[["BD","00","2E"],242,["189","0","46"]],[["BD","7E","8D"],243,["189","126","141"]],[["81","00","1F"],244,["129","0","31"]],[["81","56","60"],245,["129","86","96"]],[["68","00","19"],246,["104","0","25"]],[["68","45","4E"],247,["104","69","78"]],[["4F","00","13"],248,["79","0","19"]],[["4F","35","3B"],249,["79","53","59"]],[["33","33","33"],250,["51","51","51"]],[["50","50","50"],251,["80","80","80"]],[["69","69","69"],252,["105","105","105"]],[["82","82","82"],253,["130","130","130"]],[["BE","BE","BE"],254,["190","190","190"]],[["FF","FF","FF"],255,["255","255","255"]]];function p$1(e){let t="";const s=g$1.find((t=>{const[,s]=t;return s===e}));if(s){const[e]=s,[n,i,h]=e;t=`${n}${i}${h}`}return t}let A$1=class A{constructor(e){this.name=e,this.tags=[]}add(e,t){this.tags.push({code:e,value:t})}dxfy(e){e.push(102,`{${this.name}`);for(const t of this.tags)e.push(t.code,t.value);e.push(102,"}")}};class y{constructor(){this.lines=[]}push(e,t){null!=t&&this.lines.push(e,t)}stringify(){return this.lines.join("\n")}start(e){this.push(0,"SECTION"),this.push(2,e)}end(){this.push(0,"ENDSEC")}variableName(e){this.push(9,e)}type(e){this.push(0,e)}primaryText(e){this.push(1,e)}name(e,t=2){this.push(t,e)}handle(e){this.push(5,e)}lineType(e){this.push(6,e)}textStyle(e){this.push(7,e)}layerName(e){this.push(8,e)}point2d(e,t=0){this.push(10+t,null==e?void 0:e.x),this.push(20+t,null==e?void 0:e.y)}point3d(e,t=0){this.point2d(e,t),this.push(30+t,null==e?void 0:e.z)}elevation(e){this.push(38,e)}thickness(e){this.push(39,e)}visibilty(e){null!=e&&this.push(60,e?0:1)}colorNumber(e){this.push(62,e)}subclassMarker(e){this.push(100,e)}}var m,x$1,I$1,L;function S(e,t,s,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?n:"a"===s?n.call(e):n?n.value:t.get(e)}function D(e,t,s,n,i){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,s),s}function b(e,t){return{code:e,value:t}}function E$1(e,t=255){const s=[],n=[];for(let i=0;i<e.length;i++){const h=e[i];n.length===t||i===e.length-1?(s.push(n.join("")),n.length=0):n.push(h)}return s}!function(e){e[e.Red=1]="Red",e[e.Green=3]="Green",e[e.Cyan=4]="Cyan",e[e.Blue=5]="Blue",e[e.Magenta=6]="Magenta",e[e.White=7]="White",e[e.Black=0]="Black",e[e.Yellow=2]="Yellow"}(m||(m={})),function(e){e[e.Unitless=0]="Unitless",e[e.Inches=1]="Inches",e[e.Feet=2]="Feet",e[e.Miles=3]="Miles",e[e.Millimeters=4]="Millimeters",e[e.Centimeters=5]="Centimeters",e[e.Meters=6]="Meters",e[e.Kilometers=7]="Kilometers",e[e.Microinches=8]="Microinches",e[e.Mils=9]="Mils",e[e.Yards=10]="Yards",e[e.Angstroms=11]="Angstroms",e[e.Nanometers=12]="Nanometers",e[e.Microns=13]="Microns",e[e.Decimeters=14]="Decimeters",e[e.Decameters=15]="Decameters",e[e.Hectometers=16]="Hectometers",e[e.Gigameters=17]="Gigameters",e[e.AstronomicalUnits=18]="AstronomicalUnits",e[e.LightYears=19]="LightYears",e[e.Parsecs=20]="Parsecs",e[e.USSurveyFeet=21]="USSurveyFeet",e[e.USSurveyInch=22]="USSurveyInch",e[e.USSurveyYard=23]="USSurveyYard",e[e.USSurveyMile=24]="USSurveyMile"}(x$1||(x$1={})),(I$1||(I$1={})).Continuous="Continuous","function"==typeof SuppressedError&&SuppressedError;let F$1=class F{constructor(e){L.set(this,void 0),this.name=e,D(this,L,[])}clear(){S(this,L,"f").length=0}string(e){E$1(e).forEach((e=>S(this,L,"f").push(b(1e3,e))))}beginList(){S(this,L,"f").push(b(1002,"{"))}endList(){S(this,L,"f").push(b(1002,"}"))}layerName(e){S(this,L,"f").push(b(1003,e))}binaryData(e){E$1(e).forEach((e=>S(this,L,"f").push(b(1004,e))))}databaseHandle(e){S(this,L,"f").push(b(1005,e))}point(e){S(this,L,"f").push(b(1010,e.x)),S(this,L,"f").push(b(1020,e.y)),S(this,L,"f").push(b(1030,e.z))}position(e){S(this,L,"f").push(b(1011,e.x)),S(this,L,"f").push(b(1021,e.y)),S(this,L,"f").push(b(1031,e.z))}displacement(e){S(this,L,"f").push(b(1012,e.x)),S(this,L,"f").push(b(1022,e.y)),S(this,L,"f").push(b(1032,e.z))}direction(e){S(this,L,"f").push(b(1013,e.x)),S(this,L,"f").push(b(1023,e.y)),S(this,L,"f").push(b(1033,e.z))}real(e){S(this,L,"f").push(b(1040,e))}distance(e){S(this,L,"f").push(b(1041,e))}scale(e){S(this,L,"f").push(b(1042,e))}integer(e){S(this,L,"f").push(b(1070,e))}long(e){S(this,L,"f").push(b(1071,e))}dxfy(e){e.push(1001,this.name),e.push(1002,"{"),S(this,L,"f").forEach((t=>e.push(t.code,t.value))),e.push(1002,"}")}};L=new WeakMap;let C$1=class C{set angle(e){this.patternsData.forEach((t=>t.lineAngle=e))}constructor(e){this.name=e,this.patternsData=[],this.scale=1}dxfy(e){e.push(78,this.patternsData.length);for(const t of this.patternsData){e.push(53,t.lineAngle),e.push(43,t.x),e.push(44,t.y),e.push(45,t.offsetX*this.scale),e.push(46,t.offsetY*this.scale),e.push(79,t.dashLengthItems.length);for(const s of t.dashLengthItems)e.push(49,s*this.scale)}}add(e){this.patternsData.push(e)}};const T=new Map,X$1=new C$1("ANGLE");X$1.add({lineAngle:0,x:0,y:0,offsetX:.275,offsetY:.2,dashLengthItems:[-.075]}),X$1.add({lineAngle:90,x:0,y:0,offsetX:.275,offsetY:.2,dashLengthItems:[-.075]}),T.set("ANGLE",X$1);const R=new C$1("ANSI31");R.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:1.25,dashLengthItems:[]}),T.set("ANSI31",R);const Y=new C$1("ANSI32");Y.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),T.set("ANSI32",Y);const B$1=new C$1("ANSI33");B$1.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:9.525,dashLengthItems:[]}),B$1.add({lineAngle:45,x:4.49013,y:0,offsetX:0,offsetY:9.525,dashLengthItems:[]}),T.set("ANSI33",B$1);const w=new C$1("ANSI34");w.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[]}),w.add({lineAngle:45,x:4.49013,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[3.175,-1.5875]}),T.set("ANSI34",w);const N=new C$1("ANSI35");N.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:19.05,dashLengthItems:[]}),N.add({lineAngle:45,x:4.49013,y:0,offsetX:0,offsetY:19.05,dashLengthItems:[]}),N.add({lineAngle:45,x:8.98026,y:0,offsetX:0,offsetY:19.05,dashLengthItems:[]}),N.add({lineAngle:45,x:13.4704,y:0,offsetX:0,offsetY:19.05,dashLengthItems:[]}),T.set("ANSI35",N);const M=new C$1("ANSI36");M.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[]}),M.add({lineAngle:45,x:4.49013,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[7.9375,-1.5875,0,-1.5875]}),T.set("ANSI36",M);const P=new C$1("ANSI37");P.add({lineAngle:45,x:0,y:0,offsetX:5.55625,offsetY:3.175,dashLengthItems:[7.9375,-1.5875,0,-1.5875]}),T.set("ANSI37",P);const O=new C$1("ANSI38");O.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),O.add({lineAngle:135,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),T.set("ANSI38",O);const _=new C$1("AR_B816");_.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),_.add({lineAngle:135,x:0,y:0,offsetX:6.35,offsetY:3.175,dashLengthItems:[7.9375,-4.7625]}),T.set("AR_B816",_);const H=new C$1("AR_B816C");H.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:203.2,dashLengthItems:[]}),H.add({lineAngle:90,x:0,y:0,offsetX:203.2,offsetY:203.2,dashLengthItems:[203.2,-203.2]}),T.set("AR_B816C",H);const k=new C$1("AR_B88");k.add({lineAngle:0,x:0,y:0,offsetX:203.2,offsetY:203.2,dashLengthItems:[396.875,-9.525]}),k.add({lineAngle:0,x:-203.2,y:9.525,offsetX:203.2,offsetY:203.2,dashLengthItems:[396.875,-9.525]}),k.add({lineAngle:90,x:0,y:0,offsetX:203.2,offsetY:203.2,dashLengthItems:[-212.725,193.675]}),k.add({lineAngle:90,x:-9.525,y:0,offsetX:203.2,offsetY:203.2,dashLengthItems:[-212.725,193.675]}),T.set("AR_B88",k);const W=new C$1("AR_BRELM");W.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:203.2,dashLengthItems:[]}),W.add({lineAngle:90,x:0,y:0,offsetX:203.2,offsetY:101.6,dashLengthItems:[203.2,-203.2]}),T.set("AR_BRELM",W);const V=new C$1("AR_BRSTD");V.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:135.484,dashLengthItems:[193.675,-9.525]}),V.add({lineAngle:0,x:0,y:57.15,offsetX:0,offsetY:135.484,dashLengthItems:[193.675,-9.525]}),V.add({lineAngle:0,x:50.8,y:67.7418,offsetX:0,offsetY:135.484,dashLengthItems:[92.075,-9.525]}),V.add({lineAngle:0,x:50.8,y:124.892,offsetX:0,offsetY:135.484,dashLengthItems:[92.075,-9.525]}),V.add({lineAngle:90,x:0,y:0,offsetX:0,offsetY:203.2,dashLengthItems:[57.15,-78.334]}),V.add({lineAngle:90,x:-9.525,y:0,offsetX:0,offsetY:203.2,dashLengthItems:[57.15,-78.334]}),V.add({lineAngle:90,x:50.8,y:67.7418,offsetX:0,offsetY:101.6,dashLengthItems:[57.15,-78.334]}),V.add({lineAngle:90,x:41.275,y:67.7418,offsetX:0,offsetY:101.6,dashLengthItems:[57.15,-78.334]}),T.set("AR_BRSTD",V);const U=new C$1("AR_CONC");U.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:67.7418,dashLengthItems:[]}),U.add({lineAngle:90,x:0,y:0,offsetX:67.7418,offsetY:101.6,dashLengthItems:[67.7418,-67.7418]}),T.set("AR_CONC",U);const j=new C$1("AR_HBONE");j.add({lineAngle:50,x:0,y:0,offsetX:104.896,offsetY:-149.807,dashLengthItems:[19.05,-209.55]}),j.add({lineAngle:355,x:0,y:0,offsetX:-51.76101082,offsetY:187.25814969,dashLengthItems:[15.24,-167.64058417]}),j.add({lineAngle:100.4514447,x:15.182007,y:-1.3282535,offsetX:145.5569059,offsetY:-176.270089,dashLengthItems:[16.1900088,-178.0902446]}),j.add({lineAngle:46.1842,x:0,y:50.8,offsetX:157.343,offsetY:-224.71,dashLengthItems:[28.575,-314.325]}),j.add({lineAngle:96.63555761,x:22.5899,y:47.2965,offsetX:218.33577212,offsetY:-264.40480444,dashLengthItems:[24.28502314,-267.13560816]}),j.add({lineAngle:351.18415117,x:0,y:50.8,offsetX:196.67912063,offsetY:280.88740361,dashLengthItems:[22.85996707,-251.45973192]}),j.add({lineAngle:21,x:25.4,y:38.1,offsetX:104.89565868,offsetY:-149.80652586,dashLengthItems:[19.05,-209.55]}),j.add({lineAngle:326,x:25.4,y:38.1,offsetX:-51.7604,offsetY:187.258,dashLengthItems:[15.24,-167.64]}),j.add({lineAngle:71.451445,x:38.0345326,y:29.5779001,offsetX:145.5567546,offsetY:-176.2700748,dashLengthItems:[16.1900088,-178.0899376]}),j.add({lineAngle:37.5,x:0,y:0,offsetX:53.9242,offsetY:65.2018,dashLengthItems:[0,-165.608,0,-170.18,0,-168.275]}),j.add({lineAngle:7.5,x:0,y:0,offsetX:79.3242,offsetY:90.6018,dashLengthItems:[0,-97.028,0,-161.798,0,-64.135]}),j.add({lineAngle:-32.5,x:-56.642,y:0,offsetX:117.434,offsetY:68.0212,dashLengthItems:[0,-63.5,0,-198.12,0,-262.89]}),j.add({lineAngle:-42.5,x:-82.042,y:0,offsetX:92.0344,offsetY:118.821,dashLengthItems:[0,-82.55,0,-131.572,0,-186.69]}),T.set("AR_HBONE",j);const G=new C$1("AR_PARQ1");G.add({lineAngle:45,x:0,y:0,offsetX:101.6,offsetY:101.6,dashLengthItems:[304.8,-101.6]}),G.add({lineAngle:135,x:71.842,y:71.842,offsetX:101.6,offsetY:-101.6,dashLengthItems:[304.8,-101.6]}),T.set("AR_PARQ1",G);const z=new C$1("AR_RROOF");z.add({lineAngle:90,x:0,y:0,offsetX:304.8,offsetY:304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:90,x:50.8,y:0,offsetX:304.8,offsetY:304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:90,x:101.6,y:0,offsetX:304.8,offsetY:304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:90,x:152.4,y:0,offsetX:304.8,offsetY:304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:90,x:203.2,y:0,offsetX:304.8,offsetY:304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:90,x:254,y:0,offsetX:304.8,offsetY:304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:90,x:304.8,y:0,offsetX:304.8,offsetY:304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:0,x:0,y:304.8,offsetX:304.8,offsetY:-304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:0,x:0,y:355.6,offsetX:304.8,offsetY:-304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:0,x:0,y:406.4,offsetX:304.8,offsetY:-304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:0,x:0,y:457.2,offsetX:304.8,offsetY:-304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:0,x:0,y:508,offsetX:304.8,offsetY:-304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:0,x:0,y:558.8,offsetX:304.8,offsetY:-304.8,dashLengthItems:[304.8,-304.8]}),z.add({lineAngle:0,x:0,y:609.6,offsetX:304.8,offsetY:-304.8,dashLengthItems:[304.8,-304.8]}),T.set("AR_RROOF",z);const J=new C$1("AR_RSHKE");J.add({lineAngle:0,x:0,y:0,offsetX:55.88,offsetY:25.4,dashLengthItems:[381,-50.8,127,-25.4]}),J.add({lineAngle:0,x:33.782,y:12.7,offsetX:-25.4,offsetY:33.782,dashLengthItems:[76.2,-8.382,152.4,-19.05]}),J.add({lineAngle:0,x:12.7,y:21.59,offsetX:132.08,offsetY:17.018,dashLengthItems:[203.2,-35.56,101.6,-25.4]}),T.set("AR_RSHKE",J);const K=new C$1("AR_SAND");K.add({lineAngle:0,x:0,y:0,offsetX:647.7,offsetY:304.8,dashLengthItems:[152.4,-127,177.8,-76.2,228.6,-101.6]}),K.add({lineAngle:0,x:152.4,y:12.7,offsetX:647.7,offsetY:304.8,dashLengthItems:[127,-482.6,101.6,-152.4]}),K.add({lineAngle:0,x:457.2,y:-19.05,offsetX:647.7,offsetY:304.8,dashLengthItems:[76.2,-787.4]}),K.add({lineAngle:90,x:0,y:0,offsetX:304.8,offsetY:215.9,dashLengthItems:[292.1,-927.1]}),K.add({lineAngle:90,x:152.4,y:0,offsetX:304.8,offsetY:215.9,dashLengthItems:[285.75,-933.45]}),K.add({lineAngle:90,x:279.4,y:0,offsetX:304.8,offsetY:215.9,dashLengthItems:[266.7,-952.5]}),K.add({lineAngle:90,x:457.2,y:-19.05,offsetX:304.8,offsetY:215.9,dashLengthItems:[292.1,-927.1]}),K.add({lineAngle:90,x:533.4,y:-19.05,offsetX:304.8,offsetY:215.9,dashLengthItems:[292.1,-927.1]}),K.add({lineAngle:90,x:762,y:0,offsetX:304.8,offsetY:215.9,dashLengthItems:[279.4,-939.8]}),T.set("AR_SAND",K);const Z=new C$1("BOX");Z.add({lineAngle:37.5,x:0,y:0,offsetX:28.5242,offsetY:39.8018,dashLengthItems:[0,-38.608,0,-43.18,0,-41.275]}),Z.add({lineAngle:7.5,x:0,y:0,offsetX:53.9242,offsetY:65.2018,dashLengthItems:[0,-20.828,0,-34.798,0,-13.335]}),Z.add({lineAngle:-32.5,x:-31.242,y:0,offsetX:66.6344,offsetY:42.6212,dashLengthItems:[0,-12.7,0,-45.72,0,-59.69]}),Z.add({lineAngle:-42.5,x:-31.242,y:0,offsetX:41.2344,offsetY:68.0212,dashLengthItems:[0,-6.35,0,-29.972,0,-34.29]}),T.set("BOX",Z);const q=new C$1("BRASS");q.add({lineAngle:90,x:0,y:0,offsetX:0,offsetY:25.4,dashLengthItems:[]}),q.add({lineAngle:90,x:6.35,y:0,offsetX:0,offsetY:25.4,dashLengthItems:[]}),q.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:25.4,dashLengthItems:[-6.35,6.35]}),q.add({lineAngle:0,x:0,y:6.35,offsetX:0,offsetY:25.4,dashLengthItems:[-6.35,6.35]}),q.add({lineAngle:0,x:0,y:12.7,offsetX:0,offsetY:25.4,dashLengthItems:[6.35,-6.35]}),q.add({lineAngle:0,x:0,y:19.05,offsetX:0,offsetY:25.4,dashLengthItems:[6.35,-6.35]}),q.add({lineAngle:90,x:12.7,y:0,offsetX:0,offsetY:25.4,dashLengthItems:[6.35,-6.35]}),q.add({lineAngle:90,x:19.05,y:0,offsetX:0,offsetY:25.4,dashLengthItems:[6.35,-6.35]}),T.set("BRASS",q);const $=new C$1("BRICK");$.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[]}),$.add({lineAngle:0,x:0,y:3.175,offsetX:0,offsetY:6.35,dashLengthItems:[3.175,-1.5875]}),T.set("BRICK",$);const Q$1=new C$1("BRSTONE");Q$1.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[]}),Q$1.add({lineAngle:90,x:0,y:0,offsetX:0,offsetY:12.7,dashLengthItems:[6.35,-6.35]}),Q$1.add({lineAngle:90,x:6.35,y:0,offsetX:0,offsetY:12.7,dashLengthItems:[-6.35,6.35]}),T.set("BRSTONE",Q$1);const ee=new C$1("CLAY");ee.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:8.382,dashLengthItems:[]}),ee.add({lineAngle:90,x:22.86,y:0,offsetX:8.382,offsetY:12.7,dashLengthItems:[8.382,-8.382]}),ee.add({lineAngle:90,x:20.32,y:0,offsetX:8.382,offsetY:12.7,dashLengthItems:[8.382,-8.382]}),ee.add({lineAngle:0,x:22.86,y:1.397,offsetX:12.7,offsetY:8.382,dashLengthItems:[-22.86,2.54]}),ee.add({lineAngle:0,x:22.86,y:2.794,offsetX:12.7,offsetY:8.382,dashLengthItems:[-22.86,2.54]}),ee.add({lineAngle:0,x:22.86,y:4.191,offsetX:12.7,offsetY:8.382,dashLengthItems:[-22.86,2.54]}),ee.add({lineAngle:0,x:22.86,y:5.588,offsetX:12.7,offsetY:8.382,dashLengthItems:[-22.86,2.54]}),ee.add({lineAngle:0,x:22.86,y:6.985,offsetX:12.7,offsetY:8.382,dashLengthItems:[-22.86,2.54]}),T.set("CLAY",ee);const te=new C$1("CORK");te.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:4.7625,dashLengthItems:[]}),te.add({lineAngle:0,x:0,y:.79375,offsetX:0,offsetY:4.7625,dashLengthItems:[]}),te.add({lineAngle:0,x:0,y:1.5875,offsetX:0,offsetY:4.7625,dashLengthItems:[]}),te.add({lineAngle:0,x:0,y:3.175,offsetX:0,offsetY:4.7625,dashLengthItems:[4.7625,-3.175]}),T.set("CORK",te);const se$1=new C$1("CROSS");se$1.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),se$1.add({lineAngle:135,x:1.5875,y:-1.5875,offsetX:0,offsetY:8.98026,dashLengthItems:[4.49013,-4.49013]}),se$1.add({lineAngle:135,x:2.38125,y:-1.5875,offsetX:0,offsetY:8.98026,dashLengthItems:[4.49013,-4.49013]}),se$1.add({lineAngle:135,x:3.175,y:-1.5875,offsetX:0,offsetY:8.98026,dashLengthItems:[4.49013,-4.49013]}),T.set("CROSS",se$1);const ne=new C$1("DASH");ne.add({lineAngle:0,x:0,y:0,offsetX:6.35,offsetY:6.35,dashLengthItems:[3.175,-9.525]}),ne.add({lineAngle:90,x:1.5875,y:-1.5875,offsetX:6.35,offsetY:6.35,dashLengthItems:[3.175,-9.525]}),T.set("DASH",ne);const ie=new C$1("DOLMIT");ie.add({lineAngle:0,x:0,y:0,offsetX:3.175,offsetY:3.175,dashLengthItems:[3.175,-3.175]}),T.set("DOLMIT",ie);const he=new C$1("DOTS");he.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[]}),he.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:17.9605,dashLengthItems:[8.980256121069154,-17.960512242138307]}),T.set("DOTS",he);const oe=new C$1("EARTH");oe.add({lineAngle:0,x:0,y:0,offsetX:.79375,offsetY:1.5875,dashLengthItems:[0,-1.5875]}),T.set("EARTH",oe);const de$1=new C$1("ESCHER");de$1.add({lineAngle:0,x:0,y:0,offsetX:6.35,offsetY:6.35,dashLengthItems:[6.35,-6.35]}),de$1.add({lineAngle:0,x:0,y:2.38125,offsetX:6.35,offsetY:6.35,dashLengthItems:[6.35,-6.35]}),de$1.add({lineAngle:0,x:0,y:4.7625,offsetX:6.35,offsetY:6.35,dashLengthItems:[6.35,-6.35]}),de$1.add({lineAngle:90,x:.79375,y:5.55625,offsetX:6.35,offsetY:6.35,dashLengthItems:[6.35,-6.35]}),de$1.add({lineAngle:90,x:3.175,y:5.55625,offsetX:6.35,offsetY:6.35,dashLengthItems:[6.35,-6.35]}),de$1.add({lineAngle:90,x:5.55625,y:5.55625,offsetX:6.35,offsetY:6.35,dashLengthItems:[6.35,-6.35]}),T.set("ESCHER",de$1);const ae=new C$1("FLEX");ae.add({lineAngle:60,x:0,y:0,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[27.94,-2.54]}),ae.add({lineAngle:180,x:0,y:0,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[27.94,-2.54]}),ae.add({lineAngle:300,x:0,y:0,offsetX:15.24,offsetY:26.3964542936,dashLengthItems:[27.94,-2.54]}),ae.add({lineAngle:60,x:2.54,y:0,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:300,x:2.54,y:0,offsetX:15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:60,x:-1.27,y:2.199704516,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:180,x:-1.27,y:2.199704516,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:300,x:-1.27,y:-2.199704516,offsetX:15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:180,x:-1.27,y:-2.199704516,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:60,x:-10.16,y:0,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:300,x:-10.16,y:0,offsetX:15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:60,x:5.08,y:-8.7988180894,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:180,x:5.08,y:-8.7988180894,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:300,x:5.08,y:8.7988180894,offsetX:15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:180,x:5.08,y:8.7988180894,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[5.08,-25.4]}),ae.add({lineAngle:0,x:5.08,y:4.3994090574,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[17.78,-12.7]}),ae.add({lineAngle:0,x:5.08,y:-4.3994090574,offsetX:-15.24,offsetY:26.3964542936,dashLengthItems:[17.78,-12.7]}),ae.add({lineAngle:120,x:1.27,y:6.5991135734,offsetX:15.24,offsetY:26.3964542936,dashLengthItems:[17.78,-12.7]}),ae.add({lineAngle:120,x:-6.35,y:2.199704516,offsetX:15.24,offsetY:26.3964542936,dashLengthItems:[17.78,-12.7]}),ae.add({lineAngle:240,x:-6.35,y:-2.199704516,offsetX:15.24,offsetY:26.3964542936,dashLengthItems:[17.78,-12.7]}),ae.add({lineAngle:240,x:1.27,y:-6.5991135734,offsetX:15.24,offsetY:26.3964542936,dashLengthItems:[17.78,-12.7]}),T.set("FLEX",ae);const le=new C$1("GOST_GLASS");le.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[6.35,-6.35]}),le.add({lineAngle:45,x:6.35,y:0,offsetX:4.490128053,offsetY:4.490128053,dashLengthItems:[1.5875,-5.8052561314,1.5875,-8.9802561314]}),T.set("GOST_GLASS",le);const re=new C$1("GOST_WOOD");re.add({lineAngle:45,x:0,y:0,offsetX:6,offsetY:-6,dashLengthItems:[5,-7]}),re.add({lineAngle:45,x:2.12132,y:0,offsetX:6,offsetY:-6,dashLengthItems:[2,-10]}),re.add({lineAngle:45,x:0,y:2.12132,offsetX:6,offsetY:-6,dashLengthItems:[2,-10]}),T.set("GOST_WOOD",re);const fe=new C$1("GOST_GROUND");fe.add({lineAngle:90,x:0,y:0,offsetX:0,offsetY:-6,dashLengthItems:[10,-2]}),fe.add({lineAngle:90,x:2,y:-2,offsetX:0,offsetY:-6,dashLengthItems:[6,-1.5,3,-1.5]}),fe.add({lineAngle:90,x:4,y:-5,offsetX:0,offsetY:-6,dashLengthItems:[10,-2]}),T.set("GOST_GROUND",fe);const ue=new C$1("GRASS");ue.add({lineAngle:45,x:0,y:0,offsetX:10,offsetY:-10,dashLengthItems:[20]}),ue.add({lineAngle:45,x:3,y:0,offsetX:10,offsetY:-10,dashLengthItems:[20]}),ue.add({lineAngle:45,x:6,y:0,offsetX:10,offsetY:-10,dashLengthItems:[20]}),T.set("GRASS",ue);const ce=new C$1("GRATE");ce.add({lineAngle:90,x:0,y:0,offsetX:17.96051224,offsetY:17.96051224,dashLengthItems:[4.7625,-31.15852448]}),ce.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:25.4,dashLengthItems:[4.7625,-20.6375]}),ce.add({lineAngle:135,x:0,y:0,offsetX:0,offsetY:25.4,dashLengthItems:[4.7625,-20.6375]}),T.set("GRATE",ce);const ge=new C$1("GRAVEL");ge.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:.79375,dashLengthItems:[]}),ge.add({lineAngle:90,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),T.set("GRAVEL",ge);const pe$1=new C$1("HEX");pe$1.add({lineAngle:228.0127875,x:18.288,y:25.4,offsetX:305.85067529778,offsetY:1.88796713245,dashLengthItems:[3.4172144,-338.30483639565]}),pe$1.add({lineAngle:184.969741,x:16.002,y:22.86,offsetX:-305.8545235377,offsetY:1.10019612724,dashLengthItems:[5.8640472,-580.54048893524]}),pe$1.add({lineAngle:132.5104471,x:10.16,y:22.352,offsetX:-377.59492241548,offsetY:1.56030959675,dashLengthItems:[4.1348152,-409.347227941]}),pe$1.add({lineAngle:267.273689,x:.254,y:16.002,offsetX:-508.63316875916,offsetY:1.20815479432,dashLengthItems:[5.3400452,-528.66437425738]}),pe$1.add({lineAngle:292.83365418,x:0,y:10.668,offsetX:-330.19770134945,offsetY:1.23208097566,dashLengthItems:[5.236337,-518.39807745344]}),pe$1.add({lineAngle:357.273689,x:2.032,y:5.842,offsetX:-508.63316875916,offsetY:1.20815479432,dashLengthItems:[5.3400452,-528.66437425738]}),pe$1.add({lineAngle:37.69424047,x:7.366,y:5.588,offsetX:-416.58997273292,offsetY:.91357450169,dashLengthItems:[7.0619366,-699.13115314247]}),pe$1.add({lineAngle:72.25532837,x:12.954,y:9.906,offsetX:586.40373773403,offsetY:.96766293399,dashLengthItems:[6.6671952,-660.05256601905]}),pe$1.add({lineAngle:121.42956562,x:14.986,y:16.256,offsetX:387.71230339293,offsetY:1.2040754753,dashLengthItems:[5.35813,-530.45545698712]}),pe$1.add({lineAngle:175.2363583,x:12.192,y:20.828,offsetX:-280.5442400419,offsetY:2.10935518695,dashLengthItems:[6.1171328,-299.7393695]}),pe$1.add({lineAngle:222.3974378,x:6.096,y:21.336,offsetX:413.48123885686,offsetY:.81554484621,dashLengthItems:[7.9107792,-783.16772512177]}),pe$1.add({lineAngle:138.81407483,x:25.4,y:15.748,offsetX:234.164238558,offsetY:2.38943100688,dashLengthItems:[2.7000454,-267.30565824344]}),pe$1.add({lineAngle:171.4692344,x:23.368,y:17.526,offsetX:-334.082478726,offsetY:1.25594916784,dashLengthItems:[5.1368198,-508.5463899704]}),pe$1.add({lineAngle:225,x:18.288,y:18.288,offsetX:17.96051224214,offsetY:17.96051224214,dashLengthItems:[3.5920934,-32.32893108428]}),pe$1.add({lineAngle:203.19859051,x:16.51,y:21.336,offsetX:-136.74251918,offsetY:3.33518339548,dashLengthItems:[1.9344132,-191.50622368894]}),pe$1.add({lineAngle:291.80140949,x:14.732,y:20.574,offsetX:-80.18324702488,offsetY:4.71666158921,dashLengthItems:[2.7356562,-134.0475299]}),pe$1.add({lineAngle:30.96375653,x:15.748,y:18.034,offsetX:91.47734531502,offsetY:4.35606406258,dashLengthItems:[4.4431966,-143.6629815291]}),pe$1.add({lineAngle:161.56505118,x:19.558,y:20.32,offsetX:-56.2252967978,offsetY:8.03218525675,dashLengthItems:[3.2128714,-77.10898116828]}),pe$1.add({lineAngle:16.389540334,x:0,y:20.574,offsetX:265.17991128726,offsetY:1.43340492604,dashLengthItems:[4.50088,-445.58826672539]}),pe$1.add({lineAngle:70.34617594,x:4.318,y:21.844,offsetX:-297.29446803469,offsetY:1.70858889651,dashLengthItems:[3.7759894,-373.822156782]}),pe$1.add({lineAngle:293.19859051,x:19.558,y:25.4,offsetX:-136.7425191801,offsetY:3.33518339548,dashLengthItems:[3.868801,-189.57183588894]}),pe$1.add({lineAngle:343.61045967,x:21.082,y:21.844,offsetX:-265.17991128725,offsetY:1.433404926,dashLengthItems:[4.50088,-445.5882667254]}),pe$1.add({lineAngle:339.44395478,x:0,y:4.826,offsetX:-136.75087638398,offsetY:2.97284513779,dashLengthItems:[4.340352,-212.67734313106]}),pe$1.add({lineAngle:294.7751406,x:4.064,y:3.302,offsetX:-306.90424056705,offsetY:1.77401295215,dashLengthItems:[3.6367212,-360.0359338072]}),pe$1.add({lineAngle:66.80140949,x:19.812,y:0,offsetX:136.74251918012,offsetY:3.33518339452,dashLengthItems:[3.868801,-189.57183588894]}),pe$1.add({lineAngle:17.35402464,x:21.336,y:3.556,offsetX:-345.47402804977,offsetY:1.51523696536,dashLengthItems:[4.2578274,-421.523759802]}),pe$1.add({lineAngle:69.44395478,x:7.366,y:0,offsetX:-136.75087638396,offsetY:2.97284513874,dashLengthItems:[2.170176,-214.84751913106]}),pe$1.add({lineAngle:101.309932474,x:18.288,y:0,offsetX:104.60834648271,offsetY:4.98134983255,dashLengthItems:[1.295146,-128.21994964526]}),pe$1.add({lineAngle:165.963756532,x:18.034,y:1.27,offsetX:-80.085263387,offsetY:6.16040487582,dashLengthItems:[5.236337,-99.49054589069]}),pe$1.add({lineAngle:186.00900596,x:12.954,y:2.54,offsetX:-255.26337856879,offsetY:1.32949676118,dashLengthItems:[4.85267,-480.41364863337]}),pe$1.add({lineAngle:303.69006753,x:15.748,y:15.748,offsetX:-56.35753993648,offsetY:7.0446924921,dashLengthItems:[3.6632388,-87.9177635968]}),pe$1.add({lineAngle:353.15722659,x:17.78,y:12.7,offsetX:434.77679606606,offsetY:1.0087628707,dashLengthItems:[6.3955676,-633.16009065031]}),pe$1.add({lineAngle:60.9453959,x:24.13,y:11.938,offsetX:-204.76648550216,offsetY:2.46706609031,dashLengthItems:[2.6150824,-258.8939231811]}),pe$1.add({lineAngle:90,x:25.4,y:14.224,offsetX:25.4,offsetY:25.4,dashLengthItems:[1.524,-23.876]}),pe$1.add({lineAngle:120.25643716,x:12.446,y:3.302,offsetX:-204.77318477297,offsetY:1.8283320086,dashLengthItems:[3.5286696,-349.339407732]}),pe$1.add({lineAngle:48.0127875,x:10.668,y:6.35,offsetX:305.85067529778,offsetY:1.88796713138,dashLengthItems:[6.8344288,-334.88762199565]}),pe$1.add({lineAngle:0,x:15.24,y:11.43,offsetX:25.4,offsetY:25.4,dashLengthItems:[6.604,-18.796]}),pe$1.add({lineAngle:325.3048465,x:21.844,y:11.43,offsetX:310.04235091354,offsetY:-1.6064370526,dashLengthItems:[4.0160956,-397.5931672414]}),pe$1.add({lineAngle:254.0546041,x:25.146,y:9.144,offsetX:104.6687497289,offsetY:3.48895832444,dashLengthItems:[3.6982908,-181.21650038772]}),pe$1.add({lineAngle:207.64597536,x:24.13,y:5.588,offsetX:545.36007557253,offsetY:1.07143433066,dashLengthItems:[6.021451,-596.12464422938]}),pe$1.add({lineAngle:175.42607874,x:18.796,y:2.794,offsetX:331.1739336186,offsetY:1.01276432357,dashLengthItems:[6.3702946,-630.6584645624]}),T.set("HEX",pe$1);const Ae$1=new C$1("HONEY");Ae$1.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5.4992613154,dashLengthItems:[3.175,-6.35]}),Ae$1.add({lineAngle:120,x:0,y:0,offsetX:0,offsetY:5.4992613154,dashLengthItems:[3.175,-6.35]}),Ae$1.add({lineAngle:60,x:3.175,y:0,offsetX:0,offsetY:5.4992613154,dashLengthItems:[3.175,-6.35]}),T.set("HONEY",Ae$1);const ye=new C$1("HOUND");ye.add({lineAngle:0,x:0,y:0,offsetX:4.7625,offsetY:2.749630645,dashLengthItems:[3.175,-6.35]}),ye.add({lineAngle:120,x:0,y:0,offsetX:4.7625,offsetY:2.749630645,dashLengthItems:[3.175,-6.35]}),ye.add({lineAngle:60,x:0,y:0,offsetX:4.7625,offsetY:2.749630645,dashLengthItems:[-6.35,3.175]}),T.set("HOUND",ye);const me=new C$1("INSUL");me.add({lineAngle:0,x:0,y:0,offsetX:6.35,offsetY:1.5875,dashLengthItems:[25.4,-12.7]}),me.add({lineAngle:90,x:0,y:0,offsetX:-6.35,offsetY:1.5875,dashLengthItems:[25.4,-12.7]}),T.set("INSUL",me);const xe$1=new C$1("ACAD_ISO02W100");xe$1.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:9.525,dashLengthItems:[]}),xe$1.add({lineAngle:0,x:0,y:3.175,offsetX:0,offsetY:9.525,dashLengthItems:[3.175,-3.175]}),xe$1.add({lineAngle:0,x:0,y:6.35,offsetX:0,offsetY:9.525,dashLengthItems:[3.175,-3.175]}),T.set("ACAD_ISO02W100",xe$1);const Ie=new C$1("ACAD_ISO03W100");Ie.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[12,-3]}),T.set("ACAD_ISO03W100",Ie);const Le=new C$1("ACAD_ISO04W100");Le.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[12,-18]}),T.set("ACAD_ISO04W100",Le);const Se=new C$1("ACAD_ISO05W100");Se.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[24,-3,.5,-3]}),T.set("ACAD_ISO05W100",Se);const De=new C$1("ACAD_ISO06W100");De.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[24,-3,.5,-3,.5,-3]}),T.set("ACAD_ISO06W100",De);const be=new C$1("ACAD_ISO07W100");be.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[24,-3,.5,-3,.5,-6.5]}),be.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[-34,.5,-3]}),T.set("ACAD_ISO07W100",be);const ve=new C$1("ACAD_ISO08W100");ve.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[.5,-3]}),T.set("ACAD_ISO08W100",ve);const Ee=new C$1("ACAD_ISO09W100");Ee.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[24,-3,6,-3]}),T.set("ACAD_ISO09W100",Ee);const Fe=new C$1("ACAD_ISO10W100");Fe.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[24,-3,6,-3,6,-3]}),T.set("ACAD_ISO10W100",Fe);const Ce=new C$1("ACAD_ISO11W100");Ce.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[12,-3,.5,-3]}),T.set("ACAD_ISO11W100",Ce);const Te=new C$1("ACAD_ISO12W100");Te.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[12,-3,12,-3,.5,-3]}),T.set("ACAD_ISO12W100",Te);const Xe=new C$1("ACAD_ISO13W100");Xe.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[12,-3,.5,-3,.5,-3]}),T.set("ACAD_ISO13W100",Xe);const Re=new C$1("ACAD_ISO14W100");Re.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[12,-3,12,-3,.5,-6.5]}),Re.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[-33.5,.5,-3]}),T.set("ACAD_ISO14W100",Re);const Ye=new C$1("ACAD_ISO15W100");Ye.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[12,-3,.5,-3,.5,-6.5]}),Ye.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[-22,.5,-3]}),T.set("ACAD_ISO15W100",Ye);const Be=new C$1("JIS_LC_20");Be.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[12,-3,12,-3,.5,-10]}),Be.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5,dashLengthItems:[-33.5,.5,-3,.5,-3]}),T.set("JIS_LC_20",Be);const we=new C$1("JIS_LC_20A");we.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:20,dashLengthItems:[]}),we.add({lineAngle:45,x:.4,y:0,offsetX:0,offsetY:20,dashLengthItems:[]}),T.set("JIS_LC_20A",we);const Ne=new C$1("JIS_LC_8");Ne.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:20,dashLengthItems:[]}),Ne.add({lineAngle:45,x:1,y:0,offsetX:0,offsetY:20,dashLengthItems:[]}),T.set("JIS_LC_8",Ne);const Me=new C$1("JIS_LC_8A");Me.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:7.8,dashLengthItems:[]}),Me.add({lineAngle:45,x:.4,y:0,offsetX:0,offsetY:7.8,dashLengthItems:[]}),T.set("JIS_LC_8A",Me);const Pe=new C$1("JIS_RC_10");Pe.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:7.8,dashLengthItems:[]}),Pe.add({lineAngle:45,x:1,y:0,offsetX:0,offsetY:7.8,dashLengthItems:[]}),T.set("JIS_RC_10",Pe);const Oe=new C$1("JIS_RC_15");Oe.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:10,dashLengthItems:[]}),Oe.add({lineAngle:45,x:.725,y:0,offsetX:0,offsetY:10,dashLengthItems:[]}),Oe.add({lineAngle:45,x:1.45,y:0,offsetX:0,offsetY:10,dashLengthItems:[]}),T.set("JIS_RC_15",Oe);const _e=new C$1("JIS_RC_18");_e.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:15,dashLengthItems:[]}),_e.add({lineAngle:45,x:.725,y:0,offsetX:0,offsetY:15,dashLengthItems:[]}),_e.add({lineAngle:45,x:1.45,y:0,offsetX:0,offsetY:15,dashLengthItems:[]}),T.set("JIS_RC_18",_e);const He=new C$1("JIS_RC_30");He.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:18,dashLengthItems:[]}),He.add({lineAngle:45,x:1,y:0,offsetX:0,offsetY:18,dashLengthItems:[]}),He.add({lineAngle:45,x:2,y:0,offsetX:0,offsetY:18,dashLengthItems:[]}),T.set("JIS_RC_30",He);const ke=new C$1("JIS_STN_1E");ke.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:30,dashLengthItems:[]}),ke.add({lineAngle:45,x:1,y:0,offsetX:0,offsetY:30,dashLengthItems:[]}),ke.add({lineAngle:45,x:2,y:0,offsetX:0,offsetY:30,dashLengthItems:[]}),T.set("JIS_STN_1E",ke);const We=new C$1("JIS_STN_2_5");We.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:1,dashLengthItems:[]}),We.add({lineAngle:45,x:.705,y:0,offsetX:0,offsetY:1,dashLengthItems:[1,-.5]}),T.set("JIS_STN_2_5",We);const Ve=new C$1("JIS_WOOD");Ve.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:2.5,dashLengthItems:[]}),Ve.add({lineAngle:45,x:1.765,y:0,offsetX:0,offsetY:2.5,dashLengthItems:[1.2,-.5]}),T.set("JIS_WOOD",Ve);const Ue=new C$1("LINE");Ue.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:.70710678,dashLengthItems:[]}),T.set("LINE",Ue);const je=new C$1("MUDST");je.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),T.set("MUDST",je);const Ge=new C$1("NET");Ge.add({lineAngle:0,x:0,y:0,offsetX:12.7,offsetY:6.35,dashLengthItems:[6.35,-6.35,0,-6.35,0,-6.35]}),T.set("NET",Ge);const ze=new C$1("NET3");ze.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),ze.add({lineAngle:90,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),T.set("NET3",ze);const Je=new C$1("PLAST");Je.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),Je.add({lineAngle:60,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),Je.add({lineAngle:120,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),T.set("PLAST",Je);const Ke=new C$1("PLASTI");Ke.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[]}),Ke.add({lineAngle:0,x:0,y:.79375,offsetX:0,offsetY:6.35,dashLengthItems:[]}),Ke.add({lineAngle:0,x:0,y:1.5875,offsetX:0,offsetY:6.35,dashLengthItems:[]}),T.set("PLASTI",Ke);const Ze=new C$1("SACNCR");Ze.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[]}),Ze.add({lineAngle:0,x:0,y:.79375,offsetX:0,offsetY:6.35,dashLengthItems:[]}),Ze.add({lineAngle:0,x:0,y:1.5875,offsetX:0,offsetY:6.35,dashLengthItems:[]}),Ze.add({lineAngle:0,x:0,y:3.96875,offsetX:0,offsetY:6.35,dashLengthItems:[]}),T.set("SACNCR",Ze);const qe=new C$1("SQUARE");qe.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:2.38125,dashLengthItems:[]}),qe.add({lineAngle:45,x:1.6838,y:0,offsetX:0,offsetY:2.38125,dashLengthItems:[0,-2.38125]}),T.set("SQUARE",qe);const $e=new C$1("STARS");$e.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[3.175,-3.175]}),$e.add({lineAngle:90,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[3.175,-3.175]}),T.set("STARS",$e);const Qe=new C$1("STEEL");Qe.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:5.4992613154,dashLengthItems:[3.175,-3.175]}),Qe.add({lineAngle:60,x:0,y:0,offsetX:0,offsetY:5.4992613154,dashLengthItems:[3.175,-3.175]}),Qe.add({lineAngle:120,x:1.5875,y:2.7496306704,offsetX:0,offsetY:5.4992613154,dashLengthItems:[3.175,-3.175]}),T.set("STEEL",Qe);const et=new C$1("SWAMP");et.add({lineAngle:45,x:0,y:0,offsetX:0,offsetY:3.175,dashLengthItems:[]}),et.add({lineAngle:45,x:0,y:1.5875,offsetX:0,offsetY:3.175,dashLengthItems:[]}),T.set("SWAMP",et);const tt=new C$1("TRANS");tt.add({lineAngle:0,x:0,y:0,offsetX:12.7,offsetY:21.9970452362,dashLengthItems:[3.175,-22.225]}),tt.add({lineAngle:90,x:1.5875,y:0,offsetX:21.9970452362,offsetY:12.7,dashLengthItems:[1.5875,-42.4065904724]}),tt.add({lineAngle:90,x:1.984375,y:0,offsetX:21.9970452362,offsetY:12.7,dashLengthItems:[1.27,-42.7240904724]}),tt.add({lineAngle:90,x:1.190625,y:0,offsetX:21.9970452362,offsetY:12.7,dashLengthItems:[1.27,-42.7240904724]}),tt.add({lineAngle:60,x:2.38125,y:0,offsetX:12.7,offsetY:21.9970452362,dashLengthItems:[1.016,-24.384]}),tt.add({lineAngle:120,x:.79375,y:0,offsetX:12.7,offsetY:21.9970452362,dashLengthItems:[1.016,-24.384]}),T.set("TRANS",tt);const st=new C$1("TRIANG");st.add({lineAngle:0,x:0,y:0,offsetX:0,offsetY:6.35,dashLengthItems:[]}),st.add({lineAngle:0,x:0,y:3.175,offsetX:0,offsetY:6.35,dashLengthItems:[3.175,-3.175]}),T.set("TRIANG",st);const nt$1=new C$1("ZIGZAG");nt$1.add({lineAngle:60,x:0,y:0,offsetX:4.7625,offsetY:8.2488919604,dashLengthItems:[4.7625,-4.7625]}),nt$1.add({lineAngle:120,x:0,y:0,offsetX:4.7625,offsetY:8.2488919604,dashLengthItems:[4.7625,-4.7625]}),nt$1.add({lineAngle:0,x:-2.38125,y:4.1244459802,offsetX:4.7625,offsetY:8.2488919604,dashLengthItems:[4.7625,-4.7625]}),T.set("ZIGZAG",nt$1);class it{static fromHex(e){return e.startsWith("#")&&(e=e.replace("#","")),parseInt(e,16)}static fromRGB(e,t,s){const n=[e,t,s].reduce(((e,t)=>{const s=t.toString(16);return`${e}${1===s.length?"0"+s:s}`}),"0x00");return it.fromHex(n)}}class ht{constructor(e,t,s){this.type=e,this.subclassMarker=t,this.layerName=null==s?void 0:s.layerName,this.handle=h.next(),this.trueColor=null==s?void 0:s.trueColor,this.inPaperSpace=!1,this.colorNumber=null==s?void 0:s.colorNumber,this.visible=null==s?void 0:s.visible,this.lineType=null==s?void 0:s.lineType,this.lineTypeScale=null==s?void 0:s.lineTypeScale,this.extrusion=null==s?void 0:s.extrusion,this.xdatas=[]}boundingBox(){return a.pointBBox(t$1())}addXData(e){const t=new F$1(e);return this.xdatas.push(t),t}dxfy(e){var t,s,n;e.type(this.type),e.handle(this.handle),e.push(330,this.ownerBlockRecord),e.subclassMarker("AcDbEntity"),this.inPaperSpace&&e.push(67,Number(this.inPaperSpace)),e.push(420,this.trueColor),e.layerName(this.layerName||c.layerZeroName),e.lineType(this.lineType),e.colorNumber(this.colorNumber),e.push(48,this.lineTypeScale),e.visibilty(this.visible),e.subclassMarker(this.subclassMarker),"HATCH"!==this.type&&(e.push(210,null===(t=this.extrusion)||void 0===t?void 0:t.x),e.push(220,null===(s=this.extrusion)||void 0===s?void 0:s.y),e.push(230,null===(n=this.extrusion)||void 0===n?void 0:n.z)),this.dxfyChild(e),this.xdatas.forEach((t=>t.dxfy(e)))}}var ot,dt$1,at;!function(e){e[e.Default=0]="Default",e[e.Aligned=1]="Aligned",e[e.Angular=2]="Angular",e[e.Diameter=3]="Diameter",e[e.Radius=4]="Radius",e[e.Angular3Point=5]="Angular3Point",e[e.Ordinate=6]="Ordinate",e[e.ReferencedByThis=32]="ReferencedByThis",e[e.OrdinateType=64]="OrdinateType"}(ot||(ot={})),function(e){e[e.TopLeft=1]="TopLeft",e[e.TopCenter=2]="TopCenter",e[e.TopRight=3]="TopRight",e[e.MiddleLeft=4]="MiddleLeft",e[e.MiddleCenter=5]="MiddleCenter",e[e.MiddleRight=6]="MiddleRight",e[e.BottomLeft=7]="BottomLeft",e[e.BottomCenter=8]="BottomCenter",e[e.BottomRight=9]="BottomRight"}(dt$1||(dt$1={})),function(e){e[e.AtLeast=1]="AtLeast",e[e.Exact=2]="Exact"}(at||(at={}));class lt extends ht{constructor(e){super("DIMENSION","AcDbDimension",e),this.blockName=null==e?void 0:e.blockName,this.definitionPoint=null==e?void 0:e.definitionPoint,this.middlePoint=null==e?void 0:e.middlePoint,this.dimensionType=ot.Default,this.attachmentPoint=(null==e?void 0:e.attachmentPoint)||dt$1.MiddleCenter,this.textLineSpacingStyle=null==e?void 0:e.textLineSpacingStyle,this.textLineSpacingFactor=null==e?void 0:e.textLineSpacingFactor,this.ActualMeasurement=null==e?void 0:e.ActualMeasurement,this.text=null==e?void 0:e.text,this.rotation=null==e?void 0:e.rotation,this.horizontalDirection=null==e?void 0:e.horizontalDirection,this.styleName=null==e?void 0:e.styleName}dxfyChild(e){e.push(2,this.blockName),e.point3d(this.definitionPoint),e.point3d(this.middlePoint,1),e.push(70,this.dimensionType),e.push(71,this.attachmentPoint),e.push(72,this.textLineSpacingStyle),e.push(41,this.textLineSpacingFactor),e.push(42,this.ActualMeasurement),e.push(1,this.text),e.push(53,"auto"===this.rotation?this.rotate():this.rotation),e.push(51,this.horizontalDirection),e.push(3,this.styleName)}}const rt=/[<>/\\":;?*|=`]/g;function ft(e){return e*Math.PI/180}let ct$1=class ct extends lt{constructor(e,t,s){super(s),this.dimensionType=ot.Aligned,this.insertionPoint=null==s?void 0:s.insertionPoint,this.fisrtPoint=e,this.secondPoint=t,this.offset(null==s?void 0:s.offset)}offset(e){if(null==e)return;const[s,n]=function(e,t){const s=e.x-t.x;let n=0;return 0!==s&&(n=(e.y-t.y)/s),[n,e.y-n*e.x]}(this.fisrtPoint,this.secondPoint),i=function(e,t){const[s,n]=t;return n-e*Math.sqrt(s*s+1)}(e,[s,n]);this.definitionPoint=function(e,s){const[n,i]=e,h=null!=n?n:-1/n,o=s.y-h*s.x,d=h-n;let a=i-o;return 0!==d&&(a=(i-o)/d),t$1(a,n*a+i,s.z)}([s,i],this.fisrtPoint)}rotate(){return function ut(e,t){const s=function(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}(e,t);return 0===s?s:180*Math.asin(Math.abs(e.y-t.y)/s)/Math.PI}(this.fisrtPoint,this.secondPoint)}dxfyChild(e){super.dxfyChild(e),e.subclassMarker("AcDbAlignedDimension"),e.point3d(this.insertionPoint,2),e.point3d(this.fisrtPoint,3),e.point3d(this.secondPoint,4)}},gt$1=class gt extends lt{constructor(e,t,s,n){super(n),this.first=e,this.second=t,this.location=s,this.dimensionType=ot.Angular}rotate(){return 0}_update(){this.definitionPoint=this.second.end}dxfyChild(e){this._update(),super.dxfyChild(e),e.subclassMarker("AcDb2LineAngularDimension"),e.point3d(this.first.start,3),e.point3d(this.first.end,4),e.point3d(this.second.start,5),e.point3d(this.location,6)}};class pt extends lt{constructor(e,t,s,n){super(n),this.center=e,this.first=t,this.second=s,this.dimensionType=ot.Angular3Point}rotate(){return 0}dxfyChild(e){super.dxfyChild(e),e.subclassMarker("AcDb3PointAngularDimension"),e.point3d(this.first,3),e.point3d(this.second,4),e.point3d(this.center,5)}}let yt$1=class yt extends lt{constructor(e,t,s){super(s),this.dimensionType=ot.Diameter,this.first=e,this.definitionPoint=t,this.leaderLength=null==s?void 0:s.leaderLength}rotate(){return 0}dxfyChild(e){super.dxfyChild(e),e.subclassMarker("AcDbDiametricDimension"),e.point3d(this.first,5),e.push(40,this.leaderLength)}};class mt extends lt{constructor(e,t,s){var n;super(s),this.dimensionType=ot.Default,this.insertionPoint=null==s?void 0:s.insertionPoint,this.fisrtPoint=e,this.secondPoint=t,this.angle=null!==(n=null==s?void 0:s.angle)&&void 0!==n?n:0,this.linearType=null==s?void 0:s.linearType,this.offset(null==s?void 0:s.offset)}offset(e){if(null==e)return;const s=ft(this.angle),n=this.fisrtPoint.x+e*Math.floor(Math.sin(s)),i=this.fisrtPoint.y+e*Math.floor(Math.cos(s));this.definitionPoint=t$1(n,i,0)}rotate(){return this.angle}dxfyChild(e){super.dxfyChild(e),e.subclassMarker("AcDbAlignedDimension"),e.point3d(this.insertionPoint,2),e.point3d(this.fisrtPoint,3),e.point3d(this.secondPoint,4),e.push(50,this.angle),e.push(52,this.linearType),e.subclassMarker("AcDbRotatedDimension")}}class xt extends lt{constructor(e,t,s){super(s),this.dimensionType=ot.Radius,this.first=e,this.definitionPoint=t,this.leaderLength=null==s?void 0:s.leaderLength}rotate(){return 0}dxfyChild(e){super.dxfyChild(e),e.subclassMarker("AcDbRadialDimension"),e.point3d(this.first,5),e.push(40,this.leaderLength)}}class It extends ht{get start(){return t$1(this.center.x+this.radius*Math.cos(ft(this.startAngle)),this.center.y+this.radius*Math.sin(ft(this.startAngle)))}get end(){return t$1(this.center.x+this.radius*Math.cos(ft(this.endAngle)),this.center.y+this.radius*Math.sin(ft(this.endAngle)))}constructor(e,t,s,n,i){super("ARC","AcDbCircle",i),this.center=e,this.radius=t,this.startAngle=s,this.endAngle=n}boundingBox(){return a.centerRadiusBBox(this.center,this.radius)}dxfyChild(e){e.point3d(this.center),e.push(40,this.radius),e.subclassMarker("AcDbArc"),e.push(50,this.startAngle),e.push(51,this.endAngle)}}class Lt extends ht{constructor(e,t,s,n,i){super("ATTDEF","AcDbText",i),this.position=e,this.height=t,this.value=n,this.tag=s,this.textStyle="STANDARD",this.rotation=null==i?void 0:i.rotation,this.obliqueAngle=null==i?void 0:i.obliqueAngle,this.generationFlags=null==i?void 0:i.generationFlags,this.horizontalAlignment=null==i?void 0:i.horizontalAlignment,this.verticalAlignment=null==i?void 0:i.verticalAlignment,this.secondAlignmentPoint=null==i?void 0:i.secondAlignmentPoint,this.relativeXScaleFactor=null==i?void 0:i.relativeXScaleFactor}boundingBox(){return a.pointBBox(this.position)}dxfyChild(e){e.point3d(this.position),e.push(40,this.height),e.primaryText(this.value),e.push(50,this.rotation),e.push(41,this.relativeXScaleFactor),e.push(51,this.obliqueAngle),e.textStyle(this.textStyle),e.push(71,this.generationFlags),e.push(72,this.horizontalAlignment),this.secondAlignmentPoint&&(e.push(11,this.secondAlignmentPoint.x),e.push(21,this.secondAlignmentPoint.y),e.push(31,this.secondAlignmentPoint.z)),e.push(73,this.verticalAlignment),e.subclassMarker("AcDbAttributeDefinition"),e.push(280,0),e.push(3,""),e.push(2,this.tag),e.push(70,0)}}class St extends ht{constructor(e,t,s,n,i){super("ATTRIB","AcDbText",i),this.position=e,this.height=t,this.value=n,this.tag=s,this.textStyle="STANDARD",this.rotation=null==i?void 0:i.rotation,this.obliqueAngle=null==i?void 0:i.obliqueAngle,this.generationFlags=null==i?void 0:i.generationFlags,this.horizontalAlignment=null==i?void 0:i.horizontalAlignment,this.verticalAlignment=null==i?void 0:i.verticalAlignment,this.secondAlignmentPoint=null==i?void 0:i.secondAlignmentPoint,this.relativeXScaleFactor=null==i?void 0:i.relativeXScaleFactor}boundingBox(){return a.pointBBox(this.position)}dxfyChild(e){e.point3d(this.position),e.push(40,this.height),e.primaryText(this.value),e.push(50,this.rotation),e.push(41,this.relativeXScaleFactor),e.push(51,this.obliqueAngle),e.textStyle(this.textStyle),e.push(71,this.generationFlags),e.push(72,this.horizontalAlignment),e.point3d(this.secondAlignmentPoint,1),e.push(73,this.verticalAlignment),e.subclassMarker("AcDbAttribute"),e.push(280,0),e.push(2,this.tag),e.push(70,0)}}class Dt extends ht{constructor(e,t,s){super("CIRCLE","AcDbCircle",s),this.center=e,this.radius=t}boundingBox(){return a.centerRadiusBBox(this.center,this.radius)}dxfyChild(e){e.point3d(this.center),e.push(40,this.radius)}}class bt extends ht{constructor(e,t,s,n,i,h){super("ELLIPSE","AcDbEllipse",h),this.center=e,this.endPointOfMajorAxis=t,this.ratioOfMinorAxisToMajorAxis=s,this.startParameter=n,this.endParameter=i}boundingBox(){const e=this.center.x,t=this.center.y,s=this.endPointOfMajorAxis.x,n=this.endPointOfMajorAxis.y,i=Math.sqrt(Math.pow(e-(e+s),2)+Math.pow(t-(t+n),2));return a.centerRadiusBBox(this.center,i)}dxfyChild(e){e.point3d(this.center),e.point3d(this.endPointOfMajorAxis,1),e.push(40,this.ratioOfMinorAxisToMajorAxis),e.push(41,this.startParameter),e.push(42,this.endParameter)}}var vt,Et,Ft$1,Ct,Tt,Xt,Rt,Yt,Bt,wt,Nt,Mt,Pt,Ot$1,_t,Ht,kt,Wt,Vt,Ut,jt,Gt,zt,Jt,Kt,Zt,qt,$t$1,Qt,es,ts,ss,ns,is;!function(e){e[e.None=0]="None",e[e.First=1]="First",e[e.Second=2]="Second",e[e.Third=4]="Third",e[e.Fourth=8]="Fourth"}(vt||(vt={}));class hs extends ht{constructor(e,t,s,n,i){super("3DFACE","AcDbFace",i),this.firstCorner=e,this.secondCorner=t,this.thirdCorner=s,this.fourthCorner=n,this.invisibleEdges=(null==i?void 0:i.invisibleEdges)||vt.None}setFirstEdgeVisible(e){this.setEdgeVisible(vt.First,e)}setSecondEdgeVisible(e){this.setEdgeVisible(vt.Second,e)}setThirdEdgeVisible(e){this.setEdgeVisible(vt.Third,e)}setFourthEdgeVisible(e){this.setEdgeVisible(vt.Fourth,e)}setEdgesVisible(e){this.invisibleEdges=e?vt.None:vt.First|vt.Second|vt.Third|vt.Fourth}setEdgeVisible(e,t){t?this.invisibleEdges|=e:this.invisibleEdges===(this.invisibleEdges|e)&&(this.invisibleEdges^=e)}boundingBox(){return a.verticesBBox([this.firstCorner,this.secondCorner,this.thirdCorner,this.fourthCorner])}dxfyChild(e){e.point3d(this.firstCorner),e.point3d(this.secondCorner,1),e.point3d(this.thirdCorner,2),e.point3d(this.fourthCorner,3),e.push(70,this.invisibleEdges)}}!function(e){e.SOLID="SOLID",e.ANGLE="ANGLE",e.ANSI31="ANSI31",e.ANSI32="ANSI32",e.ANSI33="ANSI33",e.ANSI34="ANSI34",e.ANSI35="ANSI35",e.ANSI36="ANSI36",e.ANSI37="ANSI37",e.ANSI38="ANSI38",e.AR_B816="AR_B816",e.AR_B816C="AR_B816C",e.AR_B88="AR_B88",e.AR_BRELM="AR_BRELM",e.AR_BRSTD="AR_BRSTD",e.AR_CONC="AR_CONC",e.AR_HBONE="AR_HBONE",e.AR_PARQ1="AR_PARQ1",e.AR_RROOF="AR_RROOF",e.AR_RSHKE="AR_RSHKE",e.AR_SAND="AR_SAND",e.BOX="BOX",e.BRASS="BRASS",e.BRICK="BRICK",e.BRSTONE="BRSTONE",e.CLAY="CLAY",e.CORK="CORK",e.CROSS="CROSS",e.DASH="DASH",e.DOLMIT="DOLMIT",e.DOTS="DOTS",e.EARTH="EARTH",e.ESCHER="ESCHER",e.FLEX="FLEX",e.GOST_GLASS="GOST_GLASS",e.GOST_WOOD="GOST_WOOD",e.GOST_GROUND="GOST_GROUND",e.GRASS="GRASS",e.GRATE="GRATE",e.GRAVEL="GRAVEL",e.HEX="HEX",e.HONEY="HONEY",e.HOUND="HOUND",e.INSUL="INSUL",e.ACAD_ISO02W100="ACAD_ISO02W100",e.ACAD_ISO03W100="ACAD_ISO03W100",e.ACAD_ISO04W100="ACAD_ISO04W100",e.ACAD_ISO05W100="ACAD_ISO05W100",e.ACAD_ISO06W100="ACAD_ISO06W100",e.ACAD_ISO07W100="ACAD_ISO07W100",e.ACAD_ISO08W100="ACAD_ISO08W100",e.ACAD_ISO09W100="ACAD_ISO09W100",e.ACAD_ISO10W100="ACAD_ISO10W100",e.ACAD_ISO11W100="ACAD_ISO11W100",e.ACAD_ISO12W100="ACAD_ISO12W100",e.ACAD_ISO13W100="ACAD_ISO13W100",e.ACAD_ISO14W100="ACAD_ISO14W100",e.ACAD_ISO15W100="ACAD_ISO15W100",e.JIS_LC_20="JIS_LC_20",e.JIS_LC_20A="JIS_LC_20A",e.JIS_LC_8="JIS_LC_8",e.JIS_LC_8A="JIS_LC_8A",e.JIS_RC_10="JIS_RC_10",e.JIS_RC_15="JIS_RC_15",e.JIS_RC_18="JIS_RC_18",e.JIS_RC_30="JIS_RC_30",e.JIS_STN_1E="JIS_STN_1E",e.JIS_STN_2_5="JIS_STN_2_5",e.JIS_WOOD="JIS_WOOD",e.LINE="LINE",e.MUDST="MUDST",e.NET="NET",e.NET3="NET3",e.PLAST="PLAST",e.PLASTI="PLASTI",e.SACNCR="SACNCR",e.SQUARE="SQUARE",e.STARS="STARS",e.STEEL="STEEL",e.SWAMP="SWAMP",e.TRANS="TRANS",e.TRIANG="TRIANG",e.ZIGZAG="ZIGZAG"}(Et||(Et={})),function(e){e[e.UserDefined=0]="UserDefined",e[e.Predifined=1]="Predifined",e[e.Custom=2]="Custom"}(Ft$1||(Ft$1={})),function(e){e[e.Default=0]="Default",e[e.External=1]="External",e[e.Polyline=2]="Polyline",e[e.Derived=4]="Derived",e[e.Textbox=8]="Textbox",e[e.Outermost=16]="Outermost"}(Ct||(Ct={})),function(e){e[e.SolidFill=1]="SolidFill",e[e.PatternFill=0]="PatternFill"}(Tt||(Tt={})),function(e){e[e.NonAssociative=0]="NonAssociative",e[e.Associative=1]="Associative"}(Xt||(Xt={})),function(e){e[e.Normal=0]="Normal",e[e.Outer=1]="Outer",e[e.Ignore=2]="Ignore"}(Rt||(Rt={})),function(e){e.LINEAR="LINEAR",e.CYLINDER="CYLINDER",e.INVCYLINDER="INVCYLINDER",e.SPHERICAL="SPHERICAL",e.HEMISPHERICAL="HEMISPHERICAL",e.CURVED="CURVED",e.INVSPHERICAL="SPHERICAL",e.INVHEMISPHERICAL="INVHEMISPHERICAL",e.INVCURVED="INVCURVED"}(Yt||(Yt={}));class gs extends ht{get patternName(){let e=Et.SOLID;return this.isPattern(this.fill)&&(e=this.fill.name),e}get solidFillFlag(){return this.patternName===Et.SOLID?Tt.SolidFill:Tt.PatternFill}constructor(e,s,n){super("HATCH","AcDbHatch",n),this.fill=s,this.elevation=(null==n?void 0:n.elevation)||0,this.extrusion=(null==n?void 0:n.extrusion)||t$1(0,0,1),this.boundaryPath=e}pattern(e,t){var s;const n=t.name,i=null!==(s=t.angle)&&void 0!==s?s:0,h=t.scale||1,o=t.double||!1;e.push(52,i),e.push(41,h),e.push(77,Number(o));const d=T.get(n);d&&(d.scale=h,0!==i&&(d.angle=i),d.dxfy(e))}gradient(e,t){var s,n,i;const h=t.firstColor,o=null!==(s=t.secondColor)&&void 0!==s?s:7,d=null!==(n=t.angle)&&void 0!==n?n:0,a=t.definition||0,l=null!==(i=t.tint)&&void 0!==i?i:1,r=t.type||Yt.LINEAR;e.push(450,1),e.push(451,0),e.push(460,d),e.push(461,a),e.push(452,t.secondColor?0:1),e.push(462,l),e.push(453,2),e.push(463,0),e.push(63,h),e.push(421,it.fromHex(p$1(h))),e.push(463,1),e.push(63,o),e.push(421,it.fromHex(p$1(o))),e.push(470,r)}isPattern(e){return"name"in e}boundingBox(){return a.pointBBox(t$1(0,0))}dxfyChild(e){var s,n,i;e.point3d(t$1(0,0,this.elevation)),e.push(210,null===(s=this.extrusion)||void 0===s?void 0:s.x),e.push(220,null===(n=this.extrusion)||void 0===n?void 0:n.y),e.push(230,null===(i=this.extrusion)||void 0===i?void 0:i.z),e.name(this.patternName),e.push(70,this.solidFillFlag),e.push(71,Xt.NonAssociative),e.push(91,this.boundaryPath.length),this.boundaryPath.dxfy(e),e.push(75,Rt.Outer),e.push(76,Ft$1.Predifined),this.isPattern(this.fill)?(this.solidFillFlag===Tt.PatternFill&&this.pattern(e,this.fill),e.push(47,1),e.push(98,0)):(e.push(47,1),e.push(98,0),this.gradient(e,this.fill))}}!function(e){e[e.ShowImage=1]="ShowImage",e[e.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",e[e.UseClippingBoundary=4]="UseClippingBoundary",e[e.TransparencyIsOn=8]="TransparencyIsOn"}(wt||(wt={})),function(e){e[e.Rectangular=1]="Rectangular",e[e.Polygonal=2]="Polygonal"}(Nt||(Nt={})),function(e){e[e.Off=0]="Off",e[e.On=1]="On"}(Mt||(Mt={})),function(e){e[e.Outside=0]="Outside",e[e.Inside=1]="Inside"}(Pt||(Pt={}));class ps extends ht{constructor(e,t){super("IMAGE","AcDbRasterImage",t),Bt.set(this,void 0),this.width=e.width,this.height=e.height,this.scale=e.scale,this.rotation=e.rotation,this.insertionPoint=e.insertionPoint,this.ratio=this.scale/this.width,this.imageDefHandle=e.imageDefHandle,this.imageDisplayFlags=(null==t?void 0:t.imageDisplayFlags)||wt.ShowImage|wt.ShowImageWhenNotAlignedWithScreen,this.clippingStateFlag=(null==t?void 0:t.clippingStateFlag)||Mt.On,this.clipModeFlag=(null==t?void 0:t.clipModeFlag)||Pt.Inside,this.clippingType=(null==t?void 0:t.clippingType)||Nt.Rectangular,this.brightness=(null==t?void 0:t.brightness)||50,this.contrast=(null==t?void 0:t.brightness)||50,this.fade=(null==t?void 0:t.fade)||0,D(this,Bt,[]),this.classVersion=(null==t?void 0:t.classVersion)||0,this.resetClipping()}setClipBoundaryVerticies(e,t){if(t===Nt.Rectangular){if(2!=e.length)throw new Error("The number of vertices should be 2 in rectangular clipping !");D(this,Bt,e)}else{if(!(e.length>=3))throw new Error("The number of vertices should be >= 3 in polygonal clipping !");D(this,Bt,e)}D(this,Bt,[]),S(this,Bt,"f").push(...e)}resetClipping(){const e=[s(-.5,-.5),s(this.width-.5,this.height-.5)];this.setClipBoundaryVerticies(e,Nt.Rectangular)}_vector(){return s(this.ratio*Math.cos(this.rotation*Math.PI/180),this.ratio*Math.sin(this.rotation*Math.PI/180))}_uVector(){const e=this._vector();return t$1(e.x,-e.y,0)}_vVector(){const e=this._vector();return t$1(e.y,e.x,0)}boundingBox(){const e=this.scale,t=this.width/this.height*this.scale,s=Math.sqrt(Math.pow(e,2)+Math.pow(t,2));return a.centerRadiusBBox(this.insertionPoint,s)}dxfyChild(e){e.push(90,this.classVersion),e.point3d(this.insertionPoint),e.point3d(this._uVector(),1),e.point3d(this._vVector(),2),e.push(13,this.width),e.push(23,this.height),e.push(340,this.imageDefHandle),e.push(70,this.imageDisplayFlags),e.push(280,this.clippingStateFlag),e.push(281,this.brightness),e.push(282,this.contrast),e.push(283,this.fade),e.push(360,this.imageDefReactorHandle),e.push(71,this.clippingType),e.push(91,S(this,Bt,"f").length),S(this,Bt,"f").forEach((t=>e.point2d(t,4))),e.push(290,this.clipModeFlag)}}Bt=new WeakMap;class As extends ht{constructor(e,s,n){var i,h,o,d,a,l;super("INSERT","AcDbBlockReference",n),this.blockName=e,this.insertionPoint=s,this.scaleFactor=(null==n?void 0:n.scaleFactor)||t$1(1,1,1),this.rotationAngle=null!==(i=null==n?void 0:n.rotationAngle)&&void 0!==i?i:0,this.columnCount=null!==(h=null==n?void 0:n.columnCount)&&void 0!==h?h:1,this.rowCount=null!==(o=null==n?void 0:n.rowCount)&&void 0!==o?o:1,this.columnSpacing=null!==(d=null==n?void 0:n.columnSpacing)&&void 0!==d?d:0,this.rowSpacing=null!==(a=null==n?void 0:n.rowSpacing)&&void 0!==a?a:0,this.attributesFollowFlag=null!==(l=null==n?void 0:n.rowSpacing)&&void 0!==l?l:0}boundingBox(){return a.pointBBox(this.insertionPoint)}dxfyChild(e){e.name(this.blockName),e.point3d(this.insertionPoint),e.push(41,this.scaleFactor.x),e.push(42,this.scaleFactor.y),e.push(43,this.scaleFactor.z),e.push(50,this.rotationAngle),e.push(66,this.attributesFollowFlag),e.push(70,this.columnCount),e.push(71,this.rowCount),e.push(44,this.columnSpacing),e.push(45,this.rowSpacing)}}!function(e){e[e.Disabed=0]="Disabed",e[e.Enabled=1]="Enabled"}(Ot$1||(Ot$1={})),function(e){e[e.StraightLine=0]="StraightLine",e[e.Spline=1]="Spline"}(_t||(_t={}));class ys extends ht{constructor(e,t){var s,n;super("LEADER","AcDbLeader",t),this.vertices=e,this.flag=null!==(s=null==t?void 0:t.flag)&&void 0!==s?s:Ot$1.Enabled,this.leaderPathType=null!==(n=null==t?void 0:t.leaderPathType)&&void 0!==n?n:_t.StraightLine,this.dimensionStyleName=(null==t?void 0:t.dimensionStyleName)||"Standard"}boundingBox(){return a.verticesBBox(this.vertices)}dxfyChild(e){e.push(3,this.dimensionStyleName),e.push(71,this.flag),e.push(72,this.leaderPathType),e.push(76,this.vertices.length),this.vertices.forEach((t=>e.point3d(t)))}}class ms extends ht{constructor(e,t,s){super("LINE","AcDbLine",s),this.startPoint=e,this.endPoint=t}boundingBox(){return a.lineBBox(this.startPoint,this.endPoint)}dxfyChild(e){e.point3d(this.startPoint),e.point3d(this.endPoint,1)}}!function(e){e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Plinegen=128]="Plinegen"}(Ht||(Ht={}));class xs extends ht{constructor(e,t){super("LWPOLYLINE","AcDbPolyline",t),this.vertices=e,this.flags=(null==t?void 0:t.flags)||Ht.None,this.constantWidth=(null==t?void 0:t.constantWidth)||0,this.elevation=(null==t?void 0:t.elevation)||0,this.thickness=(null==t?void 0:t.thickness)||0}boundingBox(){return a.verticesBBox(this.vertices.map((e=>t$1(e.point.x,e.point.y,0))))}dxfyChild(e){var t,s,n;e.push(90,this.vertices.length),e.push(70,this.flags||0),this.vertices.find((e=>{var t,s;return(null!==(t=e.startingWidth)&&void 0!==t?t:0)>0&&(null!==(s=e.endWidth)&&void 0!==s?s:0)>0}))||e.push(43,this.constantWidth),e.elevation(this.elevation),e.thickness(this.thickness);for(const t of this.vertices)e.point2d(t.point),e.push(40,t.startingWidth),e.push(41,t.endWidth),e.push(42,t.bulge);e.push(210,null===(t=this.extrusion)||void 0===t?void 0:t.x),e.push(220,null===(s=this.extrusion)||void 0===s?void 0:s.y),e.push(230,null===(n=this.extrusion)||void 0===n?void 0:n.z)}}!function(e){e[e.TopLeft=1]="TopLeft",e[e.TopCenter=2]="TopCenter",e[e.TopRight=3]="TopRight",e[e.MiddleLeft=4]="MiddleLeft",e[e.MiddleCenter=5]="MiddleCenter",e[e.MiddleRight=6]="MiddleRight",e[e.BottomLeft=7]="BottomLeft",e[e.BottomCenter=8]="BottomCenter",e[e.BottomRight=9]="BottomRight"}(kt||(kt={})),function(e){e[e.LeftToRight=1]="LeftToRight",e[e.TopToBottom=3]="TopToBottom",e[e.ByStyle=5]="ByStyle"}(Wt||(Wt={})),function(e){e[e.AtLeast=1]="AtLeast",e[e.Exact=2]="Exact"}(Vt||(Vt={}));class Is extends ht{constructor(e,t,s,n){super("MTEXT","AcDbMText",n),this.position=e,this.height=t,this.value=s,this.textStyle="STANDARD",this.rotation=null==n?void 0:n.rotation,this.attachmentPoint=null==n?void 0:n.attachmentPoint,this.drawingDirection=null==n?void 0:n.drawingDirection,this.lineSpacingStyle=null==n?void 0:n.lineSpacingStyle,this.width=null==n?void 0:n.width}boundingBox(){return a.pointBBox(this.position)}dxfyChild(e){e.point3d(this.position),e.push(40,this.height),e.push(41,this.width),e.push(71,this.attachmentPoint),e.push(72,this.drawingDirection),e.push(73,this.lineSpacingStyle),e.primaryText(this.value),e.push(50,this.rotation),e.textStyle(this.textStyle)}}class Ls extends ht{constructor(e,t,s,n){super("POINT","AcDbPoint",n),this.x=e,this.y=t,this.z=s}boundingBox(){return a.pointBBox(t$1(this.x,this.y,this.z))}dxfyChild(e){e.point3d(t$1(this.x,this.y,this.z))}}!function(e){e[e.None=0]="None",e[e.ExtraVertex=1]="ExtraVertex",e[e.CurveFit=2]="CurveFit",e[e.NotUsed=4]="NotUsed",e[e.SplineVertex=8]="SplineVertex",e[e.SplineFrame=16]="SplineFrame",e[e.Polyline3dVertex=32]="Polyline3dVertex",e[e.Polygon3dMesh=64]="Polygon3dMesh",e[e.PolyfaceMeshVertex=128]="PolyfaceMeshVertex"}(Ut||(Ut={}));class Ss extends ht{constructor(e,t){var s;super("VERTEX","AcDbVertex",t),this.point=e,this.flags=null!==(s=null==t?void 0:t.flags)&&void 0!==s?s:Ut.None,t&&("startingWidth"in t&&(this.startingWidth=t.startingWidth),"endWidth"in t&&(this.endWidth=t.endWidth),"bulge"in t&&(this.bulge=t.bulge))}boundingBox(){return a.pointBBox(this.point)}dxfyChild(e){e.subclassMarker("AcDb3dPolylineVertex"),e.point3d(this.point),e.push(40,this.startingWidth),e.push(41,this.endWidth),e.push(42,this.bulge),e.push(70,this.flags)}}class Ds extends ht{dxfyChild(e){}constructor(){super("SEQEND")}}!function(e){e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.CurveFit=2]="CurveFit",e[e.SplineFit=4]="SplineFit",e[e.Polyline3D=8]="Polyline3D",e[e.PolygonMesh3D=16]="PolygonMesh3D",e[e.PolygonMeshClosed=32]="PolygonMeshClosed",e[e.PolyfaceMesh=64]="PolyfaceMesh",e[e.LinetypeGenerated=128]="LinetypeGenerated"}(jt||(jt={})),function(e){e[e.NoSmooth=0]="NoSmooth",e[e.QuadraticBSpline=5]="QuadraticBSpline",e[e.CubicBSpline=6]="CubicBSpline",e[e.Bezier=8]="Bezier"}(Gt||(Gt={}));class bs extends ht{constructor(e,t){var s,n,i,h,o,d,a,l,r,f;super("POLYLINE","AcDb3dPolyline",t),this._seqend=new Ds,this.vertices=[],this.thickness=null!==(s=null==t?void 0:t.thickness)&&void 0!==s?s:0,this.elevation=null!==(n=null==t?void 0:t.elevation)&&void 0!==n?n:0,this.flags=null!==(i=null==t?void 0:t.flags)&&void 0!==i?i:jt.None,this.defaultStartWidth=null!==(h=null==t?void 0:t.defaultStartWidth)&&void 0!==h?h:0,this.defaultEndWidth=null!==(o=null==t?void 0:t.defaultEndWidth)&&void 0!==o?o:0,this.polygonMeshM=null!==(d=null==t?void 0:t.polygonMeshM)&&void 0!==d?d:0,this.polygonMeshN=null!==(a=null==t?void 0:t.polygonMeshN)&&void 0!==a?a:0,this.smoothSurfaceM=null!==(l=null==t?void 0:t.smoothSurfaceM)&&void 0!==l?l:0,this.smoothSurfaceN=null!==(r=null==t?void 0:t.smoothSurfaceN)&&void 0!==r?r:0,this.surfaceType=null!==(f=null==t?void 0:t.surfaceType)&&void 0!==f?f:Gt.NoSmooth,e.forEach((e=>this.vertices.push(new Ss(e.point,{startingWidth:e.startingWidth,endWidth:e.endWidth,bulge:e.bulge,flags:Ut.Polyline3dVertex}))))}boundingBox(){return a.verticesBBox(this.vertices.map((e=>e.point)))}dxfyChild(e){e.push(66,1),e.point3d(t$1(0,0,this.elevation)),e.push(39,this.thickness),e.push(70,this.flags),e.push(40,this.defaultStartWidth),e.push(41,this.defaultEndWidth),e.push(71,this.polygonMeshM),e.push(72,this.polygonMeshN),e.push(73,this.smoothSurfaceM),e.push(74,this.smoothSurfaceN),e.push(75,this.surfaceType),this.vertices.forEach((t=>t.dxfy(e))),this._seqend.dxfy(e)}}!function(e){e[e.Closed=1]="Closed",e[e.Periodic=2]="Periodic",e[e.Rational=4]="Rational",e[e.Planar=8]="Planar",e[e.Linear=16]="Linear"}(zt||(zt={}));class vs extends ht{constructor(e,t){var s,n;super("SPLINE","AcDbSpline",t),this.controlPoints=e.controlPoints,this.degreeCurve=null!==(s=e.degreeCurve)&&void 0!==s?s:3,this.flags=null!==(n=e.flags)&&void 0!==n?n:zt.Planar,this.knots=e.knots||[],this.weights=e.weights||[],this.fitPoints=e.fitPoints||[];const i=this.controlPoints.length,h=this.degreeCurve,o=h+1,d=this.fitPoints.length;if(i<o)throw new Error(`Number of control points should be >= ${o}.`);if(0!==d&&d<2)throw new Error("Number of fit points should be >= 2.");const a=h+i+1;if(0===this.knots.length){let e=0;for(let t=0;t<a;t++)t<=h||t>=i+1?this.knots.push(e):this.knots.push(++e)}if(this.knots.length!==a)throw new Error(`Number of knots should be ${a}.`)}boundingBox(){return a.verticesBBox([...this.controlPoints,...this.fitPoints])}dxfyChild(e){e.push(70,this.flags),e.push(71,this.degreeCurve),e.push(72,this.knots.length),e.push(73,this.controlPoints.length),e.push(74,this.fitPoints.length),e.push(42,"0.0000001"),e.push(43,"0.0000001"),e.push(42,"0.0000000001"),this.knots.forEach((t=>e.push(40,t))),this.weights.forEach((t=>e.push(41,t))),this.controlPoints.forEach((t=>e.point3d(t))),this.fitPoints.forEach((t=>e.point3d(t,1)))}}!function(e){e[e.Text=1]="Text",e[e.Block=2]="Block"}(Jt||(Jt={})),function(e){e[e.False=0]="False",e[e.True=1]="True"}(Kt||(Kt={})),function(e){e[e.False=0]="False",e[e.True=1]="True"}(Zt||(Zt={})),function(e){e[e.TopLeft=1]="TopLeft",e[e.TopCenter=2]="TopCenter",e[e.TopRight=3]="TopRight",e[e.MiddleLeft=4]="MiddleLeft",e[e.MiddleCenter=5]="MiddleCenter",e[e.MiddleRight=6]="MiddleRight",e[e.BottomLeft=7]="BottomLeft",e[e.BottomCenter=8]="BottomCenter",e[e.BottomRight=9]="BottomRight"}(qt||(qt={}));class Fs extends ht{constructor(e,s,n,i,h,o,d){super("ACAD_TABLE","AcDbBlockReference",d),this.blockName=e,this.position=s,this.numberOfRows=n,this.numberOfColumn=i,this.rowsHeight=h,this.columnsHeight=o,this.horizontalDirectionVector=(null==d?void 0:d.horizontalDirectionVector)||t$1(1),this.cells=null==d?void 0:d.cell}boundingBox(){return a.pointBBox(this.position)}dxfyChild(e){var t,s,n,i;e.name(this.blockName),e.point3d(this.position),e.subclassMarker("AcDbTable"),e.point3d(this.horizontalDirectionVector,1),e.push(91,this.numberOfRows),e.push(92,this.numberOfColumn);for(let n=0;n<this.numberOfRows;n++)e.push(141,null!==(s=null!==(t=this.rowsHeight[n])&&void 0!==t?t:this.rowsHeight[0])&&void 0!==s?s:1);for(let t=0;t<this.numberOfColumn;t++)e.push(142,null!==(i=null!==(n=this.columnsHeight[t])&&void 0!==n?n:this.columnsHeight[0])&&void 0!==i?i:1);this.cells.forEach((t=>t.dxfy(e)))}}!function(e){e[e.None=0]="None",e[e.Backward=2]="Backward",e[e.UpsideDown=4]="UpsideDown"}($t$1||($t$1={})),function(e){e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e[e.Aligned=3]="Aligned",e[e.Middle=4]="Middle",e[e.Fit=5]="Fit"}(Qt||(Qt={})),function(e){e[e.BaseLine=0]="BaseLine",e[e.Bottom=1]="Bottom",e[e.Middle=2]="Middle",e[e.Top=3]="Top"}(es||(es={}));class Cs extends ht{constructor(e,t,s,n){super("TEXT","AcDbText",n),this.position=e,this.height=t,this.value=s,this.textStyle="STANDARD",this.rotation=null==n?void 0:n.rotation,this.obliqueAngle=null==n?void 0:n.obliqueAngle,this.generationFlags=null==n?void 0:n.generationFlags,this.horizontalAlignment=null==n?void 0:n.horizontalAlignment,this.verticalAlignment=null==n?void 0:n.verticalAlignment,this.secondAlignmentPoint=null==n?void 0:n.secondAlignmentPoint,this.relativeXScaleFactor=null==n?void 0:n.relativeXScaleFactor}boundingBox(){return a.pointBBox(this.position)}dxfyChild(e){e.point3d(this.position),e.push(40,this.height),e.primaryText(this.value),e.push(50,this.rotation),e.push(41,this.relativeXScaleFactor),e.push(51,this.obliqueAngle),e.textStyle(this.textStyle),e.push(71,this.generationFlags),e.push(72,this.horizontalAlignment),e.point3d(this.secondAlignmentPoint,1),e.subclassMarker("AcDbText"),e.push(73,this.verticalAlignment)}}class Ts{constructor(e,t,s){this.entities=[],this.handle=h.next(),this.objects=e,this.blockRecord=t,this.layerName=s}dxfy(e){for(const t of this.entities)t.dxfy(e)}addHatch(e,t,s){const n=new gs(e,t,s);return this.addEntity(n)}addEntity(e){return e.ownerBlockRecord=this.blockRecord.handle,this.blockRecord.isPaperSpace&&(e.inPaperSpace=!0),null==e.layerName&&(e.layerName=this.layerName),this.entities.push(e),e}addAttrib(e,t,s,n,i,h){i.attributesFollowFlag=1;const o=this.addEntity(new St(e,t,s,n,h));return this.addEntity(new Ds).ownerBlockRecord=i.handle,o}addAttdef(e,t,s,n,i){return this.addEntity(new Lt(e,t,s,n,i))}addAlignedDim(e,t,s){return this.addEntity(new ct$1(e,t,s))}addDiameterDim(e,t,s){return this.addEntity(new yt$1(e,t,s))}addRadialDim(e,t,s){return this.addEntity(new xt(e,t,s))}addLinearDim(e,t,s){return this.addEntity(new mt(e,t,s))}addAngularLinesDim(e,t,s,n){return this.addEntity(new gt$1(e,t,s,n))}addAngularPointsDim(e,t,s,n){return this.addEntity(new pt(e,t,s,n))}addLine(e,t,s){return this.addEntity(new ms(e,t,s))}addLeader(e,t){return this.addEntity(new ys(e,t))}addLWPolyline(e,t){return this.addEntity(new xs(e,t))}addRectangle(t,n,i){const h=[],o=t.x,d=t.y,a=n.x,l=n.y;if(void 0!==(null==i?void 0:i.fillet)&&void 0!==(null==i?void 0:i.chamfer))throw new Error("You cannot define both fillet and chamfer!");if(void 0!==(null==i?void 0:i.fillet)){const t=null==i?void 0:i.fillet,n=function e(e){const t=Math.sqrt(Math.pow(e,2)+Math.pow(e,2))/2;return-(e-Math.sqrt(Math.pow(e,2)-Math.pow(t,2)))/t}(t);h.push({point:s(o,d-t),bulge:n}),h.push({point:s(o+t,d)}),h.push({point:s(a-t,d),bulge:n}),h.push({point:s(a,d-t)}),h.push({point:s(a,l+t),bulge:n}),h.push({point:s(a-t,l)}),h.push({point:s(o+t,l),bulge:n}),h.push({point:s(o,l+t)})}else if(void 0!==(null==i?void 0:i.chamfer)){const e=null==i?void 0:i.chamfer.first,t=(null==i?void 0:i.chamfer.second)||e;h.push({point:s(o,d-e)}),h.push({point:s(o+t,d)}),h.push({point:s(a-e,d)}),h.push({point:s(a,d-t)}),h.push({point:s(a,l+e)}),h.push({point:s(a-t,l)}),h.push({point:s(o+e,l)}),h.push({point:s(o,l+t)})}else h.push({point:s(o,d)}),h.push({point:s(a,d)}),h.push({point:s(a,l)}),h.push({point:s(o,l)});return this.addLWPolyline(h,Object.assign(Object.assign({},i),{flags:Ht.Closed}))}addImage(e,t,s,n,i,h,o,d){const a=this.objects.addImageDef(e);a.width=n,a.height=i;const l=new ps({height:i,width:n,scale:h,rotation:o,insertionPoint:s,imageDefHandle:a.handle},d),r=this.objects.addImageDefReactor(l.handle);l.imageDefReactorHandle=r.handle,this.addEntity(l);const f=this.objects.addDictionary();return f.addEntryObject(t,a.handle),a.ownerObjecthandle=f.handle,this.objects.root.addEntryObject("ACAD_IMAGE_DICT",f.handle),a.acadImageDictHandle=f.handle,a.addImageDefReactorHandle(r.handle),l}addPolyline3D(e,t){return this.addEntity(new bs(e,t))}addPoint(e,t,s,n){return this.addEntity(new Ls(e,t,s,n))}addCircle(e,t,s){return this.addEntity(new Dt(e,t,s))}addArc(e,t,s,n,i){return this.addEntity(new It(e,t,s,n,i))}addSpline(e,t){return this.addEntity(new vs(e,t))}addEllipse(e,t,s,n,i,h){const o=new bt(e,t,s,n,i,h);return this.addEntity(o),o}add3dFace(e,t,s,n,i){return this.addEntity(new hs(e,t,s,n,i))}addText(e,t,s,n){return this.addEntity(new Cs(e,t,s,n))}addMText(e,t,s,n){return this.addEntity(new Is(e,t,s,n))}addInsert(e,t,s){return this.addEntity(new As(e,t,s||{}))}addTable(e,t,s,n,i,h,o){return this.addEntity(new Fs(e,t,s,n,i,h,o))}boundingBox(){const e=[];for(let t=0;t<this.entities.length;t++)e.push(this.entities[t].boundingBox());return a.boundingBox(e)}centerView(){return a.boundingBoxCenter(this.boundingBox())}viewHeight(){return a.boundingBoxHeight(this.boundingBox())}}!function(e){e[e.None=0]="None",e[e.AnonymousBlock=1]="AnonymousBlock",e[e.HasNonConstantAttribute=2]="HasNonConstantAttribute",e[e.XRef=4]="XRef",e[e.XRefOverlay=8]="XRefOverlay",e[e.ExternallyDependent=16]="ExternallyDependent",e[e.ResolvedXRef=32]="ResolvedXRef",e[e.ReferencedXRef=64]="ReferencedXRef"}(ts||(ts={}));class Xs extends Ts{get isPaperSpace(){return this.name.startsWith("*Paper_Space")}get isModelSpace(){return this.name.startsWith("*Model_Space")}get isModelOrPaperSpace(){return this.isModelSpace||this.isPaperSpace}constructor(e,s,n){super(n,s,"0"),this.name=e,this.flags=ts.None,this.endBlk=new o,this.ownerObjectHandle=s.handle,this.basePoint=t$1(0,0,0),this.xrefPathName=""}setLayerName(e){this.layerName=e}dxfy(e){e.type("BLOCK"),e.handle(this.handle),e.push(330,this.ownerObjectHandle),e.subclassMarker("AcDbEntity"),e.layerName(this.layerName),e.subclassMarker("AcDbBlockBegin"),e.name(this.name),e.push(70,this.flags),e.point3d(this.basePoint),e.name(this.name,3),e.push(1,this.xrefPathName),this.isModelSpace||"*Paper_Space"===this.name||super.dxfy(e),this.endBlk.dxfy(e)}}class Rs{constructor(e,t){this.blocks=[],this.paperSpaceSeed=0,this.tables=e,this.objects=t,this.modelSpace=this.addBlock("*Model_Space",t,!1),this.paperSpace=this.addBlock("*Paper_Space",t,!1)}addBlock(e,t,s=!0){s&&(e=e.replace(rt,""));const n=this.tables.addBlockRecord(e),i=new Xs(e,n,t);return this.blocks.push(i),i}addPaperSpace(){const e="*Paper_Space"+this.paperSpaceSeed++;return this.addBlock(e,this.objects,!1)}dxfy(e){e.start("BLOCKS"),this.blocks.forEach((t=>t.dxfy(e))),e.end()}}class Ys{dxfy(e){e.start("CLASSES"),e.end()}}class Bs{constructor(e){this.blocks=e,this.modelSpace=e.modelSpace,this.paperSpace=e.paperSpace}setLayerName(e){this.modelSpace.setLayerName(e)}dxfy(e){e.start("ENTITIES"),this.paperSpace.entities.forEach((t=>t.dxfy(e))),this.modelSpace.entities.forEach((t=>t.dxfy(e))),e.end()}}class ws{constructor(e,t){this.values=t,this.name=e}dxfy(e){e.variableName(this.name),Object.entries(this.values).forEach((t=>{const[s,n]=t;e.push(parseInt(s),n)}))}}class Ns{constructor(){this.variables=[]}setVariable(e,t){const s=this.variables.find((t=>t.name===e));s?s.values=t:this.variables.push(new ws(e,t))}dxfy(e){e.start("HEADER"),this.variables.forEach((t=>t.dxfy(e))),e.end()}}class Ms{constructor(e){this.type=e,this.ownerObjecthandle="0",this.handle=h.next()}dxfy(e){e.type(this.type),e.handle(this.handle),e.push(330,this.ownerObjecthandle)}}class Ps extends Ms{constructor(){super("DICTIONARY"),this.entries=[],this.duplicateRecordCloningFlag=0}addEntryObject(e,t){this.entries.push({name:e,entryObjectHandle:t})}dxfy(e){super.dxfy(e),e.subclassMarker("AcDbDictionary"),e.push(280,this.hardOwnerFlag),e.push(281,this.duplicateRecordCloningFlag);for(const t of this.entries)e.push(3,t.name),e.push(350,t.entryObjectHandle)}}!function(e){e[e.NoUnits=0]="NoUnits",e[e.Centimeters=2]="Centimeters",e[e.Inch=5]="Inch"}(ss||(ss={}));class Os extends Ms{constructor(e){super("IMAGEDEF"),this.path=e,this.acadImageDictHandle="",this.imageReactorHandles=[],this.width=1,this.height=1,this.widthPixelSize=1,this.heightPixelSize=1,this.loaded=!0,this.resolutionUnits=ss.NoUnits}addImageDefReactorHandle(e){this.imageReactorHandles.push(e)}dxfy(e){super.dxfy(e);const t=new A$1("ACAD_REACTORS");t.add(330,this.acadImageDictHandle);for(const e of this.imageReactorHandles)t.add(330,e);t.dxfy(e),e.subclassMarker("AcDbRasterImageDef"),e.push(1,this.path),e.point2d(s(this.width,this.height)),e.push(11,this.widthPixelSize),e.push(21,this.heightPixelSize),e.push(280,Number(this.loaded)),e.push(281,this.resolutionUnits)}}class _s extends Ms{constructor(e){super("IMAGEDEF_REACTOR"),this.imageHandle=e,this.classVersion=2}dxfy(e){super.dxfy(e),e.subclassMarker("AcDbRasterImageDefReactor"),e.push(90,this.classVersion),e.push(330,this.imageHandle)}}class Hs{constructor(){this.root=new Ps,this.objects=[],this.root.duplicateRecordCloningFlag=1;const e=this.addDictionary();this.root.addEntryObject("ACAD_GROUP",e.handle)}addObject(e){return this.objects.push(e),e}addImageDef(e){return this.addObject(new Os(e))}addImageDefReactor(e){return this.addObject(new _s(e))}addDictionary(){const e=new Ps;return e.ownerObjecthandle=this.root.handle,this.addObject(e),e}addEntryToRoot(e,t){this.root.addEntryObject(e,t)}dxfy(e){e.start("OBJECTS"),this.root.dxfy(e);for(const t of this.objects)t.dxfy(e);e.end(),e.type("EOF")}}class Ws{constructor(e){this.name=e,this.maxNumberEntries=0,this.ownerObjectHandle="0",this.handle=h.next(),this.records=[]}dxfy(e){e.type("TABLE"),e.name(this.name),e.handle(this.handle),e.push(330,this.ownerObjectHandle),e.subclassMarker("AcDbSymbolTable"),e.push(70,this.records.length);for(const t of this.records)t.dxfy(e);e.type("ENDTAB")}}!function(e){e[e.None=0]="None",e[e.XRefDependent=16]="XRefDependent",e[e.XRefResolved=32]="XRefResolved"}(ns||(ns={}));class Vs extends u{constructor(e,t){super("APPID"),this.name=e,this.flags=null!=t?t:ns.None}dxfy(e){super.dxfy(e),e.subclassMarker("AcDbRegAppTableRecord"),e.name(this.name),e.push(70,this.flags)}}class Us extends u{get isPaperSpace(){return this.name.startsWith("*Paper_Space")}constructor(e){super("BLOCK_RECORD"),this.name=e,this.insertionUnits=0,this.explodability=1,this.scalability=0}dxfy(e){super.dxfy(e),e.subclassMarker("AcDbBlockTableRecord"),e.name(this.name),e.push(340,this.layoutObject),e.push(70,this.insertionUnits),e.push(280,this.explodability),e.push(281,this.scalability)}}!function(e){e[e.None=0]="None",e[e.XRefDependent=16]="XRefDependent",e[e.XRefRefesolved=32]="XRefRefesolved"}(is||(is={}));class js{constructor(e,t){this.name=e,this.flags=null!=t?t:is.None,this.handle=h.next(),this.type="DIMSTYLE"}dxfy(e){e.type(this.type),e.push(105,this.handle),e.push(330,this.ownerObjectHandle),e.subclassMarker("AcDbSymbolTableRecord"),e.subclassMarker("AcDbDimStyleTableRecord"),e.name(this.name),e.push(70,this.flags),e.push(3,this.DIMPOST),e.push(4,this.DIMAPOST),e.push(5,this.DIMBLK),e.push(6,this.DIMBLK1),e.push(7,this.DIMBLK2),e.push(40,this.DIMSCALE),e.push(41,this.DIMASZ),e.push(42,this.DIMEXO),e.push(43,this.DIMDLI),e.push(44,this.DIMEXE),e.push(45,this.DIMRND),e.push(46,this.DIMDLE),e.push(47,this.DIMTP),e.push(48,this.DIMTM),e.push(140,this.DIMTXT),e.push(141,this.DIMCEN),e.push(142,this.DIMTSZ),e.push(143,this.DIMALTF),e.push(144,this.DIMLFAC),e.push(145,this.DIMTVP),e.push(146,this.DIMTFAC),e.push(147,this.DIMGAP),e.push(148,this.DIMALTRND),e.push(71,this.DIMTOL),e.push(72,this.DIMLIM),e.push(73,this.DIMTIH),e.push(74,this.DIMTOH),e.push(75,this.DIMSE1),e.push(76,this.DIMSE2),e.push(77,this.DIMTAD),e.push(78,this.DIMZIN),e.push(79,this.DIMAZIN),e.push(170,this.DIMALT),e.push(171,this.DIMALTD),e.push(172,this.DIMTOFL),e.push(173,this.DIMSAH),e.push(174,this.DIMTIX),e.push(175,this.DIMSOXD),e.push(176,this.DIMCLRD),e.push(177,this.DIMCLRE),e.push(178,this.DIMCLRT),e.push(179,this.DIMADEC),e.push(271,this.DIMDEC),e.push(272,this.DIMTDEC),e.push(273,this.DIMALTU),e.push(274,this.DIMALTTD),e.push(275,this.DIMAUNIT),e.push(276,this.DIMFRAC),e.push(277,this.DIMLUNIT),e.push(278,this.DIMDSEP),e.push(279,this.DIMTMOVE),e.push(280,this.DIMJUST),e.push(281,this.DIMSD1),e.push(282,this.DIMSD2),e.push(283,this.DIMTOLJ),e.push(284,this.DIMTZIN),e.push(285,this.DIMALTZ),e.push(286,this.DIMALTTZ),e.push(287,this.DIMFIT),e.push(288,this.DIMUPT),e.push(289,this.DIMATFIT),e.push(340,this.DIMTXSTY),e.push(341,this.DIMLDRBLK),e.push(342,this.DIMBLK),e.push(343,this.DIMBLK1),e.push(344,this.DIMBLK2),e.push(371,this.DIMLWD),e.push(372,this.DIMLWE)}}class Gs extends u{constructor(e,t,s,n){super("LTYPE"),this.name=e,this.descriptive=t,this.elements=s,this.flags=null!=n?n:0}dxfy(e){super.dxfy(e),e.subclassMarker("AcDbLinetypeTableRecord"),e.name(this.name),e.push(70,this.flags),e.push(3,this.descriptive),e.push(72,65),e.push(73,this.elements.length);let t=0;for(const e of this.elements)t+=Math.abs(e);e.push(40,t);for(const t of this.elements)e.push(49,t),e.push(74,0)}}class zs extends u{constructor(e,t){super("STYLE"),this.fixedTextHeight=0,this.widthFactor=1,this.obliqueAngle=0,this.textGenerationFlag=0,this.lastHeightUsed=1,this.fontFileName="txt",this.bigFontFileName="",this.name=e,this.flags=null!=t?t:r.None}dxfy(e){super.dxfy(e),e.subclassMarker("AcDbTextStyleTableRecord"),e.name(this.name),e.push(70,this.flags),e.push(40,this.fixedTextHeight),e.push(41,this.widthFactor),e.push(50,this.obliqueAngle),e.push(71,this.textGenerationFlag),e.push(42,this.lastHeightUsed),e.push(3,this.fontFileName),e.push(4,this.bigFontFileName)}}class Js extends u{constructor(e){super("UCS"),this.name=e}dxfy(e){super.dxfy(e)}}class Ks extends u{constructor(e){super("VPORT"),this.name=e,this.viewHeight=200,this.viewCenter=[0,0]}dxfy(e){super.dxfy(e);const[t,s]=this.viewCenter;e.subclassMarker("AcDbViewportTableRecord"),e.name(this.name),e.push(70,0),e.point2d({x:0,y:0}),e.push(11,1),e.push(21,1),e.push(12,t),e.push(22,s),e.push(13,0),e.push(23,0),e.push(14,10),e.push(24,10),e.push(15,10),e.push(25,10),e.push(16,0),e.push(26,0),e.push(36,1),e.push(17,0),e.push(27,0),e.push(37,0),e.push(40,this.viewHeight||200),e.push(41,2),e.push(42,50),e.push(43,0),e.push(44,0),e.push(50,0),e.push(51,0),e.push(71,0),e.push(72,100),e.push(73,1),e.push(74,3),e.push(75,0),e.push(76,1),e.push(77,0),e.push(78,0),e.push(281,0),e.push(65,1),e.push(110,0),e.push(120,0),e.push(130,0),e.push(111,1),e.push(121,0),e.push(131,0),e.push(112,0),e.push(122,1),e.push(132,0),e.push(79,0),e.push(146,0),e.push(348,10020),e.push(60,7),e.push(61,5),e.push(292,1),e.push(282,1),e.push(141,0),e.push(142,0),e.push(63,250),e.push(421,3358443)}}class Zs extends u{constructor(e){var t;super("VIEW"),this.name=e.name,this.flags=null!==(t=e.flags)&&void 0!==t?t:f.None,this.viewHeight=e.viewHeight,this.viewCenter=e.viewCenter,this.viewWidth=e.viewWidth,this.viewDirection=e.viewDirection,this.targetPoint=e.targetPoint,this.lensLength=e.lensLength,this.frontClipping=e.frontClipping,this.backClipping=e.backClipping,this.twistAngle=e.twistAngle,this.viewMode=e.viewMode,this.renderMode=e.renderMode,this.isUCSAssociated=e.isUCSAssociated,this.isCameraPlottable=e.isCameraPlottable||!1,e.backgroundObjectHandle&&(this.backgroundObjectHandle=e.backgroundObjectHandle),e.liveSectionObjectHandle&&(this.liveSectionObjectHandle=e.liveSectionObjectHandle),e.visualStyleObjectHandle&&(this.visualStyleObjectHandle=e.visualStyleObjectHandle)}dxfy(e){super.dxfy(e),e.subclassMarker("AcDbViewTableRecord"),e.name(this.name),e.push(70,this.flags),e.push(40,this.viewHeight),e.point2d(this.viewCenter),e.push(41,this.viewWidth),e.push(11,this.viewDirection.x),e.push(21,this.viewDirection.y),e.push(31,this.viewDirection.z),e.push(12,this.targetPoint.x),e.push(22,this.targetPoint.y),e.push(32,this.targetPoint.z),e.push(42,this.lensLength),e.push(43,this.frontClipping),e.push(44,this.backClipping),e.push(50,this.twistAngle),e.push(71,this.viewMode),e.push(281,this.renderMode),e.push(72,this.isUCSAssociated?1:0),e.push(73,this.isCameraPlottable?1:void 0),e.push(332,this.backgroundObjectHandle),e.push(334,this.liveSectionObjectHandle),e.push(348,this.visualStyleObjectHandle)}}class qs extends Ws{constructor(){super("APPID")}addAppId(e,t){const s=new Vs(e,t);return s.ownerObjectHandle=this.handle,this.records.push(s),s}}class $s extends Ws{constructor(){super("BLOCK_RECORD")}addBlockRecord(e){const t=new Us(e);return t.ownerObjectHandle=this.handle,this.records.push(t),t}}class Qs extends Ws{constructor(){super("DIMSTYLE"),this.ownerObjectHandle="0"}addDimStyle(e,t){const s=new js(e,t);return s.ownerObjectHandle=this.handle,this.records.push(s),s}dxfy(e){e.type("TABLE"),e.name(this.name),e.handle(this.handle),e.push(330,this.ownerObjectHandle),e.subclassMarker("AcDbSymbolTable"),e.push(70,this.records.length),e.subclassMarker("AcDbDimStyleTable");for(const t of this.records)t.dxfy(e);e.type("ENDTAB")}}class en extends Ws{constructor(){super("LTYPE")}exist(e){return void 0!==this.records.find((t=>t.name===e))}ltype(e){return this.records.find((t=>t.name===e))}addLType(e,t,s,n){const i=this.ltype(e);if(i)return i;const h=new Gs(e,t,s,n);return h.ownerObjectHandle=this.handle,this.records.push(h),h}}class tn extends Ws{constructor(e){super("LAYER"),this.lTypeTable=e}addLayer(e,t,s,n){e=e.replace(rt,"");const i=this.layer(e);if(i)return i;this.lTypeTable.exist(s)||(s=I$1.Continuous);const h=new c(e,t,s,n);return h.ownerObjectHandle=this.handle,this.records.push(h),h}layer(e){return e=e.replace(rt,""),this.records.find((t=>t.name===e))}exist(e){return void 0!==this.records.find((t=>t.name===e))}}class sn extends Ws{constructor(){super("STYLE")}addStyle(e,t){const s=new zs(e,t);return s.ownerObjectHandle=this.handle,this.records.push(s),s}}class nn extends Ws{constructor(){super("UCS")}addUcs(e){const t=new Js(e);return t.ownerObjectHandle=this.handle,this.records.push(t),t}}class hn extends Ws{constructor(){super("VPORT")}addViewPort(e){const t=new Ks(e);return t.ownerObjectHandle=this.handle,this.records.push(t),t}}class on extends Ws{constructor(){super("VIEW")}addView(e){const t=new Zs(e);return t.ownerObjectHandle=this.handle,this.records.push(t),t}}class dn{constructor(){this.vPortTable=new hn,this.ltypeTable=new en,this.layerTable=new tn(this.ltypeTable),this.styleTable=new sn,this.viewTable=new on,this.ucsTable=new nn,this.appIdTable=new qs,this.dimStyleTable=new Qs,this.blockRecordTable=new $s}layer(e){return this.layerTable.layer(e)}addLType(e,t,s,n){return this.ltypeTable.addLType(e,t,s,n)}addBlockRecord(e){return this.blockRecordTable.addBlockRecord(e)}addLayer(e,t,s,n){return this.layerTable.addLayer(e,t,s,n)}addStyle(e){return this.styleTable.addStyle(e)}addView(e){return this.viewTable.addView(e)}addUcs(e){return this.ucsTable.addUcs(e)}addAppId(e,t){return this.appIdTable.addAppId(e,t)}addDimStyle(e,t){return this.dimStyleTable.addDimStyle(e,t)}addVPort(e){return this.vPortTable.addViewPort(e)}dxfy(e){e.start("TABLES"),this.vPortTable.dxfy(e),this.ltypeTable.dxfy(e),this.layerTable.dxfy(e),this.styleTable.dxfy(e),this.viewTable.dxfy(e),this.ucsTable.dxfy(e),this.appIdTable.dxfy(e),this.dimStyleTable.dxfy(e),this.blockRecordTable.dxfy(e),e.end()}}class an{constructor(){h.clear(),this.header=new Ns,this.classes=new Ys,this.tables=new dn,this.objects=new Hs,this.blocks=new Rs(this.tables,this.objects),this.entities=new Bs(this.blocks),this.currentLayerName=c.layerZeroName,this.currentUnits=x$1.Unitless,this.header.setVariable("$ACADVER",{1:"AC1021"}),this.header.setVariable("$LASTSAVEDBY",{1:"@tarikjabiri/dxf"}),this._handseed(),this.setUnits(x$1.Unitless),this.tables.addLType("ByBlock","",[]),this.tables.addLType("ByLayer","",[]);const e=this.tables.addLType("Continuous","Solid line",[]);this.tables.addLayer(c.layerZeroName,m.White,e.name),this.styleStandard=this.tables.addStyle("Standard"),this.tables.addAppId("ACAD",ns.None),this.dimStyleStandard=this.tables.addDimStyle("Standard"),this.dimStyleStandard.DIMTXSTY=this.styleStandard.handle,this.activeVPort=this.tables.addVPort("*Active"),this.modelSpace=this.blocks.modelSpace,this.paperSpace=this.blocks.paperSpace,this.setZeroLayerAsCurrent()}dxfy(e){this.header.dxfy(e),this.classes.dxfy(e),this.tables.dxfy(e),this.blocks.dxfy(e),this.entities.dxfy(e),this.objects.dxfy(e)}addBlock(e){return this.blocks.addBlock(e,this.objects)}setZeroLayerAsCurrent(){this.setCurrentLayerName(c.layerZeroName)}setCurrentLayerName(e){this.currentLayerName=e.replace(rt,""),this.entities.setLayerName(this.currentLayerName),this.setCLayerVariable()}_handseed(){this.header.setVariable("$HANDSEED",{5:h.peek()})}setUnits(e){this.currentUnits=e,this.header.setVariable("$INSUNITS",{70:this.currentUnits})}setCLayerVariable(){this.header.setVariable("$CLAYER",{8:this.currentLayerName})}setViewCenter(e){this.header.setVariable("$VIEWCTR",{10:e.x,20:e.y}),this.activeVPort.viewCenter=[e.x,e.y]}stringify(){const e=new y;return this._handseed(),this.setViewCenter(this.modelSpace.centerView()),this.activeVPort.viewHeight=this.modelSpace.viewHeight(),this.dxfy(e),e.stringify()}}function exportdxf(vis2d){const dxf=new an,mat=new Matrix3D;for(const cmd of vis2d.vec)switch(cmd.type){case"push":mat.push(),(cmd.x||cmd.y)&&mat.translate(cmd.x||0,cmd.y||0,0),cmd.rot&&mat.rotateZ(cmd.rot);break;case"pop":mat.pop();break;case"offset":mat.translate(cmd.x||0,cmd.y||0,0);break;case"point":{const p=mat.transform(cmd.p.x,cmd.p.y,0);dxf.addPoint([p.x,p.y,0]);break}case"line":{const p1=mat.transform(cmd.l.p1.x,cmd.l.p1.y,0),p2=mat.transform(cmd.l.p2.x,cmd.l.p2.y,0);dxf.addLine([p1.x,p1.y,0],[p2.x,p2.y,0]);break}case"rect":{const pts=[[cmd.l.p1.x,cmd.l.p1.y],[cmd.l.p2.x,cmd.l.p1.y],[cmd.l.p2.x,cmd.l.p2.y],[cmd.l.p1.x,cmd.l.p2.y]].map((([x,y])=>mat.transform(x,y,0)));for(let i=0;i<4;i++){const a=pts[i],b=pts[(i+1)%4];dxf.addLine([a.x,a.y,0],[b.x,b.y,0])}break}case"recta":{const pts=[[cmd.l.p1.x,cmd.l.p1.y],[cmd.l.p2.x,cmd.l.p1.y],[cmd.l.p2.x,cmd.l.p2.y],[cmd.l.p1.x,cmd.l.p2.y]].map((([x,y])=>mat.transform(x,y,0)));dxf.addLwPolyline(pts.map((p=>[p.x,p.y])),!0);break}case"shape":if(cmd.s?.pt?.length>=2){const pts=cmd.s.pt.map((p=>{const pp=mat.transform(p.x,p.y,0);return[pp.x,pp.y]}));dxf.addLwPolyline(pts,!1)}break;case"shapelin":if(cmd.s?.pt?.length>=2){const pts=cmd.s.pt.map((p=>{const pp=mat.transform(p.x,p.y,0);return[pp.x,pp.y]}));dxf.addLwPolyline(pts,!1)}break;case"area":if(cmd.s?.pt?.length>=3){const pts=cmd.s.pt.map((p=>{const pp=mat.transform(p.x,p.y,0);return[pp.x,pp.y]}));dxf.addLwPolyline(pts,!0)}}return dxf.stringify()}const mgreen$1=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:THREE.DoubleSide});function getorientate(ori,x,y,z){switch(x=x||0,y=y||0,z=z||0,ori.trim().toLowerCase()){case"alp":return{x:y,y:x,z:z};case"apl":return{x:y,y:z,z:x};case"pla":return{x:z,y:x,z:y};case"pal":return{x:z,y:y,z:x};case"lpa":return{x:x,y:z,z:y};default:return{x:x,y:y,z:z}}}function parselavs(ori,id,x=0,y=0,z=0,lavorazioni="",facce="",def=""){let lavcods=function muClComments(codice,tienivuoti){const righe=(code=codice,code.replace(/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|\/\*[\s\S]*?\*\//g,((match,quoted)=>quoted||""))).split(/\r?\n/);var code;const tm=[];let rigaContinua="";for(const riga of righe){let rigaTrim=riga.trim();if(rigaTrim.includes("//")&&(rigaTrim=rigaTrim.split("//")[0].trim()),0!==rigaTrim.length)if(rigaContinua.length>0&&(rigaTrim=rigaContinua+" "+rigaTrim,rigaContinua=""),rigaTrim.endsWith("\\")){rigaTrim=rigaTrim.slice(0,-1);const indiceCommento=rigaTrim.lastIndexOf("//");-1!==indiceCommento&&(rigaTrim=rigaTrim.slice(0,indiceCommento).trim()),rigaContinua=rigaTrim}else tm.push(rigaTrim)}return tm}(lavorazioni),rets=[];for(let lavcod of lavcods){var rr=/^([({}):$\w.\\/]+)[\s;,]*(.*)?$/im.exec(lavcod);if(rr&&rr[1]){let lav={name:rr[1].trim().toLowerCase(),...getorientate(ori,x,y,z),id:id,facce:facce};if(rr[2]){let aa=getcolonne(rr[2]);for(let a of aa){let i=a.indexOf("=");i>0&&(lav[a.slice(0,i).trim()]=a.slice(i+1).trim())}}rets.push(lav)}}return!rets.length&&def&&rets.push({name:def,...getorientate(ori,x,y,z),id:id,facce:facce}),rets}function getemitter(data){let{d:d,name:name,x:x,y:y,z:z,lavs:lavs="",ids:ids="",faces:faces=null,size:size=5}=data;ids=getcolonne(clean(ids,!0));const emitter=new THREE.Object3D;if(emitter.position.set(x,y,z),emitter.userData={emitter:!0,lavs:lavs,ids:ids,faces:faces,size:size,name:name},d){const geometry=new THREE.SphereGeometry(size||5,8,8),material=new THREE.MeshBasicMaterial({color:16711680}),mesh=new THREE.Mesh(geometry,material);emitter.add(mesh)}return emitter}function getreceiver(gcad,data){gcad.gmats.__istask=1;let{d:d,ori:ori="LAP",x:x=0,y:y=0,z:z=0,tipo:tipo="",start:start="",end:end=""}=data;tipo=clean(tipo,!0);const receiver=new THREE.Object3D;if(receiver.position.set(x/2,y/2,z/2),receiver.userData={receiver:!0,ori:(ori||"").trim().toLowerCase(),x:x,y:y,z:z,tipo:tipo,start:start,end:end},d){const geometry=new THREE.BoxGeometry(x,y,z),mesh=new THREE.Mesh(geometry,mgreen$1);mesh.position.set(0,0,0),receiver.add(mesh)}return receiver}function calcolatasks(scena){const emitterWorldPosition=new WeakMap,receiverWorldMatrixInverse=new WeakMap;function boxBoxIntersects(pos,l,x,y,z){return pos.x+l>0&&pos.x-l<x&&pos.y+l>0&&pos.y-l<y&&pos.z+l>0&&pos.z-l<z}function getFacceToccate(pos,sogliafaccia,x,y,z,filtra){const facce=[];function addfaccia(f){filtra&&!filtra.includes(f)||facce.push(f)}return Math.abs(pos.x-0)<sogliafaccia&&addfaccia("s"),Math.abs(pos.x-x)<sogliafaccia&&addfaccia("d"),Math.abs(pos.y-0)<sogliafaccia&&addfaccia("b"),Math.abs(pos.y-y)<sogliafaccia&&addfaccia("a"),Math.abs(pos.z-0)<sogliafaccia&&addfaccia("z"),Math.abs(pos.z-z)<sogliafaccia&&addfaccia("f"),facce.join("")}function getEmitterWorldPosition(emitter){if(!emitterWorldPosition.has(emitter)){const pos=new THREE.Vector3;emitter.getWorldPosition(pos),emitterWorldPosition.set(emitter,pos)}return emitterWorldPosition.get(emitter)}function getReceiverWorldMatrixInverse(receiver){if(!receiverWorldMatrixInverse.has(receiver)){const inv=receiver.matrixWorld.clone().invert();receiverWorldMatrixInverse.set(receiver,inv)}return receiverWorldMatrixInverse.get(receiver)}scena.updateMatrixWorld(!0);const receivers=[],emitters=[];!function scan(obj){obj.userData?.receiver&&receivers.push(obj),obj.userData?.emitter&&emitters.push(obj),obj.children&&obj.children.forEach(scan)}(scena);let tasks=[];for(const receiver of receivers){const{mat:mat,ori:ori,x:x,y:y,z:z,start:start,end:end,tipo:tipo,size:size}=receiver.userData;let singletask={id:mat,...getorientate(ori,x,y,z),tipo:tipo,ori:ori,lavs:[]};start&&singletask.lavs.push(...parselavs(ori,"_start",0,0,0,start,"",""));const matrixInverse=getReceiverWorldMatrixInverse(receiver);for(const emitter of emitters){if("string"==typeof tipo&&""!==tipo){const idx=emitter.userData.ids;if(Array.isArray(idx)&&idx.length>0&&!idx.includes("*")&&!idx.includes(tipo))continue}const posLocalAdj=getEmitterWorldPosition(emitter).clone().applyMatrix4(matrixInverse).clone().add(new THREE.Vector3(x/2,y/2,z/2));if(!boxBoxIntersects(posLocalAdj,emitter.userData.size??0,x,y,z))continue;const facceToccate=getFacceToccate(posLocalAdj,emitter.userData.soglia??2,x,y,z,emitter.userData.faces);facceToccate&&facceToccate.length&&singletask.lavs.push(...parselavs(ori,emitter.userData.name,posLocalAdj.x,posLocalAdj.y,posLocalAdj.z,emitter.userData.lavs,facceToccate,"nd"))}end&&singletask.lavs.push(...parselavs(ori,"_end",0,0,0,end,"","")),singletask.lavs.length&&tasks.push(singletask)}return tasks}const SIDE=THREE.DoubleSide;let materialline1=new THREE.LineBasicMaterial({color:3158064}),materialline2=new THREE.LineBasicMaterial({color:5263440});const mwhite=new THREE.MeshStandardMaterial({color:16777215,roughness:.5,metalness:.4,side:SIDE}),mgray1=new THREE.MeshStandardMaterial({color:8421504,roughness:.5,metalness:.4,side:SIDE}),mgray2=new THREE.MeshStandardMaterial({color:11579568,roughness:.5,metalness:.4,side:SIDE}),mred=new THREE.MeshStandardMaterial({color:16711680,roughness:.5,metalness:.4,side:SIDE}),mblue=new THREE.MeshStandardMaterial({color:1982639,roughness:.5,metalness:.4,side:SIDE}),mgreen=new THREE.MeshStandardMaterial({color:36864,roughness:.5,metalness:.4,side:SIDE}),mblack=new THREE.MeshStandardMaterial({color:0,roughness:.5,metalness:.4,side:SIDE}),scaleunit=.001;function groupfromgeometry(geometry,material,x,y,z,name,layer){let child=new THREE.Group;child.position.set(x,y,z),child.name=name;const mesh=new THREE.Mesh(geometry,material);mesh.name=name,mesh.castShadow=!0,mesh.receiveShadow=!0,mesh.layers.set(layer);const edges=new THREE.EdgesGeometry(geometry),lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(30),child.add(mesh),child.add(lineSegments),child}function posiziona(grp,pos={}){let tm=new THREE.Group;if(grp){let g2=grp.clone(),tm2=g2,{sl:sl=0,sa:sa=0,sp:sp=0,ax:ax=0,ay:ay=0,az:az=0,ul:ul=0,ua:ua=0,up:up=0,scale:scale=1,scx:scx=scale,scy:scy=scale,scz:scz=scale,emitters:emitters,emittersname:emittersname}=pos;if(tm.position.set(sl,sa,sp),tm.rotation.set(ax*PIF,ay*PIF,az*PIF),(ul||ua||up)&&(tm2=new THREE.Group,tm2.add(g2),tm2.position.set(ul,ua,up)),tm.scale.set(scx,scy,scz),tm.add(tm2),emitters&&emitters.length)for(let e of emitters)e.name=e.name||emittersname,tm.add(getemitter(e))}return tm}function edgesfromgeometry(g1,layer=30){return getlinesgeom(new THREE.EdgesGeometry(g1,40),layer)}function getlinesgeom(edges,layer=30){const lineSegments=new THREE.LineSegments(edges,materialline1);return lineSegments.layers.set(layer),lineSegments}function getmesh(geom,material,layer=1,clone=!1){let m=new THREE.Mesh(geom,clone?material.clone():material);return m.castShadow=!0,m.receiveShadow=!0,m.layers.set(layer),m}function get3dshape(punti,material,layer){if(!punti||punti.length<3)return new THREE.BufferGeometry;const vertices=[];for(let i=0;i<punti.length;i++){const p1=punti[i],p2=punti[(i+1)%punti.length];vertices.push(p1.x,0,p1.y),vertices.push(p2.x,0,p2.y)}const geometry=new THREE.BufferGeometry;geometry.setAttribute("position",new THREE.Float32BufferAttribute(vertices,3));let m=new THREE.LineSegments(geometry,material);return m.layers.set(layer),m}function creategroup(name){let g=new THREE.Group;return g.name=name||"$$",g}function svuotanodo(n){!function _dispose(node){if(node.children.length){[...node.children].forEach((child=>{_dispose(child),node.remove(child)}))}node.geometry&&node.geometry.dispose(),node.material&&(Array.isArray(node.material)?node.material.forEach((m=>m.dispose())):node.material.dispose())}(n)}function deletegroup(grpbase,name){if(!grpbase?.children)return;let gr=grpbase.children.find((e=>e.name==name));if(gr){for(;gr.children.length>0;){const child=gr.children[0];gr.remove(child)}gr.parent&&gr.parent.remove(gr),gr=null}}function randombasemat(){const material=new THREE.LineBasicMaterial,color=new THREE.Color;return color.setHSL(Math.random(),.7,.4),material.color=color,material}
|
|
515
524
|
/**
|
|
516
525
|
* Crea una linea 3D
|
|
517
526
|
* @param {Object} l - Oggetto contenente punti p1 e p2
|
|
@@ -526,7 +535,7 @@ function calcoladivisioni(ff,notused,shape2,oggetti){return makedivisions(ff,sha
|
|
|
526
535
|
* @param {THREE.Material} [mat=null] - Materiale da applicare
|
|
527
536
|
* @param {number} [size=5] - Dimensione della sfera
|
|
528
537
|
* @returns {THREE.Mesh} Punto 3D
|
|
529
|
-
*/function getpoint(p,id,mat=null,size=5){const pointgeom=new THREE.SphereGeometry(size,8,8);let tm=new THREE.Mesh(pointgeom,mat||randombasemat());return tm.position.set(p.x,0,p.y),tm}const suffissoMap={"":{prop:"map",extra:null},n:{prop:"normalMap",extra:null},h:{prop:"displacementMap",extra:"displacementScale"},a:{prop:"aoMap",extra:"aoMapIntensity"},r:{prop:"roughnessMap",extra:null},b:{prop:"bumpMap",extra:"bumpScale"},m:{prop:"metalnessMap",extra:null},e:{prop:"emissiveMap",extra:["emissive","emissiveIntensity"]}};async function smat(gcad,file,op={}){op||(op={});let ky=hash(file+JSON.stringify(op));return gcad.smats[ky]||(gcad.smats[ky]=await async function smat0(gcad,file,op={}){let paramstr="",isColore=!1;file.startsWith("#")&&(isColore=!0,/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})(?=$|[\[(])/.test(file)||(file=file.slice(1)));let basefile=file;const paramMatch=file.match(/^(.*)\[([^\]]+)\]$/);paramMatch&&(basefile=paramMatch[1],paramstr=paramMatch[2]);const p={};paramstr&¶mstr.split(/[,;]/).forEach((kv=>{let[k,v]=kv.split("=").map((x=>x.trim()));void 0!==v&&(["e"].includes(k)?p[k]=v.startsWith("0x")?parseInt(v):v:isNaN(parseFloat(v))?p[k]=v:p[k]=parseFloat(v))}));const mappaParam={s:["sx","sy"],sx:["sx"],sy:["sy"],rot:["rot"],r:["roughness"],m:["metalness"],h:["displacementScale"],d:["bumpScale"],b:["bumpScale"],e:["emissive"],ei:["emissiveIntensity"],ao:["aoMapIntensity"],env:["envMapIntensity"],o:["opacity"],t:["transparent"],at:["alphaTest"]};let optot={...op};for(let k in p)if(mappaParam[k])for(let t of mappaParam[k])optot[t]=p[k];let sx=(optot.sx??1)*(p.sx??p.s??1),sy=(optot.sy??1)*(p.sy??p.s??1),rot=((optot.rot??0)+(p.rot??0))*PIF;try{let tm={roughness:optot.roughness??.7,metalness:optot.metalness??.3,side:THREE.DoubleSide,envMapIntensity:optot.env??1};if(file.includes("(")||isColore){let{base:base,files:files}=function getFilesToLoad(isColore,basefile){let files=[],m=basefile.match(/^([^(]+)\((([a-zA-Z0-9_\-]+)_([a-z]+)|([a-z]+))\)$/);if(!m)return{base:basefile,files:files};let base=m[1],mapalias=m[3]||base,suffstr=m[4]||m[5]||"";isColore||files.push({suff:"",file:`${base}.webp`});for(let s of suffstr)suffissoMap[s]&&files.push({suff:s,file:`${mapalias}_${s}.webp`});return{base:base,files:files}}(isColore,basefile);if(files&&files.length){let textures=await Promise.all(files.map((f=>gcad.tex(f.file,sx,sy,rot).catch((()=>null)))));for(let i=0;i<files.length;i++){let t=textures[i];if(!t)continue;let suff=files[i].suff,{prop:prop,extra:extra}=suffissoMap[suff];tm[prop]=t,extra&&("displacementScale"===extra?tm.displacementScale=optot.displacementScale??.1:"bumpScale"===extra?tm.bumpScale=optot.bumpScale??.05:"aoMapIntensity"===extra?tm.aoMapIntensity=optot.aoMapIntensity??1:Array.isArray(extra)&&extra.includes("emissive")&&(tm.emissive=optot.emissive??16777215,tm.emissiveIntensity=optot.emissiveIntensity??1))}}isColore&&(tm.color=base)}else if(basefile.includes(".")){let tx=await gcad.tex(basefile,sx,sy,rot);if(!tx)return mwhite;tm.map=tx}return["opacity","alphaTest"].forEach((k=>{void 0!==optot[k]&&(tm[k]=optot[k])})),(void 0!==tm.opacity&&tm.opacity<1||optot.transparent)&&(tm.transparent=!0),new THREE.MeshStandardMaterial(tm)}catch(error){return mwhite}}(gcad,file,op)),gcad.smats[ky]}function getfakeshadow(gcad,shape,alfa){let ky=`fk${shape.key}${alfa}`,{p1:p1,width:width,height:height}=shape.dims();gcad.texture||(gcad.texture={});let tm=gcad.texture[ky];tm||(tm=function createBlurredShadowTextureFromPoints(mshape,size=256,blurPx=32,alpha=.2,p1,width,height){if(!width||!height||!mshape.pt||mshape.pt.length<2)return;const minX=p1.x,minY=p1.y,shapeWidth=width,shapeHeight=height,points=mshape.pt,extra=2*blurPx,canvas=document.createElement("canvas");canvas.width=size+2*extra,canvas.height=size+2*extra;const ctx=canvas.getContext("2d");ctx.save(),ctx.translate(extra,extra),ctx.scale(size/shapeWidth,size/shapeHeight),ctx.translate(-minX,-minY),ctx.filter=`blur(${blurPx}px)`,ctx.beginPath(),ctx.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)ctx.lineTo(points[i].x,points[i].y);ctx.closePath(),ctx.fillStyle=`rgba(0,0,0,${alpha})`,ctx.fill(),ctx.restore();const texture=new THREE.CanvasTexture(canvas);return texture.needsUpdate=!0,texture}(shape,256,32,alfa,p1,width,height),gcad.texture[ky]=tm);const fakeShape=function pointsToShape(points){const fakeShape=new THREE.Shape;fakeShape.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)fakeShape.lineTo(points[i].x,points[i].y);return fakeShape}(shape.pt),shadowGeometry=new THREE.ShapeGeometry(fakeShape);!function applyUVtoShapeGeometry(geometry,minX,minY,width,height){const pos=geometry.attributes.position,uv=[];for(let i=0;i<pos.count;i++){const x=pos.getX(i),y=pos.getY(i);uv.push((x-minX)/width,(y-minY)/height)}geometry.setAttribute("uv",new THREE.Float32BufferAttribute(uv,2))}(shadowGeometry,p1.x,p1.y,width,height);const shadowMaterial=new THREE.MeshBasicMaterial({map:tm,transparent:!0,depthWrite:!1,side:THREE.DoubleSide});let ms=new THREE.Mesh(shadowGeometry,shadowMaterial);return ms.layers.set(9),ms.rotation.x=Math.PI/2,ms}function addmovpivot(gcad,grp,movimento,op={},x=0,y=0,z=0){if(movimento=clean(movimento,!0),!gcad.movs[movimento])return grp;gcad.movs[movimento];const pivotLocal=new THREE.Vector3(x,y,z),isZeroPivot=0===pivotLocal.lengthSq(),pivotGroup=new THREE.Group;pivotGroup.name=`pivot_${movimento}`;const movimentoGroup=new THREE.Group;if(movimentoGroup.name=`mov_${movimento}`,isZeroPivot)pivotGroup.position.copy(grp.position),pivotGroup.quaternion.copy(grp.quaternion),grp.position.set(0,0,0),grp.rotation.set(0,0,0);else{const pivotWorld=pivotLocal.clone().applyMatrix4(grp.matrixWorld);pivotGroup.position.copy(pivotWorld);const offset=pivotLocal.clone().negate();grp.position.add(offset),pivotGroup.quaternion.copy(grp.getWorldQuaternion(new THREE.Quaternion)),grp.rotation.set(0,0,0)}return movimentoGroup.add(grp),pivotGroup.add(movimentoGroup),op||(op={}),op.inmov=!1,op.key=movimento,op.dt=0,op.dtstart=!1,movimentoGroup.userData.mov={...op},pivotGroup}
|
|
538
|
+
*/function getpoint(p,id,mat=null,size=5){const pointgeom=new THREE.SphereGeometry(size,8,8);let tm=new THREE.Mesh(pointgeom,mat||randombasemat());return tm.position.set(p.x,0,p.y),tm}const suffissoMap={"":{prop:"map",extra:null},n:{prop:"normalMap",extra:null},h:{prop:"displacementMap",extra:"displacementScale"},a:{prop:"aoMap",extra:"aoMapIntensity"},r:{prop:"roughnessMap",extra:null},b:{prop:"bumpMap",extra:"bumpScale"},m:{prop:"metalnessMap",extra:null},e:{prop:"emissiveMap",extra:["emissive","emissiveIntensity"]}};async function smat(gcad,file,op={}){op||(op={});let ky=hash(file+JSON.stringify(op));return gcad.smats[ky]||(gcad.smats[ky]=await async function smat0(gcad,file,op={}){let paramstr="",isColore=!1;file.startsWith("#")&&(isColore=!0,/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})(?=$|[\[(])/.test(file)||(file=file.slice(1)));let basefile=file;const paramMatch=file.match(/^(.*)\[([^\]]+)\]$/);paramMatch&&(basefile=paramMatch[1],paramstr=paramMatch[2]);const p={};paramstr&¶mstr.split(/[,;]/).forEach((kv=>{let[k,v]=kv.split("=").map((x=>x.trim()));void 0!==v&&(["e"].includes(k)?p[k]=v.startsWith("0x")?parseInt(v):v:isNaN(parseFloat(v))?p[k]=v:p[k]=parseFloat(v))}));const mappaParam={s:["sx","sy"],sx:["sx"],sy:["sy"],rot:["rot"],r:["roughness"],m:["metalness"],h:["displacementScale"],d:["bumpScale"],b:["bumpScale"],e:["emissive"],ei:["emissiveIntensity"],ao:["aoMapIntensity"],env:["envMapIntensity"],o:["opacity"],t:["transparent"],at:["alphaTest"]};let optot={...op};for(let k in p)if(mappaParam[k])for(let t of mappaParam[k])optot[t]=p[k];let sx=(optot.sx??optot.s??1)*(p.sx??p.s??1),sy=(optot.sy??optot.s??1)*(p.sy??p.s??1),rot=((optot.rot??0)+(p.rot??0))*PIF;try{let tm={roughness:optot.roughness??.7,metalness:optot.metalness??.3,side:THREE.DoubleSide,envMapIntensity:optot.env??1};if(file.includes("(")||isColore){let{base:base,files:files}=function getFilesToLoad(isColore,basefile){let files=[],m=basefile.match(/^([^(]+)\((([a-zA-Z0-9_\-]+)_([a-z]+)|([a-z]+))\)$/);if(!m)return{base:basefile,files:files};let base=m[1],mapalias=m[3]||base,suffstr=m[4]||m[5]||"";isColore||files.push({suff:"",file:`${base}.webp`});for(let s of suffstr)suffissoMap[s]&&files.push({suff:s,file:`${mapalias}_${s}.webp`});return{base:base,files:files}}(isColore,basefile);if(files&&files.length){let textures=await Promise.all(files.map((f=>gcad.tex(f.file,sx,sy,rot).catch((()=>null)))));for(let i=0;i<files.length;i++){let t=textures[i];if(!t)continue;let suff=files[i].suff,{prop:prop,extra:extra}=suffissoMap[suff];tm[prop]=t,extra&&("displacementScale"===extra?tm.displacementScale=optot.displacementScale??.1:"bumpScale"===extra?tm.bumpScale=optot.bumpScale??.05:"aoMapIntensity"===extra?tm.aoMapIntensity=optot.aoMapIntensity??1:Array.isArray(extra)&&extra.includes("emissive")&&(tm.emissive=optot.emissive??16777215,tm.emissiveIntensity=optot.emissiveIntensity??1))}}isColore&&(tm.color=base)}else if(basefile.includes(".")){let tx=await gcad.tex(basefile,sx,sy,rot);if(!tx)return mwhite;tm.map=tx}return["opacity","alphaTest"].forEach((k=>{void 0!==optot[k]&&(tm[k]=optot[k])})),(void 0!==tm.opacity&&tm.opacity<1||optot.transparent)&&(tm.transparent=!0),new THREE.MeshStandardMaterial(tm)}catch(error){return mwhite}}(gcad,file,op)),gcad.smats[ky]}function getfakeshadow(gcad,shape,alfa){let ky=`fk${shape.key}${alfa}`,{p1:p1,width:width,height:height}=shape.dims();gcad.texture||(gcad.texture={});let tm=gcad.texture[ky];tm||(tm=function createBlurredShadowTextureFromPoints(mshape,size=256,blurPx=32,alpha=.2,p1,width,height){if(!width||!height||!mshape.pt||mshape.pt.length<2)return;const minX=p1.x,minY=p1.y,shapeWidth=width,shapeHeight=height,points=mshape.pt,extra=2*blurPx,canvas=document.createElement("canvas");canvas.width=size+2*extra,canvas.height=size+2*extra;const ctx=canvas.getContext("2d");ctx.save(),ctx.translate(extra,extra),ctx.scale(size/shapeWidth,size/shapeHeight),ctx.translate(-minX,-minY),ctx.filter=`blur(${blurPx}px)`,ctx.beginPath(),ctx.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)ctx.lineTo(points[i].x,points[i].y);ctx.closePath(),ctx.fillStyle=`rgba(0,0,0,${alpha})`,ctx.fill(),ctx.restore();const texture=new THREE.CanvasTexture(canvas);return texture.needsUpdate=!0,texture}(shape,256,32,alfa,p1,width,height),gcad.texture[ky]=tm);const fakeShape=function pointsToShape(points){const fakeShape=new THREE.Shape;fakeShape.moveTo(points[0].x,points[0].y);for(let i=1;i<points.length;i++)fakeShape.lineTo(points[i].x,points[i].y);return fakeShape}(shape.pt),shadowGeometry=new THREE.ShapeGeometry(fakeShape);!function applyUVtoShapeGeometry(geometry,minX,minY,width,height){const pos=geometry.attributes.position,uv=[];for(let i=0;i<pos.count;i++){const x=pos.getX(i),y=pos.getY(i);uv.push((x-minX)/width,(y-minY)/height)}geometry.setAttribute("uv",new THREE.Float32BufferAttribute(uv,2))}(shadowGeometry,p1.x,p1.y,width,height);const shadowMaterial=new THREE.MeshBasicMaterial({map:tm,transparent:!0,depthWrite:!1,side:THREE.DoubleSide});let ms=new THREE.Mesh(shadowGeometry,shadowMaterial);return ms.layers.set(9),ms.rotation.x=Math.PI/2,ms}function addmovpivot(gcad,grp,movimento,op={},x=0,y=0,z=0){if(movimento=clean(movimento,!0),!gcad.movs[movimento])return grp;gcad.movs[movimento];const pivotLocal=new THREE.Vector3(x,y,z),isZeroPivot=0===pivotLocal.lengthSq(),pivotGroup=new THREE.Group;pivotGroup.name=`pivot_${movimento}`;const movimentoGroup=new THREE.Group;if(movimentoGroup.name=`mov_${movimento}`,isZeroPivot)pivotGroup.position.copy(grp.position),pivotGroup.quaternion.copy(grp.quaternion),grp.position.set(0,0,0),grp.rotation.set(0,0,0);else{const pivotWorld=pivotLocal.clone().applyMatrix4(grp.matrixWorld);pivotGroup.position.copy(pivotWorld);const offset=pivotLocal.clone().negate();grp.position.add(offset),pivotGroup.quaternion.copy(grp.getWorldQuaternion(new THREE.Quaternion)),grp.rotation.set(0,0,0)}return movimentoGroup.add(grp),pivotGroup.add(movimentoGroup),op||(op={}),op.inmov=!1,op.key=movimento,op.dt=0,op.dtstart=!1,movimentoGroup.userData.mov={...op},pivotGroup}
|
|
530
539
|
/**
|
|
531
540
|
* Crea un gestore di movimento per animare oggetti 3D.
|
|
532
541
|
* @param {string} key - Chiave identificativa del movimento
|
|
@@ -1073,4 +1082,4 @@ constructor(data,position,debugMessage){this.data=data,this.offset=position,this
|
|
|
1073
1082
|
/**
|
|
1074
1083
|
* Libera tutte le risorse caricate
|
|
1075
1084
|
*/
|
|
1076
|
-
async function clear(){function destroymesh(mesh){function disposeMaterial(material){material.map&&material.map.dispose(),material.lightMap&&material.lightMap.dispose(),material.bumpMap&&material.bumpMap.dispose(),material.normalMap&&material.normalMap.dispose(),material.specularMap&&material.specularMap.dispose(),material.dispose()}mesh&&mesh.traverse((child=>{child.isMesh&&(child.geometry.dispose(),child.material&&(Array.isArray(child.material)?child.material.forEach(disposeMaterial):disposeMaterial(child.material)))}))}_gmatricole={},THREE.Cache.clear();for(const c in _geometries)_geometries[c]?.dispose();for(const key in _textures)if(_textures[key]){const texture=await _textures[key];texture?.dispose()}for(const key in _smats)_smats[key]&&_smats[key]?.dispose();for(const[key,texOrPromise]of textureCache.entries()){const texture=texOrPromise instanceof Promise?await texOrPromise:texOrPromise;texture?.dispose&&texture.dispose()}textureCache.clear();for(const key in _meshes)if(_meshes[key]){destroymesh(await _meshes[key])}_movs={},_textures={},_meshes={},_geometries={},_smats={},_scripts={}},getScript:async function getScript(file){file.endsWith(".custom")?file=file.slice(-7):file.endsWith(".js")&&(file=file.slice(-3));let key=hash(`${getcat()}|${file}`);if(!_scripts[key]){let script;try{script=await P.fetch("mufiles/customfn",{id:getcat(),name:file,ispar:1})}catch(error){script=`log('undefined ${getcat()}/${file}: ${error.message}');`}_scripts[key]=script}return _scripts[key]},checkScripts:async function checkScripts(files){let cl=[];if(!files||!Array.isArray(files))return;let ct=getcat();for(let f of files){let key=hash(`${ct}|${f}`);_scripts[key]||cl.push(f)}if(cl?.length){let scripts=await P.fetch("mufiles/customfn",{id:ct,name:cl,ispar:1});if(scripts)for(let s of scripts){let key=hash(`${ct}|${s.n}`);_scripts[key]=s.v}}},gmats:_gmatricole,scripts:()=>Object.keys(_scripts),geo:_geometries,movs:_movs,textures:_textures,smats:_smats,dump(){console.log(`SMATS:\n${Object.keys(_smats).join(" - ")};\nGEOMS:\n${Object.keys(_geometries).join(" - ")};\nTEX:\n${Object.keys(_textures).join(" - ")};\nMESH:\n${Object.keys(_meshes).join(" - ")};\n`)},get cat(){return getcat()},pushcat(cat){cats.push(cat)},popcat:()=>(cats.length>1&&cats.length--,getcat()),async tex(file,sx=1,sy,rot){sy||(sy=sx),rot||(rot=0);const key=hash(`${getcat()}|${file}|${sx}|${sy}|${rot}`);return _textures[key]||(_textures[key]=new Promise(((resolve,reject)=>{let url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"textures",name:file,force:1});if(textureCache.has(url)){const tex=textureCache.get(url).clone();return tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.001*sx,.001*sy),tex.rotation=rot,void resolve(tex)}_loadertex.load(url,(tex=>{textureCache.set(url,tex),tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.001*sx,.001*sy),tex.rotation=rot,resolve(tex)}),void 0,(error=>{console.log(`Manca Texture ${file}!. questo rallenta molto il processo`),delete _textures[key],resolve(void 0)}))}))),_textures[key]},async get3ds(file,callback,ky=""){file.endsWith(".3ds")&&(file=file.slice(0,-4));const modifierKey=callback?hash(callback.toString()):"nomod",key=hash(`${getcat()}|${file}.3ds|${modifierKey}|${ky}`);return _meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{let url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:".3ds"});_loader3DS.setResourcePath(url+"&tex="),_loader3DS.load(url,(object=>{callback&&object.traverse((child=>{child.isMesh&&(Array.isArray(child.material)?child.material=child.material.map((mat=>callback(mat,child))):child.material=callback(child.material,child))})),resolve(object)}),void 0,(error=>{delete _meshes[key],resolve(void 0)}))}))),_meshes[key]},async getglb(file,textures,callback=null,ky=""){const ext=".glb";file.endsWith(ext)&&(file=file.slice(0,-4)),Array.isArray(textures)||(textures=[]);const modifierKey=callback?hash(callback.toString()):"nomod",texturesKey=textures.map((tex=>tex?.uuid||"null")).join("|"),key=hash(`${getcat()}|${file}${ext}|${texturesKey}|${modifierKey}|${ky}`);return _meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{const url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:ext});_loaderGLTF.setPath(""),_loaderGLTF.setResourcePath((resource=>(console.log("risorsa",resource),`${url}&tex=${resource}`))),_loaderGLTF.load(url,(async gltf=>{gltf.scene.traverse((child=>{if(child.isMesh){child.frustumCulled=!0;(Array.isArray(child.material)?child.material:[child.material]).forEach((material=>{if(!material||!material.map)return;const originalTexName=material.map.source?.data?.src;if(!originalTexName)return;const match=originalTexName.match(/(\d{2})\.jpg$/);if(!match)return;const textureIndex=parseInt(match[1]);textures[textureIndex]&&(material.map=textures[textureIndex],material.needsUpdate=!0)})),callback&&(Array.isArray(child.material)?child.material=child.material.map((mat=>callback(mat,child))):child.material=callback(child.material,child))}})),resolve(gltf.scene)}),void 0,(error=>{console.log(error),delete _meshes[key],resolve(void 0)}))}))),_meshes[key]}}}function TODEG(a,dec=1){let C=10**dec;return Math.round(180*a*C/Math.PI)/C}function TORAD(a,dec=3){let C=10**dec;return Math.round(a*PIF*C)/C}const blocked={window:void 0,self:void 0,globalThis:void 0,document:void 0,Function:void 0,eval:void 0,fetch:void 0,XMLHttpRequest:void 0};function getOggetto(obj,exclude=[]){if(Array.isArray(obj))return obj.map((item=>getOggetto(item,exclude)));if(obj&&"object"==typeof obj){const result={};for(const[key,value]of Object.entries(obj))"function"==typeof value||exclude&&exclude.includes(key)||(result[key]=getOggetto(value,exclude));return result}return obj}async function evalcustomfunction(amb,code,values,objects){try{values||(values={}),objects||(objects={});const params={GCAD:!1,...values,A:amb,V:amb.vari,amb:amb,log:function addlog(...pars){const sanitized=pars.map((p=>getOggetto(p)));console.log(...sanitized)},Math:Math,clean:clean,SP:SP,Punto2:Punto2,Linea2:Linea2,clamp:clamp,hash:hash,PIF:PIF,getshape:getshape,shapeclip:shapeclip,...objects},paramNames=[...Object.keys(params),...Object.keys(blocked)],paramValues=[...Object.values(params),...Object.values(blocked)],fn=new Function(...paramNames,`\n try {\n return (async () => {\n ${code}\n })();\n } catch (err) {\n err.stack = '[SCRIPT] ' + err.stack;\n throw err;\n }`);return await fn(...paramValues)}catch(error){throw console.error("Errore durante l'esecuzione:",error),error}}function setLineColorMode(white){white?(materialline1.color.set(16777215),materialline2.color.set(16777215)):(materialline1.color.set(3158064),materialline2.color.set(5263440)),materialline1.needsUpdate=!0,materialline2.needsUpdate=!0}export{Linea2,Matrix3D,PIF,Punto2,SIDE,SP,TODEG,TORAD,Vis2d,addmovpivot,angle2vec,angle3point,blocked,calcolatasks,clamp,clean,creategroup,deletegroup,edgesfromgeometry,elaborapercorso,estruso,estrusopat,evalcustomfunction,get3dshape,getOggetto,getbordi,getbox,getcilindro,getcyl,getdumpmacro,getemitter,getface,getfakeshadow,getline,getlinesgeom,getmesh,getmovimento,getnodebyid,getpannello,getpoint,getprojectkeys,getptsoffset,getpunto,getquota,getreceiver,getriferimento,getshape,getsprite,getsubrules,gettarghetta,groupfromgeometry,hash,infoestrudi,isfn,ismacro,materialline1,materialline2,mblack,mblue,mgray1,mgray2,mgreen,mred,mwhite,newgcad,normal2,posiziona,raccordabezier,randombasemat,revolve,scaleunit,setLineColorMode,shapeclip,smat,spritemat,svuotanodo,valutagrafica};
|
|
1085
|
+
async function clear(){function destroymesh(mesh){function disposeMaterial(material){material.map&&material.map.dispose(),material.lightMap&&material.lightMap.dispose(),material.bumpMap&&material.bumpMap.dispose(),material.normalMap&&material.normalMap.dispose(),material.specularMap&&material.specularMap.dispose(),material.dispose()}mesh&&mesh.traverse((child=>{child.isMesh&&(child.geometry.dispose(),child.material&&(Array.isArray(child.material)?child.material.forEach(disposeMaterial):disposeMaterial(child.material)))}))}_gmatricole={},THREE.Cache.clear();for(const c in _geometries)_geometries[c]?.dispose();for(const key in _textures)if(_textures[key]){const texture=await _textures[key];texture?.dispose()}for(const key in _smats)_smats[key]&&_smats[key]?.dispose();for(const[key,texOrPromise]of textureCache.entries()){const texture=texOrPromise instanceof Promise?await texOrPromise:texOrPromise;texture?.dispose&&texture.dispose()}textureCache.clear();for(const key in _meshes)if(_meshes[key]){destroymesh(await _meshes[key])}_movs={},_textures={},_meshes={},_geometries={},_smats={},_scripts={}},getScript:async function getScript(file){file.endsWith(".custom")?file=file.slice(-7):file.endsWith(".js")&&(file=file.slice(-3));let key=hash(`${getcat()}|${file}`);if(!_scripts[key]){let script;try{script=await P.fetch("mufiles/customfn",{id:getcat(),name:file,ispar:1})}catch(error){script=`log('undefined ${getcat()}/${file}: ${error.message}');`}_scripts[key]=script}return _scripts[key]},checkScripts:async function checkScripts(files){let cl=[];if(!files||!Array.isArray(files))return;let ct=getcat();for(let f of files){let key=hash(`${ct}|${f}`);_scripts[key]||cl.push(f)}if(cl?.length){let scripts=await P.fetch("mufiles/customfn",{id:ct,name:cl,ispar:1});if(scripts)for(let s of scripts){let key=hash(`${ct}|${s.n}`);_scripts[key]=s.v}}},gmats:_gmatricole,scripts:()=>Object.keys(_scripts),geo:_geometries,movs:_movs,textures:_textures,smats:_smats,dump(){console.log(`SMATS:\n${Object.keys(_smats).join(" - ")};\nGEOMS:\n${Object.keys(_geometries).join(" - ")};\nTEX:\n${Object.keys(_textures).join(" - ")};\nMESH:\n${Object.keys(_meshes).join(" - ")};\n`)},get cat(){return getcat()},pushcat(cat){cats.push(cat)},popcat:()=>(cats.length>1&&cats.length--,getcat()),async tex(file,sx=1,sy,rot){sy||(sy=sx),rot||(rot=0);const key=hash(`${getcat()}|${file}|${sx}|${sy}|${rot}`);return _textures[key]||(_textures[key]=new Promise(((resolve,reject)=>{let url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"textures",name:file,force:1});if(textureCache.has(url)){const tex=textureCache.get(url).clone();return tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.001*sx,.001*sy),tex.rotation=rot,void resolve(tex)}_loadertex.load(url,(tex=>{textureCache.set(url,tex),tex.wrapS=THREE.RepeatWrapping,tex.wrapT=THREE.RepeatWrapping,tex.repeat.set(.001*sx,.001*sy),tex.rotation=rot,resolve(tex)}),void 0,(error=>{console.log(`Manca Texture ${file}!. questo rallenta molto il processo`),delete _textures[key],resolve(void 0)}))}))),_textures[key]},async get3ds(file,callback,ky=""){file.endsWith(".3ds")&&(file=file.slice(0,-4));const modifierKey=callback?hash(callback.toString()):"nomod",key=hash(`${getcat()}|${file}.3ds|${modifierKey}|${ky}`);return _meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{let url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:".3ds"});_loader3DS.setResourcePath(url+"&tex="),_loader3DS.load(url,(object=>{callback&&object.traverse((child=>{child.isMesh&&(Array.isArray(child.material)?child.material=child.material.map((mat=>callback(mat,child))):child.material=callback(child.material,child))})),resolve(object)}),void 0,(error=>{delete _meshes[key],resolve(void 0)}))}))),_meshes[key]},async getglb(file,textures,callback=null,ky=""){const ext=".glb";file.endsWith(ext)&&(file=file.slice(0,-4)),Array.isArray(textures)||(textures=[]);const modifierKey=callback?hash(callback.toString()):"nomod",texturesKey=textures.map((tex=>tex?.uuid||"null")).join("|"),key=hash(`${getcat()}|${file}${ext}|${texturesKey}|${modifierKey}|${ky}`);return _meshes[key]||(_meshes[key]=await new Promise(((resolve,reject)=>{const url=P.fullget("mufiles/getfile",{id:getcat(),subfolder:"3d",name:file,ext:ext});_loaderGLTF.setPath(""),_loaderGLTF.setResourcePath((resource=>(console.log("risorsa",resource),`${url}&tex=${resource}`))),_loaderGLTF.load(url,(async gltf=>{gltf.scene.traverse((child=>{if(child.isMesh){child.frustumCulled=!0;(Array.isArray(child.material)?child.material:[child.material]).forEach((material=>{if(!material||!material.map)return;const originalTexName=material.map.source?.data?.src;if(!originalTexName)return;const match=originalTexName.match(/(\d{2})\.jpg$/);if(!match)return;const textureIndex=parseInt(match[1]);textures[textureIndex]&&(material.map=textures[textureIndex],material.needsUpdate=!0)})),callback&&(Array.isArray(child.material)?child.material=child.material.map((mat=>callback(mat,child))):child.material=callback(child.material,child))}})),resolve(gltf.scene)}),void 0,(error=>{console.log(error),delete _meshes[key],resolve(void 0)}))}))),_meshes[key]}}}function TODEG(a,dec=1){let C=10**dec;return Math.round(180*a*C/Math.PI)/C}function TORAD(a,dec=3){let C=10**dec;return Math.round(a*PIF*C)/C}const blocked={window:void 0,self:void 0,globalThis:void 0,document:void 0,Function:void 0,eval:void 0,fetch:void 0,XMLHttpRequest:void 0};function getOggetto(obj,exclude=[]){if(Array.isArray(obj))return obj.map((item=>getOggetto(item,exclude)));if(obj&&"object"==typeof obj){const result={};for(const[key,value]of Object.entries(obj))"function"==typeof value||exclude&&exclude.includes(key)||(result[key]=getOggetto(value,exclude));return result}return obj}async function evalcustomfunction(amb,code,values,objects){try{values||(values={}),objects||(objects={});const params={GCAD:!1,...values,A:amb,V:amb.vari,amb:amb,log:function addlog(...pars){const sanitized=pars.map((p=>getOggetto(p)));console.log(...sanitized)},Math:Math,clean:clean,SP:SP,Punto2:Punto2,Linea2:Linea2,clamp:clamp,hash:hash,PIF:PIF,getshape:getshape,shapeclip:shapeclip,...objects},paramNames=[...Object.keys(params),...Object.keys(blocked)],paramValues=[...Object.values(params),...Object.values(blocked)],fn=new Function(...paramNames,`\n try {\n return (async () => {\n ${code}\n })();\n } catch (err) {\n err.stack = '[SCRIPT] ' + err.stack;\n throw err;\n }`);return await fn(...paramValues)}catch(error){throw console.error("Errore durante l'esecuzione:",error),error}}function setLineColorMode(white){white?(materialline1.color.set(16777215),materialline2.color.set(16777215)):(materialline1.color.set(3158064),materialline2.color.set(5263440)),materialline1.needsUpdate=!0,materialline2.needsUpdate=!0}export{Linea2,Matrix3D,PIF,Punto2,SIDE,SP,TODEG,TORAD,Vis2d,addmovpivot,angle2vec,angle3point,blocked,calcolatasks,clamp,clean,creategroup,deletegroup,dxfbulge,edgesfromgeometry,elaborapercorso,estruso,estrusopat,evalcustomfunction,exportdxf,get3dshape,getOggetto,getbordi,getbox,getcilindro,getcyl,getdumpmacro,getemitter,getface,getfakeshadow,getline,getlinesgeom,getmesh,getmovimento,getnodebyid,getpannello,getpoint,getprojectkeys,getptsoffset,getpunto,getquota,getreceiver,getriferimento,getshape,getsprite,getsubrules,gettarghetta,groupfromgeometry,hash,infoestrudi,isfn,ismacro,materialline1,materialline2,mblack,mblue,mgray1,mgray2,mgreen,mred,mwhite,newgcad,normal2,posiziona,raccordabezier,randombasemat,revolve,scaleunit,setLineColorMode,shapeclip,smat,spritemat,svuotanodo,valutagrafica};
|
package/package.json
CHANGED
package/types/markcad.d.ts
CHANGED
|
@@ -305,6 +305,26 @@ export function clamp(n: any, min?: number, max?: number): any;
|
|
|
305
305
|
export function clean(k: any, locase?: boolean): any;
|
|
306
306
|
export function creategroup(name: any): any;
|
|
307
307
|
export function deletegroup(grpbase: any, name: any): void;
|
|
308
|
+
/**
|
|
309
|
+
* Esegue la semplificazione di un poligono (array di punti) combinando
|
|
310
|
+
* l’algoritmo di distanza radiale e l’algoritmo di Ramer–Douglas–Peucker.
|
|
311
|
+
*
|
|
312
|
+
* @param {Array<{x:number,y:number}>} points - Array di punti {x,y} da semplificare.
|
|
313
|
+
* @param {number} [tolerance=1] - Tolleranza di semplificazione: distanza minima consentita
|
|
314
|
+
* (in unità lineari) tra i punti; internamente usata al quadrato per il calcolo
|
|
315
|
+
* (`sqTolerance = tolerance * tolerance`). Valori più grandi rimuovono più punti.
|
|
316
|
+
* @param {boolean} [highestQuality=false] - Se `true`, salta il passaggio di
|
|
317
|
+
* semplificazione radiale e usa solo Douglas–Peucker per massima qualità.
|
|
318
|
+
* @returns {Array<{x:number,y:number}>} Nuovo array di punti semplificato.
|
|
319
|
+
*/
|
|
320
|
+
/**
|
|
321
|
+
* Calcola i punti di un arco DXF dato p1, p2, bulge e n punti intermedi.
|
|
322
|
+
* p1, p2: oggetti {x, y}
|
|
323
|
+
* bulge: valore DXF tra p1 e p2
|
|
324
|
+
* n: numero di punti INTERMEDI da inserire tra p1 e p2 (n=0 -> solo estremi)
|
|
325
|
+
* Return: array di punti [{x, y}, ..., {x, y}]
|
|
326
|
+
*/
|
|
327
|
+
export function dxfbulge(p1: any, p2: any, bulge: any, n?: number): any;
|
|
308
328
|
export function edgesfromgeometry(g1: any, layer?: number): any;
|
|
309
329
|
export function elaborapercorso(sh1: any, bordo: any, taglio: any, oggetti: any, countid?: number): {
|
|
310
330
|
countid: number;
|
|
@@ -335,6 +355,7 @@ export function elaborapercorso(sh1: any, bordo: any, taglio: any, oggetti: any,
|
|
|
335
355
|
* @returns {THREE.Group} Gruppo contenente la geometria estrusa
|
|
336
356
|
*/ export function estrusopat(gcad: any, orient: string, pat: any, shape: any, mats: any[], options: any): THREE.Group;
|
|
337
357
|
export function evalcustomfunction(amb: any, code: any, values: any, objects: any): Promise<any>;
|
|
358
|
+
export function exportdxf(vis2d: any): string;
|
|
338
359
|
export function get3dshape(punti: any, material: any, layer: any): any;
|
|
339
360
|
export function getOggetto(obj: any, exclude?: any[]): any;
|
|
340
361
|
export function getbordi(oggetti: any, bordo: any): {
|
|
@@ -477,6 +498,7 @@ export function getriferimento(dati: any, x?: number, y?: number, z?: number, id
|
|
|
477
498
|
* @method fromclip(vv) - Inizializza da punti in formato clipper
|
|
478
499
|
* @method fromvec(aa) - Inizializza da array di coordinate [x1,y1,x2,y2,...]
|
|
479
500
|
* @method frompt(pts) - Inizializza da array di punti [{x,y},...]
|
|
501
|
+
* @method fromdxfvec(verts) - vertici nel formato DXF LWPOLYLINE con bulge per i raccordi:
|
|
480
502
|
* @method fromstr(str) - Inizializza da stringa con sintassi speciale
|
|
481
503
|
* @method addpt(pts) - Aggiunge punti alla forma
|
|
482
504
|
* @method addracc(v1,v2,suddivisioni,addv1v2) - Aggiunge raccordo tra punti
|
|
@@ -568,18 +590,6 @@ export function newgcad(P: any, _cat: any, islog?: boolean): {
|
|
|
568
590
|
* @returns {Object} Vettore normale unitario {nx,ny}
|
|
569
591
|
*/ export function normal2(p1: any, p2: any): any;
|
|
570
592
|
export function posiziona(grp: any, pos?: {}): any;
|
|
571
|
-
/**
|
|
572
|
-
* Esegue la semplificazione di un poligono (array di punti) combinando
|
|
573
|
-
* l’algoritmo di distanza radiale e l’algoritmo di Ramer–Douglas–Peucker.
|
|
574
|
-
*
|
|
575
|
-
* @param {Array<{x:number,y:number}>} points - Array di punti {x,y} da semplificare.
|
|
576
|
-
* @param {number} [tolerance=1] - Tolleranza di semplificazione: distanza minima consentita
|
|
577
|
-
* (in unità lineari) tra i punti; internamente usata al quadrato per il calcolo
|
|
578
|
-
* (`sqTolerance = tolerance * tolerance`). Valori più grandi rimuovono più punti.
|
|
579
|
-
* @param {boolean} [highestQuality=false] - Se `true`, salta il passaggio di
|
|
580
|
-
* semplificazione radiale e usa solo Douglas–Peucker per massima qualità.
|
|
581
|
-
* @returns {Array<{x:number,y:number}>} Nuovo array di punti semplificato.
|
|
582
|
-
*/
|
|
583
593
|
/**
|
|
584
594
|
* Crea una curva di Bézier quadratica tra due segmenti di linea.
|
|
585
595
|
* @param {Object} a1 - Punto iniziale del primo segmento {x,y}
|