Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
87019841
Commit
87019841
authored
May 20, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start updating stlview to use gcoder parsed GCode
parent
5af6da86
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
26 deletions
+31
-26
stlview.py
printrun/stlview.py
+31
-26
No files found.
printrun/stlview.py
View file @
87019841
...
@@ -233,7 +233,7 @@ def vdiff(v, o):
...
@@ -233,7 +233,7 @@ def vdiff(v, o):
class
gcview
(
object
):
class
gcview
(
object
):
def
__init__
(
self
,
lines
,
batch
,
w
=
0.5
,
h
=
0.5
):
def
__init__
(
self
,
gcode
,
batch
,
w
=
0.5
,
h
=
0.5
):
# Create the vertex and normal arrays.
# Create the vertex and normal arrays.
vertices
=
[]
vertices
=
[]
normals
=
[]
normals
=
[]
...
@@ -242,8 +242,12 @@ class gcview(object):
...
@@ -242,8 +242,12 @@ class gcview(object):
self
.
vlists
=
[]
self
.
vlists
=
[]
self
.
layers
=
{}
self
.
layers
=
{}
t0
=
time
.
time
()
t0
=
time
.
time
()
lines
=
[
self
.
transform
(
i
)
for
i
in
lines
]
if
gcode
:
lines
=
[
i
for
i
in
lines
if
i
is
not
None
]
lines
=
[
self
.
transform
(
gline
)
for
gline
in
gcode
.
lines
]
lines
=
[
line
for
line
in
lines
if
line
]
print
len
(
lines
)
else
:
lines
=
[]
print
"transformed lines in
%
fs"
%
(
time
.
time
()
-
t0
)
print
"transformed lines in
%
fs"
%
(
time
.
time
()
-
t0
)
t0
=
time
.
time
()
t0
=
time
.
time
()
layertemp
=
{}
layertemp
=
{}
...
@@ -355,22 +359,21 @@ class gcview(object):
...
@@ -355,22 +359,21 @@ class gcview(object):
epoints
=
map
(
lambda
x
:
vadd
(
E
,
x
),
points
)
epoints
=
map
(
lambda
x
:
vadd
(
E
,
x
),
points
)
return
spoints
,
epoints
,
S
,
E
return
spoints
,
epoints
,
S
,
E
def
transform
(
self
,
line
):
def
transform
(
self
,
gline
):
line
=
line
.
split
(
";"
)[
0
]
cur
=
self
.
prev
[:]
cur
=
self
.
prev
[:]
i
f
len
(
line
)
>
0
:
i
sg92
=
(
gline
.
command
==
"G92"
)
if
"G1"
in
line
or
"G0"
in
line
or
"G92"
in
line
:
if
gline
.
is_move
or
isg92
:
if
(
"X"
in
line
)
:
if
gline
.
x
is
not
None
:
cur
[
0
]
=
float
(
line
.
split
(
"X"
)[
1
]
.
split
(
" "
)[
0
])
cur
[
0
]
=
gline
.
x
if
(
"Y"
in
line
)
:
if
gline
.
y
is
not
None
:
cur
[
1
]
=
float
(
line
.
split
(
"Y"
)[
1
]
.
split
(
" "
)[
0
])
cur
[
1
]
=
gline
.
y
if
(
"Z"
in
line
)
:
if
gline
.
z
is
not
None
:
cur
[
2
]
=
float
(
line
.
split
(
"Z"
)[
1
]
.
split
(
" "
)[
0
])
cur
[
2
]
=
gline
.
z
if
(
"E"
in
line
)
:
if
gline
.
e
is
not
None
:
cur
[
3
]
=
float
(
line
.
split
(
"E"
)[
1
]
.
split
(
" "
)[
0
])
cur
[
3
]
=
gline
.
e
if
self
.
prev
==
cur
:
if
self
.
prev
==
cur
:
return
None
return
None
if
self
.
fline
or
"G92"
in
line
:
elif
self
.
fline
or
isg92
:
self
.
prev
=
cur
self
.
prev
=
cur
self
.
fline
=
0
self
.
fline
=
0
return
None
return
None
...
@@ -378,6 +381,8 @@ class gcview(object):
...
@@ -378,6 +381,8 @@ class gcview(object):
r
=
[
self
.
prev
,
cur
]
r
=
[
self
.
prev
,
cur
]
self
.
prev
=
cur
self
.
prev
=
cur
return
r
return
r
else
:
return
None
def
delete
(
self
):
def
delete
(
self
):
for
i
in
self
.
vlists
:
for
i
in
self
.
vlists
:
...
@@ -833,7 +838,7 @@ class GCFrame(wx.Frame):
...
@@ -833,7 +838,7 @@ class GCFrame(wx.Frame):
m
.
curlayer
=
0.0
m
.
curlayer
=
0.0
m
.
scale
=
[
1.0
,
1.0
,
1.0
]
m
.
scale
=
[
1.0
,
1.0
,
1.0
]
m
.
batch
=
pyglet
.
graphics
.
Batch
()
m
.
batch
=
pyglet
.
graphics
.
Batch
()
m
.
gc
=
gcview
(
[]
,
batch
=
m
.
batch
)
m
.
gc
=
gcview
(
None
,
batch
=
m
.
batch
)
self
.
models
=
{
""
:
m
}
self
.
models
=
{
""
:
m
}
self
.
l
=
d
()
self
.
l
=
d
()
self
.
modelindex
=
0
self
.
modelindex
=
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment