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
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
+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() {
mod.dia_in.value = 0.0156
mod.dia_mm.value = 25.4*parseFloat(mod.dia_in.value)
mod.stepover.value = 0.5
mod.error.value = 1
mod.error.value =
0.00
1
}
//
// inputs
...
...
@@ -38,12 +38,14 @@ var inputs = {
mod.map = evt.detail.map
mod.width = evt.detail.width
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.xmax = evt.detail.xmax
mod.ymin = evt.detail.ymin
mod.ymax = evt.detail.ymax
mod.zmin = evt.detail.zmin
mod.zmax = evt.detail.zmax
mod.dpi = mod.width/(mod.xmax-mod.xmin)
var ctx = mod.img.getContext("2d")
ctx.canvas.width = mod.width
ctx.canvas.height = mod.height
...
...
@@ -54,14 +56,15 @@ var inputs = {
var outputs = {
toolpath:{type:'',
event:function(){
cmd = {}
cmd.path = mod.path
cmd.name = mod.name
cmd.dpi = mod.dpi
cmd.width = mod.width
cmd.height = mod.height
cmd.depth = mod.depth
mods.output(mod,'toolpath',cmd)
obj = {}
obj.path = mod.path
obj.name = "mill raster 3D"
obj.dpi = mod.dpi
obj.width = mod.width
obj.height = mod.height
obj.depth = mod.depth
mods.output(mod,'toolpath',obj)
console.log(mod.path[0].length)
}}}
//
// interface
...
...
@@ -216,7 +219,9 @@ function calculate_path() {
var url = window.URL.createObjectURL(blob)
var webworker = new Worker(url)
webworker.addEventListener('message',function(evt) {
mod.triangles = evt.data.triangles
//
// webworker handler
//
mod.path = evt.data.path
mod.label.nodeValue = 'calculate'
mod.labelspan.style.fontWeight = 'normal'
...
...
@@ -240,7 +245,8 @@ function calculate_path() {
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')
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')
...
...
@@ -250,7 +256,14 @@ function calculate_path() {
line.setAttribute('y2',iy-iz)
g.appendChild(line)
}
//
// output path
//
outputs.toolpath.event()
})
//
// call webworker
//
webworker.postMessage({
h:mod.height,w:mod.width,error:mod.error.value,
xmin:mod.xmin,xmax:mod.xmax,
...
...
@@ -275,7 +288,7 @@ function calculate_path_worker() {
var map = evt.data.map
var path = [[]]
//
// l
ine loop
// l
oop over lines
//
xstart = 0
ystart = h-1
...
...
@@ -287,6 +300,9 @@ function calculate_path_worker() {
dx = 1
dy = 0
while (1) {
//
// vectorize
//
xnext = xcur+dx
ynext = ycur+dy
znext = Math.floor((map[ynext*w+xnext]-zmax)*w/(xmax-xmin))
...
...
@@ -301,13 +317,13 @@ function calculate_path_worker() {
nzcur = dzcur/dcur
dxnext = xnext-xcur
dynext = ynext-ycur
dznext = znext-
x
cur
dznext = znext-
z
cur
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) {
if (
dot <= (1-
error)
)
{
path[0].push([xcur,ycur,zcur])
xstart = xcur
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