| 164 | } |
| 165 | |
| 166 | export async function auditIfc(modelId: string, idsData: string | Uint8Array | ArrayBuffer) { |
| 167 | try { |
| 168 | let idsBytes: Uint8Array; |
| 169 | if (typeof idsData === 'string') { |
| 170 | idsBytes = new TextEncoder().encode(idsData); |
| 171 | } else if (idsData instanceof ArrayBuffer) { |
| 172 | idsBytes = new Uint8Array(idsData); |
| 173 | } else { |
| 174 | idsBytes = idsData; |
| 175 | } |
| 176 | |
| 177 | // Run audit |
| 178 | const auditResult = await wasm.auditIfc(modelId, idsBytes) as { json: AuditReportData; html: string }; |
| 179 | |
| 180 | console.log(`Audit completed for model ${modelId}`); |
| 181 | return auditResult; |
| 182 | } catch (error) { |
| 183 | console.error('Failed to audit IFC model:', error); |
| 184 | throw error; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | export function getLoadedModels() { |
| 189 | return IFCModels.models; |