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
fdef5a8d
Commit
fdef5a8d
authored
Apr 06, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize gcoder (~10% faster) #525
parent
fcbd113a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
+20
-18
gcoder.py
printrun/gcoder.py
+20
-18
No files found.
printrun/gcoder.py
View file @
fdef5a8d
...
...
@@ -329,6 +329,9 @@ class GCode(object):
total_e
=
self
.
total_e
max_e
=
self
.
max_e
# Store this one out of the build_layers scope for efficiency
cur_layer_has_extrusion
=
False
# Initialize layers and other global computations
if
build_layers
:
# Bounding box computation
...
...
@@ -373,15 +376,15 @@ class GCode(object):
prev_base_z
=
(
None
,
None
)
cur_z
=
None
cur_lines
=
[]
cur_layer_has_extrusion
=
False
if
self
.
line_class
!=
Line
:
get_line
=
lambda
l
:
Line
(
l
.
raw
)
else
:
get_line
=
lambda
l
:
l
for
true_line
in
lines
:
# # Parse line
# Use a heavy copy of the light line to preprocess
if
self
.
line_class
!=
Line
:
line
=
Line
(
true_line
.
raw
)
else
:
line
=
true_line
line
=
get_line
(
true_line
)
split_raw
=
split
(
line
)
if
line
.
command
:
# Update properties
...
...
@@ -465,6 +468,7 @@ class GCode(object):
total_e
+=
new_e
-
current_e
current_e
=
new_e
max_e
=
max
(
max_e
,
total_e
)
cur_layer_has_extrusion
|=
line
.
extruding
elif
line
.
command
==
"G92"
:
offset_e
=
current_e
-
line
.
e
...
...
@@ -479,6 +483,7 @@ class GCode(object):
if
line
.
current_y
is
not
None
:
ymin_e
=
min
(
ymin_e
,
line
.
current_y
)
ymax_e
=
max
(
ymax_e
,
line
.
current_y
)
if
max_e
<=
0
:
if
line
.
current_x
is
not
None
:
xmin
=
min
(
xmin
,
line
.
current_x
)
xmax
=
max
(
xmax
,
line
.
current_x
)
...
...
@@ -555,18 +560,15 @@ class GCode(object):
lastf
=
f
# FIXME : looks like this needs to be tested with "lift Z on move"
if
line
.
command
==
"G92"
and
line
.
z
is
not
None
:
if
line
.
z
is
not
None
:
if
line
.
command
==
"G92"
:
cur_z
=
line
.
z
elif
line
.
is_move
:
if
line
.
z
is
not
None
:
if
line
.
relative
and
cur_z
is
not
None
:
cur_z
+=
line
.
z
else
:
cur_z
=
line
.
z
if
line
.
e
is
not
None
and
line
.
is_move
:
cur_layer_has_extrusion
|=
line
.
extruding
# FIXME: the logic behind this code seems to work, but it might be
# broken
if
cur_z
!=
prev_z
:
...
...
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