-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
testLargeStepFile.js
74 lines (63 loc) · 1.89 KB
/
testLargeStepFile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const assert = require("assert");
const occ = require(".").occ;
const ProgressBar = require('progress');
const fs = require("fs");
require("should");
const filename = process.argv[2];
console.log("filename = ",filename);
if (!fs.existsSync(filename)) {
console.log("cannot find file ",filename);
process.exit(1);
}
const b3_step = filename;
let bar = new ProgressBar("reading file [:bar] :percent elapsed :elapseds ETA :etas", {
complete: '=',
incomplete: '-',
width: 100,
total: 1000
});
function read_file(callback) {
occ.readSTEP(b3_step, function (err, shapes) {
console.log(" nbShapes = ",shapes.length);
callback(err,shapes);
}, function feedback(percent) {
bar.tick(percent);
});
}
function performMesh(solids,callback) {
let bar = new ProgressBar("meshing solids [:bar] :percent elapsed :elapseds ETA :etas", {
complete: '=',
incomplete: '-',
width: 100,
total: solids.length
});
let nbTri = 0;
let nbVert = 0;
let jsonSize =0;
for (let i in solids) {
bar.tick();
let solid = solids[i];
if (solid.numFaces <= 1) {
console.log("solid has only one face !",solid);
}
solid.numFaces.should.be.greaterThan(0);
solid.name = "solid_" + i;
try {
const jsObj = occ.buildSolidMeshNew(solid);
let mesh = solid.mesh;
solid.mesh.numVertices.should.be.greaterThan(3);
nbVert += solid.mesh.numVertices;
nbTri += solid.mesh.numTriangles;
jsonSize += JSON.stringify(jsObj).length;
}
catch (err) {
console.log(" Error in meshing" ,err )
}
}
console.log(" nb Tri = ",nbTri," nbVertices = ",nbVert," size ",jsonSize);
}
read_file(function(err,shapes){
performMesh(shapes,function() {
console.log("done");
})
});