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
10aa5d73
Commit
10aa5d73
authored
5 years ago
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
3D vectorization working?
parent
d124f0e7
Branches
Branches containing commit
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
+30
-14
30 additions, 14 deletions
modules/processes/mill/raster/3D
with
30 additions
and
14 deletions
modules/processes/mill/raster/3D
+
30
−
14
View file @
10aa5d73
...
@@ -27,7 +27,7 @@ var init = function() {
...
@@ -27,7 +27,7 @@ var init = function() {
mod.dia_in.value = 0.0156
mod.dia_in.value = 0.0156
mod.dia_mm.value = 25.4*parseFloat(mod.dia_in.value)
mod.dia_mm.value = 25.4*parseFloat(mod.dia_in.value)
mod.stepover.value = 0.5
mod.stepover.value = 0.5
mod.error.value = 1
mod.error.value =
0.00
1
}
}
//
//
// inputs
// inputs
...
@@ -38,12 +38,14 @@ var inputs = {
...
@@ -38,12 +38,14 @@ var inputs = {
mod.map = evt.detail.map
mod.map = evt.detail.map
mod.width = evt.detail.width
mod.width = evt.detail.width
mod.height = evt.detail.height
mod.height = evt.detail.height
mod.depth = Math.floor((mod.zmax-mod.zmin)*mod.width/(mod.xmax-mod.xmin))
mod.xmin = evt.detail.xmin
mod.xmin = evt.detail.xmin
mod.xmax = evt.detail.xmax
mod.xmax = evt.detail.xmax
mod.ymin = evt.detail.ymin
mod.ymin = evt.detail.ymin
mod.ymax = evt.detail.ymax
mod.ymax = evt.detail.ymax
mod.zmin = evt.detail.zmin
mod.zmin = evt.detail.zmin
mod.zmax = evt.detail.zmax
mod.zmax = evt.detail.zmax
mod.dpi = mod.width/(mod.xmax-mod.xmin)
var ctx = mod.img.getContext("2d")
var ctx = mod.img.getContext("2d")
ctx.canvas.width = mod.width
ctx.canvas.width = mod.width
ctx.canvas.height = mod.height
ctx.canvas.height = mod.height
...
@@ -54,14 +56,15 @@ var inputs = {
...
@@ -54,14 +56,15 @@ var inputs = {
var outputs = {
var outputs = {
toolpath:{type:'',
toolpath:{type:'',
event:function(){
event:function(){
cmd = {}
obj = {}
cmd.path = mod.path
obj.path = mod.path
cmd.name = mod.name
obj.name = "mill raster 3D"
cmd.dpi = mod.dpi
obj.dpi = mod.dpi
cmd.width = mod.width
obj.width = mod.width
cmd.height = mod.height
obj.height = mod.height
cmd.depth = mod.depth
obj.depth = mod.depth
mods.output(mod,'toolpath',cmd)
mods.output(mod,'toolpath',obj)
console.log(mod.path[0].length)
}}}
}}}
//
//
// interface
// interface
...
@@ -216,7 +219,9 @@ function calculate_path() {
...
@@ -216,7 +219,9 @@ function calculate_path() {
var url = window.URL.createObjectURL(blob)
var url = window.URL.createObjectURL(blob)
var webworker = new Worker(url)
var webworker = new Worker(url)
webworker.addEventListener('message',function(evt) {
webworker.addEventListener('message',function(evt) {
mod.triangles = evt.data.triangles
//
// webworker handler
//
mod.path = evt.data.path
mod.path = evt.data.path
mod.label.nodeValue = 'calculate'
mod.label.nodeValue = 'calculate'
mod.labelspan.style.fontWeight = 'normal'
mod.labelspan.style.fontWeight = 'normal'
...
@@ -240,7 +245,8 @@ function calculate_path() {
...
@@ -240,7 +245,8 @@ function calculate_path() {
var ix = mod.path[0][i][0]
var ix = mod.path[0][i][0]
var iy = mod.path[0][i][1]
var iy = mod.path[0][i][1]
var iz = 0.1*mod.path[0][i][2]
var iz = 0.1*mod.path[0][i][2]
var line = document.createElementNS('http://www.w3.org/2000/svg','line')
var line = document.createElementNS(
'http://www.w3.org/2000/svg','line')
line.setAttribute('stroke','black')
line.setAttribute('stroke','black')
line.setAttribute('stroke-width',1)
line.setAttribute('stroke-width',1)
line.setAttribute('stroke-linecap','round')
line.setAttribute('stroke-linecap','round')
...
@@ -250,7 +256,14 @@ function calculate_path() {
...
@@ -250,7 +256,14 @@ function calculate_path() {
line.setAttribute('y2',iy-iz)
line.setAttribute('y2',iy-iz)
g.appendChild(line)
g.appendChild(line)
}
}
//
// output path
//
outputs.toolpath.event()
})
})
//
// call webworker
//
webworker.postMessage({
webworker.postMessage({
h:mod.height,w:mod.width,error:mod.error.value,
h:mod.height,w:mod.width,error:mod.error.value,
xmin:mod.xmin,xmax:mod.xmax,
xmin:mod.xmin,xmax:mod.xmax,
...
@@ -275,7 +288,7 @@ function calculate_path_worker() {
...
@@ -275,7 +288,7 @@ function calculate_path_worker() {
var map = evt.data.map
var map = evt.data.map
var path = [[]]
var path = [[]]
//
//
// l
ine loop
// l
oop over lines
//
//
xstart = 0
xstart = 0
ystart = h-1
ystart = h-1
...
@@ -287,6 +300,9 @@ function calculate_path_worker() {
...
@@ -287,6 +300,9 @@ function calculate_path_worker() {
dx = 1
dx = 1
dy = 0
dy = 0
while (1) {
while (1) {
//
// vectorize
//
xnext = xcur+dx
xnext = xcur+dx
ynext = ycur+dy
ynext = ycur+dy
znext = Math.floor((map[ynext*w+xnext]-zmax)*w/(xmax-xmin))
znext = Math.floor((map[ynext*w+xnext]-zmax)*w/(xmax-xmin))
...
@@ -301,13 +317,13 @@ function calculate_path_worker() {
...
@@ -301,13 +317,13 @@ function calculate_path_worker() {
nzcur = dzcur/dcur
nzcur = dzcur/dcur
dxnext = xnext-xcur
dxnext = xnext-xcur
dynext = ynext-ycur
dynext = ynext-ycur
dznext = znext-
x
cur
dznext = znext-
z
cur
dnext = Math.sqrt(dxnext*dxnext+dynext*dynext+dznext*dznext)
dnext = Math.sqrt(dxnext*dxnext+dynext*dynext+dznext*dznext)
nxnext = dxnext/dnext
nxnext = dxnext/dnext
nynext = dynext/dnext
nynext = dynext/dnext
nznext = dznext/dnext
nznext = dznext/dnext
dot = nxcur*nxnext+nycur*nynext+nzcur*nznext
dot = nxcur*nxnext+nycur*nynext+nzcur*nznext
if (
Math.abs(dot) >=
error) {
if (
dot <= (1-
error)
)
{
path[0].push([xcur,ycur,zcur])
path[0].push([xcur,ycur,zcur])
xstart = xcur
xstart = xcur
ystart = ycur
ystart = ycur
...
...
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