@typecad/typecad
Version:
🤖programmatically 💥create 🛰️hardware
1 lines • 28.3 kB
JavaScript
function a28_0x2741aa(_0x20b5ff,_0x1f4583){return a28_0x4636(_0x20b5ff- -0x1b5,_0x1f4583);}import a28_0x357743 from'chalk';import a28_0x2de824 from'../../logging.js';function a28_0x4636(_0x3975f9,_0x46366e){const _0x548a93=a28_0x3975();return a28_0x4636=function(_0x279f25,_0x1caaa8){_0x279f25=_0x279f25-0x0;let _0x105e49=_0x548a93[_0x279f25];return _0x105e49;},a28_0x4636(_0x3975f9,_0x46366e);}const loggerDebug=a28_0x2de824['debug'];export function pointToSegmentDistance(_0x173eb9,_0x39c540,_0xad1ec9,_0xa06ac7,_0x5cca2d,_0x20f65d){const _0x2f3382=_0x5cca2d-_0xad1ec9;function _0x16e862(_0x47a0e5,_0x48c009){return a28_0x4636(_0x47a0e5- -0x13c,_0x48c009);}const _0x25e23c=_0x20f65d-_0xa06ac7,_0x5bdbc1=_0x2f3382*_0x2f3382+_0x25e23c*_0x25e23c;if(_0x5bdbc1===0x0)return Math[_0x16e862(-0x13c,-0x14e)](_0x173eb9-_0xad1ec9,_0x39c540-_0xa06ac7);let _0x15f741=((_0x173eb9-_0xad1ec9)*_0x2f3382+(_0x39c540-_0xa06ac7)*_0x25e23c)/_0x5bdbc1;_0x15f741=Math['max'](0x0,Math['min'](0x1,_0x15f741));const _0x174096=_0xad1ec9+_0x15f741*_0x2f3382,_0x481708=_0xa06ac7+_0x15f741*_0x25e23c;return Math['hypot'](_0x173eb9-_0x174096,_0x39c540-_0x481708);}export class RoutingGrid{constructor(_0x1c3855,_0x316392,_0x40390e,_0x1d20bb=![]){this[_0x51f18c(-0x3f3,-0x3df)]=_0x1d20bb,this['bounds']=_0x1c3855,this['gridResolution']=_0x316392,this[_0x51f18c(-0x3e8,-0x3de)]=_0x40390e,this['cells']=new Map(),this['obstacles']=new Map();function _0x51f18c(_0x47bcdd,_0x27ad9e){return a28_0x4636(_0x27ad9e- -0x3e0,_0x47bcdd);}this['maxObstacleClearance']=0x0,this['gridWidth']=Math['ceil']((_0x1c3855['maxX']-_0x1c3855['minX'])/_0x316392),this['gridHeight']=Math[_0x51f18c(-0x3d8,-0x3dd)]((_0x1c3855['maxY']-_0x1c3855['minY'])/_0x316392),this['maxObstacleHalfWidthMm']=0x0,this['debug']&&(loggerDebug&&loggerDebug(a28_0x357743['blue'](_0x51f18c(-0x3e6,-0x3dc)+this['gridWidth']+'x'+this[_0x51f18c(-0x3d1,-0x3db)]+'\x20cells\x20('+this[_0x51f18c(-0x3df,-0x3da)]*this['gridHeight']*_0x40390e['length']+'\x20total\x20across\x20'+_0x40390e['length']+'\x20layers)')),loggerDebug&&loggerDebug(a28_0x357743['blue']('[RoutingGrid]\x20Resolution:\x20'+_0x316392+'mm,\x20Bounds:\x20'+_0x1c3855[_0x51f18c(-0x3d9,-0x3d9)]+','+_0x1c3855['minY']+'\x20to\x20'+_0x1c3855['maxX']+','+_0x1c3855[_0x51f18c(-0x3c8,-0x3d8)])));}[a28_0x2741aa(-0x1ac,-0x1ab)](_0x2a1611){const _0x16354e=_0x2a1611[_0x2c556b(-0x27b,-0x28b)]+'_'+Date['now']()+'_'+Math['random']()['toString'](0x24)['substr'](0x2,0x9);this['obstacles'][_0x2c556b(-0x27a,-0x27c)](_0x16354e,{..._0x2a1611});const _0x52503b=_0x3c8ec4=>{if(!_0x3c8ec4||_0x3c8ec4['length']===0x0)return[];if(_0x3c8ec4['some'](_0x1845c9=>_0x1845c9==='*.Cu'))return this['layers'];return _0x3c8ec4;},_0x1c42f5=_0x52503b(_0x2a1611['layers']);for(const _0x10f0be of _0x1c42f5){if(!this['layers']['includes'](_0x10f0be))continue;const _0x57f8e8=this['worldBoundsToGridBounds'](_0x2a1611[_0x2c556b(-0x279,-0x27f)]['minX'],_0x2a1611['bounds'][_0x2c556b(-0x278,-0x28a)],_0x2a1611[_0x2c556b(-0x279,-0x288)]['minY'],_0x2a1611['bounds']['maxY']),_0x3bfe2e=(_0xd9fd7c,_0x593722,_0x109e22)=>{const _0x21a37e=this['getCellKey'](_0x10f0be,_0xd9fd7c,_0x593722);function _0x12e866(_0x206aef,_0xed1cfa){return a28_0x4636(_0x206aef-0x155,_0xed1cfa);}const _0x58bee8=this['cells']['get'](_0x21a37e);if(_0x58bee8){_0x58bee8['occupied']=!![];(_0x2a1611['type']==='keepout'||_0x2a1611[_0x12e866(0x15f,0x155)]==='outline')&&(_0x58bee8['absoluteBlock']=!![]);_0x2a1611['type']==='pad'&&(_0x58bee8[_0x12e866(0x163,0x177)]=!![]);const _0x1c9b65=_0x2a1611['clearance']??0x0;_0x1c9b65>(_0x58bee8['clearance']??0x0)&&(_0x58bee8['clearance']=_0x1c9b65);typeof _0x109e22==='number'&&(_0x58bee8['obstacleHalfWidthMm']=Math['max'](_0x58bee8['obstacleHalfWidthMm']??0x0,_0x109e22));if(_0x2a1611['net']){if(!_0x58bee8['net'])_0x58bee8[_0x12e866(0x164,0x16a)]=_0x2a1611['net'];else{if(_0x58bee8[_0x12e866(0x164,0x172)]===_0x2a1611['net']){}else{}}}_0x2a1611['isManualRoute']&&(_0x58bee8[_0x12e866(0x165,0x170)]=!![],_0x58bee8['cost']=Math[_0x12e866(0x166,0x164)](_0x58bee8[_0x12e866(0x167,0x153)],0.2)),!_0x58bee8['obstacleIds']&&(_0x58bee8['obstacleIds']=[]),!_0x58bee8['obstacleIds'][_0x12e866(0x168,0x165)](_0x16354e)&&_0x58bee8['obstacleIds']['push'](_0x16354e);}else{const _0x2bd2e1=_0x2a1611['clearance']??0x0;this['cells']['set'](_0x21a37e,{'x':_0xd9fd7c,'y':_0x593722,'layer':_0x10f0be,'occupied':!![],'net':_0x2a1611['net'],'isManualRoute':_0x2a1611[_0x12e866(0x165,0x16a)],'absoluteBlock':_0x2a1611['type']==='keepout'||_0x2a1611['type']==='outline'?!![]:undefined,'pad':_0x2a1611[_0x12e866(0x15f,0x156)]===_0x12e866(0x163,0x159)?!![]:undefined,'cost':_0x2a1611['isManualRoute']?0.2:0x1,'clearance':_0x2bd2e1>0x0?_0x2bd2e1:undefined,'obstacleHalfWidthMm':typeof _0x109e22==='number'?_0x109e22:undefined,'obstacleIds':[_0x16354e]});}},_0x5d3141=_0x2a1611['segment'];if(_0x2a1611['type']==='track'&&_0x5d3141){const _0x30cb15=_0x5d3141['width']/0x2,_0x163b9e=(_0x9da148,_0x3bb276,_0x55698b,_0x4b0223,_0x4ea04b,_0x56fd1c)=>_0x9da148>=_0x55698b&&_0x9da148<=_0x4ea04b&&_0x3bb276>=_0x4b0223&&_0x3bb276<=_0x56fd1c,_0x1ec663=(_0x4450f6,_0x393fc6,_0x36fe11,_0x48cdbc,_0x2b0f5e,_0x4dcedc)=>{const _0xd3c9dc=(_0x48cdbc-_0x393fc6)*(_0x2b0f5e-_0x36fe11)-(_0x36fe11-_0x4450f6)*(_0x4dcedc-_0x48cdbc);if(Math['abs'](_0xd3c9dc)<1e-12)return 0x0;return _0xd3c9dc>0x0?0x1:0x2;},_0x30e30f=(_0x131b78,_0x1a46d8,_0x56a190,_0x56c9d4,_0x2d15bb,_0x4e58f6)=>_0x2d15bb<=Math['max'](_0x131b78,_0x56a190)+1e-12&&_0x2d15bb+1e-12>=Math['min'](_0x131b78,_0x56a190)&&_0x4e58f6<=Math[_0x2c556b(-0x271,-0x279)](_0x1a46d8,_0x56c9d4)+1e-12&&_0x4e58f6+1e-12>=Math[_0x2c556b(-0x274,-0x25e)](_0x1a46d8,_0x56c9d4),_0x34c444=(_0x45ad6b,_0x5ecb6e,_0x3e1b47,_0x52788c,_0x57a756,_0x488d8e,_0xfc05bf,_0x9dc426)=>{const _0x1d0333=_0x1ec663(_0x45ad6b,_0x5ecb6e,_0x3e1b47,_0x52788c,_0x57a756,_0x488d8e),_0x10875f=_0x1ec663(_0x45ad6b,_0x5ecb6e,_0x3e1b47,_0x52788c,_0xfc05bf,_0x9dc426),_0x14d044=_0x1ec663(_0x57a756,_0x488d8e,_0xfc05bf,_0x9dc426,_0x45ad6b,_0x5ecb6e),_0x16b823=_0x1ec663(_0x57a756,_0x488d8e,_0xfc05bf,_0x9dc426,_0x3e1b47,_0x52788c);if(_0x1d0333!==_0x10875f&&_0x14d044!==_0x16b823)return!![];if(_0x1d0333===0x0&&_0x30e30f(_0x45ad6b,_0x5ecb6e,_0x3e1b47,_0x52788c,_0x57a756,_0x488d8e))return!![];if(_0x10875f===0x0&&_0x30e30f(_0x45ad6b,_0x5ecb6e,_0x3e1b47,_0x52788c,_0xfc05bf,_0x9dc426))return!![];if(_0x14d044===0x0&&_0x30e30f(_0x57a756,_0x488d8e,_0xfc05bf,_0x9dc426,_0x45ad6b,_0x5ecb6e))return!![];if(_0x16b823===0x0&&_0x30e30f(_0x57a756,_0x488d8e,_0xfc05bf,_0x9dc426,_0x3e1b47,_0x52788c))return!![];return![];},_0x58ed32=_0x5d3141['x1'],_0x4c5aa2=_0x5d3141['y1'],_0x2cfb01=_0x5d3141['x2'],_0x281220=_0x5d3141['y2'];for(let _0x47c791=_0x57f8e8['minX'];_0x47c791<=_0x57f8e8['maxX'];_0x47c791++){for(let _0x5e06c1=_0x57f8e8[_0x2c556b(-0x270,-0x268)];_0x5e06c1<=_0x57f8e8['maxY'];_0x5e06c1++){const _0x187f9f=this['gridToWorld'](_0x47c791,_0x5e06c1),_0x53fac7=this['gridResolution']/0x2,_0x2029db=_0x187f9f['x']-_0x53fac7-_0x30cb15,_0x23e9ce=_0x187f9f['x']+_0x53fac7+_0x30cb15,_0x26f9f2=_0x187f9f['y']-_0x53fac7-_0x30cb15,_0x3be828=_0x187f9f['y']+_0x53fac7+_0x30cb15;let _0x578823=_0x163b9e(_0x58ed32,_0x4c5aa2,_0x2029db,_0x26f9f2,_0x23e9ce,_0x3be828)||_0x163b9e(_0x2cfb01,_0x281220,_0x2029db,_0x26f9f2,_0x23e9ce,_0x3be828);if(!_0x578823){const _0x1fade8=[[_0x2029db,_0x26f9f2,_0x23e9ce,_0x26f9f2],[_0x23e9ce,_0x26f9f2,_0x23e9ce,_0x3be828],[_0x23e9ce,_0x3be828,_0x2029db,_0x3be828],[_0x2029db,_0x3be828,_0x2029db,_0x26f9f2]];for(const _0x2dfd2c of _0x1fade8){if(_0x34c444(_0x58ed32,_0x4c5aa2,_0x2cfb01,_0x281220,_0x2dfd2c[0x0],_0x2dfd2c[0x1],_0x2dfd2c[0x2],_0x2dfd2c[0x3])){_0x578823=!![];break;}}}_0x578823&&_0x3bfe2e(_0x47c791,_0x5e06c1,_0x30cb15);}}this[_0x2c556b(-0x26f,-0x261)]=Math[_0x2c556b(-0x271,-0x282)](this['maxObstacleClearance'],_0x2a1611['clearance']??0x0,_0x30cb15),this['maxObstacleHalfWidthMm']=Math[_0x2c556b(-0x271,-0x25c)](this['maxObstacleHalfWidthMm'],_0x30cb15);}else{if(_0x2a1611['type']===_0x2c556b(-0x277,-0x264)&&_0x2a1611['padShape']){const {shape:_0x545825,center:_0x3099a2,width:_0x307c92,height:_0x4c8955,rotation:_0x249f22}=_0x2a1611[_0x2c556b(-0x26e,-0x26a)],_0x2999e7=_0x307c92/0x2,_0x21b438=_0x4c8955/0x2;let _0x46a4ab;if(_0x545825==='circle')_0x46a4ab=Math['min'](_0x2999e7,_0x21b438);else _0x545825===_0x2c556b(-0x26d,-0x25c)?_0x46a4ab=Math['max'](_0x2999e7,_0x21b438):_0x46a4ab=Math['sqrt'](_0x2999e7*_0x2999e7+_0x21b438*_0x21b438);const _0x448ad9=_0x249f22*Math['PI']/0xb4,_0x4b6380=Math[_0x2c556b(-0x26c,-0x264)](_0x448ad9),_0x5dbe85=Math['sin'](_0x448ad9),_0x299841=(_0x35bc3c,_0x1c92d4)=>({'x':_0x3099a2['x']+_0x35bc3c*_0x4b6380-_0x1c92d4*_0x5dbe85,'y':_0x3099a2['y']+_0x35bc3c*_0x5dbe85+_0x1c92d4*_0x4b6380}),_0x224f49=[],_0x54c234=(_0x4d0c0c,_0x4e01f9)=>{_0x224f49['push'](_0x299841(_0x4d0c0c,_0x4e01f9));},_0x35a3b7=0xc;if(_0x545825===_0x2c556b(-0x26b,-0x272)||_0x545825===_0x2c556b(-0x26a,-0x27a))_0x54c234(-_0x2999e7,-_0x21b438),_0x54c234(_0x2999e7,-_0x21b438),_0x54c234(_0x2999e7,_0x21b438),_0x54c234(-_0x2999e7,_0x21b438);else{if(_0x545825===_0x2c556b(-0x269,-0x25d)){const _0xdeb621=Math[_0x2c556b(-0x274,-0x276)](_0x2999e7,_0x21b438);for(let _0x457ecd=0x0;_0x457ecd<_0x35a3b7;_0x457ecd++){const _0x1c1f3f=0x2*Math['PI']*_0x457ecd/_0x35a3b7;_0x54c234(_0xdeb621*Math['cos'](_0x1c1f3f),_0xdeb621*Math['sin'](_0x1c1f3f));}}else{if(_0x545825==='oval'){if(_0x307c92>=_0x4c8955){const _0xc6fe6b=_0x21b438,_0x1faff6=Math['max'](0x0,_0x2999e7-_0xc6fe6b);_0x54c234(-_0x1faff6,_0xc6fe6b),_0x54c234(_0x1faff6,_0xc6fe6b);for(let _0x5c2ad6=0x1;_0x5c2ad6<_0x35a3b7;_0x5c2ad6++){const _0x1fadd4=Math['PI']/0x2-Math['PI']*_0x5c2ad6/_0x35a3b7;_0x54c234(_0x1faff6+_0xc6fe6b*Math['cos'](_0x1fadd4),_0xc6fe6b*Math[_0x2c556b(-0x268,-0x264)](_0x1fadd4));}_0x54c234(_0x1faff6,-_0xc6fe6b),_0x54c234(-_0x1faff6,-_0xc6fe6b);for(let _0x48dedb=0x1;_0x48dedb<_0x35a3b7;_0x48dedb++){const _0x46ff42=-Math['PI']/0x2+Math['PI']*_0x48dedb/_0x35a3b7;_0x54c234(-_0x1faff6+_0xc6fe6b*Math['cos'](_0x46ff42),_0xc6fe6b*Math['sin'](_0x46ff42));}}else{const _0x2006c7=_0x2999e7,_0x304514=Math[_0x2c556b(-0x271,-0x27c)](0x0,_0x21b438-_0x2006c7);for(let _0x3c3029=0x0;_0x3c3029<=_0x35a3b7;_0x3c3029++){const _0xed4c4=Math['PI']-Math['PI']*_0x3c3029/_0x35a3b7;_0x54c234(_0x2006c7*Math['cos'](_0xed4c4),_0x304514+_0x2006c7*Math['sin'](_0xed4c4));}_0x54c234(_0x2006c7,-_0x304514);for(let _0x532391=0x0;_0x532391<=_0x35a3b7;_0x532391++){const _0x334acc=Math['PI']*_0x532391/_0x35a3b7;_0x54c234(_0x2006c7*Math[_0x2c556b(-0x26c,-0x281)](_0x334acc),-_0x304514+_0x2006c7*Math['sin'](_0x334acc));}_0x54c234(-_0x2006c7,_0x304514);}}else for(let _0x25e7c8=_0x57f8e8['minX'];_0x25e7c8<=_0x57f8e8['maxX'];_0x25e7c8++){for(let _0x5d6994=_0x57f8e8['minY'];_0x5d6994<=_0x57f8e8['maxY'];_0x5d6994++){_0x3bfe2e(_0x25e7c8,_0x5d6994);}}}}if(_0x224f49['length']>0x0){const _0x8cd1af=(_0x3cc204,_0x2ab792)=>{function _0x44c0bc(_0x590395,_0x5efa54){return a28_0x4636(_0x5efa54- -0x2fd,_0x590395);}let _0xa9c224=![];for(let _0xe71744=0x0,_0x1b3e13=_0x224f49['length']-0x1;_0xe71744<_0x224f49[_0x44c0bc(-0x2e6,-0x2df)];_0x1b3e13=_0xe71744++){const _0x29d93d=_0x224f49[_0xe71744]['x'],_0x16db39=_0x224f49[_0xe71744]['y'],_0x65b07c=_0x224f49[_0x1b3e13]['x'],_0x4a45b1=_0x224f49[_0x1b3e13]['y'],_0x103f84=_0x16db39>_0x2ab792!==_0x4a45b1>_0x2ab792&&_0x3cc204<(_0x65b07c-_0x29d93d)*(_0x2ab792-_0x16db39)/(_0x4a45b1-_0x16db39||1e-12)+_0x29d93d;if(_0x103f84)_0xa9c224=!_0xa9c224;}return _0xa9c224;},_0x4d21d9=(_0x132058,_0x2fcf51,_0x57909b,_0x176669,_0x134ca6,_0x142673)=>_0x134ca6<=Math['max'](_0x132058,_0x57909b)+1e-12&&_0x134ca6+1e-12>=Math['min'](_0x132058,_0x57909b)&&_0x142673<=Math['max'](_0x2fcf51,_0x176669)+1e-12&&_0x142673+1e-12>=Math['min'](_0x2fcf51,_0x176669),_0x54a5bf=(_0x249546,_0x1ec0ca,_0x1472e2,_0x55cc92,_0x37543e,_0xca13e9)=>{const _0x1890eb=(_0x55cc92-_0x1ec0ca)*(_0x37543e-_0x1472e2)-(_0x1472e2-_0x249546)*(_0xca13e9-_0x55cc92);if(Math[_0x2c798e(-0xc6,-0xc6)](_0x1890eb)<1e-12)return 0x0;function _0x2c798e(_0x952ade,_0xd7f8e7){return a28_0x4636(_0xd7f8e7- -0xe5,_0x952ade);}return _0x1890eb>0x0?0x1:0x2;},_0x136f6d=(_0x238475,_0x5f2fde,_0x44b9f2,_0x6b9981,_0x47d3f3,_0x4fff1f,_0x99f994,_0x5ef282)=>{const _0x1d6b2c=_0x54a5bf(_0x238475,_0x5f2fde,_0x44b9f2,_0x6b9981,_0x47d3f3,_0x4fff1f),_0x14f783=_0x54a5bf(_0x238475,_0x5f2fde,_0x44b9f2,_0x6b9981,_0x99f994,_0x5ef282),_0x23d0f4=_0x54a5bf(_0x47d3f3,_0x4fff1f,_0x99f994,_0x5ef282,_0x238475,_0x5f2fde),_0x447587=_0x54a5bf(_0x47d3f3,_0x4fff1f,_0x99f994,_0x5ef282,_0x44b9f2,_0x6b9981);if(_0x1d6b2c!==_0x14f783&&_0x23d0f4!==_0x447587)return!![];if(_0x1d6b2c===0x0&&_0x4d21d9(_0x238475,_0x5f2fde,_0x44b9f2,_0x6b9981,_0x47d3f3,_0x4fff1f))return!![];if(_0x14f783===0x0&&_0x4d21d9(_0x238475,_0x5f2fde,_0x44b9f2,_0x6b9981,_0x99f994,_0x5ef282))return!![];if(_0x23d0f4===0x0&&_0x4d21d9(_0x47d3f3,_0x4fff1f,_0x99f994,_0x5ef282,_0x238475,_0x5f2fde))return!![];if(_0x447587===0x0&&_0x4d21d9(_0x47d3f3,_0x4fff1f,_0x99f994,_0x5ef282,_0x44b9f2,_0x6b9981))return!![];return![];},_0x1c9513=this[_0x2c556b(-0x265,-0x26c)]/0x2;for(let _0x863ab5=_0x57f8e8['minX'];_0x863ab5<=_0x57f8e8[_0x2c556b(-0x278,-0x27f)];_0x863ab5++){for(let _0x3af485=_0x57f8e8['minY'];_0x3af485<=_0x57f8e8['maxY'];_0x3af485++){const _0x4b1c56=this[_0x2c556b(-0x264,-0x269)](_0x863ab5,_0x3af485),_0x123d39=_0x4b1c56['x']-_0x1c9513,_0x1a018a=_0x4b1c56['x']+_0x1c9513,_0x496119=_0x4b1c56['y']-_0x1c9513,_0x4905cb=_0x4b1c56['y']+_0x1c9513;let _0x3868a9=![];if(!_0x3868a9){const _0x756883=[{'x':_0x123d39,'y':_0x496119},{'x':_0x1a018a,'y':_0x496119},{'x':_0x1a018a,'y':_0x4905cb},{'x':_0x123d39,'y':_0x4905cb}];for(const _0x602329 of _0x756883){if(_0x8cd1af(_0x602329['x'],_0x602329['y'])){_0x3868a9=!![];break;}}}if(!_0x3868a9){const _0x58195b=(_0x5acb7e,_0x56add6)=>_0x5acb7e>=_0x123d39-1e-12&&_0x5acb7e<=_0x1a018a+1e-12&&_0x56add6>=_0x496119-1e-12&&_0x56add6<=_0x4905cb+1e-12;for(let _0x38197c=0x0;_0x38197c<_0x224f49[_0x2c556b(-0x267,-0x259)];_0x38197c++){if(_0x58195b(_0x224f49[_0x38197c]['x'],_0x224f49[_0x38197c]['y'])){_0x3868a9=!![];break;}}}if(!_0x3868a9){const _0x279c28=[[_0x123d39,_0x496119,_0x1a018a,_0x496119],[_0x1a018a,_0x496119,_0x1a018a,_0x4905cb],[_0x1a018a,_0x4905cb,_0x123d39,_0x4905cb],[_0x123d39,_0x4905cb,_0x123d39,_0x496119]];for(let _0x5d8b8b=0x0,_0x35d56b=_0x224f49['length']-0x1;_0x5d8b8b<_0x224f49['length'];_0x35d56b=_0x5d8b8b++){const _0x33e2d7=_0x224f49[_0x35d56b]['x'],_0x227022=_0x224f49[_0x35d56b]['y'],_0x748685=_0x224f49[_0x5d8b8b]['x'],_0x4121b4=_0x224f49[_0x5d8b8b]['y'];for(const _0x4a19d4 of _0x279c28){if(_0x136f6d(_0x33e2d7,_0x227022,_0x748685,_0x4121b4,_0x4a19d4[0x0],_0x4a19d4[0x1],_0x4a19d4[0x2],_0x4a19d4[0x3])){_0x3868a9=!![];break;}}if(_0x3868a9)break;}}if(_0x3868a9)_0x3bfe2e(_0x863ab5,_0x3af485,_0x46a4ab);}}this['maxObstacleHalfWidthMm']=Math[_0x2c556b(-0x271,-0x25c)](this[_0x2c556b(-0x263,-0x24e)],_0x46a4ab);}}else{if(_0x2a1611[_0x2c556b(-0x262,-0x260)]&&_0x2a1611[_0x2c556b(-0x262,-0x275)]['points']&&_0x2a1611['polygon']['points']['length']>=0x3){const _0x333cf4=_0x2a1611['polygon']['points'],_0x67a175=(_0x4b3abb,_0x4c3195)=>{let _0x41d644=![];function _0x4a93a9(_0x42f8dd,_0x49797f){return a28_0x4636(_0x42f8dd-0x3ae,_0x49797f);}for(let _0x515793=0x0,_0x34975d=_0x333cf4['length']-0x1;_0x515793<_0x333cf4[_0x4a93a9(0x3cc,0x3dd)];_0x34975d=_0x515793++){const _0x32cd9d=_0x333cf4[_0x515793]['x'],_0x4497da=_0x333cf4[_0x515793]['y'],_0x1917a2=_0x333cf4[_0x34975d]['x'],_0x1dbf43=_0x333cf4[_0x34975d]['y'],_0x133af2=_0x4497da>_0x4c3195!==_0x1dbf43>_0x4c3195&&_0x4b3abb<(_0x1917a2-_0x32cd9d)*(_0x4c3195-_0x4497da)/(_0x1dbf43-_0x4497da||1e-12)+_0x32cd9d;if(_0x133af2)_0x41d644=!_0x41d644;}return _0x41d644;},_0x70afa2=(_0x11e405,_0x1bf0a5,_0x534d07,_0x3fb889,_0xbd8a30,_0x14a033)=>{return _0xbd8a30<=Math['max'](_0x11e405,_0x534d07)+1e-12&&_0xbd8a30+1e-12>=Math['min'](_0x11e405,_0x534d07)&&_0x14a033<=Math['max'](_0x1bf0a5,_0x3fb889)+1e-12&&_0x14a033+1e-12>=Math['min'](_0x1bf0a5,_0x3fb889);},_0xd14c63=(_0x577825,_0x127ad9,_0x1e94a7,_0x19460c,_0x5027fa,_0x617bfa)=>{const _0xe5c5bf=(_0x19460c-_0x127ad9)*(_0x5027fa-_0x1e94a7)-(_0x1e94a7-_0x577825)*(_0x617bfa-_0x19460c);if(Math['abs'](_0xe5c5bf)<1e-12)return 0x0;return _0xe5c5bf>0x0?0x1:0x2;},_0x35538f=(_0x338f6e,_0x50ccde,_0x387013,_0x185115,_0x272c0a,_0xf4ea84,_0x546895,_0xc2ccf9)=>{const _0x4c480b=_0xd14c63(_0x338f6e,_0x50ccde,_0x387013,_0x185115,_0x272c0a,_0xf4ea84),_0x307191=_0xd14c63(_0x338f6e,_0x50ccde,_0x387013,_0x185115,_0x546895,_0xc2ccf9),_0x412131=_0xd14c63(_0x272c0a,_0xf4ea84,_0x546895,_0xc2ccf9,_0x338f6e,_0x50ccde),_0x64bd64=_0xd14c63(_0x272c0a,_0xf4ea84,_0x546895,_0xc2ccf9,_0x387013,_0x185115);if(_0x4c480b!==_0x307191&&_0x412131!==_0x64bd64)return!![];if(_0x4c480b===0x0&&_0x70afa2(_0x338f6e,_0x50ccde,_0x387013,_0x185115,_0x272c0a,_0xf4ea84))return!![];if(_0x307191===0x0&&_0x70afa2(_0x338f6e,_0x50ccde,_0x387013,_0x185115,_0x546895,_0xc2ccf9))return!![];if(_0x412131===0x0&&_0x70afa2(_0x272c0a,_0xf4ea84,_0x546895,_0xc2ccf9,_0x338f6e,_0x50ccde))return!![];if(_0x64bd64===0x0&&_0x70afa2(_0x272c0a,_0xf4ea84,_0x546895,_0xc2ccf9,_0x387013,_0x185115))return!![];return![];},_0x431c2a=this['gridResolution']/0x2;for(let _0xdf7c26=_0x57f8e8['minX'];_0xdf7c26<=_0x57f8e8['maxX'];_0xdf7c26++){for(let _0x4172f0=_0x57f8e8['minY'];_0x4172f0<=_0x57f8e8[_0x2c556b(-0x27d,-0x26e)];_0x4172f0++){const _0x35a13e=this['gridToWorld'](_0xdf7c26,_0x4172f0),_0x3cd7d1=_0x35a13e['x']-_0x431c2a,_0x38889c=_0x35a13e['x']+_0x431c2a,_0x4fc168=_0x35a13e['y']-_0x431c2a,_0x22f7f5=_0x35a13e['y']+_0x431c2a,_0x2b6377=[{'x':_0x3cd7d1,'y':_0x4fc168},{'x':_0x38889c,'y':_0x4fc168},{'x':_0x38889c,'y':_0x22f7f5},{'x':_0x3cd7d1,'y':_0x22f7f5}];let _0x38a554=![];for(const _0x2ede3d of _0x2b6377){if(_0x67a175(_0x2ede3d['x'],_0x2ede3d['y'])){_0x38a554=!![];break;}}const _0x4eb697=(_0x49a80b,_0x922920)=>_0x49a80b>=_0x3cd7d1-1e-12&&_0x49a80b<=_0x38889c+1e-12&&_0x922920>=_0x4fc168-1e-12&&_0x922920<=_0x22f7f5+1e-12;if(!_0x38a554)for(let _0x5667ce=0x0;_0x5667ce<_0x333cf4['length'];_0x5667ce++){if(_0x4eb697(_0x333cf4[_0x5667ce]['x'],_0x333cf4[_0x5667ce]['y'])){_0x38a554=!![];break;}}if(!_0x38a554){const _0x38de72=[[_0x3cd7d1,_0x4fc168,_0x38889c,_0x4fc168],[_0x38889c,_0x4fc168,_0x38889c,_0x22f7f5],[_0x38889c,_0x22f7f5,_0x3cd7d1,_0x22f7f5],[_0x3cd7d1,_0x22f7f5,_0x3cd7d1,_0x4fc168]];for(let _0x59ba87=0x0,_0x565c23=_0x333cf4[_0x2c556b(-0x267,-0x276)]-0x1;_0x59ba87<_0x333cf4[_0x2c556b(-0x267,-0x273)];_0x565c23=_0x59ba87++){const _0x90226=_0x333cf4[_0x565c23]['x'],_0x5a858e=_0x333cf4[_0x565c23]['y'],_0xbed42b=_0x333cf4[_0x59ba87]['x'],_0x32e387=_0x333cf4[_0x59ba87]['y'];for(const _0x1c89b3 of _0x38de72){if(_0x35538f(_0x90226,_0x5a858e,_0xbed42b,_0x32e387,_0x1c89b3[0x0],_0x1c89b3[0x1],_0x1c89b3[0x2],_0x1c89b3[0x3])){_0x38a554=!![];break;}}if(_0x38a554)break;}}if(_0x38a554)_0x3bfe2e(_0xdf7c26,_0x4172f0);}}}else for(let _0x2451b2=_0x57f8e8[_0x2c556b(-0x27e,-0x28a)];_0x2451b2<=_0x57f8e8[_0x2c556b(-0x278,-0x279)];_0x2451b2++){for(let _0xed9f48=_0x57f8e8['minY'];_0xed9f48<=_0x57f8e8['maxY'];_0xed9f48++){_0x3bfe2e(_0x2451b2,_0xed9f48);}}}}}function _0x2c556b(_0x3d68b0,_0x6bc73f){return a28_0x4636(_0x3d68b0- -0x285,_0x6bc73f);}this['maxObstacleClearance']=Math[_0x2c556b(-0x271,-0x26f)](this['maxObstacleClearance'],_0x2a1611['clearance']??0x0);}['isPadCell'](_0x2f5e62,_0x19a8eb,_0x25728a){const _0x30c9b6=this[_0x2b952d(0x2fb,0x2fc)](_0x25728a,_0x2f5e62,_0x19a8eb),_0x582e39=this['cells']['get'](_0x30c9b6);function _0x2b952d(_0x51eb17,_0x2c6754){return a28_0x4636(_0x51eb17-0x2d7,_0x2c6754);}return!!_0x582e39?.['pad'];}['hasPadWithinClearance'](_0x4ba63a,_0x18f1ba,_0x24c9e3,_0x4f0909){if(_0x4f0909<=0x0)return![];function _0x1627d2(_0x262cfe,_0x451da5){return a28_0x4636(_0x262cfe- -0x28c,_0x451da5);}const _0x12deea=Math['ceil']((_0x4f0909+this['maxObstacleHalfWidthMm'])/this['gridResolution']);for(let _0x378324=-_0x12deea;_0x378324<=_0x12deea;_0x378324++){for(let _0x3d9bd2=-_0x12deea;_0x3d9bd2<=_0x12deea;_0x3d9bd2++){const _0x51a203=_0x4ba63a+_0x378324,_0x3ea143=_0x18f1ba+_0x3d9bd2;if(!this['isInBounds'](_0x51a203,_0x3ea143))continue;const _0x2e0926=this['cells']['get'](this['getCellKey'](_0x24c9e3,_0x51a203,_0x3ea143));if(!_0x2e0926?.['pad'])continue;const _0x403214=_0x2e0926['obstacleHalfWidthMm']??0x0,_0x1a5ed5=_0x2e0926['clearance']??0x0,_0x22d183=Math[_0x1627d2(-0x278,-0x276)](_0x4f0909,_0x1a5ed5),_0x529933=Math['sqrt'](_0x378324*_0x378324+_0x3d9bd2*_0x3d9bd2)*this[_0x1627d2(-0x26c,-0x260)],_0x4eb27b=Math['max'](0x0,_0x529933-_0x403214);if(_0x4eb27b<_0x22d183)return!![];}}return![];}[a28_0x2741aa(-0x190,-0x18e)](_0x50722d,_0x170e8f,_0x564c66,_0x1731bf=0x0,_0x5e8af0,_0x5d2387=![],_0xb456b9=![]){function _0x41e678(_0x195aa1,_0xcafce8){return a28_0x4636(_0x195aa1-0xcb,_0xcafce8);}if(!this[_0x41e678(0xf1,0xe1)](_0x50722d,_0x170e8f))return!![];if(_0x1731bf<=0x0&&!_0x5d2387)return this['isCellOccupied'](_0x50722d,_0x170e8f,_0x564c66,_0x5e8af0);const _0x5343c8=_0x5d2387?_0xb456b9?_0x1731bf+this[_0x41e678(0xe1,0xd4)]+this['maxObstacleHalfWidthMm']:Math[_0x41e678(0xdf,0xf5)](_0x1731bf,this['maxObstacleClearance']):_0x1731bf,_0x21cc35=Math['ceil'](_0x5343c8/this['gridResolution']);for(let _0xd3a0f5=-_0x21cc35;_0xd3a0f5<=_0x21cc35;_0xd3a0f5++){for(let _0x2b2141=-_0x21cc35;_0x2b2141<=_0x21cc35;_0x2b2141++){const _0x32afe7=_0x50722d+_0xd3a0f5,_0x4e7dc1=_0x170e8f+_0x2b2141;if(!this['isInBounds'](_0x32afe7,_0x4e7dc1))continue;const _0x185440=this['getCellKey'](_0x564c66,_0x32afe7,_0x4e7dc1),_0x6e645c=this['cells']['get'](_0x185440);if(!_0x6e645c||!_0x6e645c['occupied'])continue;if(_0x5e8af0&&_0x6e645c['net']&&_0x6e645c['net']===_0x5e8af0&&!_0x6e645c['isManualRoute']&&!_0x6e645c['absoluteBlock'])continue;const _0x2be820=_0x5d2387?_0x6e645c['clearance']??0x0:0x0,_0x3292e1=_0x6e645c['obstacleHalfWidthMm']??0x0,_0x1a4348=_0xb456b9?_0x1731bf+_0x2be820:Math['max'](_0x1731bf,_0x2be820),_0x303441=_0x1a4348+_0x3292e1,_0x28cb04=Math['sqrt'](_0xd3a0f5*_0xd3a0f5+_0x2b2141*_0x2b2141)*this[_0x41e678(0xeb,0xf8)],_0x2c7391=Math['max'](0x0,_0x28cb04-_0x3292e1);if(_0x6e645c['absoluteBlock']&&_0x2c7391<=_0x303441)return!![];if(_0x6e645c['isManualRoute']){if(!(_0x5e8af0&&_0x6e645c[_0x41e678(0xda,0xf0)]&&_0x6e645c[_0x41e678(0xda,0xd2)]===_0x5e8af0)){if(_0x2c7391<=_0x303441)return!![];}continue;}if(_0x2c7391<=_0x303441)return!![];}}return![];}[a28_0x2741aa(-0x18e,-0x19b)](_0x425dac,_0xa47ca,_0x652997,_0x1ce4ee,_0x48e7fb){for(const [_0x257031,_0x53e373]of this['cells']){if(!_0x53e373['occupied']||!_0x257031['startsWith'](_0x652997+':'))continue;if(_0x48e7fb&&_0x53e373['net']&&_0x53e373['net']===_0x48e7fb&&!_0x53e373['isManualRoute']&&!_0x53e373['absoluteBlock'])continue;if(_0x53e373['obstacleHalfWidthMm']!==undefined&&_0x53e373['obstacleIds'])for(const _0x42862f of _0x53e373['obstacleIds']){const _0x2cd5b2=this['getCellObstacle'](_0x42862f);if(_0x2cd5b2?.['segment']){const _0x4e7137=_0x2cd5b2['segment'],_0x4462ba=_0x4e7137['width']/0x2,_0x472dcd=pointToSegmentDistance(_0x425dac,_0xa47ca,_0x4e7137['x1'],_0x4e7137['y1'],_0x4e7137['x2'],_0x4e7137['y2']),_0x5d8e7f=_0x2cd5b2['clearance']||0x0,_0x16eadb=_0x4462ba+_0x5d8e7f+_0x1ce4ee;if(_0x472dcd<=_0x16eadb)return!![];}}}return![];}['getCellObstacle'](_0x259560){function _0x439044(_0x1c089f,_0x285911){return a28_0x4636(_0x285911-0x1f6,_0x1c089f);}return this['obstacles'][_0x439044(0x20c,0x21e)](_0x259560)||null;}['gridToWorldX'](_0x3019c3){return this['bounds']['minX']+(_0x3019c3+0.5)*this['gridResolution'];}['gridToWorldY'](_0x5d8930){return this['bounds']['minY']+(_0x5d8930+0.5)*this['gridResolution'];}['getWorldXFromGrid'](_0xb0a3b6){function _0xfb9d8a(_0x391693,_0x5227cb){return a28_0x4636(_0x5227cb- -0x68,_0x391693);}return this['bounds'][_0xfb9d8a(-0x66,-0x61)]+_0xb0a3b6*this['gridResolution'];}['getWorldYFromGrid'](_0x28c3fe){return this['bounds']['minY']+_0x28c3fe*this['gridResolution'];}['isCellOccupied'](_0x5ce676,_0x2757c7,_0xd4c9c9,_0x3d43eb){function _0x4df209(_0x1fd4e7,_0x56e2fc){return a28_0x4636(_0x56e2fc-0x92,_0x1fd4e7);}const _0x5bbd4b=this['getCellKey'](_0xd4c9c9,_0x5ce676,_0x2757c7),_0x2e6725=this[_0x4df209(0xb5,0xbb)][_0x4df209(0xc2,0xba)](_0x5bbd4b);if(!_0x2e6725)return![];if(!_0x2e6725['occupied'])return![];if(_0x2e6725[_0x4df209(0xb5,0xbc)])return!![];if(_0x2e6725['isManualRoute']){if(_0x3d43eb&&_0x2e6725[_0x4df209(0xa1,0xa1)]&&_0x2e6725['net']===_0x3d43eb)return![];return!![];}if(_0x3d43eb&&_0x2e6725['net']&&_0x2e6725['net']===_0x3d43eb)return![];return!![];}['getCellCost'](_0x1aa604,_0x5be158,_0x2226fe){const _0x40d5f2=this['getCellKey'](_0x2226fe,_0x1aa604,_0x5be158),_0x5a67f8=this['cells']['get'](_0x40d5f2);return _0x5a67f8?.['cost']||0x1;}['setCellCost'](_0x39ecd2,_0x246855,_0x21ae8c,_0x1d0bf5){const _0x291310=this['getCellKey'](_0x21ae8c,_0x39ecd2,_0x246855);let _0x38047a=this['cells']['get'](_0x291310);!_0x38047a?(_0x38047a={'x':_0x39ecd2,'y':_0x246855,'layer':_0x21ae8c,'occupied':![],'cost':_0x1d0bf5},this['cells']['set'](_0x291310,_0x38047a)):_0x38047a['cost']=_0x1d0bf5;}['worldToGrid'](_0x382ed2,_0x57e6b6){function _0x27a7bd(_0x29702c,_0x3500c6){return a28_0x4636(_0x3500c6- -0x3cc,_0x29702c);}return{'x':Math['floor']((_0x382ed2-this['bounds'][_0x27a7bd(-0x3c2,-0x3c5)])/this[_0x27a7bd(-0x3ba,-0x3ac)]),'y':Math['floor']((_0x57e6b6-this['bounds']['minY'])/this[_0x27a7bd(-0x398,-0x3ac)])};}[a28_0x2741aa(-0x194,-0x1a1)](_0x1cbc1e,_0x21baaa){function _0x19dc75(_0x5cb7dc,_0x4bd588){return a28_0x4636(_0x4bd588-0xdd,_0x5cb7dc);}return{'x':this[_0x19dc75(0xdb,0xe9)]['minX']+(_0x1cbc1e+0.5)*this[_0x19dc75(0xfc,0xfd)],'y':this[_0x19dc75(0xf8,0xe9)][_0x19dc75(0xde,0xf2)]+(_0x21baaa+0.5)*this[_0x19dc75(0x112,0xfd)]};}['isInBounds'](_0x4c2ca9,_0x55d27e){function _0x3fe4fa(_0x2f9622,_0x47e6a8){return a28_0x4636(_0x47e6a8-0x27d,_0x2f9622);}return _0x4c2ca9>=0x0&&_0x4c2ca9<this['gridWidth']&&_0x55d27e>=0x0&&_0x55d27e<this[_0x3fe4fa(0x287,0x282)];}['getCellKey'](_0x451846,_0xb284d2,_0x261d22){return _0x451846+':'+_0xb284d2+':'+_0x261d22;}['getCell'](_0x5839ef,_0x21d7eb,_0x5e0ff4){const _0x56cb21=this[_0x4dd10b(-0x3d,-0x45)](_0x5e0ff4,_0x5839ef,_0x21d7eb);function _0x4dd10b(_0x4a0e48,_0x24d70b){return a28_0x4636(_0x24d70b- -0x69,_0x4a0e48);}return this[_0x4dd10b(-0x4f,-0x40)]['get'](_0x56cb21);}['worldBoundsToGridBounds'](_0x5274db,_0x3c9495,_0x5a18fd,_0x47c6a0){function _0x2bc1e6(_0x1bb850,_0x394195){return a28_0x4636(_0x1bb850-0x26,_0x394195);}const _0x40d2c0=this['worldToGrid'](_0x5274db,_0x5a18fd),_0x243de5=this['worldToGrid'](_0x3c9495,_0x47c6a0);return{'minX':Math['max'](0x0,_0x40d2c0['x']),'maxX':Math[_0x2bc1e6(0x37,0x4d)](this['gridWidth']-0x1,_0x243de5['x']),'minY':Math['max'](0x0,_0x40d2c0['y']),'maxY':Math[_0x2bc1e6(0x37,0x30)](this['gridHeight']-0x1,_0x243de5['y'])};}['getDimensions'](){function _0x3c53be(_0x18e3e5,_0x5ba433){return a28_0x4636(_0x18e3e5- -0x106,_0x5ba433);}return{'width':this[_0x3c53be(-0x100,-0x112)],'height':this['gridHeight'],'layers':this['layers']['length']};}['getResolution'](){return this['gridResolution'];}['getLayers'](){return[...this['layers']];}['getBounds'](){return{...this['bounds']};}['clear'](){this['cells']['clear']();function _0x47d29e(_0x402c36,_0x42677b){return a28_0x4636(_0x42677b-0x2e8,_0x402c36);}this['maxObstacleClearance']=0x0,this[_0x47d29e(0x309,0x30a)]=0x0,this['debug']&&(loggerDebug&&loggerDebug(a28_0x357743['blue']('[RoutingGrid]\x20Cleared\x20all\x20cells')));}['getStats'](){const _0xd37f9=this['gridWidth']*this['gridHeight']*this['layers']['length'],_0x59d99a=Array[_0x30b3aa(0x36e,0x372)](this['cells']['values']())['filter'](_0x3bc9d3=>_0x3bc9d3['occupied'])['length'];function _0x30b3aa(_0x1d363c,_0x3a1e1c){return a28_0x4636(_0x1d363c-0x343,_0x3a1e1c);}const _0x290d2f=_0xd37f9-_0x59d99a;return{'totalCells':_0xd37f9,'occupiedCells':_0x59d99a,'freeCells':_0x290d2f,'occupancyPercent':_0x59d99a/_0xd37f9*0x64};}}function a28_0x3975(){const _0x21ca63=['hypot','debug','layers','ceil','[RoutingGrid]\x20Created\x20grid:\x20','gridHeight','gridWidth','minX','maxY','addObstacle','type','set','bounds','maxX','pad','net','isManualRoute','min','cost','includes','max','minY','maxObstacleClearance','padShape','oval','cos','rect','roundrect','circle','sin','length','abs','gridResolution','gridToWorld','maxObstacleHalfWidthMm','polygon','getCellKey','isOccupied','isInBounds','checkTrackObstaclePrecise','get','cells','absoluteBlock','from'];a28_0x3975=function(){return _0x21ca63;};return a28_0x3975();}