Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
237096a8
Commit
237096a8
authored
5 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
to worker
parent
8fdcd854
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/processes/mill/raster/3D
+102
-70
102 additions, 70 deletions
modules/processes/mill/raster/3D
with
102 additions
and
70 deletions
modules/processes/mill/raster/3D
+
102
−
70
View file @
237096a8
...
...
@@ -212,60 +212,88 @@ var interface = function(div){
//
// local functions
//
// calculate
_
path
// calculate
path
//
function calculate_path() {
var
h = mod.height
var
w = mod.width
var
xmin = mod.xmin
var xmax = mod.xmax
var ymin = mod.ymin
var ymax = mod.ymax
var zmin = mod.zmin
var zmax = mod.zmax
var
blob = new Blob(['('+calculate_path_worker.toString()+'())'])
var
url = window.URL.createObjectURL(blob)
var
webworker = new Worker(url)
webworker.addEventListener('message',function(evt) {
mod.triangles = evt.data.triangles
mod.path = evt.data.path
mod.label.nodeValue = 'calculate'
mod.labelspan.style.fontWeight = 'normal'
//
// clear SVG
//
var svg = document.getElementById(mod.div.id+'svg')
svg.setAttribute('viewBox',"0 0 "+(
w-1)+" "+(h
-1))
svg.setAttribute('viewBox',"0 0 "+(
mod.width-1)+" "+(mod.height
-1))
var g = document.getElementById(mod.div.id+'g')
svg.removeChild(g)
var g = document.createElementNS('http://www.w3.org/2000/svg','g')
g.setAttribute('id',mod.div.id+'g')
svg.appendChild(g)
//
// plot path
//
for (var i = 1; i < mod.path[0].length; ++i) {
var ixp = mod.path[0][i-1][0]
var iyp = mod.path[0][i-1][1]
var izp = 0.1*mod.path[0][i-1][2]
var ix = mod.path[0][i][0]
var iy = mod.path[0][i][1]
var iz = 0.1*mod.path[0][i][2]
var line = document.createElementNS('http://www.w3.org/2000/svg','line')
line.setAttribute('stroke','black')
line.setAttribute('stroke-width',1)
line.setAttribute('stroke-linecap','round')
line.setAttribute('x1',ixp)
line.setAttribute('y1',iyp-izp)
line.setAttribute('x2',ix)
line.setAttribute('y2',iy-iz)
g.appendChild(line)
}
})
webworker.postMessage({
h:mod.height,w:mod.width,
xmin:mod.xmin,xmax:mod.xmax,
ymin:mod.ymin,ymax:mod.ymax,
zmin:mod.zmin,zmax:mod.zmax,
map:mod.map})
}
//
// calculate path worker
//
function calculate_path_worker() {
self.addEventListener('message',function(evt) {
var h = evt.data.h
var w = evt.data.w
var xmin = evt.data.xmin
var xmax = evt.data.xmax
var ymin = evt.data.ymin
var ymax = evt.data.ymax
var zmin = evt.data.zmin
var zmax = evt.data.zmax
var map = evt.data.map
var path = [[]]
//
// line loop
//
var ix = 0
var iy = h-1
var dx = 1
var dy = 0
var x = xmin+(xmax-xmin)*ix/(w-1)
var y = ymin+(ymax-ymin)*iy/(h-1)
var z = mod.map[(h-1-iy)*w+ix]
var dz = 0.1*h*(zmax-z)/(ymax-ymin)
var iz = Math.floor((map[iy*w+ix]-zmax)*w/(xmax-xmin))
while (1) {
var ixp = ix
var iyp = iy
var dzp = dz
ix += dx
iy += dy
if (iy <= 0)
break;
var x = xmin+(xmax-xmin)*ix/(w-1)
var y = ymin+(ymax-ymin)*iy/(h-1)
var z = mod.map[iy*w+ix]
var dz = 0.1*h*(zmax-z)/(zmax-zmin)
var line = document.createElementNS('http://www.w3.org/2000/svg','line')
line.setAttribute('stroke','black')
line.setAttribute('stroke-width',1)
line.setAttribute('stroke-linecap','round')
line.setAttribute('x1',ixp)
line.setAttribute('y1',iyp+dzp)
line.setAttribute('x2',ix)
line.setAttribute('y2',iy+dz)
g.appendChild(line)
if (ix == (mod.width-1)) {
var iz = Math.floor((map[iy*w+ix]-zmax)*w/(xmax-xmin))
path[0].push([ix,iy,iz])
if (ix == (w-1)) {
if (dx == 1) {
dx = 0
dy = -10
...
...
@@ -286,8 +314,12 @@ function calculate_path() {
}
}
}
mod.label.nodeValue = 'calculate'
mod.labelspan.style.fontWeight = 'normal'
//
// return
//
self.postMessage({path:path})
self.close()
})
}
//
// return values
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment