Skip to content
Snippets Groups Projects
Commit c2772027 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent 18393c42
Branches
No related tags found
No related merge requests found
Pipeline #4724 passed
#!/usr/bin/env node #!/usr/bin/env node
// //
// frepw.js // frep.js
// functional representation solver, worker version // functional representation solver
// //
// usage: // usage:
// pcb.py | node --experimental-worker frepw.js [dpi [filename]] // pcb.py | frep.js [dpi [workers [filename]]]
// with: // with:
// https://gitlab.cba.mit.edu/pub/libraries/blob/master/python/pcb.py // https://gitlab.cba.mit.edu/pub/libraries/blob/master/python/pcb.py
// //
// Neil Gershenfeld 12/9/18 // Neil Gershenfeld 12/7/19
// (c) Massachusetts Institute of Technology 2018
// //
// This work may be reproduced, modified, distributed, // This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must // performed, and displayed for any purpose, but must
...@@ -49,17 +48,26 @@ function render(frep) { ...@@ -49,17 +48,26 @@ function render(frep) {
} }
if (process.argv.length == 2) { if (process.argv.length == 2) {
var dpi = 100 var dpi = 100
workers = os.cpus().length
var filename = 'out.png' var filename = 'out.png'
console.log('output to out.png at 100 DPI') console.log('output to out.png at 100 DPI')
} }
else if (process.argv.length == 3) { else if (process.argv.length == 3) {
var dpi = parseInt(process.argv[2]) var dpi = parseInt(process.argv[2])
workers = os.cpus().length
var filename = 'out.png' var filename = 'out.png'
console.log('output to out.png at '+dpi+' DPI') console.log('output to out.png at '+dpi+' DPI')
} }
else if (process.argv.length == 4) { else if (process.argv.length == 4) {
var dpi = parseInt(process.argv[2]) var dpi = parseInt(process.argv[2])
var filename = process.argv[3] var workers = parseInt(process.argv[3])
var filename = 'out.png'
console.log('output to '+filename+' at '+dpi+' DPI')
}
else if (process.argv.length == 5) {
var dpi = parseInt(process.argv[2])
var workers = parseInt(process.argv[3])
var filename = process.argv[4]
console.log('output to '+filename+' at '+dpi+' DPI') console.log('output to '+filename+' at '+dpi+' DPI')
} }
// //
...@@ -108,7 +116,6 @@ function render(frep) { ...@@ -108,7 +116,6 @@ function render(frep) {
// //
// start workers // start workers
// //
var workers = os.cpus().length
console.log('start '+workers+' workers') console.log('start '+workers+' workers')
var count = 0 var count = 0
for (let i = 0; i < workers; ++i) { for (let i = 0; i < workers; ++i) {
...@@ -130,7 +137,8 @@ function render(frep) { ...@@ -130,7 +137,8 @@ function render(frep) {
} }
}) })
worker.postMessage({index:i,workers:workers, worker.postMessage({index:i,workers:workers,
delta:delta,width:width,height:height,xmin:frep.xmin,ymin:frep.ymin,z:frep.zmin, delta:delta,width:width,height:height,xmin:frep.xmin,ymin:frep.ymin,
z:frep.layers[0], // need to handle multiple layers
buf:buf,fn:frep.function}) buf:buf,fn:frep.function})
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment