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
d124f0e7
Commit
d124f0e7
authored
5 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
working on z vectorization
parent
237096a8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/processes/mill/raster/3D
+42
-19
42 additions, 19 deletions
modules/processes/mill/raster/3D
with
42 additions
and
19 deletions
modules/processes/mill/raster/3D
+
42
−
19
View file @
d124f0e7
...
@@ -131,14 +131,11 @@ var interface = function(div){
...
@@ -131,14 +131,11 @@ var interface = function(div){
//
//
// fit error
// fit error
//
//
div.appendChild(document.createTextNode('vector fit
(%)
: '))
div.appendChild(document.createTextNode('vector fit: '))
//div.appendChild(document.createElement('br'))
//div.appendChild(document.createElement('br'))
var input = document.createElement('input')
var input = document.createElement('input')
input.type = 'text'
input.type = 'text'
input.size = 6
input.size = 6
input.addEventListener('change',function(){
vectorize()
})
div.appendChild(input)
div.appendChild(input)
mod.error = input
mod.error = input
div.appendChild(document.createElement('br'))
div.appendChild(document.createElement('br'))
...
@@ -255,7 +252,7 @@ function calculate_path() {
...
@@ -255,7 +252,7 @@ function calculate_path() {
}
}
})
})
webworker.postMessage({
webworker.postMessage({
h:mod.height,w:mod.width,
h:mod.height,w:mod.width,
error:mod.error.value,
xmin:mod.xmin,xmax:mod.xmax,
xmin:mod.xmin,xmax:mod.xmax,
ymin:mod.ymin,ymax:mod.ymax,
ymin:mod.ymin,ymax:mod.ymax,
zmin:mod.zmin,zmax:mod.zmax,
zmin:mod.zmin,zmax:mod.zmax,
...
@@ -268,6 +265,7 @@ function calculate_path_worker() {
...
@@ -268,6 +265,7 @@ function calculate_path_worker() {
self.addEventListener('message',function(evt) {
self.addEventListener('message',function(evt) {
var h = evt.data.h
var h = evt.data.h
var w = evt.data.w
var w = evt.data.w
var error = evt.data.error
var xmin = evt.data.xmin
var xmin = evt.data.xmin
var xmax = evt.data.xmax
var xmax = evt.data.xmax
var ymin = evt.data.ymin
var ymin = evt.data.ymin
...
@@ -279,21 +277,46 @@ function calculate_path_worker() {
...
@@ -279,21 +277,46 @@ function calculate_path_worker() {
//
//
// line loop
// line loop
//
//
var ix = 0
xstart = 0
var iy = h-1
ystart = h-1
var dx = 1
zstart = Math.floor((map[ystart*w+xstart]-zmax)*w/(xmax-xmin))
var dy = 0
path[0].push([xstart,ystart,zstart])
var iz = Math.floor((map[iy*w+ix]-zmax)*w/(xmax-xmin))
xcur = 1
ycur = h-1
zcur = Math.floor((map[ycur*w+xcur]-zmax)*w/(xmax-xmin))
dx = 1
dy = 0
while (1) {
while (1) {
var ixp = ix
xnext = xcur+dx
var iyp = iy
ynext = ycur+dy
ix += dx
znext = Math.floor((map[ynext*w+xnext]-zmax)*w/(xmax-xmin))
iy += dy
if (ynext <= 0)
if (iy <= 0)
break;
break;
var iz = Math.floor((map[iy*w+ix]-zmax)*w/(xmax-xmin))
dxcur = xcur-xstart
path[0].push([ix,iy,iz])
dycur = ycur-ystart
if (ix == (w-1)) {
dzcur = zcur-zstart
dcur = Math.sqrt(dxcur*dxcur+dycur*dycur+dzcur*dzcur)
nxcur = dxcur/dcur
nycur = dycur/dcur
nzcur = dzcur/dcur
dxnext = xnext-xcur
dynext = ynext-ycur
dznext = znext-xcur
dnext = Math.sqrt(dxnext*dxnext+dynext*dynext+dznext*dznext)
nxnext = dxnext/dnext
nynext = dynext/dnext
nznext = dznext/dnext
dot = nxcur*nxnext+nycur*nynext+nzcur*nznext
if (Math.abs(dot) >= error) {
path[0].push([xcur,ycur,zcur])
xstart = xcur
ystart = ycur
zstart = zcur
}
xcur = xnext
ycur = ynext
zcur = znext
if (xcur == (w-1)) {
if (dx == 1) {
if (dx == 1) {
dx = 0
dx = 0
dy = -10
dy = -10
...
@@ -303,7 +326,7 @@ function calculate_path_worker() {
...
@@ -303,7 +326,7 @@ function calculate_path_worker() {
dy = 0
dy = 0
}
}
}
}
else if (
i
x == 0) {
else if (x
cur
== 0) {
if (dx == -1) {
if (dx == -1) {
dx = 0
dx = 0
dy = -10
dy = -10
...
...
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