far-shell-geometry.test.mjs 1.1 KB

1234567891011
  1. import assert from 'node:assert/strict'
  2. import {surveyShell,verifyClosedTriangles} from './far-shell-geometry.mjs'
  3. const a={id:'rect',footprintENU:[[0,0],[10,0],[10,5],[0,5]],foundationBottom:1,positionENU:[5,2.5,2],heightM:8}
  4. const l={id:'l',footprintENU:[[0,0],[10,0],[10,3],[4,3],[4,8],[0,8]],foundationBottom:1,positionENU:[5,4,2],heightM:8}
  5. const collinear={...a,id:'collinear',footprintENU:[[0,0],[5,0],[10,0],[10,5],[0,5],[0,2.5]]}
  6. const shifted={...l,id:'large-coordinates',footprintENU:l.footprintENU.map(([x,y])=>[x+1100,y+1700])}
  7. for(const b of [a,l,collinear,shifted]){const g=surveyShell(b);verifyClosedTriangles([...g.roof,...g.body]);assert.ok(g.triangles<=20_000);assert.equal(g.top,b.positionENU[2]+b.heightM)}
  8. const g=surveyShell(a),complete=[...g.roof,...g.body]
  9. assert.throws(()=>verifyClosedTriangles(complete.slice(1)))
  10. assert.throws(()=>verifyClosedTriangles([complete[0].toReversed(),...complete.slice(1)]))
  11. assert.throws(()=>surveyShell({...a,footprintENU:[[0,0],[1,0]]}));assert.throws(()=>surveyShell({...a,heightM:-1}));console.log(JSON.stringify({passed:true,scope:'closed surveyed exterior shell area/LOD budget/invalid outline rejection'}))