feat(IFC): adds file id and parsing time to root commit object

This commit is contained in:
Dimitrie Stefanescu
2022-11-23 21:26:26 +00:00
parent 16c989e43c
commit 2b0e4a7dd5
3 changed files with 28 additions and 29 deletions
+15 -14
View File
@@ -7,7 +7,7 @@ const { parseAndCreateCommit } = require('./index')
async function main() {
const cmdArgs = process.argv.slice(2)
const [filePath, userId, streamId, branchName, commitMessage] = cmdArgs
const [filePath, userId, streamId, branchName, commitMessage, fileId] = cmdArgs
// eslint-disable-next-line no-console
console.log('ARGV: ', filePath, userId, streamId, branchName, commitMessage)
@@ -18,27 +18,28 @@ async function main() {
data,
streamId,
userId,
message: filePath + commitMessage || ' Imported file'
message: filePath + commitMessage || ' Imported file',
fileId
}
if (branchName) ifcInput.branchName = branchName
const output = {
let output = {
success: false,
error: 'Unknown error'
}
const commitId = await parseAndCreateCommit(ifcInput)
// try {
// output = {
// success: true,
// commitId
// }
// } catch (err) {
// output = {
// success: false,
// error: err.toString()
// }
// }
try {
output = {
success: true,
commitId
}
} catch (err) {
output = {
success: false,
error: err.toString()
}
}
fs.writeFileSync(TMP_RESULTS_PATH, JSON.stringify(output))
+3 -2
View File
@@ -8,10 +8,11 @@ async function parseAndCreateCommit({
streamId,
branchName = 'uploads',
userId,
message = 'Manual IFC file upload'
message = 'Manual IFC file upload',
fileId
}) {
const serverApi = new ServerAPI({ streamId })
const myParser = new Parser({ serverApi })
const myParser = new Parser({ serverApi, fileId })
const start = performance.now()
const { id, tCount } = await myParser.parse(data)
+10 -13
View File
@@ -10,18 +10,19 @@ const {
} = require('./utils')
module.exports = class IFCParser {
constructor({ serverApi }) {
constructor({ serverApi, fileId }) {
this.ifcapi = new WebIFC.IfcAPI()
this.ifcapi.SetWasmPath('./', false)
this.serverApi = serverApi
this.fileId = fileId
}
async parse(data) {
await this.ifcapi.Init()
this.modelId = this.ifcapi.OpenModel(new Uint8Array(data), { USE_FAST_BOOLS: true })
this.startTime = performance.now()
// prepoulate types
const p1 = performance.now()
this.types = await this.getAllTypesOfModel()
// prime caches for property sets and their relating objects, as well as,
@@ -32,23 +33,15 @@ module.exports = class IFCParser {
this.properties = properties
this.propCache = {}
// create and save the geometries; we're storing only references locally.
const p2 = performance.now()
console.log(`prop warmup ${(p2 - p1).toFixed(2)}ms`)
this.geometryReferences = await this.createAndSaveMeshes()
const p3 = performance.now()
console.log(`geometry warmup ${(p3 - p2).toFixed(2)}ms`)
// create and save the geometries; we're storing only references locally.
this.geometryReferences = await this.createAndSaveMeshes()
// create and save the spatial tree, populating both properties and geometry references
// where appropriate
this.spatialNodeCount = 0
this.nodeBatch = []
const structure = await this.createSpatialStructure()
const p4 = performance.now()
console.log(`structure ${(p4 - p3).toFixed(2)}ms`)
console.log(`total time spent: ${(p4 - p1).toFixed(2)}ms`)
console.log(structure.id)
return { id: structure.id, tCount: structure.closureLen }
}
@@ -65,6 +58,10 @@ module.exports = class IFCParser {
}
await this.populateSpatialNode(project, chunks, [])
this.endTime = performance.now()
project.parseTime = (this.endTime - this.startTime).toFixed(2) + 'ms'
project.fileId = this.fileId
if (this.nodeBatch.length !== 0) {
await this.flushNodeBatch()
}
@@ -93,7 +90,7 @@ module.exports = class IFCParser {
node.closureLen = node.closure.length
node.__closure = this.formatClosure(node.closure)
node.id = getHash(node)
// delete node.closure
this.nodeBatch.push(node)
if (this.nodeBatch.length > 3000) {