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
93f616f1
Commit
93f616f1
authored
Jun 2, 2018
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
a477ed61
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/mesh/slice
+45
-42
45 additions, 42 deletions
modules/mesh/slice
with
45 additions
and
42 deletions
modules/mesh/slice
+
45
−
42
View file @
93f616f1
...
@@ -402,12 +402,42 @@ function worker() {
...
@@ -402,12 +402,42 @@ function worker() {
return([x3,y3,z3])
return([x3,y3,z3])
}
}
//
//
// get vars
// function to draw line
//
function line(x0,y0,x1,y1) {
var ix0 = Math.floor(w*(x0-xmin)/(xmax-xmin))
var iy0 = Math.floor(h*(y0-ymin)/(ymax-ymin))
var ix1 = Math.floor(w*(x1-xmin)/(xmax-xmin))
var iy1 = Math.floor(h*(y1-ymin)/(ymax-ymin))
var dx = ix1-ix0
var dy = iy1-iy0
console.log(ix0,iy0)
buf[(h-1-iy0)*w*4+ix0*4+0] = 255
buf[(h-1-iy0)*w*4+ix0*4+1] = 255
buf[(h-1-iy0)*w*4+ix0*4+2] = 255
}
//
// get vars from buffer
//
//
var endian = true
var endian = true
var triangles = view.getUint32(80,endian)
var triangles = view.getUint32(80,endian)
var size = 80+4+triangles*(4*12+2)
var size = 80+4+triangles*(4*12+2)
//
//
// initialize slice image
//
for (var row = 0; row < h; ++row) {
for (var col = 0; col < w; ++col) {
r = buf[(h-1-row)*w*4+col*4+0]
g = buf[(h-1-row)*w*4+col*4+1]
b = buf[(h-1-row)*w*4+col*4+2]
a = buf[(h-1-row)*w*4+col*4+3]
buf[(h-1-row)*w*4+col*4+0] = 0
buf[(h-1-row)*w*4+col*4+1] = 0
buf[(h-1-row)*w*4+col*4+2] = 0
buf[(h-1-row)*w*4+col*4+3] = 255
}
}
//
// find triangles crossing the slice
// find triangles crossing the slice
//
//
var segs = []
var segs = []
...
@@ -437,12 +467,12 @@ function worker() {
...
@@ -437,12 +467,12 @@ function worker() {
// rotate vertices
// rotate vertices
//
//
offset += 2
offset += 2
var
p
= [rotate(x0,y0,z0),
var
v
= [rotate(x0,y0,z0),
rotate(x1,y1,z1),rotate(x2,y2,z2)]
rotate(x1,y1,z1),rotate(x2,y2,z2)]
//
//
// sort z
// sort z
//
//
p
.sort(function(a,b) {
v
.sort(function(a,b) {
if (a[2] < b[2])
if (a[2] < b[2])
return -1
return -1
else if (a[2] > b[2])
else if (a[2] > b[2])
...
@@ -453,60 +483,33 @@ function worker() {
...
@@ -453,60 +483,33 @@ function worker() {
//
//
// check for crossing
// check for crossing
//
//
if ((
p
[0][2] <= (zmax-depth)) && (
p
[2][2] >= (zmax-depth))) {
if ((
v
[0][2] <= (zmax-depth)) && (
v
[2][2] >= (zmax-depth))) {
count += 1
count += 1
}
/*
//
//
// crossing found, check for side and s
av
e
// crossing found, check for side and s
trok
e
//
//
if (p[1][2] < z) {
line(v[0][0],v[0][1],v[1][0],v[1][1])
line(v[1][0],v[1][1],v[2][0],v[2][1])
line(v[2][0],v[2][1],v[0][0],v[0][1])
if (v[1][2] < (zmax-depth)) {
;
}
}
else if (p[1][2] > z) {
else if (v[1][2] > (zmax-depth)) {
;
}
}
else {
else {
;
}
}
}
}
*/
}
}
/*
/*
//
//
// initialize slice image
// loop over scan lines and fill interior
//
for row
for col
//
// loop over scan lines
//
for row
//
// find scan line intersections with segments
//
//
//
// perturb vertex intersections
*/
//
//
// sort and stroke intersections
//
//
//
// output the slice
// output the slice
//
//
*/
for (var row = 0; row < h; ++row) {
for (var col = 0; col < w; ++col) {
r = buf[(h-1-row)*w*4+col*4+0]
g = buf[(h-1-row)*w*4+col*4+1]
b = buf[(h-1-row)*w*4+col*4+2]
a = buf[(h-1-row)*w*4+col*4+3]
buf[(h-1-row)*w*4+col*4+0] = row
buf[(h-1-row)*w*4+col*4+1] = col
buf[(h-1-row)*w*4+col*4+2] = row+col
buf[(h-1-row)*w*4+col*4+3] = 255
}
}
self.postMessage({count:count,buffer:buf.buffer},[buf.buffer])
self.postMessage({count:count,buffer:buf.buffer},[buf.buffer])
})
})
}
}
...
...
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
sign in
to comment