@ifc-lite/viewer 1.26.0 → 1.28.0
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/.turbo/turbo-build.log +45 -38
- package/CHANGELOG.md +93 -0
- package/dist/assets/{basketViewActivator-ZpTYWE3K.js → basketViewActivator-BNRDNuUJ.js} +9 -9
- package/dist/assets/{bcf-Ctcu_Sc2.js → bcf-DCwCuP7n.js} +56 -56
- package/dist/assets/{browser-DXS29_v9.js → browser-BIoDDfBW.js} +1 -1
- package/dist/assets/{cesium-BoVuJvTC.js → cesium-CzZn5yVA.js} +319 -319
- package/dist/assets/{decode-worker-CgM1iNSK.js → decode-worker-Cjign7Zh.js} +1 -1
- package/dist/assets/deflate-DNGgs8Ur.js +1 -0
- package/dist/assets/drawing-2d-D0dDf6Lh.js +257 -0
- package/dist/assets/e57-source-2wI9jkCA.js +1 -0
- package/dist/assets/exceljs.min-DsuzKYnj.js +29 -0
- package/dist/assets/{exporters-DSq76AVM.js → exporters-B9v81gi9.js} +1861 -1524
- package/dist/assets/geometry.worker-Bpa3115V.js +1 -0
- package/dist/assets/{geotiff-A5UjhI6L.js → geotiff-D-YCLS4g.js} +10 -10
- package/dist/assets/html2canvas.esm-Ge7aVWlp.js +5 -0
- package/dist/assets/{ids-DiLcGTer.js → ids-CCpq-5d3.js} +952 -945
- package/dist/assets/ifc-lite_bg-DbgS5EUA.wasm +0 -0
- package/dist/assets/{index-BAH8IJVR.js → index-Bgb3_Pu_.js} +47682 -42474
- package/dist/assets/index-BtbXFKsX.css +1 -0
- package/dist/assets/index.es-CWfqZyyr.js +6866 -0
- package/dist/assets/{jpeg-BzSkwo5D.js → jpeg-DGOAeUqU.js} +1 -1
- package/dist/assets/jspdf.es.min-XPLU2Wkq.js +19571 -0
- package/dist/assets/jspdf.plugin.autotable-BBLUVd7n.js +2 -0
- package/dist/assets/lens-C4p1kQ0p.js +1 -0
- package/dist/assets/{lerc-Cg2Rz-D5.js → lerc-1PMSCHwX.js} +1 -1
- package/dist/assets/{lzw-BBPPLW-0.js → lzw-C65U9lNM.js} +1 -1
- package/dist/assets/{maplibre-gl-Do6O5tDc.js → maplibre-gl-BF3Z0idw.js} +1 -1
- package/dist/assets/{native-bridge-CPojOeGE.js → native-bridge-XxXos6yI.js} +2 -2
- package/dist/assets/{packbits-yLSpjW-V.js → packbits-BdMWXC3m.js} +1 -1
- package/dist/assets/{pako.esm-Cram60i4.js → pako.esm-n3Pgozwg.js} +1 -1
- package/dist/assets/parser.worker-Ddwo3_06.js +182 -0
- package/dist/assets/pdf-CRwaZf3s.js +135 -0
- package/dist/assets/raw-CJgQdyuZ.js +1 -0
- package/dist/assets/{sandbox-CsRXlgCO.js → sandbox-0sDo3g3m.js} +3037 -2554
- package/dist/assets/server-client-cTCJ-853.js +719 -0
- package/dist/assets/{webimage-YafxjjGr.js → webimage-BtakWX7W.js} +1 -1
- package/dist/assets/xlsx-B1YOg2QB.js +142 -0
- package/dist/assets/{zip-BJqVbRkU.js → zip-DFgP-l20.js} +1 -1
- package/dist/assets/{zstd-CkSLOiuu.js → zstd-CmwsbxmM.js} +1 -1
- package/dist/index.html +10 -10
- package/package.json +27 -23
- package/src/components/mcp/PlaygroundChat.tsx +1 -0
- package/src/components/mcp/data.ts +6 -0
- package/src/components/mcp/playground-dispatcher.ts +280 -0
- package/src/components/mcp/playground-files.ts +33 -1
- package/src/components/mcp/types.ts +2 -1
- package/src/components/ui/combo-input.tsx +163 -0
- package/src/components/ui/tabs.tsx +1 -1
- package/src/components/viewer/CommandPalette.tsx +6 -1
- package/src/components/viewer/ComparePanel.tsx +420 -0
- package/src/components/viewer/HierarchyPanel.tsx +46 -7
- package/src/components/viewer/MainToolbar.tsx +19 -2
- package/src/components/viewer/PropertiesPanel.tsx +84 -8
- package/src/components/viewer/SearchInline.tsx +62 -2
- package/src/components/viewer/SearchModal.filter.builder.tsx +24 -393
- package/src/components/viewer/SearchModal.filter.editors.tsx +503 -0
- package/src/components/viewer/SearchModal.filter.tsx +64 -1
- package/src/components/viewer/SearchModal.tsx +19 -6
- package/src/components/viewer/ViewerLayout.tsx +5 -0
- package/src/components/viewer/Viewport.tsx +18 -0
- package/src/components/viewer/hierarchy/HierarchyNode.tsx +3 -3
- package/src/components/viewer/hierarchy/ifc-icons.ts +9 -0
- package/src/components/viewer/hierarchy/treeDataBuilder.ts +87 -0
- package/src/components/viewer/hierarchy/types.ts +1 -0
- package/src/components/viewer/hierarchy/useHierarchyTree.ts +6 -2
- package/src/components/viewer/lists/ColumnHeaderMenu.tsx +84 -0
- package/src/components/viewer/lists/ListBuilder.tsx +789 -280
- package/src/components/viewer/lists/ListGroupingBar.tsx +72 -0
- package/src/components/viewer/lists/ListPanel.tsx +49 -5
- package/src/components/viewer/lists/ListResultsTable.tsx +270 -176
- package/src/components/viewer/lists/list-table-utils.ts +123 -0
- package/src/components/viewer/properties/MaterialTotalsPanel.tsx +283 -0
- package/src/generated/mcp-catalog.json +4 -0
- package/src/hooks/federationLoadGate.test.ts +12 -2
- package/src/hooks/federationLoadGate.ts +9 -2
- package/src/hooks/ingest/federationAlign.ts +481 -0
- package/src/hooks/ingest/viewerModelIngest.ts +3 -212
- package/src/hooks/source-key.ts +35 -0
- package/src/hooks/useAlignmentLines3D.ts +1 -26
- package/src/hooks/useCompare.ts +0 -0
- package/src/hooks/useCompareOverlay.ts +119 -0
- package/src/hooks/useDrawingGeneration.ts +23 -1
- package/src/hooks/useGridLines3D.ts +140 -0
- package/src/hooks/useIfc.ts +1 -1
- package/src/hooks/useIfcCache.ts +32 -9
- package/src/hooks/useIfcFederation.ts +42 -810
- package/src/hooks/useIfcLoader.ts +361 -488
- package/src/hooks/useIfcServer.ts +3 -0
- package/src/hooks/useLens.ts +5 -1
- package/src/hooks/useSymbolicAnnotations.ts +70 -38
- package/src/lib/compare/buildFingerprints.ts +173 -0
- package/src/lib/compare/describeChange.ts +0 -0
- package/src/lib/compare/geometricData.test.ts +54 -0
- package/src/lib/compare/geometricData.ts +37 -0
- package/src/lib/compare/overlay.test.ts +99 -0
- package/src/lib/compare/overlay.ts +91 -0
- package/src/lib/geo/cesium-placement.ts +1 -1
- package/src/lib/geo/reproject.ts +4 -1
- package/src/lib/length-unit-scale.ts +41 -0
- package/src/lib/lists/adapter.ts +136 -11
- package/src/lib/lists/export/csv.ts +47 -0
- package/src/lib/lists/export/index.ts +49 -0
- package/src/lib/lists/export/model.ts +111 -0
- package/src/lib/lists/export/pdf.ts +67 -0
- package/src/lib/lists/export/xlsx.ts +83 -0
- package/src/lib/lists/index.ts +2 -0
- package/src/lib/llm/script-edit-ops.ts +23 -0
- package/src/lib/llm/stream-client.ts +8 -1
- package/src/lib/search/filter-evaluate.test.ts +81 -0
- package/src/lib/search/filter-evaluate.ts +59 -87
- package/src/lib/search/filter-match.ts +167 -0
- package/src/lib/search/filter-rules.test.ts +25 -0
- package/src/lib/search/filter-rules.ts +75 -2
- package/src/lib/search/filter-schema.ts +0 -0
- package/src/lib/search/result-export.ts +7 -1
- package/src/lib/slab-edit.test.ts +72 -0
- package/src/lib/slab-edit.ts +159 -19
- package/src/sdk/adapters/export-adapter.ts +9 -4
- package/src/sdk/adapters/query-adapter.ts +3 -3
- package/src/store/globalId.ts +15 -13
- package/src/store/index.ts +16 -1
- package/src/store/slices/cesiumSlice.ts +8 -1
- package/src/store/slices/compareSlice.ts +96 -0
- package/src/store/slices/lensSlice.ts +8 -0
- package/src/store/slices/listSlice.ts +6 -0
- package/src/store/slices/mutationSlice.ts +14 -6
- package/src/store/slices/searchSlice.ts +29 -3
- package/src/utils/acquireFileBuffer.test.ts +12 -4
- package/src/utils/desktopModelSnapshot.ts +2 -1
- package/src/utils/loadingUtils.ts +32 -0
- package/src/utils/nativeSpatialDataStore.ts +6 -0
- package/src/utils/serverDataModel.test.ts +6 -0
- package/src/utils/serverDataModel.ts +7 -0
- package/src/utils/spatialHierarchy.test.ts +53 -1
- package/src/utils/spatialHierarchy.ts +42 -2
- package/src/vite-env.d.ts +2 -0
- package/dist/assets/deflate-Cnx0il6E.js +0 -1
- package/dist/assets/drawing-2d-C71b8Ugx.js +0 -257
- package/dist/assets/e57-source-CQHxE8n3.js +0 -1
- package/dist/assets/geometry.worker-0Q9qEa6p.js +0 -1
- package/dist/assets/ifc-lite_bg-CEZnhM2e.wasm +0 -0
- package/dist/assets/index-B9Ug2EqU.css +0 -1
- package/dist/assets/lens-PYsLu_MA.js +0 -1
- package/dist/assets/parser.worker-8md211IW.js +0 -182
- package/dist/assets/raw-BQrAgxwT.js +0 -1
- package/dist/assets/server-client-Bk4c1CPO.js +0 -626
- package/src/hooks/ingest/resolveDataStoreOrAbort.test.ts +0 -61
- package/src/hooks/ingest/resolveDataStoreOrAbort.ts +0 -28
- package/src/hooks/ingest/watchedGeometryStream.test.ts +0 -78
- package/src/hooks/ingest/watchedGeometryStream.ts +0 -76
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
const Ft={projectionDepth:10,includeHiddenLines:!0,creaseAngle:30,scale:100};function W(n,t){return`${n}:${t}`}const $=1e-7;function G(n,t,e){return{x:n,y:t,z:e}}function Z(n,t){return{x:n.x-t.x,y:n.y-t.y,z:n.z-t.z}}function _(n,t){return n.x*t.x+n.y*t.y+n.z*t.z}function St(n,t){return{x:n.y*t.z-n.z*t.y,y:n.z*t.x-n.x*t.z,z:n.x*t.y-n.y*t.x}}function $t(n){return Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z)}function J(n){const t=$t(n);return t<$?{x:0,y:0,z:0}:{x:n.x/t,y:n.y/t,z:n.z/t}}function Pt(n,t,e){return{x:n.x+e*(t.x-n.x),y:n.y+e*(t.y-n.y),z:n.z+e*(t.z-n.z)}}function z(n,t){return{x:n.x-t.x,y:n.y-t.y}}function At(n,t){return n.x*t.x+n.y*t.y}function Lt(n){return Math.sqrt(n.x*n.x+n.y*n.y)}function R(n,t){const e=t.x-n.x,i=t.y-n.y;return Math.sqrt(e*e+i*i)}function K(n,t,e){return{x:n.x+e*(t.x-n.x),y:n.y+e*(t.y-n.y)}}function Et(n){const t=Lt(n);return t<$?{x:0,y:0}:{x:n.x/t,y:n.y/t}}function Q(n,t){return n.x*t.y-n.y*t.x}function tt(n){return R(n.start,n.end)}function Y(n){return Et(z(n.end,n.start))}function ct(){return{min:{x:1/0,y:1/0},max:{x:-1/0,y:-1/0}}}function H(n,t){return{min:{x:Math.min(n.min.x,t.x),y:Math.min(n.min.y,t.y)},max:{x:Math.max(n.max.x,t.x),y:Math.max(n.max.y,t.y)}}}function kt(n,t){let e=H(n,t.start);return e=H(e,t.end),e}function vt(n){return{x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2}}function Tt(n){return{x:n.max.x-n.min.x,y:n.max.y-n.min.y}}function N(n,t,e){return _(n,t)-e}function ht(n,t){switch(n){case"x":return{x:1,y:0,z:0};case"y":return{x:0,y:1,z:0};case"z":return{x:0,y:0,z:1}}}function dt(n){switch(n){case"x":return{u:"z",v:"y"};case"y":return{u:"x",v:"z"};case"z":return{u:"x",v:"y"}}}function D(n,t,e){const i=dt(t),s=n[i.u],o=n[i.v];return{x:e?-s:s,y:o}}function et(n,t,e,i){const s=n.x-t.x,o=n.y-t.y,r=n.z-t.z;return{x:s*e.x+o*e.y+r*e.z,y:s*i.x+o*i.y+r*i.z}}function ut(n){if(n.length<3)return 0;let t=0;for(let e=0;e<n.length;e++){const i=(e+1)%n.length;t+=n[e].x*n[i].y,t-=n[i].x*n[e].y}return t/2}function ft(n){return ut(n)>0}function gt(n){return[...n].reverse()}function Rt(n){return ft(n)?n:gt(n)}function Dt(n){return ft(n)?gt(n):n}class pt{tolerance;constructor(t=1e-4){this.tolerance=t}buildPolygons(t){const e=new Map;for(const s of t){const o=W(s.modelIndex,s.entityId);e.has(o)||e.set(o,[]),e.get(o).push(s)}const i=[];for(const[s,o]of e){const r=this.buildEntityPolygons(o);i.push(r)}return i.flat()}buildEntityPolygons(t){if(t.length===0)return[];const e=t[0],{entityId:i,ifcType:s,modelIndex:o}=e,r=t.map(c=>({start:c.p0_2d,end:c.p1_2d,used:!1})),a=this.buildLoops(r);return a.length===0?[]:this.classifyLoops(a).map(c=>({polygon:{outer:c.outer,holes:c.holes},entityId:i,ifcType:s,modelIndex:o,isCut:!0}))}buildLoops(t){const e=[];for(;;){const i=t.findIndex(o=>!o.used);if(i===-1)break;const s=this.buildSingleLoop(t,i);if(s&&s.length>=3){const o=ut(s);e.push({points:s,area:o})}}return e}buildSingleLoop(t,e){const i=[],s=t[e];s.used=!0,i.push(s.start);let o=s.end;const r=s.start,a=t.length;let l=0;for(;l<a;){if(l++,R(o,r)<this.tolerance)return i;const c=this.findConnectingSegment(t,o);if(c===-1)break;const u=t[c];u.used=!0,R(u.start,o)<this.tolerance?(i.push(u.start),o=u.end):(i.push(u.end),o=u.start)}return i.length>=3?i:null}findConnectingSegment(t,e){let i=-1,s=this.tolerance;for(let o=0;o<t.length;o++){if(t[o].used)continue;const r=t[o],a=R(r.start,e);a<s&&(s=a,i=o);const l=R(r.end,e);l<s&&(s=l,i=o)}return i}classifyLoops(t){if(t.length===0)return[];const e=[...t].sort((o,r)=>Math.abs(r.area)-Math.abs(o.area)),i=[],s=new Set;for(let o=0;o<e.length;o++){if(s.has(o))continue;const r=e[o],a=Rt(r.points),l=[];for(let c=o+1;c<e.length;c++){if(s.has(c))continue;const u=e[c];this.isLoopContainedIn(u.points,a)&&(l.push(Dt(u.points)),s.add(c))}s.add(o),i.push({outer:a,holes:l})}return i}isLoopContainedIn(t,e){const i=t[0];return this.pointInPolygon(i,e)}pointInPolygon(t,e){let i=!1;const s=e.length;for(let o=0,r=s-1;o<s;r=o++){const a=e[o],l=e[r];a.y>t.y!=l.y>t.y&&t.x<(l.x-a.x)*(t.y-a.y)/(l.y-a.y)+a.x&&(i=!i)}return i}}class Wt{planeNormal;planeDistance;axis;flipped;customPlane;constructor(t){this.axis=t.axis,this.flipped=t.flipped,this.customPlane=t.customPlane,this.customPlane?(this.planeNormal=this.customPlane.normal,this.planeDistance=this.customPlane.distance):(this.planeNormal=ht(t.axis),this.planeDistance=t.position)}cutMeshes(t){const e=performance.now(),i=[];let s=0,o=0;for(const u of t){const h=this.cutSingleMesh(u);i.push(h.segments),s+=h.trianglesProcessed,o+=h.trianglesIntersected}const r=i.flat(),l=new pt().buildPolygons(r),c=performance.now()-e;return{segments:r,polygons:l,stats:{totalTriangles:s,intersectedTriangles:o,segmentCount:r.length,polygonCount:l.length,processingTimeMs:c}}}cutSingleMesh(t){const e=[],{positions:i,indices:s,expressId:o,ifcType:r,modelIndex:a}=t,l=s.length/3;let c=0;for(let u=0;u<l;u++){const h=s[u*3],d=s[u*3+1],f=s[u*3+2],g=this.getVertex(i,h),y=this.getVertex(i,d),p=this.getVertex(i,f),m=N(g,this.planeNormal,this.planeDistance),I=N(y,this.planeNormal,this.planeDistance),w=N(p,this.planeNormal,this.planeDistance),x=this.intersectTrianglePlane(g,y,p,m,I,w);if(x){c++;const C=this.customPlane?et(x.p0,this.customPlane.origin,this.customPlane.tangent,this.customPlane.bitangent):D(x.p0,this.axis,this.flipped),b=this.customPlane?et(x.p1,this.customPlane.origin,this.customPlane.tangent,this.customPlane.bitangent):D(x.p1,this.axis,this.flipped),P=b.x-C.x,M=b.y-C.y;if(P*P+M*M<$*$)continue;e.push({p0:x.p0,p1:x.p1,p0_2d:C,p1_2d:b,entityId:o,ifcType:r||"Unknown",modelIndex:a||0})}}return{segments:e,trianglesProcessed:l,trianglesIntersected:c}}getVertex(t,e){const i=e*3;return G(t[i],t[i+1],t[i+2])}intersectTrianglePlane(t,e,i,s,o,r){const a=(s>$?1:0)+(o>$?1:0)+(r>$?1:0),l=(s<-$?1:0)+(o<-$?1:0)+(r<-$?1:0);if(a===3||l===3||a===0&&l===0)return null;const c=[],u=this.edgePlaneIntersection(t,e,s,o);u&&c.push(u);const h=this.edgePlaneIntersection(e,i,o,r);if(h&&c.push(h),c.length<2){const d=this.edgePlaneIntersection(i,t,r,s);d&&c.push(d)}return c.length>=2?{p0:c[0],p1:c[1]}:null}edgePlaneIntersection(t,e,i,s){if(Math.abs(i)<$&&Math.abs(s)<$)return null;if(Math.abs(i)<$)return t;if(Math.abs(s)<$)return e;if(i>0==s>0)return null;const o=i/(i-s);return Pt(t,e,o)}}const yt={angleTolerance:.01,distanceTolerance:.001,gapTolerance:.01};function _t(n,t={}){const e={...yt,...t},i=new Map;for(const o of n){const r=`${o.modelIndex}:${o.entityId}:${o.category}:${o.visibility}`;i.has(r)||i.set(r,[]),i.get(r).push(o)}const s=[];for(const o of i.values()){const r=zt(o,e);s.push(...r)}return s}function zt(n,t){if(n.length<=1)return n;const e=n.map(o=>o.line),i=Bt(e,t),s=n[0];return i.map(o=>({...s,line:o}))}function Bt(n,t={}){const e={...yt,...t};if(n.length<=1)return n;const i=Nt(n,e.angleTolerance),s=[];for(const o of i.values()){const r=Ot(o,e.distanceTolerance);for(const a of r){const l=Ut(a,e.gapTolerance);s.push(...l)}}return s}function Nt(n,t){const e=new Map,i=t*2;for(const s of n){const o=Y(s);let r=Math.atan2(o.y,o.x);r<0&&(r+=Math.PI),r>=Math.PI&&(r-=Math.PI);const a=Math.floor(r/i);e.has(a)||e.set(a,[]),e.get(a).push(s)}return e}function Ot(n,t){const e=[],i=new Set;for(let s=0;s<n.length;s++){if(i.has(s))continue;const o=[n[s]];i.add(s);for(let r=s+1;r<n.length;r++)i.has(r)||Ht(n[s],n[r],t)&&(o.push(n[r]),i.add(r));e.push(o)}return e}function Ht(n,t,e){const i=Y(n),s=z(t.start,n.start);if(Math.abs(Q(i,s))>e)return!1;const r=z(t.end,n.start);return Math.abs(Q(i,r))<=e}function Ut(n,t){if(n.length<=1)return n;const e=n[0],i=Y(e),s=e.start,o=n.map(l=>{const c=nt(l.start,s,i),u=nt(l.end,s,i);return{t0:Math.min(c,u),t1:Math.max(c,u)}});o.sort((l,c)=>l.t0-c.t0);const r=[];let a=o[0];for(let l=1;l<o.length;l++){const c=o[l];c.t0<=a.t1+t?a={t0:a.t0,t1:Math.max(a.t1,c.t1)}:(r.push(a),a=c)}return r.push(a),r.map(l=>({start:{x:s.x+i.x*l.t0,y:s.y+i.y*l.t0},end:{x:s.x+i.x*l.t1,y:s.y+i.y*l.t1}}))}function nt(n,t,e){const i=z(n,t);return At(i,e)}class jt{creaseAngle;constructor(t=30){this.creaseAngle=t*Math.PI/180}extractEdges(t){const{positions:e,indices:i,expressId:s,ifcType:o,modelIndex:r}=t,a=new Map,l=[],c=i.length/3;for(let h=0;h<c;h++){const d=i[h*3],f=i[h*3+1],g=i[h*3+2],y=this.getVertex(e,d),p=this.getVertex(e,f),m=this.getVertex(e,g),I=this.computeFaceNormal(y,p,m);l.push(I),this.registerEdge(a,d,f,h),this.registerEdge(a,f,g,h),this.registerEdge(a,g,d,h)}const u=[];for(const[,h]of a){const d=this.getVertex(e,h.v0Idx),f=this.getVertex(e,h.v1Idx);let g=null,y=null,p=0,m="smooth";if(h.faceIndices.length===1)m="boundary",g=l[h.faceIndices[0]];else if(h.faceIndices.length>=2){g=l[h.faceIndices[0]],y=l[h.faceIndices[1]];const I=Math.max(-1,Math.min(1,_(g,y)));p=Math.acos(I),p>this.creaseAngle&&(m="crease")}m!=="smooth"&&u.push({v0:d,v1:f,face0Normal:g,face1Normal:y,dihedralAngle:p,type:m,entityId:s,ifcType:o||"Unknown",modelIndex:r||0})}return u}extractEdgesFromMeshes(t){const e=[];for(const i of t){const s=this.extractEdges(i);e.push(...s)}return e}extractSilhouettes(t,e){const i=J(e);return t.filter(s=>{if(s.type==="boundary")return!0;if(!s.face0Normal||!s.face1Normal)return!1;const o=_(s.face0Normal,i),r=_(s.face1Normal,i);return o<0!=r<0})}edgesToDrawingLines(t,e,i,s,o){return t.map(r=>{const a=D(r.v0,e,i),l=D(r.v1,e,i),c=e,u=Math.min(Math.abs(r.v0[c]-o),Math.abs(r.v1[c]-o));return{line:{start:a,end:l},category:s,visibility:"visible",entityId:r.entityId,ifcType:r.ifcType,modelIndex:r.modelIndex,depth:u}})}filterEdgesByDepth(t,e,i,s,o){return t.filter(r=>{const a=r.v0[e]-i,l=r.v1[e]-i,c=o?-s:0,u=o?0:s,h=a>=c&&a<=u,d=l>=c&&l<=u,f=a<c&&l>u||l<c&&a>u;return h||d||f})}getVertex(t,e){const i=e*3;return G(t[i],t[i+1],t[i+2])}computeFaceNormal(t,e,i){const s=Z(e,t),o=Z(i,t),r=St(s,o);return J(r)}registerEdge(t,e,i,s){const o=Math.min(e,i),r=Math.max(e,i),a=`${o}:${r}`;t.has(a)||t.set(a,{v0Idx:o,v1Idx:r,faceIndices:[]}),t.get(a).faceIndices.push(s)}}function Gt(n,t){const e=t?1:-1;switch(n){case"x":return{x:e,y:0,z:0};case"y":return{x:0,y:e,z:0};case"z":return{x:0,y:0,z:e}}}function Yt(n,t,e){const i=[];for(const s of n){if(!Vt(s,t,e))continue;it(i,s,s.outerPoints,"projection",t);let o=0;for(let r=0;r<s.holeCounts.length;r++){const a=s.holeCounts[r];if(a<2||o+a*2>s.holePoints.length){o+=a*2;continue}const l=s.holePoints.subarray(o,o+a*2);it(i,s,l,"projection",t),o+=a*2}}return i}function Vt(n,t,e){const{axis:i,position:s,flipped:o}=t,{min:r,max:a}=qt(n,i),l=o?s-e:s,c=o?s:s+e;return r<=c&&a>=l}function it(n,t,e,i,s){const o=Math.floor(e.length/2);if(o<2)return;const r=t.transform;for(let a=0;a<o;a++){const l=(a+1)%o,c=e[a*2],u=e[a*2+1],h=e[l*2],d=e[l*2+1],f=U(c,u,r),g=U(h,d,r),y=D(f,s.axis,s.flipped),p=D(g,s.axis,s.flipped);Math.abs(y.x-p.x)<1e-7&&Math.abs(y.y-p.y)<1e-7||n.push({line:{start:y,end:p},category:i,visibility:"visible",entityId:t.expressId,ifcType:t.ifcType,modelIndex:t.modelIndex,depth:Zt(f,g,s.axis,s.position)})}}function U(n,t,e){return{x:e[0]*n+e[4]*t+e[12],y:e[1]*n+e[5]*t+e[13],z:e[2]*n+e[6]*t+e[14]}}function Xt(n,t){return n[12+mt(t)]}function qt(n,t){const e=t,i=n.extrusionDir[mt(t)]*n.extrusionDepth;let s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;const r=a=>{const l=Math.floor(a.length/2);for(let c=0;c<l;c++){const h=U(a[c*2],a[c*2+1],n.transform)[e],d=h+i;s=Math.min(s,h,d),o=Math.max(o,h,d)}};if(r(n.outerPoints),r(n.holePoints),!Number.isFinite(s)||!Number.isFinite(o)){const a=Xt(n.transform,t),l=a+i;return{min:Math.min(a,l),max:Math.max(a,l)}}return{min:s,max:o}}function mt(n){return n==="x"?0:n==="y"?1:2}function Zt(n,t,e,i){const s=(n[e]+t[e])/2;return Math.abs(s-i)}const Jt={resolution:1024,samplesPerLine:10,depthBias:.001};class Kt{options;depthBuffer=null;width=0;height=0;bounds=null;constructor(t={}){this.options={...Jt,...t}}buildDepthBuffer(t,e,i,s,o,r){r||(r=this.computeBounds(t,e,i,s,o)),this.bounds=r;const a=r.max.x-r.min.x,l=r.max.y-r.min.y;if(a<$||l<$){this.width=1,this.height=1,this.depthBuffer=new Float32Array([1/0]);return}const c=a/l;c>1?(this.width=this.options.resolution,this.height=Math.max(1,Math.floor(this.options.resolution/c))):(this.height=this.options.resolution,this.width=Math.max(1,Math.floor(this.options.resolution*c))),this.depthBuffer=new Float32Array(this.width*this.height),this.depthBuffer.fill(1/0);for(const u of t)this.rasterizeMesh(u,e,i,s,o)}classifyLines(t){if(!this.depthBuffer||!this.bounds)throw new Error("Depth buffer not built. Call buildDepthBuffer first.");const e=[];for(const i of t){const s=this.classifySingleLine(i);e.push(s)}return e}applyVisibility(t){const e=this.classifyLines(t),i=[];for(const s of e)if(s.overallVisibility==="visible")i.push({...s.line,visibility:"visible"});else if(s.overallVisibility==="hidden")i.push({...s.line,visibility:"hidden"});else for(const o of s.segments)i.push({...s.line,line:{start:o.start,end:o.end},visibility:o.visible?"visible":"hidden"});return i}computeBounds(t,e,i,s,o){let r=ct();const a=this.getProjectionAxes(e);for(const c of t){const{positions:u}=c,h=u.length/3;for(let d=0;d<h;d++){const f=u[d*3],g=u[d*3+1],y=u[d*3+2],p={x:f,y:g,z:y},m=p[e]-i;if(o?m<=0&&m>=-s:m>=0&&m<=s){const w=p[a.u],x=p[a.v],C={x:o?-w:w,y:x};r=H(r,C)}}}const l=Math.max(r.max.x-r.min.x,r.max.y-r.min.y)*.01;return r.min.x-=l,r.min.y-=l,r.max.x+=l,r.max.y+=l,r}getProjectionAxes(t){switch(t){case"x":return{u:"z",v:"y"};case"y":return{u:"x",v:"z"};case"z":return{u:"x",v:"y"}}}rasterizeMesh(t,e,i,s,o){const{positions:r,indices:a}=t,l=this.getProjectionAxes(e),c=a.length/3;for(let u=0;u<c;u++){const h=a[u*3],d=a[u*3+1],f=a[u*3+2],g=this.getVertex(r,h),y=this.getVertex(r,d),p=this.getVertex(r,f),m=g[e]-i,I=y[e]-i,w=p[e]-i,x=M=>o?M<=0&&M>=-s:M>=0&&M<=s;if(!x(m)&&!x(I)&&!x(w))continue;const C=this.projectVertex(g,l,o),b=this.projectVertex(y,l,o),P=this.projectVertex(p,l,o);this.rasterizeTriangle(C,b,P)}}getVertex(t,e){const i=e*3;return G(t[i],t[i+1],t[i+2])}projectVertex(t,e,i){const s=t[e.u],o=t[e.v],a=["x","y","z"].find(l=>l!==e.u&&l!==e.v)??"z";return{x:i?-s:s,y:o,depth:t[a]}}rasterizeTriangle(t,e,i){if(!this.bounds||!this.depthBuffer)return;const s=f=>(f-this.bounds.min.x)/(this.bounds.max.x-this.bounds.min.x)*(this.width-1),o=f=>(f-this.bounds.min.y)/(this.bounds.max.y-this.bounds.min.y)*(this.height-1),r={x:s(t.x),y:o(t.y),depth:t.depth},a={x:s(e.x),y:o(e.y),depth:e.depth},l={x:s(i.x),y:o(i.y),depth:i.depth},c=Math.max(0,Math.floor(Math.min(r.x,a.x,l.x))),u=Math.min(this.width-1,Math.ceil(Math.max(r.x,a.x,l.x))),h=Math.max(0,Math.floor(Math.min(r.y,a.y,l.y))),d=Math.min(this.height-1,Math.ceil(Math.max(r.y,a.y,l.y)));for(let f=h;f<=d;f++)for(let g=c;g<=u;g++){const y=this.barycentricCoords(g+.5,f+.5,r,a,l);if(y.u>=0&&y.v>=0&&y.w>=0){const p=y.u*r.depth+y.v*a.depth+y.w*l.depth,m=f*this.width+g;p<this.depthBuffer[m]&&(this.depthBuffer[m]=p)}}}barycentricCoords(t,e,i,s,o){const r=s.x-i.x,a=s.y-i.y,l=o.x-i.x,c=o.y-i.y,u=t-i.x,h=e-i.y,d=r*r+a*a,f=r*l+a*c,g=r*u+a*h,y=l*l+c*c,p=l*u+c*h,m=d*y-f*f;if(Math.abs(m)<1e-10)return{u:-1,v:-1,w:-1};const I=1/m,w=(y*g-f*p)*I,x=(d*p-f*g)*I;return{u:1-w-x,v:w,w:x}}classifySingleLine(t){if(!this.bounds||!this.depthBuffer)return{line:t,segments:[{start:t.line.start,end:t.line.end,visible:!0}],overallVisibility:"visible"};const{samplesPerLine:e,depthBias:i}=this.options,o=R(t.line.start,t.line.end)<$?1:Math.max(2,e),r=[];let a=t.line.start,l=this.sampleVisibility(t.line.start,t.depth,i),c=l?1:0;for(let h=1;h<=o;h++){const d=h/o,f=K(t.line.start,t.line.end,d),g=this.sampleVisibility(f,t.depth,i);if(g&&c++,g!==l&&h<o){const y=(h-.5)/o,p=K(t.line.start,t.line.end,y);r.push({start:a,end:p,visible:l}),a=p,l=g}}r.push({start:a,end:t.line.end,visible:l});let u;return c===o+1?u="visible":c===0?u="hidden":u="partial",{line:t,segments:r,overallVisibility:u}}sampleVisibility(t,e,i){if(!this.bounds||!this.depthBuffer)return!0;const s=(t.x-this.bounds.min.x)/(this.bounds.max.x-this.bounds.min.x)*(this.width-1),o=(t.y-this.bounds.min.y)/(this.bounds.max.y-this.bounds.min.y)*(this.height-1),r=Math.max(0,Math.min(this.width-1,Math.floor(s))),a=Math.max(0,Math.min(this.height-1,Math.floor(o))),l=this.depthBuffer[a*this.width+r];return e<=l+i}}const ot={IfcWall:{type:"diagonal",spacing:3,angle:45,lineWeight:.18,strokeColor:"#000000"},IfcWallStandardCase:{type:"diagonal",spacing:3,angle:45,lineWeight:.18,strokeColor:"#000000"},IfcCurtainWall:{type:"none",spacing:0,angle:0,lineWeight:.13,strokeColor:"#0066CC"},IfcSlab:{type:"concrete",spacing:2.5,angle:0,lineWeight:.13,strokeColor:"#666666"},IfcRoof:{type:"cross-hatch",spacing:4,angle:45,secondaryAngle:-45,lineWeight:.13,strokeColor:"#8B4513"},IfcCovering:{type:"horizontal",spacing:8,angle:0,lineWeight:.09,strokeColor:"#999999"},IfcColumn:{type:"steel",spacing:2,angle:45,lineWeight:.25,strokeColor:"#333333"},IfcBeam:{type:"steel",spacing:2,angle:45,lineWeight:.25,strokeColor:"#333333"},IfcMember:{type:"diagonal",spacing:2.5,angle:45,lineWeight:.18,strokeColor:"#444444"},IfcPlate:{type:"steel",spacing:1.5,angle:45,lineWeight:.18,strokeColor:"#555555"},IfcFooting:{type:"concrete",spacing:3,angle:0,lineWeight:.18,strokeColor:"#777777"},IfcPile:{type:"concrete",spacing:2.5,angle:0,lineWeight:.18,strokeColor:"#666666"},IfcWindow:{type:"glass",spacing:0,angle:0,lineWeight:.13,strokeColor:"#0099CC",fillColor:"rgba(200, 230, 255, 0.3)"},IfcDoor:{type:"none",spacing:0,angle:0,lineWeight:.25,strokeColor:"#000000"},IfcOpeningElement:{type:"none",spacing:0,angle:0,lineWeight:.13,strokeColor:"#CCCCCC"},IfcStair:{type:"horizontal",spacing:5,angle:0,lineWeight:.18,strokeColor:"#444444"},IfcStairFlight:{type:"horizontal",spacing:5,angle:0,lineWeight:.18,strokeColor:"#444444"},IfcRamp:{type:"diagonal",spacing:6,angle:30,lineWeight:.13,strokeColor:"#555555"},IfcRailing:{type:"none",spacing:0,angle:0,lineWeight:.13,strokeColor:"#666666"},IfcFlowTerminal:{type:"none",spacing:0,angle:0,lineWeight:.13,strokeColor:"#0066AA"},IfcFlowSegment:{type:"none",spacing:0,angle:0,lineWeight:.18,strokeColor:"#0066AA"},IfcDistributionElement:{type:"none",spacing:0,angle:0,lineWeight:.13,strokeColor:"#006688"},IfcSpace:{type:"none",spacing:0,angle:0,lineWeight:.09,strokeColor:"#CCCCCC"},IfcFurnishingElement:{type:"none",spacing:0,angle:0,lineWeight:.13,strokeColor:"#888888"},IfcFurniture:{type:"none",spacing:0,angle:0,lineWeight:.13,strokeColor:"#888888"},default:{type:"diagonal",spacing:4,angle:45,lineWeight:.13,strokeColor:"#666666"}};function xt(n){return ot[n]||ot.default}const Qt={cut:{weight:.5,color:"#000000",dashPattern:[],lineCap:"round",lineJoin:"round"},projection:{weight:.25,color:"#000000",dashPattern:[],lineCap:"round",lineJoin:"round"},hidden:{weight:.18,color:"#666666",dashPattern:[2,1],lineCap:"butt",lineJoin:"round"},silhouette:{weight:.35,color:"#000000",dashPattern:[],lineCap:"round",lineJoin:"round"},crease:{weight:.18,color:"#000000",dashPattern:[],lineCap:"round",lineJoin:"round"},boundary:{weight:.25,color:"#000000",dashPattern:[],lineCap:"round",lineJoin:"round"},annotation:{weight:.13,color:"#000000",dashPattern:[],lineCap:"butt",lineJoin:"miter"}},st={IfcWall:{cut:.7,projection:.35},IfcWallStandardCase:{cut:.7,projection:.35},IfcSlab:{cut:.5,projection:.25},IfcColumn:{cut:.5,projection:.35},IfcBeam:{cut:.5,projection:.35},IfcWindow:{cut:.35,projection:.18},IfcDoor:{cut:.35,projection:.25},IfcStair:{cut:.35,projection:.25},IfcFurnishingElement:{cut:.18,projection:.13},IfcFurniture:{cut:.18,projection:.13},IfcSpace:{cut:.09,projection:.09}};function te(n,t){const e=Qt[n];if(t&&st[t]){const i=st[t][n];if(i!==void 0)return{...e,weight:i}}return e}const O=[{name:"1:1",factor:1,useCase:"Full size details"},{name:"1:2",factor:2,useCase:"Large details"},{name:"1:5",factor:5,useCase:"Construction details"},{name:"1:10",factor:10,useCase:"Details"},{name:"1:20",factor:20,useCase:"Room plans, sections"},{name:"1:50",factor:50,useCase:"Floor plans, elevations"},{name:"1:100",factor:100,useCase:"Building plans"},{name:"1:200",factor:200,useCase:"Site plans"},{name:"1:500",factor:500,useCase:"Site context"},{name:"1:1000",factor:1e3,useCase:"Urban context"}],rt={A3_LANDSCAPE:{name:"A3 Landscape",width:420,height:297}};class Ct{generateHatch(t,e=100,i){const s=xt(t.ifcType),o=i?{...s,type:i.type,spacing:i.spacing??s.spacing,angle:i.angle??s.angle,secondaryAngle:i.secondaryAngle??s.secondaryAngle}:s;if(o.type==="none"||o.type==="solid"||o.type==="glass")return{lines:[],pattern:o,polygon:t};const r=o.spacing*(e/100);let a=[];const l=this.generateParallelLines(t.polygon,r,o.angle,t.entityId,t.ifcType,t.modelIndex);if(a.push(...l),o.type==="cross-hatch"&&o.secondaryAngle!==void 0){const c=this.generateParallelLines(t.polygon,r,o.secondaryAngle,t.entityId,t.ifcType,t.modelIndex);a.push(...c)}if(o.type==="concrete"){const c=this.generateParallelLines(t.polygon,r*1.5,o.angle+90,t.entityId,t.ifcType,t.modelIndex);a.push(...c)}return{lines:a,pattern:o,polygon:t}}generateHatches(t,e=100,i){return t.map(s=>{const o=i?.(s);return this.generateHatch(s,e,o)})}generateParallelLines(t,e,i,s,o,r){if(e<$)return[];const a=i*Math.PI/180,l=Math.cos(a),c=Math.sin(a),u=-c,h=l,d=this.computePolygonBounds(t);if(!d)return[];const f=[{x:d.min.x,y:d.min.y},{x:d.max.x,y:d.min.y},{x:d.max.x,y:d.max.y},{x:d.min.x,y:d.max.y}];let g=1/0,y=-1/0;for(const I of f){const w=I.x*l+I.y*c;g=Math.min(g,w),y=Math.max(y,w)}const p=Math.sqrt(Math.pow(d.max.x-d.min.x,2)+Math.pow(d.max.y-d.min.y,2))*1.5,m=[];for(let I=g;I<=y;I+=e){const w=I*l,x=I*c,C={x:w-u*p,y:x-h*p},b={x:w+u*p,y:x+h*p},P=this.clipLineToPolygon({start:C,end:b},t);for(const M of P)m.push({line:M,entityId:s,ifcType:o,modelIndex:r})}return m}clipLineToPolygon(t,e){let i=this.clipLineToRing(t,e.outer,!0);for(const s of e.holes){const o=[];for(const r of i){const a=this.clipLineToRing(r,s,!1);o.push(...a)}i=o}return i}clipLineToRing(t,e,i){const s=[],o=t.end.x-t.start.x,r=t.end.y-t.start.y;for(let h=0;h<e.length;h++){const d=(h+1)%e.length,f=e[h],g=e[d],y=this.lineLineIntersection(t.start,t.end,f,g);if(y!==null&&y.t>=0&&y.t<=1){const p=-(g.y-f.y),m=g.x-f.x,I=o*p+r*m>0;s.push({t:y.t,entering:I})}}s.sort((h,d)=>h.t-d.t);const a=[];for(const h of s)(a.length===0||Math.abs(h.t-a[a.length-1].t)>$)&&a.push(h);if(a.length===0){const h={x:(t.start.x+t.end.x)/2,y:(t.start.y+t.end.y)/2};return this.pointInRing(h,e)===i?[t]:[]}const l=[];let c=this.pointInRing(t.start,e),u=0;for(const h of a)c===i&&l.push({start:{x:t.start.x+u*o,y:t.start.y+u*r},end:{x:t.start.x+h.t*o,y:t.start.y+h.t*r}}),u=h.t,c=!c;return c===i&&l.push({start:{x:t.start.x+u*o,y:t.start.y+u*r},end:t.end}),l.filter(h=>Math.abs(h.end.x-h.start.x)+Math.abs(h.end.y-h.start.y)>$)}lineLineIntersection(t,e,i,s){const o=e.x-t.x,r=e.y-t.y,a=s.x-i.x,l=s.y-i.y,c=o*l-r*a;if(Math.abs(c)<$)return null;const u=i.x-t.x,h=i.y-t.y,d=(u*l-h*a)/c,f=(u*r-h*o)/c;return f<0||f>1?null:{t:d,u:f}}pointInRing(t,e){let i=!1;const s=e.length;for(let o=0,r=s-1;o<s;r=o++){const a=e[o],l=e[r];a.y>t.y!=l.y>t.y&&t.x<(l.x-a.x)*(t.y-a.y)/(l.y-a.y)+a.x&&(i=!i)}return i}computePolygonBounds(t){if(t.outer.length===0)return null;let e=1/0,i=1/0,s=-1/0,o=-1/0;for(const r of t.outer)e=Math.min(e,r.x),i=Math.min(i,r.y),s=Math.max(s,r.x),o=Math.max(o,r.y);return{min:{x:e,y:i},max:{x:s,y:o}}}}class ee{hatchGenerator=new Ct;export(t,e={}){const{paperSize:i=rt.A3_LANDSCAPE,scale:s=O.find(m=>m.factor===t.config.scale)||O[5],padding:o=20,showHiddenLines:r=!0,showHatching:a=!0,showTitleBlock:l=!1,title:c="Section",projectName:u="",backgroundColor:h="#FFFFFF"}=e,d=this.computeTransform(t.bounds,i,s,o);let f=this.createHeader(i,h);if(f+=this.createDefs(t,s.factor),a&&t.cutPolygons.length>0&&(f+=this.createHatchingLayer(t.cutPolygons,d,s.factor)),r){const m=t.lines.filter(I=>I.visibility==="hidden");m.length>0&&(f+=this.createLineLayer("hidden-lines",m,d,"Hidden Lines"))}const g=t.lines.filter(m=>m.category==="projection"&&m.visibility!=="hidden");g.length>0&&(f+=this.createLineLayer("projection-lines",g,d,"Projection"));const y=t.lines.filter(m=>(m.category==="silhouette"||m.category==="crease"||m.category==="boundary")&&m.visibility!=="hidden");y.length>0&&(f+=this.createLineLayer("feature-lines",y,d,"Feature Edges"));const p=t.lines.filter(m=>m.category==="cut");return p.length>0&&(f+=this.createLineLayer("cut-lines",p,d,"Cut Lines")),l&&(f+=this.createTitleBlock(i,c,u,s)),f+="</svg>",f}exportPolygons(t,e,i={}){const{paperSize:s=rt.A3_LANDSCAPE,scale:o=O[5],padding:r=20,backgroundColor:a="#FFFFFF"}=i,l=this.computeTransform(e,s,o,r);let c=this.createHeader(s,a);return c+=this.createPolygonDefs(o.factor),c+=this.createHatchingLayer(t,l,o.factor),c+="</svg>",c}computeTransform(t,e,i,s){Tt(t);const o=vt(t);e.width-s*2,e.height-s*2;const r=1e3/i.factor,a=e.width/2-o.x*r,l=e.height/2+o.y*r;return{scale:r,offsetX:a,offsetY:l,flipY:!0}}transformPoint(t,e){return{x:t.x*e.scale+e.offsetX,y:e.flipY?-t.y*e.scale+e.offsetY:t.y*e.scale+e.offsetY}}createHeader(t,e){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<svg xmlns="http://www.w3.org/2000/svg"
|
|
3
|
-
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
4
|
-
width="${t.width}mm"
|
|
5
|
-
height="${t.height}mm"
|
|
6
|
-
viewBox="0 0 ${t.width} ${t.height}">
|
|
7
|
-
<rect width="100%" height="100%" fill="${e}"/>
|
|
8
|
-
`}createDefs(t,e){let i=` <defs>
|
|
9
|
-
`;return i+=this.createHatchPatternDefs(e),i+=` </defs>
|
|
10
|
-
`,i}createPolygonDefs(t){let e=` <defs>
|
|
11
|
-
`;return e+=this.createHatchPatternDefs(t),e+=` </defs>
|
|
12
|
-
`,e}createHatchPatternDefs(t){const e=3*(t/100);let i="";return i+=` <pattern id="hatch-diagonal" patternUnits="userSpaceOnUse"
|
|
13
|
-
width="${e}" height="${e}" patternTransform="rotate(45)">
|
|
14
|
-
<line x1="0" y1="0" x2="0" y2="${e}" stroke="#000" stroke-width="0.15"/>
|
|
15
|
-
</pattern>
|
|
16
|
-
`,i+=` <pattern id="hatch-cross" patternUnits="userSpaceOnUse"
|
|
17
|
-
width="${e}" height="${e}">
|
|
18
|
-
<line x1="0" y1="0" x2="${e}" y2="${e}" stroke="#000" stroke-width="0.1"/>
|
|
19
|
-
<line x1="${e}" y1="0" x2="0" y2="${e}" stroke="#000" stroke-width="0.1"/>
|
|
20
|
-
</pattern>
|
|
21
|
-
`,i+=` <pattern id="hatch-horizontal" patternUnits="userSpaceOnUse"
|
|
22
|
-
width="${e}" height="${e}">
|
|
23
|
-
<line x1="0" y1="${e/2}" x2="${e}" y2="${e/2}" stroke="#000" stroke-width="0.1"/>
|
|
24
|
-
</pattern>
|
|
25
|
-
`,i+=` <pattern id="hatch-concrete" patternUnits="userSpaceOnUse"
|
|
26
|
-
width="${e*2}" height="${e*2}">
|
|
27
|
-
<circle cx="${e*.3}" cy="${e*.3}" r="0.3" fill="#666"/>
|
|
28
|
-
<circle cx="${e*1.3}" cy="${e*1.3}" r="0.3" fill="#666"/>
|
|
29
|
-
<circle cx="${e*.8}" cy="${e*1.6}" r="0.2" fill="#888"/>
|
|
30
|
-
</pattern>
|
|
31
|
-
`,i+=` <pattern id="hatch-steel" patternUnits="userSpaceOnUse"
|
|
32
|
-
width="${e*.7}" height="${e*.7}" patternTransform="rotate(45)">
|
|
33
|
-
<line x1="0" y1="0" x2="0" y2="${e*.7}" stroke="#333" stroke-width="0.2"/>
|
|
34
|
-
</pattern>
|
|
35
|
-
`,i}createLineLayer(t,e,i,s){let o=` <g id="${t}" inkscape:label="${s}" inkscape:groupmode="layer">
|
|
36
|
-
`;for(const r of e)o+=this.renderLine(r,i);return o+=` </g>
|
|
37
|
-
`,o}renderLine(t,e){const i=te(t.category,t.ifcType),s=this.transformPoint(t.line.start,e),o=this.transformPoint(t.line.end,e),r=i.dashPattern.length>0?` stroke-dasharray="${i.dashPattern.join(" ")}"`:"";return` <line x1="${s.x.toFixed(3)}" y1="${s.y.toFixed(3)}" x2="${o.x.toFixed(3)}" y2="${o.y.toFixed(3)}"
|
|
38
|
-
stroke="${i.color}" stroke-width="${i.weight}"
|
|
39
|
-
stroke-linecap="${i.lineCap}"${r}
|
|
40
|
-
data-entity-id="${t.entityId}" data-ifc-type="${t.ifcType}"/>
|
|
41
|
-
`}createHatchingLayer(t,e,i){let s=` <g id="hatching" inkscape:label="Hatching" inkscape:groupmode="layer">
|
|
42
|
-
`;for(const o of t){const r=xt(o.ifcType);if(r.type!=="none"&&(s+=this.renderPolygon(o,e,r),r.type!=="solid"&&r.type!=="glass")){const a=this.hatchGenerator.generateHatch(o,i);for(const l of a.lines)s+=this.renderHatchLine(l,e,r)}}return s+=` </g>
|
|
43
|
-
`,s}renderPolygon(t,e,i){const s=this.polygonToPath(t.polygon,e);let o;return i.type==="solid"?o=i.fillColor||"#CCCCCC":i.type==="glass"?o=i.fillColor||"rgba(200, 230, 255, 0.3)":i.type==="none"?o="none":o=`url(#hatch-${i.type})`,` <path d="${s}" fill="${o}"
|
|
44
|
-
stroke="${i.strokeColor}" stroke-width="${i.lineWeight}"
|
|
45
|
-
data-entity-id="${t.entityId}" data-ifc-type="${t.ifcType}"/>
|
|
46
|
-
`}polygonToPath(t,e){let i="";if(t.outer.length>0){const s=this.transformPoint(t.outer[0],e);i+=`M ${s.x.toFixed(3)} ${s.y.toFixed(3)}`;for(let o=1;o<t.outer.length;o++){const r=this.transformPoint(t.outer[o],e);i+=` L ${r.x.toFixed(3)} ${r.y.toFixed(3)}`}i+=" Z"}for(const s of t.holes)if(s.length>0){const o=this.transformPoint(s[0],e);i+=` M ${o.x.toFixed(3)} ${o.y.toFixed(3)}`;for(let r=1;r<s.length;r++){const a=this.transformPoint(s[r],e);i+=` L ${a.x.toFixed(3)} ${a.y.toFixed(3)}`}i+=" Z"}return i}renderHatchLine(t,e,i){const s=this.transformPoint(t.line.start,e),o=this.transformPoint(t.line.end,e);return` <line x1="${s.x.toFixed(3)}" y1="${s.y.toFixed(3)}" x2="${o.x.toFixed(3)}" y2="${o.y.toFixed(3)}"
|
|
47
|
-
stroke="${i.strokeColor}" stroke-width="${i.lineWeight}" stroke-linecap="butt"/>
|
|
48
|
-
`}createTitleBlock(t,e,i,s){const a=t.width-180-10,l=t.height-50-10;return` <g id="title-block">
|
|
49
|
-
<rect x="${a}" y="${l}" width="180" height="50"
|
|
50
|
-
fill="white" stroke="black" stroke-width="0.5"/>
|
|
51
|
-
<line x1="${a}" y1="${l+20}" x2="${a+180}" y2="${l+20}" stroke="black" stroke-width="0.3"/>
|
|
52
|
-
<line x1="${a}" y1="${l+35}" x2="${a+180}" y2="${l+35}" stroke="black" stroke-width="0.3"/>
|
|
53
|
-
<line x1="${a+100}" y1="${l+20}" x2="${a+100}" y2="${l+50}" stroke="black" stroke-width="0.3"/>
|
|
54
|
-
<text x="${a+5}" y="${l+14}" font-family="Arial" font-size="10" font-weight="bold">${this.escapeXml(e)}</text>
|
|
55
|
-
<text x="${a+5}" y="${l+30}" font-family="Arial" font-size="8">${this.escapeXml(i)}</text>
|
|
56
|
-
<text x="${a+5}" y="${l+45}" font-family="Arial" font-size="8">Scale: ${s.name}</text>
|
|
57
|
-
<text x="${a+105}" y="${l+30}" font-family="Arial" font-size="7">Date:</text>
|
|
58
|
-
<text x="${a+105}" y="${l+45}" font-family="Arial" font-size="7">${new Date().toLocaleDateString()}</text>
|
|
59
|
-
</g>
|
|
60
|
-
`}escapeXml(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}}const ne=`
|
|
61
|
-
struct Triangle {
|
|
62
|
-
v0: vec3<f32>,
|
|
63
|
-
v1: vec3<f32>,
|
|
64
|
-
v2: vec3<f32>,
|
|
65
|
-
entityId: u32,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
struct Plane {
|
|
69
|
-
normal: vec3<f32>,
|
|
70
|
-
distance: f32,
|
|
71
|
-
// Projection axes for 2D output
|
|
72
|
-
axisU: u32, // 0=x, 1=y, 2=z
|
|
73
|
-
axisV: u32,
|
|
74
|
-
flipU: f32, // 1.0 or -1.0
|
|
75
|
-
_padding: f32,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
struct Segment {
|
|
79
|
-
p0_3d: vec3<f32>,
|
|
80
|
-
_pad0: f32,
|
|
81
|
-
p1_3d: vec3<f32>,
|
|
82
|
-
_pad1: f32,
|
|
83
|
-
p0_2d: vec2<f32>,
|
|
84
|
-
p1_2d: vec2<f32>,
|
|
85
|
-
entityId: u32,
|
|
86
|
-
valid: u32,
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@group(0) @binding(0) var<storage, read> triangles: array<Triangle>;
|
|
90
|
-
@group(0) @binding(1) var<uniform> plane: Plane;
|
|
91
|
-
@group(0) @binding(2) var<storage, read_write> segments: array<Segment>;
|
|
92
|
-
@group(0) @binding(3) var<storage, read_write> segmentCount: atomic<u32>;
|
|
93
|
-
|
|
94
|
-
const EPSILON: f32 = 1e-7;
|
|
95
|
-
|
|
96
|
-
fn signedDistance(point: vec3<f32>) -> f32 {
|
|
97
|
-
return dot(point, plane.normal) - plane.distance;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
fn edgeIntersection(v0: vec3<f32>, v1: vec3<f32>, d0: f32, d1: f32) -> vec3<f32> {
|
|
101
|
-
let t = d0 / (d0 - d1);
|
|
102
|
-
return mix(v0, v1, t);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
fn projectTo2D(p: vec3<f32>) -> vec2<f32> {
|
|
106
|
-
var coords: array<f32, 3>;
|
|
107
|
-
coords[0] = p.x;
|
|
108
|
-
coords[1] = p.y;
|
|
109
|
-
coords[2] = p.z;
|
|
110
|
-
|
|
111
|
-
let u = coords[plane.axisU] * plane.flipU;
|
|
112
|
-
let v = coords[plane.axisV];
|
|
113
|
-
return vec2<f32>(u, v);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
@compute @workgroup_size(64)
|
|
117
|
-
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
|
|
118
|
-
let triIdx = id.x;
|
|
119
|
-
if (triIdx >= arrayLength(&triangles)) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
let tri = triangles[triIdx];
|
|
124
|
-
|
|
125
|
-
// Signed distances from plane
|
|
126
|
-
let d0 = signedDistance(tri.v0);
|
|
127
|
-
let d1 = signedDistance(tri.v1);
|
|
128
|
-
let d2 = signedDistance(tri.v2);
|
|
129
|
-
|
|
130
|
-
// Check for intersection
|
|
131
|
-
let pos = u32(d0 > EPSILON) + u32(d1 > EPSILON) + u32(d2 > EPSILON);
|
|
132
|
-
let neg = u32(d0 < -EPSILON) + u32(d1 < -EPSILON) + u32(d2 < -EPSILON);
|
|
133
|
-
|
|
134
|
-
// No intersection if all on same side
|
|
135
|
-
if (pos == 3u || neg == 3u || (pos == 0u && neg == 0u)) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Find intersection points
|
|
140
|
-
var points: array<vec3<f32>, 2>;
|
|
141
|
-
var count: u32 = 0u;
|
|
142
|
-
|
|
143
|
-
// Edge v0-v1
|
|
144
|
-
if ((d0 > EPSILON) != (d1 > EPSILON)) {
|
|
145
|
-
points[count] = edgeIntersection(tri.v0, tri.v1, d0, d1);
|
|
146
|
-
count = count + 1u;
|
|
147
|
-
} else if (abs(d0) < EPSILON) {
|
|
148
|
-
points[count] = tri.v0;
|
|
149
|
-
count = count + 1u;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Edge v1-v2
|
|
153
|
-
if ((d1 > EPSILON) != (d2 > EPSILON)) {
|
|
154
|
-
points[count] = edgeIntersection(tri.v1, tri.v2, d1, d2);
|
|
155
|
-
count = count + 1u;
|
|
156
|
-
} else if (abs(d1) < EPSILON && count < 2u) {
|
|
157
|
-
points[count] = tri.v1;
|
|
158
|
-
count = count + 1u;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Edge v2-v0
|
|
162
|
-
if (count < 2u) {
|
|
163
|
-
if ((d2 > EPSILON) != (d0 > EPSILON)) {
|
|
164
|
-
points[count] = edgeIntersection(tri.v2, tri.v0, d2, d0);
|
|
165
|
-
count = count + 1u;
|
|
166
|
-
} else if (abs(d2) < EPSILON && count < 2u) {
|
|
167
|
-
points[count] = tri.v2;
|
|
168
|
-
count = count + 1u;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (count >= 2u) {
|
|
173
|
-
// Project to 2D
|
|
174
|
-
let p0_2d = projectTo2D(points[0]);
|
|
175
|
-
let p1_2d = projectTo2D(points[1]);
|
|
176
|
-
|
|
177
|
-
// Skip degenerate segments
|
|
178
|
-
let diff = p1_2d - p0_2d;
|
|
179
|
-
if (dot(diff, diff) < EPSILON * EPSILON) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Atomically allocate output slot
|
|
184
|
-
let outIdx = atomicAdd(&segmentCount, 1u);
|
|
185
|
-
|
|
186
|
-
segments[outIdx].p0_3d = points[0];
|
|
187
|
-
segments[outIdx].p1_3d = points[1];
|
|
188
|
-
segments[outIdx].p0_2d = p0_2d;
|
|
189
|
-
segments[outIdx].p1_2d = p1_2d;
|
|
190
|
-
segments[outIdx].entityId = tri.entityId;
|
|
191
|
-
segments[outIdx].valid = 1u;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
`;class ie{device;resources=null;constructor(t){this.device=t}async initialize(t){const e=t,i=this.device.createShaderModule({code:ne}),s=this.device.createComputePipeline({layout:"auto",compute:{module:i,entryPoint:"main"}}),o=t*48,r=this.device.createBuffer({size:o,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),a=this.device.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),l=e*64,c=this.device.createBuffer({size:l,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC}),u=this.device.createBuffer({size:4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC}),h=this.device.createBuffer({size:l,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),d=this.device.createBuffer({size:4,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),f=this.device.createBindGroup({layout:s.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:r}},{binding:1,resource:{buffer:a}},{binding:2,resource:{buffer:c}},{binding:3,resource:{buffer:u}}]});this.resources={pipeline:s,triangleBuffer:r,planeBuffer:a,segmentBuffer:c,countBuffer:u,readbackBuffer:h,countReadbackBuffer:d,bindGroup:f,maxTriangles:t,maxSegments:e}}async cutMeshes(t,e){if(!this.resources)throw new Error("GPU resources not initialized. Call initialize() first.");const i=this.collectTriangles(t),s=i.count;if(s===0)return[];s>this.resources.maxTriangles&&await this.initialize(s*2);const o=this.resources;if(!o)throw new Error("GPU resources became unavailable after initialization");this.device.queue.writeBuffer(o.triangleBuffer,0,i.buffer.buffer,i.buffer.byteOffset,i.buffer.byteLength);const r=this.createPlaneData(e);this.device.queue.writeBuffer(o.planeBuffer,0,r.buffer,r.byteOffset,r.byteLength),this.device.queue.writeBuffer(o.countBuffer,0,new Uint32Array([0]));const a=this.device.createCommandEncoder(),l=a.beginComputePass();l.setPipeline(o.pipeline),l.setBindGroup(0,o.bindGroup);const c=Math.ceil(s/64);l.dispatchWorkgroups(c),l.end(),a.copyBufferToBuffer(o.countBuffer,0,o.countReadbackBuffer,0,4),this.device.queue.submit([a.finish()]),await o.countReadbackBuffer.mapAsync(GPUMapMode.READ);const h=new Uint32Array(o.countReadbackBuffer.getMappedRange())[0];if(o.countReadbackBuffer.unmap(),h===0)return[];const d=this.device.createCommandEncoder();d.copyBufferToBuffer(o.segmentBuffer,0,o.readbackBuffer,0,h*64),this.device.queue.submit([d.finish()]),await o.readbackBuffer.mapAsync(GPUMapMode.READ);const f=new Float32Array(o.readbackBuffer.getMappedRange(0,h*64)),g=this.parseSegments(f,h,i.entityMap);return o.readbackBuffer.unmap(),g}collectTriangles(t){let e=0;for(const a of t)e+=a.indices.length/3;const i=new Float32Array(e*12),s=new Map;let o=0,r=0;for(const a of t){const{positions:l,indices:c,expressId:u,ifcType:h,modelIndex:d}=a,f=c.length/3;s.set(r,{entityId:u,ifcType:h||"Unknown",modelIndex:d||0});for(let g=0;g<f;g++){const y=c[g*3],p=c[g*3+1],m=c[g*3+2],I=o*12;i[I+0]=l[y*3],i[I+1]=l[y*3+1],i[I+2]=l[y*3+2],i[I+3]=l[p*3],i[I+4]=l[p*3+1],i[I+5]=l[p*3+2],i[I+6]=l[m*3],i[I+7]=l[m*3+1],i[I+8]=l[m*3+2],new DataView(i.buffer,(I+9)*4,4).setUint32(0,r,!0),i[I+10]=0,i[I+11]=0,o++}r++}return{buffer:i,count:e,entityMap:s}}createPlaneData(t){const e=ht(t.axis),i=dt(t.axis),s={x:0,y:1,z:2},o=new Float32Array(8);o[0]=e.x,o[1]=e.y,o[2]=e.z,o[3]=t.position;const r=new DataView(o.buffer);return r.setUint32(16,s[i.u],!0),r.setUint32(20,s[i.v],!0),o[6]=t.flipped?-1:1,o[7]=0,o}parseSegments(t,e,i){const s=[];for(let o=0;o<e;o++){const r=o*16;if(new DataView(t.buffer,(r+14)*4,4).getUint32(0,!0)!==1)continue;const l=new DataView(t.buffer,(r+13)*4,4).getUint32(0,!0),c=i.get(l)||{entityId:0,ifcType:"Unknown",modelIndex:0};s.push({p0:{x:t[r+0],y:t[r+1],z:t[r+2]},p1:{x:t[r+4],y:t[r+5],z:t[r+6]},p0_2d:{x:t[r+8],y:t[r+9]},p1_2d:{x:t[r+10],y:t[r+11]},entityId:c.entityId,ifcType:c.ifcType,modelIndex:c.modelIndex})}return s}destroy(){this.resources&&(this.resources.triangleBuffer.destroy(),this.resources.planeBuffer.destroy(),this.resources.segmentBuffer.destroy(),this.resources.countBuffer.destroy(),this.resources.readbackBuffer.destroy(),this.resources.countReadbackBuffer.destroy(),this.resources=null)}}const oe={useGPU:!0,includeHiddenLines:!0,includeProjection:!0,includeEdges:!0,mergeLines:!0};class ve{gpuCutter=null;cpuCutter=null;polygonBuilder=new pt;edgeExtractor=new jt(30);hiddenLineClassifier=new Kt({resolution:1024});hatchGenerator=new Ct;svgExporter=new ee;gpuDevice=null;initialized=!1;async initialize(t){t&&(this.gpuDevice=t,this.gpuCutter=new ie(t),await this.gpuCutter.initialize(1e5)),this.initialized=!0}async generate(t,e,i={},s){const o={...oe,...i},r=performance.now(),a=(x,C)=>{o.onProgress?.(x,C)};a("cutting",0);let l;o.useGPU&&this.gpuCutter&&this.gpuDevice&&!e.plane.customPlane?l=await this.gpuCutter.cutMeshes(t,e.plane):(this.cpuCutter=new Wt(e.plane),l=this.cpuCutter.cutMeshes(t).segments),a("cutting",1),a("polygons",0);const c=this.polygonBuilder.buildPolygons(l);a("polygons",1);const u=l.map(x=>({line:{start:x.p0_2d,end:x.p1_2d},category:"cut",visibility:"visible",entityId:x.entityId,ifcType:x.ifcType,modelIndex:x.modelIndex,depth:0}));let h=[],d=[];if(o.includeProjection||o.includeEdges){if(a("edges",0),s&&s.length>0&&o.includeProjection&&(h=Yt(s,e.plane,e.projectionDepth)),o.includeEdges){const C=this.edgeExtractor.extractEdgesFromMeshes(t),b=this.edgeExtractor.filterEdgesByDepth(C,e.plane.axis,e.plane.position,e.projectionDepth,e.plane.flipped),P=Gt(e.plane.axis,e.plane.flipped),M=this.edgeExtractor.extractSilhouettes(b,P);if(d=this.edgeExtractor.edgesToDrawingLines(M,e.plane.axis,e.plane.flipped,"silhouette",e.plane.position),o.includeProjection){const A=new Set((s??[]).map(L=>W(L.modelIndex,L.expressId))),E=b.filter(L=>L.type!=="crease"||M.includes(L)?!1:A.size===0?!0:!A.has(W(L.modelIndex,L.entityId)));h=[...h,...this.edgeExtractor.edgesToDrawingLines(E,e.plane.axis,e.plane.flipped,"projection",e.plane.position)]}}else if(o.includeProjection){const C=new Set((s??[]).map(A=>W(A.modelIndex,A.expressId))),b=this.edgeExtractor.extractEdgesFromMeshes(t),M=this.edgeExtractor.filterEdgesByDepth(b,e.plane.axis,e.plane.position,e.projectionDepth,e.plane.flipped).filter(A=>A.type!=="crease"?!1:C.size===0?!0:!C.has(W(A.modelIndex,A.entityId)));h=[...h,...this.edgeExtractor.edgesToDrawingLines(M,e.plane.axis,e.plane.flipped,"projection",e.plane.position)]}const x=this.computeBounds(u);if(x.min.x<x.max.x&&x.min.y<x.max.y){const C=x.max.x-x.min.x,b=x.max.y-x.min.y,M=Math.sqrt(C*C+b*b)*1.5;d=d.filter(A=>tt(A.line)<=M),h=h.filter(A=>tt(A.line)<=M)}a("edges",1)}let f=[...u,...h,...d];if(o.includeHiddenLines&&(h.length>0||d.length>0)){a("hidden",0);const x=this.computeBounds(f);this.hiddenLineClassifier.buildDepthBuffer(t,e.plane.axis,e.plane.position,e.projectionDepth,e.plane.flipped,x);const C=f.filter(P=>P.category!=="cut"),b=this.hiddenLineClassifier.applyVisibility(C);f=[...u,...b],a("hidden",1)}o.mergeLines&&(a("merging",0),f=_t(f),a("merging",1));const g=this.computeBounds(f),y=performance.now()-r,p=f.filter(x=>x.category==="cut").length,m=f.filter(x=>x.category==="projection").length,I=f.filter(x=>x.visibility==="hidden").length,w=f.filter(x=>x.category==="silhouette").length;return a("complete",1),{config:e,lines:f,cutPolygons:c,projectionPolygons:[],bounds:g,stats:{cutLineCount:p,projectionLineCount:m,hiddenLineCount:I,silhouetteLineCount:w,polygonCount:c.length,totalTriangles:t.reduce((x,C)=>x+C.indices.length/3,0),processingTimeMs:y}}}exportSVG(t,e){return this.svgExporter.export(t,e)}generateHatching(t){const e=this.hatchGenerator.generateHatches(t.cutPolygons,t.config.scale),i=[];for(const s of e)for(const o of s.lines)i.push({line:o.line,category:"annotation",visibility:"visible",entityId:o.entityId,ifcType:o.ifcType,modelIndex:o.modelIndex,depth:0});return i}computeBounds(t){let e=ct();for(const i of t)e=kt(e,i.line);return e}dispose(){this.gpuCutter&&(this.gpuCutter.destroy(),this.gpuCutter=null),this.gpuDevice=null,this.initialized=!1}}function Te(n,t,e={}){return{plane:{axis:n,position:t,flipped:!1},...Ft,...e}}const se={heavy:.5,medium:.35,light:.25,hairline:.18},at={solid:[],dashed:[2,1],dotted:[.5,.5],dashdot:[3,1,.5,1],center:[6,1,1,1]},k={fillColor:"#CCCCCC",strokeColor:"#000000",backgroundColor:"#FFFFFF",lineWeight:.25,lineCap:"round",lineJoin:"round",dashPattern:[],hatchPattern:"none",hatchSpacing:3,hatchAngle:45,hatchSecondaryAngle:-45,hatchColor:"#000000",hatchLineWeight:.13,visible:!0,opacity:1,drawOrder:0},re={IfcWall:["IfcWallStandardCase","IfcWallElementedCase"],IfcSlab:["IfcSlabStandardCase","IfcSlabElementedCase"],IfcBeam:["IfcBeamStandardCase"],IfcColumn:["IfcColumnStandardCase"],IfcDoor:["IfcDoorStandardCase"],IfcWindow:["IfcWindowStandardCase"],IfcMember:["IfcMemberStandardCase"],IfcPlate:["IfcPlateStandardCase"],IfcStair:["IfcStairFlight"],IfcRamp:["IfcRampFlight"],IfcBuildingElement:["IfcWall","IfcSlab","IfcBeam","IfcColumn","IfcDoor","IfcWindow","IfcStair","IfcRamp","IfcRoof","IfcRailing","IfcCovering"],IfcDistributionElement:["IfcDistributionFlowElement","IfcDistributionControlElement"],IfcFlowElement:["IfcFlowTerminal","IfcFlowSegment","IfcFlowFitting","IfcFlowController"]};function It(n){const t=re[n]||[],e=[...t];for(const i of t)e.push(...It(i));return e}function ae(n,t,e){switch(t){case"equals":return n===e;case"notEquals":return n!==e;case"contains":return typeof n=="string"&&typeof e=="string"?n.toLowerCase().includes(e.toLowerCase()):!1;case"notContains":return typeof n=="string"&&typeof e=="string"?!n.toLowerCase().includes(e.toLowerCase()):!0;case"startsWith":return typeof n=="string"&&typeof e=="string"?n.toLowerCase().startsWith(e.toLowerCase()):!1;case"endsWith":return typeof n=="string"&&typeof e=="string"?n.toLowerCase().endsWith(e.toLowerCase()):!1;case"greaterThan":return typeof n=="number"&&typeof e=="number"?n>e:!1;case"lessThan":return typeof n=="number"&&typeof e=="number"?n<e:!1;case"greaterOrEqual":return typeof n=="number"&&typeof e=="number"?n>=e:!1;case"lessOrEqual":return typeof n=="number"&&typeof e=="number"?n<=e:!1;case"exists":return n!=null;case"notExists":return n==null;case"in":return Array.isArray(e)?e.includes(n):!1;case"notIn":return Array.isArray(e)?!e.includes(n):!0;default:return!1}}function le(n,t){switch(n.type){case"all":return!0;case"ifcType":return!n.ifcTypes||n.ifcTypes.length===0?!0:(n.includeSubtypes?n.ifcTypes.flatMap(i=>[i,...It(i)]):n.ifcTypes).some(i=>i.toLowerCase()===t.ifcType.toLowerCase());case"property":{if(!n.propertyName)return!1;const e=n.operator||"equals";let i;if(n.propertySet&&t.properties)i=t.properties[n.propertySet]?.[n.propertyName];else if(t.properties){for(const s of Object.values(t.properties))if(n.propertyName in s){i=s[n.propertyName];break}}return ae(i,e,n.value)}case"propertySet":{if(!n.propertySet||!t.properties)return n.operator==="notExists";const e=n.propertySet in t.properties,i=n.operator||"exists";return i==="exists"?e:i==="notExists"?!e:e}case"material":return!n.materialNames||!t.materials?!1:n.materialNames.some(e=>t.materials.some(i=>i.toLowerCase().includes(e.toLowerCase())));case"layer":return!n.layerNames||!t.layers?!1:n.layerNames.some(e=>t.layers.some(i=>i.toLowerCase().includes(e.toLowerCase())));case"expressId":return n.expressIds?n.expressIds.includes(t.expressId):!1;case"modelId":return!n.modelIds||!t.modelId?!1:n.modelIds.includes(t.modelId);default:return!1}}function bt(n){return"logic"in n&&"conditions"in n}function j(n,t){if(bt(n)){const e=n.conditions.map(i=>j(i,t));return n.logic==="and"?e.every(Boolean):e.some(Boolean)}return le(n,t)}function ce(n){if(n===void 0)return k.lineWeight;if(typeof n=="number")return n;const t=se[n];return t!==void 0?t:k.lineWeight}function he(n){return n===void 0?k.dashPattern:typeof n=="string"?at[n]??k.dashPattern:n.custom?n.custom:n.preset?at[n.preset]??k.dashPattern:k.dashPattern}function lt(n,t){return{fillColor:t.fillColor??n.fillColor,strokeColor:t.strokeColor??n.strokeColor,backgroundColor:t.backgroundColor??n.backgroundColor,lineWeight:t.lineWeight!==void 0?ce(t.lineWeight):n.lineWeight,lineCap:t.lineCap??n.lineCap,lineJoin:t.lineJoin??n.lineJoin,dashPattern:t.lineStyle?he(t.lineStyle):n.dashPattern,hatchPattern:t.hatchPattern??n.hatchPattern,hatchSpacing:t.hatchSpacing??n.hatchSpacing,hatchAngle:t.hatchAngle??n.hatchAngle,hatchSecondaryAngle:t.hatchSecondaryAngle??n.hatchSecondaryAngle,hatchColor:t.hatchColor??n.hatchColor,hatchLineWeight:t.hatchLineWeight??n.hatchLineWeight,visible:t.visible??n.visible,opacity:t.opacity??n.opacity,drawOrder:t.drawOrder??n.drawOrder}}class Mt{rules=[];constructor(t){t&&this.setRules(t)}setRules(t){this.rules=[...t].sort((e,i)=>e.priority-i.priority)}addRule(t){this.rules.push(t),this.rules.sort((e,i)=>e.priority-i.priority)}removeRule(t){this.rules=this.rules.filter(e=>e.id!==t)}getRules(){return[...this.rules]}applyOverrides(t,e){let i=e?lt(k,e):{...k};const s=[];for(const o of this.rules)o.enabled&&j(o.criteria,t)&&(i=lt(i,o.style),s.push(o));return{element:t,style:i,matchedRules:s}}applyOverridesToMany(t,e){const i=new Map;for(const s of t){const o=e?.get(s.expressId);i.set(s.expressId,this.applyOverrides(s,o))}return i}getMatchingRules(t){return this.rules.filter(e=>e.enabled&&j(e.criteria,t))}static validateCriteria(t){const e=[];if(bt(t)){(!t.conditions||t.conditions.length===0)&&e.push("Compound criteria must have at least one condition");for(const i of t.conditions)e.push(...Mt.validateCriteria(i))}else t.type||e.push("Criterion must have a type"),t.type==="property"&&!t.propertyName&&e.push("Property criterion requires propertyName"),t.type==="ifcType"&&(!t.ifcTypes||t.ifcTypes.length===0)&&e.push("IFC type criterion requires at least one type");return e}}function S(n,t=!0){return{type:"ifcType",ifcTypes:n,includeSubtypes:t}}function v(n,t,e,i){return{type:"property",propertyName:n,propertySet:i,operator:t,value:e}}function T(...n){return{logic:"and",conditions:n}}let de=0;function ue(){return`builtin-rule-${++de}`}function F(n,t,e,i=100,s){return{id:ue(),name:n,description:s,enabled:!0,priority:i,criteria:t,style:e}}const fe=[F("Walls - Heavy cut lines",S(["IfcWall"]),{lineWeight:"heavy",strokeColor:"#000000",hatchPattern:"diagonal",hatchSpacing:3,hatchAngle:45},100,"Standard wall representation"),F("Columns - Heavy cut lines",S(["IfcColumn"]),{lineWeight:"heavy",strokeColor:"#000000",hatchPattern:"cross-hatch",hatchSpacing:2},100),F("Slabs - Medium lines",S(["IfcSlab"]),{lineWeight:"medium",fillColor:"#E0E0E0",hatchPattern:"concrete"},90),F("Windows - Light blue tint",S(["IfcWindow"]),{lineWeight:"light",fillColor:"#E3F2FD",strokeColor:"#1976D2",hatchPattern:"none"},80),F("Doors - No fill",S(["IfcDoor"]),{lineWeight:"medium",fillColor:"#FFFFFF",strokeColor:"#000000",hatchPattern:"none"},80),F("Furniture - Hairline",S(["IfcFurnishingElement","IfcFurniture"]),{lineWeight:"hairline",strokeColor:"#666666",fillColor:"#F5F5F5",hatchPattern:"none"},60)],ge={id:"preset-architectural",name:"Architectural Standards",description:"ISO 128 compliant architectural drawing standards",icon:"PenTool",rules:fe,builtIn:!0,category:"Standards"},pe=[F("Fire Rated 2hr+ - Red",T(S(["IfcWall"]),v("FireRating","greaterOrEqual",120)),{fillColor:"#FFCDD2",strokeColor:"#C62828",lineWeight:"heavy",hatchPattern:"diagonal",hatchColor:"#C62828"},200,"2-hour or higher fire rating"),F("Fire Rated 1hr - Orange",T(S(["IfcWall"]),v("FireRating","greaterOrEqual",60)),{fillColor:"#FFE0B2",strokeColor:"#E65100",lineWeight:"heavy",hatchPattern:"diagonal",hatchColor:"#E65100"},190),F("Fire Rated 30min - Yellow",T(S(["IfcWall"]),v("FireRating","greaterOrEqual",30)),{fillColor:"#FFF9C4",strokeColor:"#F9A825",lineWeight:"medium",hatchPattern:"diagonal",hatchColor:"#F9A825"},180),F("Fire Doors - Red outline",T(S(["IfcDoor"]),v("FireRating","exists")),{strokeColor:"#C62828",lineWeight:"heavy"},200),F("Escape Routes - Green",T(S(["IfcSpace"]),v("OccupancyType","contains","CIRCULATION")),{fillColor:"#C8E6C9",strokeColor:"#2E7D32",lineWeight:"light"},150)],ye={id:"preset-fire-safety",name:"Fire Safety",description:"Highlight fire-rated elements and escape routes",icon:"Flame",rules:pe,builtIn:!0,category:"Safety"},me=[F("Load-bearing Walls - Blue",T(S(["IfcWall"]),v("LoadBearing","equals",!0)),{fillColor:"#BBDEFB",strokeColor:"#1565C0",lineWeight:"heavy",hatchPattern:"diagonal",hatchColor:"#1565C0"},200),F("Columns - Blue heavy",S(["IfcColumn"]),{fillColor:"#90CAF9",strokeColor:"#0D47A1",lineWeight:"heavy",hatchPattern:"cross-hatch",hatchColor:"#0D47A1"},190),F("Beams - Blue medium",S(["IfcBeam"]),{fillColor:"#64B5F6",strokeColor:"#1976D2",lineWeight:"medium",hatchPattern:"diagonal"},180),F("Slabs - Light blue",S(["IfcSlab"]),{fillColor:"#E3F2FD",strokeColor:"#42A5F5",lineWeight:"medium"},170),F("Footings - Dark blue",S(["IfcFooting","IfcPile"]),{fillColor:"#1976D2",strokeColor:"#0D47A1",lineWeight:"heavy",hatchPattern:"concrete"},200),F("Non-structural - Faded",S(["IfcFurnishingElement","IfcFurniture","IfcCovering"]),{opacity:.3,lineWeight:"hairline"},50)],xe={id:"preset-structural",name:"Structural Highlight",description:"Emphasize structural elements, fade non-structural",icon:"Building2",rules:me,builtIn:!0,category:"Discipline"},Ce=[F("HVAC Ducts - Blue",S(["IfcDuctSegment","IfcDuctFitting"]),{fillColor:"#E3F2FD",strokeColor:"#1976D2",lineWeight:"medium"},150),F("Air Terminals - Blue",S(["IfcAirTerminal","IfcAirTerminalBox"]),{fillColor:"#BBDEFB",strokeColor:"#1565C0",lineWeight:"light"},140),F("Pipes - Green",S(["IfcPipeSegment","IfcPipeFitting"]),{fillColor:"#E8F5E9",strokeColor:"#388E3C",lineWeight:"medium"},150),F("Plumbing Fixtures - Green",S(["IfcSanitaryTerminal","IfcWasteTerminal"]),{fillColor:"#C8E6C9",strokeColor:"#2E7D32",lineWeight:"light"},140),F("Cable Trays - Orange",S(["IfcCableCarrierSegment","IfcCableCarrierFitting"]),{fillColor:"#FFF3E0",strokeColor:"#E65100",lineWeight:"light"},150),F("Electrical Equipment - Yellow",S(["IfcElectricDistributionBoard","IfcSwitchingDevice","IfcOutlet"]),{fillColor:"#FFFDE7",strokeColor:"#F9A825",lineWeight:"light"},140),F("Architectural - Faded",S(["IfcWall","IfcSlab","IfcDoor","IfcWindow"]),{opacity:.4,strokeColor:"#9E9E9E"},50)],Ie={id:"preset-mep",name:"MEP Highlight",description:"Color-code mechanical, electrical, and plumbing systems",icon:"Wrench",rules:Ce,builtIn:!0,category:"Discipline"},be={id:"preset-3d-colors",name:"Default",description:"By material color",icon:"Palette",rules:[],builtIn:!0,category:"Standards"},Me=[F("All elements - Black and white",{type:"all"},{strokeColor:"#000000",fillColor:"#FFFFFF",hatchColor:"#000000"},1),F("Cut elements - Gray fill",S(["IfcWall","IfcColumn","IfcSlab","IfcBeam"]),{fillColor:"#E0E0E0"},10)],we={id:"preset-monochrome",name:"Monochrome",description:"Black and white print-ready output",icon:"Printer",rules:Me,builtIn:!0,category:"Output"},Re=[be,ge,ye,xe,Ie,we],De={A0_LANDSCAPE:{id:"A0_LANDSCAPE",name:"A0 Landscape",category:"ISO",widthMm:1189,heightMm:841,orientation:"landscape",defaultMarginMm:20},A0_PORTRAIT:{id:"A0_PORTRAIT",name:"A0 Portrait",category:"ISO",widthMm:841,heightMm:1189,orientation:"portrait",defaultMarginMm:20},A1_LANDSCAPE:{id:"A1_LANDSCAPE",name:"A1 Landscape",category:"ISO",widthMm:841,heightMm:594,orientation:"landscape",defaultMarginMm:20},A1_PORTRAIT:{id:"A1_PORTRAIT",name:"A1 Portrait",category:"ISO",widthMm:594,heightMm:841,orientation:"portrait",defaultMarginMm:20},A2_LANDSCAPE:{id:"A2_LANDSCAPE",name:"A2 Landscape",category:"ISO",widthMm:594,heightMm:420,orientation:"landscape",defaultMarginMm:15},A2_PORTRAIT:{id:"A2_PORTRAIT",name:"A2 Portrait",category:"ISO",widthMm:420,heightMm:594,orientation:"portrait",defaultMarginMm:15},A3_LANDSCAPE:{id:"A3_LANDSCAPE",name:"A3 Landscape",category:"ISO",widthMm:420,heightMm:297,orientation:"landscape",defaultMarginMm:10},A3_PORTRAIT:{id:"A3_PORTRAIT",name:"A3 Portrait",category:"ISO",widthMm:297,heightMm:420,orientation:"portrait",defaultMarginMm:10},A4_LANDSCAPE:{id:"A4_LANDSCAPE",name:"A4 Landscape",category:"ISO",widthMm:297,heightMm:210,orientation:"landscape",defaultMarginMm:10},A4_PORTRAIT:{id:"A4_PORTRAIT",name:"A4 Portrait",category:"ISO",widthMm:210,heightMm:297,orientation:"portrait",defaultMarginMm:10},LETTER_LANDSCAPE:{id:"LETTER_LANDSCAPE",name:"US Letter Landscape",category:"ANSI",widthMm:279.4,heightMm:215.9,orientation:"landscape",defaultMarginMm:10},LETTER_PORTRAIT:{id:"LETTER_PORTRAIT",name:"US Letter Portrait",category:"ANSI",widthMm:215.9,heightMm:279.4,orientation:"portrait",defaultMarginMm:10},LEGAL_LANDSCAPE:{id:"LEGAL_LANDSCAPE",name:"US Legal Landscape",category:"ANSI",widthMm:355.6,heightMm:215.9,orientation:"landscape",defaultMarginMm:10},LEGAL_PORTRAIT:{id:"LEGAL_PORTRAIT",name:"US Legal Portrait",category:"ANSI",widthMm:215.9,heightMm:355.6,orientation:"portrait",defaultMarginMm:10},TABLOID_LANDSCAPE:{id:"TABLOID_LANDSCAPE",name:"US Tabloid Landscape",category:"ANSI",widthMm:431.8,heightMm:279.4,orientation:"landscape",defaultMarginMm:15},TABLOID_PORTRAIT:{id:"TABLOID_PORTRAIT",name:"US Tabloid Portrait",category:"ANSI",widthMm:279.4,heightMm:431.8,orientation:"portrait",defaultMarginMm:15},ANSI_C:{id:"ANSI_C",name:"ANSI C (17x22)",category:"ANSI",widthMm:558.8,heightMm:431.8,orientation:"landscape",defaultMarginMm:15},ANSI_D:{id:"ANSI_D",name:"ANSI D (22x34)",category:"ANSI",widthMm:863.6,heightMm:558.8,orientation:"landscape",defaultMarginMm:20},ANSI_E:{id:"ANSI_E",name:"ANSI E (34x44)",category:"ANSI",widthMm:1117.6,heightMm:863.6,orientation:"landscape",defaultMarginMm:20},ARCH_A:{id:"ARCH_A",name:"ARCH A (9x12)",category:"ARCH",widthMm:304.8,heightMm:228.6,orientation:"landscape",defaultMarginMm:10},ARCH_B:{id:"ARCH_B",name:"ARCH B (12x18)",category:"ARCH",widthMm:457.2,heightMm:304.8,orientation:"landscape",defaultMarginMm:15},ARCH_C:{id:"ARCH_C",name:"ARCH C (18x24)",category:"ARCH",widthMm:609.6,heightMm:457.2,orientation:"landscape",defaultMarginMm:15},ARCH_D:{id:"ARCH_D",name:"ARCH D (24x36)",category:"ARCH",widthMm:914.4,heightMm:609.6,orientation:"landscape",defaultMarginMm:20},ARCH_E:{id:"ARCH_E",name:"ARCH E (36x48)",category:"ARCH",widthMm:1219.2,heightMm:914.4,orientation:"landscape",defaultMarginMm:20},ARCH_E1:{id:"ARCH_E1",name:"ARCH E1 (30x42)",category:"ARCH",widthMm:1066.8,heightMm:762,orientation:"landscape",defaultMarginMm:20}},We={simple:{margins:{top:10,right:10,bottom:10,left:10,bindingMargin:0},border:{outerLineWeight:.7,innerLineWeight:.35,borderGap:0,showFoldMarks:!1,showTrimMarks:!1},showZoneReferences:!1,horizontalZones:0,verticalZones:0,zoneFontSize:3},professional:{margins:{top:10,right:10,bottom:10,left:20,bindingMargin:10},border:{outerLineWeight:.7,innerLineWeight:.35,borderGap:5,showFoldMarks:!0,showTrimMarks:!0},showZoneReferences:!0,horizontalZones:8,verticalZones:6,zoneFontSize:3.5},minimal:{margins:{top:5,right:5,bottom:5,left:5,bindingMargin:0},border:{outerLineWeight:.35,innerLineWeight:0,borderGap:0,showFoldMarks:!1,showTrimMarks:!1},showZoneReferences:!1,horizontalZones:0,verticalZones:0,zoneFontSize:3},iso:{margins:{top:10,right:10,bottom:10,left:20,bindingMargin:10},border:{outerLineWeight:.7,innerLineWeight:.35,borderGap:5,showFoldMarks:!0,showTrimMarks:!0},showZoneReferences:!0,horizontalZones:8,verticalZones:4,zoneFontSize:3.5},custom:{margins:{top:10,right:10,bottom:10,left:10,bindingMargin:0},border:{outerLineWeight:.5,innerLineWeight:.25,borderGap:3,showFoldMarks:!1,showTrimMarks:!1},showZoneReferences:!1,horizontalZones:0,verticalZones:0,zoneFontSize:3}},_e=[{id:"project-name",label:"Project",value:"",editable:!0,autoPopulate:!0,autoPopulateSource:"project.name",fontSize:4.5,fontWeight:"bold",row:0,col:0,colSpan:2},{id:"drawing-title",label:"Drawing Title",value:"Section",editable:!0,autoPopulate:!1,fontSize:5,fontWeight:"bold",row:1,col:0,colSpan:2},{id:"drawing-number",label:"Drawing No.",value:"A-001",editable:!0,autoPopulate:!1,fontSize:4,fontWeight:"bold",row:2,col:0},{id:"revision",label:"Rev",value:"-",editable:!0,autoPopulate:!1,fontSize:3.5,fontWeight:"bold",row:2,col:1},{id:"scale",label:"Scale",value:"1:100",editable:!1,autoPopulate:!0,autoPopulateSource:"drawing.scale",fontSize:3.5,fontWeight:"normal",row:3,col:0},{id:"date",label:"Date",value:"",editable:!0,autoPopulate:!0,autoPopulateSource:"date.today",fontSize:3,fontWeight:"normal",row:3,col:1},{id:"drawn-by",label:"Drawn",value:"",editable:!0,autoPopulate:!1,fontSize:3,fontWeight:"normal",row:4,col:0},{id:"checked-by",label:"Checked",value:"",editable:!0,autoPopulate:!1,fontSize:3,fontWeight:"normal",row:4,col:1},{id:"sheet-number",label:"Sheet",value:"1 of 1",editable:!0,autoPopulate:!1,fontSize:3,fontWeight:"normal",row:5,col:0,colSpan:2}],ze={compact:{layout:"compact",position:"bottom-right",widthMm:120,heightMm:35,borderWeight:.5,gridWeight:.25,showRevisionHistory:!1,maxRevisionEntries:0},standard:{layout:"standard",position:"bottom-right",widthMm:180,heightMm:55,borderWeight:.5,gridWeight:.25,showRevisionHistory:!0,maxRevisionEntries:3},extended:{layout:"extended",position:"bottom-full",widthMm:0,heightMm:70,borderWeight:.5,gridWeight:.25,showRevisionHistory:!0,maxRevisionEntries:5},custom:{layout:"custom",position:"bottom-right",widthMm:180,heightMm:55,borderWeight:.5,gridWeight:.25,showRevisionHistory:!1,maxRevisionEntries:0}},Be={visible:!0,style:"alternating",position:"below-viewport",units:"metric",totalLengthM:5,primaryDivisions:5,subdivisions:2,heightMm:3,labelFontSize:2.5,showUnitLabel:!0,fillColor:"#000000",strokeColor:"#000000",lineWeight:.25};function Ne(n,t){const i=Math.min(80,t*.8)*n/1e3,s=[.1,.2,.5,1,2,5,10,20,50,100,200,500,1e3];for(const o of s)if(o>=i*.5&&o<=i*1.5)return o;return Math.round(i)}const Oe={style:"simple",rotation:0,positionMm:{x:30,y:30},sizeMm:15};function He(n,t,e){const i=t.margins.left+t.margins.bindingMargin+t.border.borderGap,s=n.widthMm-t.margins.right-t.border.borderGap,o=t.margins.top+t.border.borderGap,r=n.heightMm-t.margins.bottom-t.border.borderGap;let a=i,l=o,c=s-i,u=r-o;const h=5;switch(e.position){case"bottom-right":u=r-o-e.heightMm-h;break;case"bottom-full":u=r-o-e.heightMm-h;break;case"right-strip":c=s-i-e.widthMm-h;break}return{x:a,y:l,width:c,height:u}}function Ue(n,t,e){const i=n.maxX-n.minX,s=n.maxY-n.minY,o=1e3/e.factor,r=i*o,a=s*o,l=.95,c=t.width*l/r,u=t.height*l/a,h=Math.min(c,u,1),d=o*h,f=i*d,g=s*d,y=t.x+(t.width-f)/2-n.minX*d,p=t.y+(t.height-g)/2+n.maxY*d;return{translateX:y,translateY:p,scaleFactor:d}}function je(n,t){let e=` <g id="drawing-frame">
|
|
195
|
-
`;const i=t.margins.left+t.margins.bindingMargin,s=t.margins.top,o=n.widthMm-t.margins.left-t.margins.right-t.margins.bindingMargin,r=n.heightMm-t.margins.top-t.margins.bottom;e+=` <rect x="${i.toFixed(2)}" y="${s.toFixed(2)}" `,e+=`width="${o.toFixed(2)}" height="${r.toFixed(2)}" `,e+=`fill="none" stroke="#000000" stroke-width="${t.border.outerLineWeight}"/>
|
|
196
|
-
`;let a=i,l=s,c=o,u=r;return t.border.borderGap>0&&t.border.innerLineWeight>0&&(a=i+t.border.borderGap,l=s+t.border.borderGap,c=o-2*t.border.borderGap,u=r-2*t.border.borderGap,e+=` <rect x="${a.toFixed(2)}" y="${l.toFixed(2)}" `,e+=`width="${c.toFixed(2)}" height="${u.toFixed(2)}" `,e+=`fill="none" stroke="#000000" stroke-width="${t.border.innerLineWeight}"/>
|
|
197
|
-
`),t.showZoneReferences&&t.horizontalZones>0&&(e+=Fe(i,s,o,r,t.border.borderGap,t.horizontalZones,t.verticalZones,t.zoneFontSize,t.border.innerLineWeight)),t.border.showFoldMarks&&(e+=Se(n)),t.border.showTrimMarks&&(e+=$e(n)),e+=` </g>
|
|
198
|
-
`,{svgElements:e,innerBounds:{x:a,y:l,width:c,height:u}}}function Fe(n,t,e,i,s,o,r,a,l){let c=` <g id="zone-references">
|
|
199
|
-
`;const u=e/o,h=i/r,d="ABCDEFGHIJKLMNOPQRSTUVWXYZ";for(let f=0;f<o;f++){const g=n+u*(f+.5),y=d[f%26];if(c+=` <text x="${g.toFixed(2)}" y="${(t-s/2).toFixed(2)}" `,c+=`font-family="Arial, sans-serif" font-size="${a}" `,c+=`text-anchor="middle" dominant-baseline="middle">${y}</text>
|
|
200
|
-
`,c+=` <text x="${g.toFixed(2)}" y="${(t+i+s/2).toFixed(2)}" `,c+=`font-family="Arial, sans-serif" font-size="${a}" `,c+=`text-anchor="middle" dominant-baseline="middle">${y}</text>
|
|
201
|
-
`,f>0){const p=n+u*f;c+=` <line x1="${p.toFixed(2)}" y1="${t.toFixed(2)}" `,c+=`x2="${p.toFixed(2)}" y2="${(t-s+2).toFixed(2)}" `,c+=`stroke="#000000" stroke-width="${l}"/>
|
|
202
|
-
`,c+=` <line x1="${p.toFixed(2)}" y1="${(t+i).toFixed(2)}" `,c+=`x2="${p.toFixed(2)}" y2="${(t+i+s-2).toFixed(2)}" `,c+=`stroke="#000000" stroke-width="${l}"/>
|
|
203
|
-
`}}for(let f=0;f<r;f++){const g=t+h*(f+.5),y=(f+1).toString();if(c+=` <text x="${(n-s/2).toFixed(2)}" y="${g.toFixed(2)}" `,c+=`font-family="Arial, sans-serif" font-size="${a}" `,c+=`text-anchor="middle" dominant-baseline="middle">${y}</text>
|
|
204
|
-
`,c+=` <text x="${(n+e+s/2).toFixed(2)}" y="${g.toFixed(2)}" `,c+=`font-family="Arial, sans-serif" font-size="${a}" `,c+=`text-anchor="middle" dominant-baseline="middle">${y}</text>
|
|
205
|
-
`,f>0){const p=t+h*f;c+=` <line x1="${n.toFixed(2)}" y1="${p.toFixed(2)}" `,c+=`x2="${(n-s+2).toFixed(2)}" y2="${p.toFixed(2)}" `,c+=`stroke="#000000" stroke-width="${l}"/>
|
|
206
|
-
`,c+=` <line x1="${(n+e).toFixed(2)}" y1="${p.toFixed(2)}" `,c+=`x2="${(n+e+s-2).toFixed(2)}" y2="${p.toFixed(2)}" `,c+=`stroke="#000000" stroke-width="${l}"/>
|
|
207
|
-
`}}return c+=` </g>
|
|
208
|
-
`,c}function Se(n,t,e,i,s){let o=` <g id="fold-marks">
|
|
209
|
-
`;if(n.heightMm>297){const u=Math.ceil(n.heightMm/297);for(let h=1;h<u;h++){const d=h*297;d<n.heightMm-20&&(o+=` <line x1="0" y1="${d.toFixed(2)}" x2="${5 .toFixed(2)}" y2="${d.toFixed(2)}" `,o+=`stroke="#000000" stroke-width="${.25}"/>
|
|
210
|
-
`,o+=` <line x1="${(n.widthMm-5).toFixed(2)}" y1="${d.toFixed(2)}" `,o+=`x2="${n.widthMm.toFixed(2)}" y2="${d.toFixed(2)}" `,o+=`stroke="#000000" stroke-width="${.25}"/>
|
|
211
|
-
`)}}if(n.widthMm>210){const u=Math.ceil(n.widthMm/210);for(let h=1;h<u;h++){const d=n.widthMm-h*210;d>20&&(o+=` <line x1="${d.toFixed(2)}" y1="0" x2="${d.toFixed(2)}" y2="${5 .toFixed(2)}" `,o+=`stroke="#000000" stroke-width="${.25}"/>
|
|
212
|
-
`,o+=` <line x1="${d.toFixed(2)}" y1="${(n.heightMm-5).toFixed(2)}" `,o+=`x2="${d.toFixed(2)}" y2="${n.heightMm.toFixed(2)}" `,o+=`stroke="#000000" stroke-width="${.25}"/>
|
|
213
|
-
`)}}return o+=` </g>
|
|
214
|
-
`,o}function $e(n){let t=` <g id="trim-marks">
|
|
215
|
-
`;return t+=` <line x1="${3 .toFixed(2)}" y1="0" x2="${3 .toFixed(2)}" y2="${8 .toFixed(2)}" `,t+=`stroke="#000000" stroke-width="${.15}"/>
|
|
216
|
-
`,t+=` <line x1="0" y1="${3 .toFixed(2)}" x2="${8 .toFixed(2)}" y2="${3 .toFixed(2)}" `,t+=`stroke="#000000" stroke-width="${.15}"/>
|
|
217
|
-
`,t+=` <line x1="${(n.widthMm-3).toFixed(2)}" y1="0" `,t+=`x2="${(n.widthMm-3).toFixed(2)}" y2="${8 .toFixed(2)}" `,t+=`stroke="#000000" stroke-width="${.15}"/>
|
|
218
|
-
`,t+=` <line x1="${(n.widthMm-8).toFixed(2)}" y1="${3 .toFixed(2)}" `,t+=`x2="${n.widthMm.toFixed(2)}" y2="${3 .toFixed(2)}" `,t+=`stroke="#000000" stroke-width="${.15}"/>
|
|
219
|
-
`,t+=` <line x1="${3 .toFixed(2)}" y1="${(n.heightMm-8).toFixed(2)}" `,t+=`x2="${3 .toFixed(2)}" y2="${n.heightMm.toFixed(2)}" `,t+=`stroke="#000000" stroke-width="${.15}"/>
|
|
220
|
-
`,t+=` <line x1="0" y1="${(n.heightMm-3).toFixed(2)}" `,t+=`x2="${8 .toFixed(2)}" y2="${(n.heightMm-3).toFixed(2)}" `,t+=`stroke="#000000" stroke-width="${.15}"/>
|
|
221
|
-
`,t+=` <line x1="${(n.widthMm-3).toFixed(2)}" y1="${(n.heightMm-8).toFixed(2)}" `,t+=`x2="${(n.widthMm-3).toFixed(2)}" y2="${n.heightMm.toFixed(2)}" `,t+=`stroke="#000000" stroke-width="${.15}"/>
|
|
222
|
-
`,t+=` <line x1="${(n.widthMm-8).toFixed(2)}" y1="${(n.heightMm-3).toFixed(2)}" `,t+=`x2="${n.widthMm.toFixed(2)}" y2="${(n.heightMm-3).toFixed(2)}" `,t+=`stroke="#000000" stroke-width="${.15}"/>
|
|
223
|
-
`,t+=` </g>
|
|
224
|
-
`,t}function Ge(n,t,e=[],i){let s,o,r,a;switch(n.position){case"bottom-right":r=n.widthMm,a=n.heightMm,s=t.x+t.width-r,o=t.y+t.height-a;break;case"bottom-full":r=t.width,a=n.heightMm,s=t.x,o=t.y+t.height-a;break;case"right-strip":r=n.widthMm,a=t.height,s=t.x+t.width-r,o=t.y;break;default:r=n.widthMm,a=n.heightMm,s=t.x+t.width-r,o=t.y+t.height-a}let l=` <g id="title-block">
|
|
225
|
-
`;return n.backgroundColor&&(l+=` <rect x="${s.toFixed(2)}" y="${o.toFixed(2)}" `,l+=`width="${r.toFixed(2)}" height="${a.toFixed(2)}" `,l+=`fill="${n.backgroundColor}"/>
|
|
226
|
-
`),l+=` <rect x="${s.toFixed(2)}" y="${o.toFixed(2)}" `,l+=`width="${r.toFixed(2)}" height="${a.toFixed(2)}" `,l+=`fill="none" stroke="#000000" stroke-width="${n.borderWeight}"/>
|
|
227
|
-
`,l+=Pe(n,s,o,r,a),n.logo?.source&&(l+=Ae(n.logo,s,o,r,a)),i?.scaleBar?.visible&&i?.scale&&a>10&&(l+=Ee(i.scaleBar,i.scale,s,o,r,a,n.logo!=null,i.effectiveScaleFactor)),i?.northArrow&&i.northArrow.style!=="none"&&a>15&&(l+=ke(i.northArrow,s,o,r,a,n.logo!=null,n.position)),n.showRevisionHistory&&e.length>0&&(l+=Le(e.slice(0,n.maxRevisionEntries),s,o,r,a,n)),l+=` </g>
|
|
228
|
-
`,{svgElements:l,bounds:{x:s,y:o,width:r,height:a}}}function Pe(n,t,e,i,s){let o=` <g id="title-block-fields">
|
|
229
|
-
`;const a=n.logo?50:0,l=n.showRevisionHistory?20:0,c=i-a-5,u=s-l-4,h=new Map;for(const C of n.fields){const b=C.row??0;h.has(b)||h.set(b,[]),h.get(b).push(C)}const d=Math.max(...Array.from(h.keys()))+1,f=[];let g=0;for(let C=0;C<d;C++){const b=h.get(C)||[],P=b.length>0?Math.max(...b.map(E=>E.fontSize)):3,A=Math.min(P*.5,2.2)+1+P+2;f.push(A),g+=A}const y=g>u?u/g:1,p=f.map(C=>C*y),m=t+a+2,I=e+2,w=c/2,x=[I];for(let C=0;C<p.length-1;C++)x.push(x[C]+p[C]);for(let C=1;C<d;C++){const b=x[C];o+=` <line x1="${m.toFixed(2)}" y1="${b.toFixed(2)}" `,o+=`x2="${(m+c-4).toFixed(2)}" y2="${b.toFixed(2)}" `,o+=`stroke="#000000" stroke-width="${n.gridWeight}"/>
|
|
230
|
-
`}for(const[C,b]of h)if(b.some(M=>(M.colSpan??1)<2)){const M=m+w,A=x[C],E=x[C]+p[C];o+=` <line x1="${M.toFixed(2)}" y1="${A.toFixed(2)}" `,o+=`x2="${M.toFixed(2)}" y2="${E.toFixed(2)}" `,o+=`stroke="#000000" stroke-width="${n.gridWeight}"/>
|
|
231
|
-
`}for(const[C,b]of h){const P=x[C];p[C];for(const M of b){const A=M.col??0;M.colSpan;const E=m+A*w+1.5,L=y<1?y:1,V=Math.min(M.fontSize*.45,2.2)*Math.max(L,.7),X=M.fontSize*Math.max(L,.7),q=P+.5+V;o+=` <text x="${E.toFixed(2)}" y="${q.toFixed(2)}" `,o+=`font-family="Arial, sans-serif" font-size="${V.toFixed(2)}" `,o+=`fill="#666666">${B(M.label)}</text>
|
|
232
|
-
`;const wt=q+.8+X*.8;o+=` <text x="${E.toFixed(2)}" y="${wt.toFixed(2)}" `,o+=`font-family="Arial, sans-serif" font-size="${X.toFixed(2)}" `,o+=`font-weight="${M.fontWeight}" fill="#000000">${B(M.value)}</text>
|
|
233
|
-
`}}return o+=` </g>
|
|
234
|
-
`,o}function Ae(n,t,e,i,s){let o=` <g id="title-block-logo">
|
|
235
|
-
`,r,a;switch(n.position){case"top-left":r=t+3,a=e+3;break;case"top-right":r=t+i-n.widthMm-3,a=e+3;break;case"bottom-left":default:r=t+3,a=e+s-n.heightMm-3;break}return o+=` <image x="${r.toFixed(2)}" y="${a.toFixed(2)}" `,o+=`width="${n.widthMm.toFixed(2)}" height="${n.heightMm.toFixed(2)}" `,o+=`href="${B(n.source)}" preserveAspectRatio="xMidYMid meet"/>
|
|
236
|
-
`,o+=` </g>
|
|
237
|
-
`,o}function Le(n,t,e,i,s,o){let r=` <g id="revision-history">
|
|
238
|
-
`;const l=e-18-2,c=4,u=2.2;r+=` <rect x="${t.toFixed(2)}" y="${l.toFixed(2)}" `,r+=`width="${i.toFixed(2)}" height="${18 .toFixed(2)}" `,r+=`fill="none" stroke="#000000" stroke-width="${o.gridWeight}"/>
|
|
239
|
-
`;const h=[{label:"REV",width:i*.1},{label:"DESCRIPTION",width:i*.5},{label:"DATE",width:i*.2},{label:"BY",width:i*.2}];let d=t;for(const f of h)r+=` <text x="${(d+1).toFixed(2)}" y="${(l+3).toFixed(2)}" `,r+=`font-family="Arial, sans-serif" font-size="${u}" `,r+=`font-weight="bold" fill="#000000">${f.label}</text>
|
|
240
|
-
`,d>t&&(r+=` <line x1="${d.toFixed(2)}" y1="${l.toFixed(2)}" `,r+=`x2="${d.toFixed(2)}" y2="${(l+18).toFixed(2)}" `,r+=`stroke="#000000" stroke-width="${o.gridWeight}"/>
|
|
241
|
-
`),d+=f.width;r+=` <line x1="${t.toFixed(2)}" y1="${(l+c).toFixed(2)}" `,r+=`x2="${(t+i).toFixed(2)}" y2="${(l+c).toFixed(2)}" `,r+=`stroke="#000000" stroke-width="${o.gridWeight}"/>
|
|
242
|
-
`;for(let f=0;f<n.length&&f<o.maxRevisionEntries;f++){const g=n[f],y=l+c*(f+1.5);d=t;const p=[g.revision,g.description,g.date,g.author];for(let m=0;m<h.length;m++){const I=Math.floor(h[m].width/2),w=p[m].length>I?p[m].substring(0,I-2)+"..":p[m];r+=` <text x="${(d+1).toFixed(2)}" y="${y.toFixed(2)}" `,r+=`font-family="Arial, sans-serif" font-size="${u}" `,r+=`fill="#000000">${B(w)}</text>
|
|
243
|
-
`,d+=h[m].width}f<n.length-1&&(r+=` <line x1="${t.toFixed(2)}" y1="${(l+c*(f+2)).toFixed(2)}" `,r+=`x2="${(t+i).toFixed(2)}" y2="${(l+c*(f+2)).toFixed(2)}" `,r+=`stroke="#000000" stroke-width="${o.gridWeight*.5}"/>
|
|
244
|
-
`)}return r+=` </g>
|
|
245
|
-
`,r}function Ee(n,t,e,i,s,o,r,a){let l=` <g id="title-block-scale-bar">
|
|
246
|
-
`;const c=a??t.factor,u=e+3,h=i+o-8,d=Math.min(s*.3,50),f=n.totalLengthM*1e3/c,g=Math.min(f,d),y=Math.min(n.heightMm,3),p=g*c/1e3,m=n.primaryDivisions,I=g/m;for(let b=0;b<m;b++){const P=u+b*I,M=b%2===0?n.fillColor:"#ffffff";l+=` <rect x="${P.toFixed(2)}" y="${h.toFixed(2)}" `,l+=`width="${I.toFixed(2)}" height="${y.toFixed(2)}" `,l+=`fill="${M}" stroke="${n.strokeColor}" stroke-width="${n.lineWeight}"/>
|
|
247
|
-
`}const w=1.8,x=h+y+w+.3;l+=` <text x="${u.toFixed(2)}" y="${x.toFixed(2)}" `,l+=`font-family="Arial, sans-serif" font-size="${w}" `,l+=`text-anchor="start" fill="#000000">0</text>
|
|
248
|
-
`;const C=p<1?`${(p*100).toFixed(0)}cm`:`${p.toFixed(0)}m`;return l+=` <text x="${(u+g).toFixed(2)}" y="${x.toFixed(2)}" `,l+=`font-family="Arial, sans-serif" font-size="${w}" `,l+=`text-anchor="end" fill="#000000">${C}</text>
|
|
249
|
-
`,l+=` </g>
|
|
250
|
-
`,l}function ke(n,t,e,i,s,o,r){let a=` <g id="title-block-north-arrow">
|
|
251
|
-
`;const l=Math.min(n.sizeMm,8,s*.6),c=t+i-l-5,u=e+s-l/2-3,h=n.rotation;a+=` <g transform="translate(${c.toFixed(2)}, ${u.toFixed(2)}) rotate(${h})">
|
|
252
|
-
`;const d=l/2;a+=` <polygon points="0,${(-d).toFixed(2)} ${(-d/3).toFixed(2)},${(d/2).toFixed(2)} ${(d/3).toFixed(2)},${(d/2).toFixed(2)}" `,a+=`fill="#000000" stroke="none"/>
|
|
253
|
-
`,a+=` <polygon points="0,${(d/3).toFixed(2)} ${(-d/3).toFixed(2)},${(d/2).toFixed(2)} ${(d/3).toFixed(2)},${(d/2).toFixed(2)}" `,a+=`fill="#ffffff" stroke="#000000" stroke-width="0.25"/>
|
|
254
|
-
`;const f=l*.4;return a+=` <text x="0" y="${(-d-1).toFixed(2)}" `,a+=`font-family="Arial, sans-serif" font-size="${f.toFixed(2)}" font-weight="bold" `,a+=`text-anchor="middle" fill="#000000">N</text>
|
|
255
|
-
`,a+=` </g>
|
|
256
|
-
`,a+=` </g>
|
|
257
|
-
`,a}function B(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}export{Re as B,O as C,Oe as D,We as F,Mt as G,De as P,ze as T,Be as a,_e as b,ve as c,Ue as d,Ne as e,He as f,Te as g,Ge as h,je as r};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const q="ASTM-E57";function Q(t){if(t.length<48)throw new Error("E57: header truncated (need 48 bytes)");const e=String.fromCharCode(...t.subarray(0,8));if(e!==q)throw new Error(`E57: bad magic "${e}" (expected "${q}")`);const n=new DataView(t.buffer,t.byteOffset,t.byteLength);return{majorVersion:n.getUint32(8,!0),minorVersion:n.getUint32(12,!0),fileLogicalSize:P(n,16),xmlLogicalOffset:R(P(n,24),P(n,40)),xmlLogicalLength:P(n,32),pageSize:P(n,40)}}function tt(t,e){if(e<=4)throw new Error("E57: pageSize too small");const n=e-4,o=Math.floor(t.length/e),r=t.length-o*e,i=new Uint8Array(o*n+Math.max(0,r-4));let s=0;for(let f=0;f<o;f++){const a=f*e;i.set(t.subarray(a,a+n),s),s+=n}if(r>4){const f=o*e;i.set(t.subarray(f,f+r-4),s)}return i}function R(t,e){const n=e-4,o=Math.floor(t/e),r=t-o*e;return o*n+r}function nt(t,e,n){const o=R(e,n);if(o+32>t.length)throw new Error(`E57: CompressedVector section header at logical ${o} runs past end of file (length ${t.length})`);const r=new DataView(t.buffer,t.byteOffset+o,32),i=r.getUint8(0);if(i!==1)throw new Error(`E57: expected CompressedVector section (id=1) at physical ${e}, got id=${i}`);const s=P(r,16);return R(s,n)}function P(t,e){const n=t.getUint32(e,!0);return t.getUint32(e+4,!0)*4294967296+n}function et(t){const e={name:"",attrs:new Map,children:[],text:""},n=[e];let o=0;const r=t.length;let i=-1;const s=f=>{if(i<0||i>=f){i=-1;return}const a=t.slice(i,f).trim();if(a.length>0){const c=n[n.length-1];c.children.length===0&&(c.text=c.text+G(a))}i=-1};for(;o<r;){if(t.charCodeAt(o)!==60){i<0&&(i=o),o++;continue}if(s(o),t.startsWith("<?",o)){const l=t.indexOf("?>",o+2);o=l<0?r:l+2;continue}if(t.startsWith("<!--",o)){const l=t.indexOf("-->",o+4);o=l<0?r:l+3;continue}if(t.startsWith("<![CDATA[",o)){const l=t.indexOf("]]>",o+9),b=t.slice(o+9,l<0?r:l),w=n[n.length-1];w.children.length===0&&(w.text=w.text+b),o=l<0?r:l+3;continue}if(t.startsWith("<!",o)){const l=t.indexOf(">",o+2);o=l<0?r:l+1;continue}if(t.charCodeAt(o+1)===47){const l=t.indexOf(">",o+2);if(l<0)throw new Error("XML: unterminated closing tag");const b=t.slice(o+2,l).trim(),w=n[n.length-1];if(w.name!==b)throw new Error(`XML: mismatched closing tag </${b}> (expected </${w.name}>)`);n.pop(),o=l+1;continue}const a=ot(t,o+1);if(a<0)throw new Error("XML: unterminated tag");let c=t.slice(o+1,a).trim(),d=!1;c.endsWith("/")&&(d=!0,c=c.slice(0,-1).trim());const h=c.match(/^([A-Za-z_][\w:.\-]*)/);if(!h){o=a+1;continue}const g=h[1],m=c.slice(g.length).trim(),u=rt(m),p={name:g,attrs:u,children:[],text:""};n.length===1&&e.name===""?(e.name=g,e.attrs=u,d||n.push(e)):(n[n.length-1].children.push(p),d||n.push(p)),o=a+1}if(s(r),n.length!==1)throw new Error(`XML: unclosed tag <${n[n.length-1].name}>`);if(e.name==="")throw new Error("XML: missing root element");return e}function ot(t,e){let n=!1;for(let o=e;o<t.length;o++){const r=t.charCodeAt(o);if(r===34)n=!n;else if(r===62&&!n)return o}return-1}const W=/([A-Za-z_][\w:.\-]*)\s*=\s*"([^"]*)"/g;function rt(t){const e=new Map;if(!t)return e;let n;for(W.lastIndex=0;(n=W.exec(t))!==null;)e.set(n[1],G(n[2]));return e}function G(t){return t.indexOf("&")<0?t:t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(e,n)=>String.fromCharCode(parseInt(n,10))).replace(/&#x([0-9a-fA-F]+);/g,(e,n)=>String.fromCharCode(parseInt(n,16))).replace(/&/g,"&")}function N(t,e){for(const n of t.children)if(n.name===e)return n;return null}function it(t,e){return t.children.filter(n=>n.name===e)}function A(t,e){const n=N(t,e);if(!n)return null;const o=n.text.trim();return o.length>0?o:null}function st(t){const e=et(t);if(e.name!=="e57Root")throw new Error(`E57: XML root is not <e57Root> (saw <${e.name||"?"}>)`);const n=N(e,"data3D");if(!n)return[];const o=[];for(const r of it(n,"vectorChild")){const i=N(r,"points");if(!i||i.attrs.get("type")!=="CompressedVector")continue;const s=i.attrs.get("fileOffset"),f=i.attrs.get("recordCount");if(!s||!f)continue;const a=Number(s),c=Number(f);if(!Number.isFinite(a)||a<0||!Number.isFinite(c)||c<0)continue;const d=N(i,"prototype");if(!d)continue;const h=[];for(const g of d.children){const m=g.attrs.get("type")??"";m==="Float"?h.push({name:g.name,kind:"Float",precision:g.attrs.get("precision")==="single"?"single":"double"}):m==="ScaledInteger"?h.push({name:g.name,kind:"ScaledInteger",scale:Number(g.attrs.get("scale")??"1"),offset:Number(g.attrs.get("offset")??"0"),minimum:Number(g.attrs.get("minimum")??"0"),maximum:Number(g.attrs.get("maximum")??"0")}):m==="Integer"&&h.push({name:g.name,kind:"Integer",minimum:Number(g.attrs.get("minimum")??"0"),maximum:Number(g.attrs.get("maximum")??"0")})}o.push({guid:A(r,"guid")??"",name:A(r,"name")??void 0,recordCount:c,binaryFileOffset:a,prototype:h,pose:at(N(r,"pose"))??void 0})}return o}function at(t){if(!t)return null;const e=N(t,"rotation"),n=N(t,"translation");if(!e||!n)return null;const o=Number(A(e,"w")??"1"),r=Number(A(e,"x")??"0"),i=Number(A(e,"y")??"0"),s=Number(A(e,"z")??"0"),f=Number(A(n,"x")??"0"),a=Number(A(n,"y")??"0"),c=Number(A(n,"z")??"0");return[o,r,i,s,f,a,c].every(Number.isFinite)?{rotation:{w:o,x:r,y:i,z:s},translation:{x:f,y:a,z:c}}:null}function U(t,e){return t.find(n=>n.name===e)}function ct(t,e){const n=U(e.prototype,"cartesianX"),o=U(e.prototype,"cartesianY"),r=U(e.prototype,"cartesianZ");if(!n||!o||!r)throw new Error("E57: prototype missing cartesianX/Y/Z");for(const w of[n,o,r])if(w.kind==="Integer")throw new Error(`E57: cartesian${w.name.slice(-1)} encoded as plain Integer (only Float / ScaledInteger supported)`);const i=U(e.prototype,"colorRed"),s=U(e.prototype,"colorGreen"),f=U(e.prototype,"colorBlue"),a=!!(i&&s&&f),c=U(e.prototype,"intensity"),d=U(e.prototype,"classification"),h=new Float32Array(e.recordCount*3),g=a?new Float32Array(e.recordCount*3):void 0,m=c&&(c.kind==="Float"||c.kind==="Integer"||c.kind==="ScaledInteger")?new Uint16Array(e.recordCount):void 0,u=d&&(d.kind==="Integer"||d.kind==="ScaledInteger")?new Uint8Array(e.recordCount):void 0;let p=e.binaryFileOffset;const l=new DataView(t.buffer,t.byteOffset,t.byteLength);let b=0;for(;b<e.recordCount&&p<t.length;){if(p+4>t.length)throw new Error("E57: truncated DataPacket header");const w=l.getUint8(p),x=l.getUint16(p+2,!0)+1;if(w!==1){p+=x;continue}const y=p+x;if(y>t.length)throw new Error("E57: DataPacket runs past end of logical bytes");const E=y;if(p+6>E)throw new Error("E57: truncated DataPacket header");const M=l.getUint16(p+4,!0);if(M!==e.prototype.length)throw new Error(`E57: packet bytestreamCount (${M}) ≠ prototype length (${e.prototype.length})`);const L=[];let S=p+6;for(let C=0;C<M;C++){if(S+2>E)throw new Error("E57: truncated bytestream length table");L.push(l.getUint16(S,!0)),S+=2}const F=new Map;let k=S;for(let C=0;C<M;C++){if(k+L[C]>E)throw new Error(`E57: bytestream ${e.prototype[C].name} (${L[C]} bytes) runs past packet payload at offset ${k}`);F.set(e.prototype[C].name,{start:k,length:L[C]}),k+=L[C]}const V=F.get("cartesianX"),Z=F.get("cartesianY"),_=F.get("cartesianZ"),j=v(n,V.length),H=v(o,Z.length),J=v(r,_.length),K=Math.min(j,H,J),I=Math.min(K,e.recordCount-b);D(t,l,n,V.start,h,b,I,0),D(t,l,o,Z.start,h,b,I,1),D(t,l,r,_.start,h,b,I,2),g&&i&&s&&f&&(z(l,F.get("colorRed").start,i,g,b,I,0,t),z(l,F.get("colorGreen").start,s,g,b,I,1,t),z(l,F.get("colorBlue").start,f,g,b,I,2,t)),m&&c&&ut(t,l,c,F.get("intensity").start,m,b,I),u&&d&<(t,l,d,F.get("classification").start,u,b,I),b+=I,p=y}return b<e.recordCount?Y(h.subarray(0,b*3),g?.subarray(0,b*3),m?.subarray(0,b),u?.subarray(0,b),b):Y(h,g,m,u,e.recordCount)}function z(t,e,n,o,r,i,s,f){if(n.kind==="Float"){const a=n.precision==="single"?4:8;for(let c=0;c<i;c++){const d=a===4?t.getFloat32(e+c*a,!0):t.getFloat64(e+c*a,!0);o[(r+c)*3+s]=X(d)}}else if(n.kind==="Integer"){const a=n.minimum??0,c=n.maximum??255,d=c-a,h=d>0?1/d:1,m=Math.max(Math.abs(a),Math.abs(c))>255?2:1,u=a<0;for(let p=0;p<i;p++){const l=e+p*m,b=m===2?u?t.getInt16(l,!0):t.getUint16(l,!0):u?t.getInt8(l):t.getUint8(l);o[(r+p)*3+s]=X((b-a)*h)}}else{const a=n.minimum??0,d=(n.maximum??1)-a,h=d>0?1/d:1,g=O(n),m=e*8;for(let u=0;u<i;u++){const p=$(f,m+u*g,g);o[(r+u)*3+s]=X(p*h)}}}function D(t,e,n,o,r,i,s,f){if(n.kind==="Float"){const m=n.precision==="single"?4:8;if(m===4)for(let u=0;u<s;u++)r[(i+u)*3+f]=e.getFloat32(o+u*m,!0);else for(let u=0;u<s;u++)r[(i+u)*3+f]=e.getFloat64(o+u*m,!0);return}const a=O(n),c=n.minimum??0,d=n.scale??1,h=n.offset??0,g=o*8;for(let m=0;m<s;m++){const u=$(t,g+m*a,a);r[(i+m)*3+f]=(u+c)*d+h}}function ut(t,e,n,o,r,i,s){if(n.kind==="Float"){const m=n.precision==="single"?4:8;for(let u=0;u<s;u++){const p=m===4?e.getFloat32(o+u*m,!0):e.getFloat64(o+u*m,!0);r[i+u]=Math.min(65535,Math.max(0,Math.round(p*65535)))}return}if(n.kind==="Integer"){const m=n.minimum??0,u=n.maximum??65535,p=u-m,l=p>0?1/p:1,w=Math.max(Math.abs(m),Math.abs(u))>255?2:1,x=m<0;for(let y=0;y<s;y++){const E=o+y*w,L=((w===2?x?e.getInt16(E,!0):e.getUint16(E,!0):x?e.getInt8(E):e.getUint8(E))-m)*l;r[i+y]=Math.min(65535,Math.max(0,Math.round(L*65535)))}return}const f=O(n),a=n.minimum??0,d=(n.maximum??a)-a,h=d>0?1/d:1,g=o*8;for(let m=0;m<s;m++){const u=$(t,g+m*f,f);r[i+m]=Math.min(65535,Math.max(0,Math.round(u*h*65535)))}}function O(t){const e=t.minimum??0,n=t.maximum??e,o=Math.max(0,n-e);if(o===0)return 1;const r=Math.ceil(Math.log2(o+1));if(r>53)throw new Error(`E57: ScaledInteger field "${t.name}" needs ${r} bits — exceeds the 53-bit Number-precision limit`);return Math.max(1,r)}function v(t,e){if(t.kind==="Float"){const s=t.precision==="single"?4:8;return Math.floor(e/s)}if(t.kind==="ScaledInteger"){const s=O(t);return Math.floor(e*8/s)}const n=t.minimum??0,o=t.maximum??255,i=Math.max(Math.abs(n),Math.abs(o))>255?2:1;return Math.floor(e/i)}function $(t,e,n){let o=0,r=0,i=e>>>3,s=e&7;for(;r<n;){const f=8-s,a=Math.min(f,n-r),c=(1<<a)-1,d=t[i]>>>s&c;o+=d*Math.pow(2,r),r+=a,s=0,i++}return o}function Y(t,e,n,o,r){return{positions:new Float32Array(t),colors:e?new Float32Array(e):void 0,intensities:n?new Uint16Array(n):void 0,classifications:o?new Uint8Array(o):void 0,pointCount:r,bbox:T(t)}}function lt(t,e,n,o,r,i,s){if(n.kind==="Integer"){const d=n.minimum??0,h=n.maximum??255,m=Math.max(Math.abs(d),Math.abs(h))>255?2:1,u=d<0;for(let p=0;p<s;p++){const l=o+p*m,b=m===2?u?e.getInt16(l,!0):e.getUint16(l,!0):u?e.getInt8(l):e.getUint8(l);r[i+p]=Math.max(0,Math.min(255,b))}return}const f=O(n),a=n.minimum??0,c=o*8;for(let d=0;d<s;d++){const h=$(t,c+d*f,f);r[i+d]=Math.max(0,Math.min(255,h+a))}}function X(t){return t<0?0:t>1?1:t}function T(t){if(t.length<3)return{min:[0,0,0],max:[0,0,0]};let e=1/0,n=1/0,o=1/0,r=-1/0,i=-1/0,s=-1/0,f=!1;for(let a=0;a+2<t.length;a+=3){const c=t[a],d=t[a+1],h=t[a+2];!Number.isFinite(c)||!Number.isFinite(d)||!Number.isFinite(h)||(f=!0,c<e&&(e=c),c>r&&(r=c),d<n&&(n=d),d>i&&(i=d),h<o&&(o=h),h>s&&(s=h))}return f?{min:[e,n,o],max:[r,i,s]}:{min:[0,0,0],max:[0,0,0]}}const ft=new TextDecoder;function mt(t){const e=Q(t),n=tt(t,e.pageSize),o=n.subarray(e.xmlLogicalOffset,e.xmlLogicalOffset+e.xmlLogicalLength),r=ft.decode(o),i=st(r);if(i.length===0)return null;const s=i.map(u=>{const p=nt(n,u.binaryFileOffset,e.pageSize),l=ct(n,{...u,binaryFileOffset:p});return u.pose&&(dt(l.positions,l.pointCount,u.pose),l.bbox=T(l.positions)),l});if(s.length===1)return s[0];let f=0;for(const u of s)f+=u.pointCount;const a=new Float32Array(f*3),c=s.some(u=>u.colors),d=s.some(u=>u.intensities),h=c?new Float32Array(f*3):void 0,g=d?new Uint16Array(f):void 0;let m=0;for(const u of s)a.set(u.positions,m*3),h&&u.colors&&h.set(u.colors,m*3),g&&u.intensities&&g.set(u.intensities,m),m+=u.pointCount;return{positions:a,colors:h,intensities:g,pointCount:f,bbox:T(a)}}function dt(t,e,n){const{w:o,x:r,y:i,z:s}=n.rotation,f=n.translation.x,a=n.translation.y,c=n.translation.z,d=1-2*(i*i+s*s),h=2*(r*i-o*s),g=2*(r*s+o*i),m=2*(r*i+o*s),u=1-2*(r*r+s*s),p=2*(i*s-o*r),l=2*(r*s-o*i),b=2*(i*s+o*r),w=1-2*(r*r+i*i);for(let x=0;x<e;x++){const y=t[x*3],E=t[x*3+1],M=t[x*3+2];t[x*3]=d*y+h*E+g*M+f,t[x*3+1]=m*y+u*E+p*M+a,t[x*3+2]=l*y+b*E+w*M+c}}class gt{blob;downsample;label;chunk=null;served=!1;constructor(e,n={}){this.blob=e,this.downsample=n.downsample??{stride:1},this.label=n.label}async open(e){B(e);const n=await this.blob.arrayBuffer();B(e);const o=mt(new Uint8Array(n));if(!o)throw new Error("E57: file contains no Data3D scans");return this.chunk=ht(o,this.downsample.stride),{totalPointCount:this.chunk.pointCount,bbox:this.chunk.bbox,hasColor:!!this.chunk.colors,hasClassification:!!this.chunk.classifications,hasIntensity:!!this.chunk.intensities,label:this.label}}async next(e,n){return B(n),!this.chunk||this.served?null:(this.served=!0,this.chunk)}close(){this.chunk=null,this.served=!1}}function ht(t,e){const n=Math.max(1,e|0);if(n===1)return t;const o=Math.ceil(t.pointCount/n),r=new Float32Array(o*3),i=t.colors?new Float32Array(o*3):void 0,s=t.intensities?new Uint16Array(o):void 0,f=t.classifications?new Uint8Array(o):void 0;let a=0;for(let c=0;c<t.pointCount;c+=n)r[a*3]=t.positions[c*3],r[a*3+1]=t.positions[c*3+1],r[a*3+2]=t.positions[c*3+2],i&&t.colors&&(i[a*3]=t.colors[c*3],i[a*3+1]=t.colors[c*3+1],i[a*3+2]=t.colors[c*3+2]),s&&t.intensities&&(s[a]=t.intensities[c]),f&&t.classifications&&(f[a]=t.classifications[c]),a++;return{positions:r,colors:i,intensities:s,classifications:f,pointCount:o,bbox:t.bbox}}function B(t){if(t?.aborted)throw new DOMException("Aborted","AbortError")}export{gt as E57StreamingSource};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let n;function l(e){j===w.length&&w.push(w.length+1);const t=j;return j=w[t],w[t]=e,t}function Yt(e){if(X==1)throw new Error("out of js stack");return w[--X]=e,X}const nt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>e.dtor(e.a,e.b));function Dt(e){e<132||(w[e]=j,j=e)}function Q(e,t){return e=e>>>0,Xt().subarray(e/4,e/4+t)}function Vt(e,t){return e=e>>>0,Gt().subarray(e/8,e/8+t)}function ht(e,t){return e=e>>>0,mt().subarray(e/4,e/4+t)}let I=null;function o(){return(I===null||I.buffer.detached===!0||I.buffer.detached===void 0&&I.buffer!==n.memory.buffer)&&(I=new DataView(n.memory.buffer)),I}let F=null;function Xt(){return(F===null||F.byteLength===0)&&(F=new Float32Array(n.memory.buffer)),F}let k=null;function Gt(){return(k===null||k.byteLength===0)&&(k=new Float64Array(n.memory.buffer)),k}function b(e,t){return e=e>>>0,$t(e,t)}let M=null;function mt(){return(M===null||M.byteLength===0)&&(M=new Uint32Array(n.memory.buffer)),M}let C=null;function R(){return(C===null||C.byteLength===0)&&(C=new Uint8Array(n.memory.buffer)),C}function p(e){return w[e]}function N(e,t){try{return e.apply(this,t)}catch(r){n.__wbindgen_export(l(r))}}let w=new Array(128).fill(void 0);w.push(void 0,null,!0,!1);let j=w.length;function V(e){return e==null}function Zt(e,t,r,_){const i={a:e,b:t,cnt:1,dtor:r},s=(...c)=>{i.cnt++;const a=i.a;i.a=0;try{return _(a,i.b,...c)}finally{i.a=a,s._wbg_cb_unref()}};return s._wbg_cb_unref=()=>{--i.cnt===0&&(i.dtor(i.a,i.b),i.a=0,nt.unregister(i))},nt.register(s,i,i),s}function h(e,t){const r=t(e.length*4,4)>>>0;return mt().set(e,r/4),g=e.length,r}function v(e,t){const r=t(e.length*1,1)>>>0;return R().set(e,r/1),g=e.length,r}function m(e,t,r){if(r===void 0){const a=P.encode(e),f=t(a.length,1)>>>0;return R().subarray(f,f+a.length).set(a),g=a.length,f}let _=e.length,i=t(_,1)>>>0;const s=R();let c=0;for(;c<_;c++){const a=e.charCodeAt(c);if(a>127)break;s[i+c]=a}if(c!==_){c!==0&&(e=e.slice(c)),i=r(i,_,_=c+e.length*3,1)>>>0;const a=R().subarray(i+c,i+_),f=P.encodeInto(e,a);c+=f.written,i=r(i,_,c,1)>>>0}return g=c,i}let X=128;function d(e){const t=p(e);return Dt(e),t}let G=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});G.decode();const Kt=2146435072;let J=0;function $t(e,t){return J+=t,J>=Kt&&(G=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),G.decode(),J=t),G.decode(R().subarray(e,e+t))}const P=new TextEncoder;"encodeInto"in P||(P.encodeInto=function(e,t){const r=P.encode(e);return t.set(r),{read:e.length,written:r.length}});let g=0;function qt(e,t,r){n.__wasm_bindgen_func_elem_593(e,t,l(r))}function Ht(e,t,r,_){n.__wasm_bindgen_func_elem_627(e,t,l(r),l(_))}typeof FinalizationRegistry>"u"||new FinalizationRegistry(e=>n.__wbg_clashrunresult_free(e>>>0,1));typeof FinalizationRegistry>"u"||new FinalizationRegistry(e=>n.__wbg_clashsession_free(e>>>0,1));const _t=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_ifcapi_free(e>>>0,1)),it=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_meshcollection_free(e>>>0,1)),st=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_meshdatajs_free(e>>>0,1)),ot=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_profilecollection_free(e>>>0,1)),at=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_profileentryjs_free(e>>>0,1)),ct=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_symboliccircle_free(e>>>0,1)),lt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_symbolicfillarea_free(e>>>0,1)),gt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_symbolicpolyline_free(e>>>0,1)),dt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_symbolicrepresentationcollection_free(e>>>0,1)),pt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>n.__wbg_symbolictext_free(e>>>0,1));class K{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,_t.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_ifcapi_free(t,0)}buildPrePassFast(t){const r=v(t,n.__wbindgen_export3),_=g,i=n.ifcapi_buildPrePassFast(this.__wbg_ptr,r,_);return d(i)}buildPrePassOnce(t){const r=v(t,n.__wbindgen_export3),_=g,i=n.ifcapi_buildPrePassOnce(this.__wbg_ptr,r,_);return d(i)}processGeometryBatch(t,r,_,i,s,c,a,f,x,$,q,H){const A=v(t,n.__wbindgen_export3),kt=g,Mt=h(r,n.__wbindgen_export3),Ct=g,Rt=h(f,n.__wbindgen_export3),jt=g,Pt=h(x,n.__wbindgen_export3),Et=g,Tt=h($,n.__wbindgen_export3),Bt=g,Ot=h(q,n.__wbindgen_export3),zt=g,Lt=v(H,n.__wbindgen_export3),Wt=g,Ut=n.ifcapi_processGeometryBatch(this.__wbg_ptr,A,kt,Mt,Ct,_,i,s,c,a,Rt,jt,Pt,Et,Tt,Bt,Ot,zt,Lt,Wt);return E.__wrap(Ut)}buildPrePassStreaming(t,r,_){try{const a=n.__wbindgen_add_to_stack_pointer(-16),f=v(t,n.__wbindgen_export3),x=g;n.ifcapi_buildPrePassStreaming(a,this.__wbg_ptr,f,x,Yt(r),_);var i=o().getInt32(a+0,!0),s=o().getInt32(a+4,!0),c=o().getInt32(a+8,!0);if(c)throw d(s);return d(i)}finally{n.__wbindgen_add_to_stack_pointer(16),w[X++]=void 0}}parseAlignmentLines(t){const r=m(t,n.__wbindgen_export3,n.__wbindgen_export4),_=g,i=n.ifcapi_parseAlignmentLines(this.__wbg_ptr,r,_);return d(i)}extractProfiles(t,r){const _=m(t,n.__wbindgen_export3,n.__wbindgen_export4),i=g,s=n.ifcapi_extractProfiles(this.__wbg_ptr,_,i,r);return B.__wrap(s)}getMemory(){const t=n.ifcapi_getMemory(this.__wbg_ptr);return d(t)}setEntityIndex(t,r,_){const i=h(t,n.__wbindgen_export3),s=g,c=h(r,n.__wbindgen_export3),a=g,f=h(_,n.__wbindgen_export3),x=g;n.ifcapi_setEntityIndex(this.__wbg_ptr,i,s,c,a,f,x)}setMergeLayers(t){n.ifcapi_setMergeLayers(this.__wbg_ptr,t)}clearPrePassCache(){n.ifcapi_clearPrePassCache(this.__wbg_ptr)}constructor(){const t=n.ifcapi_new();return this.__wbg_ptr=t>>>0,_t.register(this,this.__wbg_ptr,this),this}get version(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.ifcapi_version(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get is_ready(){return n.ifcapi_is_ready(this.__wbg_ptr)!==0}parseStreaming(t,r){const _=m(t,n.__wbindgen_export3,n.__wbindgen_export4),i=g,s=n.ifcapi_parseStreaming(this.__wbg_ptr,_,i,l(r));return d(s)}scanEntitiesFast(t){const r=m(t,n.__wbindgen_export3,n.__wbindgen_export4),_=g,i=n.ifcapi_scanEntitiesFast(this.__wbg_ptr,r,_);return d(i)}scanEntitiesFastBytes(t){const r=v(t,n.__wbindgen_export3),_=g,i=n.ifcapi_scanEntitiesFastBytes(this.__wbg_ptr,r,_);return d(i)}scanGeometryEntitiesFast(t){const r=m(t,n.__wbindgen_export3,n.__wbindgen_export4),_=g,i=n.ifcapi_scanGeometryEntitiesFast(this.__wbg_ptr,r,_);return d(i)}scanRelevantEntitiesFastBytes(t){const r=v(t,n.__wbindgen_export3),_=g,i=n.ifcapi_scanRelevantEntitiesFastBytes(this.__wbg_ptr,r,_);return d(i)}parse(t){const r=m(t,n.__wbindgen_export3,n.__wbindgen_export4),_=g,i=n.ifcapi_parse(this.__wbg_ptr,r,_);return d(i)}parseSymbolicRepresentations(t){const r=m(t,n.__wbindgen_export3,n.__wbindgen_export4),_=g,i=n.ifcapi_parseSymbolicRepresentations(this.__wbg_ptr,r,_);return U.__wrap(i)}}Symbol.dispose&&(K.prototype[Symbol.dispose]=K.prototype.free);class E{static __wrap(t){t=t>>>0;const r=Object.create(E.prototype);return r.__wbg_ptr=t,it.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,it.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_meshcollection_free(t,0)}get rtcOffsetX(){return n.meshcollection_rtcOffsetX(this.__wbg_ptr)}get rtcOffsetY(){return n.meshcollection_rtcOffsetY(this.__wbg_ptr)}get rtcOffsetZ(){return n.meshcollection_rtcOffsetZ(this.__wbg_ptr)}hasRtcOffset(){return n.meshcollection_hasRtcOffset(this.__wbg_ptr)!==0}localToWorld(t,r,_){try{const a=n.__wbindgen_add_to_stack_pointer(-16);n.meshcollection_localToWorld(a,this.__wbg_ptr,t,r,_);var i=o().getInt32(a+0,!0),s=o().getInt32(a+4,!0),c=Vt(i,s).slice();return n.__wbindgen_export2(i,s*8,8),c}finally{n.__wbindgen_add_to_stack_pointer(16)}}get totalVertices(){return n.meshcollection_totalVertices(this.__wbg_ptr)>>>0}get totalTriangles(){return n.meshcollection_totalTriangles(this.__wbg_ptr)>>>0}get buildingRotation(){try{const _=n.__wbindgen_add_to_stack_pointer(-16);n.meshcollection_buildingRotation(_,this.__wbg_ptr);var t=o().getInt32(_+0,!0),r=o().getFloat64(_+8,!0);return t===0?void 0:r}finally{n.__wbindgen_add_to_stack_pointer(16)}}get(t){const r=n.meshcollection_get(this.__wbg_ptr,t);return r===0?void 0:T.__wrap(r)}get length(){return n.meshcollection_length(this.__wbg_ptr)>>>0}}Symbol.dispose&&(E.prototype[Symbol.dispose]=E.prototype.free);class T{static __wrap(t){t=t>>>0;const r=Object.create(T.prototype);return r.__wbg_ptr=t,st.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,st.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_meshdatajs_free(t,0)}get expressId(){return n.meshdatajs_expressId(this.__wbg_ptr)>>>0}get vertexCount(){return n.meshdatajs_vertexCount(this.__wbg_ptr)>>>0}get shadingColor(){try{const _=n.__wbindgen_add_to_stack_pointer(-16);n.meshdatajs_shadingColor(_,this.__wbg_ptr);var t=o().getInt32(_+0,!0),r=o().getInt32(_+4,!0);let i;return t!==0&&(i=Q(t,r).slice(),n.__wbindgen_export2(t,r*4,4)),i}finally{n.__wbindgen_add_to_stack_pointer(16)}}get triangleCount(){return n.meshdatajs_triangleCount(this.__wbg_ptr)>>>0}get color(){try{const i=n.__wbindgen_add_to_stack_pointer(-16);n.meshdatajs_color(i,this.__wbg_ptr);var t=o().getInt32(i+0,!0),r=o().getInt32(i+4,!0),_=Q(t,r).slice();return n.__wbindgen_export2(t,r*4,4),_}finally{n.__wbindgen_add_to_stack_pointer(16)}}get indices(){const t=n.meshdatajs_indices(this.__wbg_ptr);return d(t)}get normals(){const t=n.meshdatajs_normals(this.__wbg_ptr);return d(t)}get ifcType(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.meshdatajs_ifcType(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get positions(){const t=n.meshdatajs_positions(this.__wbg_ptr);return d(t)}}Symbol.dispose&&(T.prototype[Symbol.dispose]=T.prototype.free);class B{static __wrap(t){t=t>>>0;const r=Object.create(B.prototype);return r.__wbg_ptr=t,ot.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,ot.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_profilecollection_free(t,0)}get(t){const r=n.profilecollection_get(this.__wbg_ptr,t);return r===0?void 0:O.__wrap(r)}get length(){return n.profilecollection_length(this.__wbg_ptr)>>>0}}Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);class O{static __wrap(t){t=t>>>0;const r=Object.create(O.prototype);return r.__wbg_ptr=t,at.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,at.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_profileentryjs_free(t,0)}get expressId(){return n.profileentryjs_expressId(this.__wbg_ptr)>>>0}get holeCounts(){const t=n.profileentryjs_holeCounts(this.__wbg_ptr);return d(t)}get holePoints(){const t=n.profileentryjs_holePoints(this.__wbg_ptr);return d(t)}get modelIndex(){return n.profileentryjs_modelIndex(this.__wbg_ptr)>>>0}get outerPoints(){const t=n.profileentryjs_outerPoints(this.__wbg_ptr);return d(t)}get extrusionDir(){const t=n.profileentryjs_extrusionDir(this.__wbg_ptr);return d(t)}get extrusionDepth(){return n.profileentryjs_extrusionDepth(this.__wbg_ptr)}get ifcType(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.profileentryjs_ifcType(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get transform(){const t=n.profileentryjs_transform(this.__wbg_ptr);return d(t)}}Symbol.dispose&&(O.prototype[Symbol.dispose]=O.prototype.free);class z{static __wrap(t){t=t>>>0;const r=Object.create(z.prototype);return r.__wbg_ptr=t,ct.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,ct.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_symboliccircle_free(t,0)}get expressId(){return n.symboliccircle_expressId(this.__wbg_ptr)>>>0}get startAngle(){return n.symboliccircle_startAngle(this.__wbg_ptr)}get isFullCircle(){return n.symboliccircle_isFullCircle(this.__wbg_ptr)!==0}get repIdentifier(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symboliccircle_repIdentifier(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get radius(){return n.symboliccircle_radius(this.__wbg_ptr)}get worldY(){return n.symboliccircle_worldY(this.__wbg_ptr)}get centerX(){return n.symboliccircle_centerX(this.__wbg_ptr)}get centerY(){return n.symboliccircle_centerY(this.__wbg_ptr)}get ifcType(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symboliccircle_ifcType(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get endAngle(){return n.symboliccircle_endAngle(this.__wbg_ptr)}}Symbol.dispose&&(z.prototype[Symbol.dispose]=z.prototype.free);class L{static __wrap(t){t=t>>>0;const r=Object.create(L.prototype);return r.__wbg_ptr=t,lt.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,lt.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_symbolicfillarea_free(t,0)}get expressId(){return n.profileentryjs_expressId(this.__wbg_ptr)>>>0}get holeCount(){return n.symbolicfillarea_holeCount(this.__wbg_ptr)>>>0}get hatchAngle(){return n.symbolicfillarea_hatchAngle(this.__wbg_ptr)}get pointCount(){return n.symbolicfillarea_pointCount(this.__wbg_ptr)>>>0}get hasHatching(){return n.symbolicfillarea_hasHatching(this.__wbg_ptr)!==0}get hatchSpacing(){return n.symbolicfillarea_hatchSpacing(this.__wbg_ptr)}get holesOffsets(){const t=n.symbolicfillarea_holesOffsets(this.__wbg_ptr);return d(t)}get repIdentifier(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symbolicfillarea_repIdentifier(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get hatchLineWidth(){return n.symbolicfillarea_hatchLineWidth(this.__wbg_ptr)}get hatchAngleSecondary(){return n.symbolicfillarea_hatchAngleSecondary(this.__wbg_ptr)}get fillA(){return n.symbolicfillarea_fillA(this.__wbg_ptr)}get fillB(){return n.symbolicfillarea_fillB(this.__wbg_ptr)}get fillG(){return n.symbolicfillarea_fillG(this.__wbg_ptr)}get fillR(){return n.symbolicfillarea_fillR(this.__wbg_ptr)}get points(){const t=n.symbolicfillarea_points(this.__wbg_ptr);return d(t)}get worldY(){return n.symbolicfillarea_worldY(this.__wbg_ptr)}get ifcType(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symbolicfillarea_ifcType(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}}Symbol.dispose&&(L.prototype[Symbol.dispose]=L.prototype.free);class W{static __wrap(t){t=t>>>0;const r=Object.create(W.prototype);return r.__wbg_ptr=t,gt.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,gt.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_symbolicpolyline_free(t,0)}get expressId(){return n.symbolicpolyline_expressId(this.__wbg_ptr)>>>0}get pointCount(){return n.symbolicfillarea_pointCount(this.__wbg_ptr)>>>0}get repIdentifier(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symbolicpolyline_repIdentifier(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get points(){const t=n.symbolicpolyline_points(this.__wbg_ptr);return d(t)}get worldY(){return n.symboliccircle_worldY(this.__wbg_ptr)}get ifcType(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symbolicpolyline_ifcType(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get isClosed(){return n.symbolicpolyline_isClosed(this.__wbg_ptr)!==0}}Symbol.dispose&&(W.prototype[Symbol.dispose]=W.prototype.free);class U{static __wrap(t){t=t>>>0;const r=Object.create(U.prototype);return r.__wbg_ptr=t,dt.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,dt.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_symbolicrepresentationcollection_free(t,0)}get fillCount(){return n.symbolicrepresentationcollection_fillCount(this.__wbg_ptr)>>>0}getCircle(t){const r=n.symbolicrepresentationcollection_getCircle(this.__wbg_ptr,t);return r===0?void 0:z.__wrap(r)}get textCount(){return n.symbolicrepresentationcollection_textCount(this.__wbg_ptr)>>>0}get totalCount(){return n.symbolicrepresentationcollection_totalCount(this.__wbg_ptr)>>>0}get circleCount(){return n.symbolicrepresentationcollection_circleCount(this.__wbg_ptr)>>>0}getPolyline(t){const r=n.symbolicrepresentationcollection_getPolyline(this.__wbg_ptr,t);return r===0?void 0:W.__wrap(r)}get polylineCount(){return n.symbolicrepresentationcollection_polylineCount(this.__wbg_ptr)>>>0}getExpressIds(){try{const i=n.__wbindgen_add_to_stack_pointer(-16);n.symbolicrepresentationcollection_getExpressIds(i,this.__wbg_ptr);var t=o().getInt32(i+0,!0),r=o().getInt32(i+4,!0),_=ht(t,r).slice();return n.__wbindgen_export2(t,r*4,4),_}finally{n.__wbindgen_add_to_stack_pointer(16)}}getFill(t){const r=n.symbolicrepresentationcollection_getFill(this.__wbg_ptr,t);return r===0?void 0:L.__wrap(r)}getText(t){const r=n.symbolicrepresentationcollection_getText(this.__wbg_ptr,t);return r===0?void 0:Y.__wrap(r)}get isEmpty(){return n.symbolicrepresentationcollection_isEmpty(this.__wbg_ptr)!==0}}Symbol.dispose&&(U.prototype[Symbol.dispose]=U.prototype.free);class Y{static __wrap(t){t=t>>>0;const r=Object.create(Y.prototype);return r.__wbg_ptr=t,pt.register(r,r.__wbg_ptr,r),r}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,pt.unregister(this),t}free(){const t=this.__destroy_into_raw();n.__wbg_symbolictext_free(t,0)}get expressId(){return n.profileentryjs_expressId(this.__wbg_ptr)>>>0}get repIdentifier(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symbolictext_repIdentifier(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get x(){return n.symbolicfillarea_fillR(this.__wbg_ptr)}get y(){return n.symbolicfillarea_fillG(this.__wbg_ptr)}get dirX(){return n.symbolicfillarea_fillB(this.__wbg_ptr)}get dirY(){return n.symbolicfillarea_fillA(this.__wbg_ptr)}get height(){return n.symbolicfillarea_hatchSpacing(this.__wbg_ptr)}get colorA(){return n.symbolictext_colorA(this.__wbg_ptr)}get colorB(){return n.symbolicfillarea_worldY(this.__wbg_ptr)}get colorG(){return n.symbolicfillarea_hatchLineWidth(this.__wbg_ptr)}get colorR(){return n.symbolicfillarea_hatchAngleSecondary(this.__wbg_ptr)}get content(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symbolictext_content(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get worldY(){return n.symbolicfillarea_hatchAngle(this.__wbg_ptr)}get ifcType(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symbolictext_ifcType(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get alignment(){let t,r;try{const s=n.__wbindgen_add_to_stack_pointer(-16);n.symbolictext_alignment(s,this.__wbg_ptr);var _=o().getInt32(s+0,!0),i=o().getInt32(s+4,!0);return t=_,r=i,b(_,i)}finally{n.__wbindgen_add_to_stack_pointer(16),n.__wbindgen_export2(t,r,1)}}get targetPx(){return n.symbolictext_targetPx(this.__wbg_ptr)}}Symbol.dispose&&(Y.prototype[Symbol.dispose]=Y.prototype.free);const Nt=new Set(["basic","cors","default"]);async function Jt(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(_){if(e.ok&&Nt.has(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",_);else throw _}const r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{const r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}}function xt(){const e={};return e.wbg={},e.wbg.__wbg_Error_52673b7de5a0ca89=function(t,r){const _=Error(b(t,r));return l(_)},e.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(t){return typeof p(t)=="function"},e.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(t){return p(t)===void 0},e.wbg.__wbg___wbindgen_memory_a342e963fbcabd68=function(){const t=n.memory;return l(t)},e.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(t,r){throw new Error(b(t,r))},e.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(t){p(t)._wbg_cb_unref()},e.wbg.__wbg_call_3020136f7a2d6e44=function(){return N(function(t,r,_){const i=p(t).call(p(r),p(_));return l(i)},arguments)},e.wbg.__wbg_call_abb4ff46ce38be40=function(){return N(function(t,r){const _=p(t).call(p(r));return l(_)},arguments)},e.wbg.__wbg_error_7534b8e9a36f1ab4=function(t,r){let _,i;try{_=t,i=r,console.error(b(t,r))}finally{n.__wbindgen_export2(_,i,1)}},e.wbg.__wbg_info_ce6bcc489c22f6f0=function(t){console.info(p(t))},e.wbg.__wbg_new_1ba21ce319a06297=function(){const t=new Object;return l(t)},e.wbg.__wbg_new_25f239778d6112b9=function(){const t=new Array;return l(t)},e.wbg.__wbg_new_8a6f238a6ece86ea=function(){const t=new Error;return l(t)},e.wbg.__wbg_new_ff12d2b041fb48f1=function(t,r){try{var _={a:t,b:r},i=(c,a)=>{const f=_.a;_.a=0;try{return Ht(f,_.b,c,a)}finally{_.a=f}};const s=new Promise(i);return l(s)}finally{_.a=_.b=0}},e.wbg.__wbg_new_from_slice_41e2764a343e3cb1=function(t,r){const _=new Float32Array(Q(t,r));return l(_)},e.wbg.__wbg_new_from_slice_db0691b69e9d3891=function(t,r){const _=new Uint32Array(ht(t,r));return l(_)},e.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(t,r){const _=new Function(b(t,r));return l(_)},e.wbg.__wbg_new_with_length_202b3db94ba5fc86=function(t){const r=new Uint32Array(t>>>0);return l(r)},e.wbg.__wbg_new_with_length_806b9e5b8290af7c=function(t){const r=new Float64Array(t>>>0);return l(r)},e.wbg.__wbg_new_with_length_aa5eaf41d35235e5=function(t){const r=new Uint8Array(t>>>0);return l(r)},e.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(t){const r=p(t).queueMicrotask;return l(r)},e.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(t){queueMicrotask(p(t))},e.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(t){const r=Promise.resolve(p(t));return l(r)},e.wbg.__wbg_set_3f1d0b984ed272ed=function(t,r,_){p(t)[d(r)]=d(_)},e.wbg.__wbg_set_781438a03c0c3c81=function(){return N(function(t,r,_){return Reflect.set(p(t),p(r),p(_))},arguments)},e.wbg.__wbg_set_7df433eea03a5c14=function(t,r,_){p(t)[r>>>0]=d(_)},e.wbg.__wbg_set_index_021489b2916af13e=function(t,r,_){p(t)[r>>>0]=_},e.wbg.__wbg_set_index_04c4b93e64d08a52=function(t,r,_){p(t)[r>>>0]=_},e.wbg.__wbg_set_index_42abe35f117e614e=function(t,r,_){p(t)[r>>>0]=_>>>0},e.wbg.__wbg_stack_0ed75d68575b0f3c=function(t,r){const _=p(r).stack,i=m(_,n.__wbindgen_export3,n.__wbindgen_export4),s=g;o().setInt32(t+4,s,!0),o().setInt32(t+0,i,!0)},e.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){const t=typeof global>"u"?null:global;return V(t)?0:l(t)},e.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){const t=typeof globalThis>"u"?null:globalThis;return V(t)?0:l(t)},e.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){const t=typeof self>"u"?null:self;return V(t)?0:l(t)},e.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){const t=typeof window>"u"?null:window;return V(t)?0:l(t)},e.wbg.__wbg_then_4f95312d68691235=function(t,r){const _=p(t).then(p(r));return l(_)},e.wbg.__wbg_warn_6e567d0d926ff881=function(t){console.warn(p(t))},e.wbg.__wbindgen_cast_2241b6af4c4b2941=function(t,r){const _=b(t,r);return l(_)},e.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(t){const r=BigInt.asUintN(64,t);return l(r)},e.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(t){return l(t)},e.wbg.__wbindgen_cast_e7ad0d7b317830d5=function(t,r){const _=Zt(t,r,n.__wasm_bindgen_func_elem_592,qt);return l(_)},e.wbg.__wbindgen_object_clone_ref=function(t){const r=p(t);return l(r)},e.wbg.__wbindgen_object_drop_ref=function(t){d(t)},e}function vt(e,t){return n=e.exports,It.__wbindgen_wasm_module=t,I=null,F=null,k=null,M=null,C=null,n.__wbindgen_start(),n}function Qt(e){if(n!==void 0)return n;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module:e}=e:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const t=xt();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));const r=new WebAssembly.Instance(e,t);return vt(r,e)}async function It(e){if(n!==void 0)return n;typeof e<"u"&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof e>"u"&&(e=new URL("/assets/ifc-lite_bg-CEZnhM2e.wasm",import.meta.url));const t=xt();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));const{instance:r,module:_}=await Jt(await e,t);return vt(r,_)}let y=null,St;async function S(){return y||(await It(St),y=new K,D=!1,tt(),y)}let At=!1,D=!1;function tt(){if(!y||D)return;const e=y;typeof e.setMergeLayers=="function"&&e.setMergeLayers(At),D=!0}function et(e){return new Uint8Array(e)}function rt(e){const t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t}let u=null;const ft=1e6;function bt(e){return{sharedBuffer:e.sharedBuffer,localBytes:et(e.sharedBuffer),sabFallbackTaken:!1,unitScale:e.unitScale,rtcX:e.rtcX,rtcY:e.rtcY,rtcZ:e.rtcZ,needsShift:e.needsShift,voidKeys:e.voidKeys,voidCounts:e.voidCounts,voidValues:e.voidValues,styleIds:e.styleIds,styleColors:e.styleColors,pendingMeshes:[],pendingTransfers:[],totalMeshesEmitted:0,cumulativeMeshBytes:0}}function Ft(e){if(e.pendingMeshes.length===0)return;const t=e.pendingMeshes,r=e.pendingTransfers;e.pendingMeshes=[],e.pendingTransfers=[],e.totalMeshesEmitted+=t.length,self.postMessage({type:"batch",meshes:t},r)}function te(e,t){for(let r=0;r<t.length;r++){const _=t.get(r);if(!_)continue;const i=new Float32Array(_.positions),s=new Float32Array(_.normals),c=new Uint32Array(_.indices);e.pendingMeshes.push({expressId:_.expressId,ifcType:_.ifcType,positions:i,normals:s,indices:c,color:[_.color[0],_.color[1],_.color[2],_.color[3]]}),e.pendingTransfers.push(i.buffer,s.buffer,c.buffer),e.cumulativeMeshBytes+=i.byteLength+s.byteLength+c.byteLength,_.free()}t.free()}async function Z(e,t){const r=Math.floor(t.length/3);if(r!==0)try{const i=(await S()).processGeometryBatch(e.localBytes,t,e.unitScale,e.rtcX,e.rtcY,e.rtcZ,e.needsShift,e.voidKeys,e.voidCounts,e.voidValues,e.styleIds,e.styleColors);te(e,i)}catch(_){const i=_.message;if(!e.sabFallbackTaken&&e.localBytes.buffer instanceof SharedArrayBuffer){e.sabFallbackTaken=!0,console.warn(`[Worker] processGeometryBatch rejected SAB view (${i}), falling back to copy`),e.localBytes=rt(e.sharedBuffer),await Z(e,t);return}if(r===1){console.warn(`[Worker] Skipping entity #${t[0]}: ${i}`),y=null;return}console.warn(`[Worker] Batch of ${r} entities failed (${i}), splitting…`),y=null;const s=Math.floor(r/2)*3;await Z(e,t.slice(0,s)),await Z(e,t.slice(s))}}async function ut(e,t){const r=Math.floor(t.length/3);for(let _=0;_<r;_+=ft){const i=_*3,s=Math.min(i+ft*3,t.length);await Z(e,t.subarray(i,s)),Ft(e)}}function wt(e){Ft(e);let t=0;try{t=y?.getMemory()?.buffer?.byteLength??0}catch{}self.postMessage({type:"memory",meshBytes:e.cumulativeMeshBytes,wasmHeapBytes:t}),self.postMessage({type:"complete",totalMeshes:e.totalMeshesEmitted})}let yt=Promise.resolve();self.onmessage=e=>{yt=yt.then(()=>ee(e)).catch(t=>{self.postMessage({type:"error",message:t instanceof Error?t.message:String(t)})})};async function ee(e){try{if(e.data.type==="prepass-streaming"){const t=await S();self.postMessage({type:"prepass-progress",phase:"parsing"});const r=e.data.sharedBuffer,_=e.data.chunkSize??5e4;let i=et(r),s=!1;const c=a=>{self.postMessage({type:"prepass-stream",event:a})};try{t.buildPrePassStreaming(i,c,_)}catch(a){const f=a instanceof Error?a.message:String(a);if(!s)s=!0,console.warn(`[Worker] Streaming prepass with SAB view failed (${f}), retrying with copy`),i=rt(r),t.buildPrePassStreaming(i,c,_);else throw a}return}if(e.data.type==="prepass"||e.data.type==="prepass-fast"){const t=await S();self.postMessage({type:"prepass-progress",phase:"parsing"});const r=e.data.sharedBuffer,_=e.data.type==="prepass-fast";let i;try{const s=et(r);i=_?t.buildPrePassFast(s):t.buildPrePassOnce(s)}catch(s){const c=s instanceof Error?s.message:String(s);console.warn(`[Worker] Prepass with SAB view failed (${c}), retrying with copy`);const a=rt(r);i=_?t.buildPrePassFast(a):t.buildPrePassOnce(a)}self.postMessage({type:"prepass-result",result:i});return}if(e.data.type==="init"){e.data.wasmUrl&&(St=e.data.wasmUrl),e.data.wasmModule?(Qt({module_or_path:e.data.wasmModule}),y=new K,D=!1,tt()):await S(),self.postMessage({type:"ready"});return}if(e.data.type==="process"){await S();const{sharedBuffer:t,jobsFlat:r,unitScale:_,rtcX:i,rtcY:s,rtcZ:c,needsShift:a,voidKeys:f,voidCounts:x,voidValues:$,styleIds:q,styleColors:H}=e.data,A=bt({sharedBuffer:t,unitScale:_,rtcX:i,rtcY:s,rtcZ:c,needsShift:a,voidKeys:f,voidCounts:x,voidValues:$,styleIds:q,styleColors:H});u=A,await ut(A,r),wt(A),u=null;return}if(e.data.type==="stream-start"){await S(),u=bt({sharedBuffer:e.data.sharedBuffer,unitScale:e.data.unitScale,rtcX:e.data.rtcX,rtcY:e.data.rtcY,rtcZ:e.data.rtcZ,needsShift:e.data.needsShift,voidKeys:e.data.voidKeys,voidCounts:e.data.voidCounts,voidValues:e.data.voidValues,styleIds:e.data.styleIds,styleColors:e.data.styleColors});return}if(e.data.type==="stream-chunk"){if(!u)throw new Error("stream-chunk received before stream-start");await ut(u,e.data.jobsFlat);return}if(e.data.type==="set-styles"){if(!u)return;u.styleIds=e.data.styleIds,u.styleColors=e.data.styleColors,u.voidKeys=e.data.voidKeys,u.voidCounts=e.data.voidCounts,u.voidValues=e.data.voidValues;return}if(e.data.type==="set-entity-index"){(await S()).setEntityIndex(e.data.ids,e.data.starts,e.data.lengths);return}if(e.data.type==="set-merge-layers"){At=e.data.enabled===!0,D=!1,tt();return}if(e.data.type==="stream-end"){if(!u)throw new Error("stream-end received before stream-start");wt(u),u=null;return}}catch(t){self.postMessage({type:"error",message:t instanceof Error?t.message:String(t)})}}
|
|
Binary file
|