Merge pull request #2730 from eyal0/faster_analysis

Improve octoprint gcode analysis speed
This commit is contained in:
Gina Häußge authored and GitHub committed 2018-07-13 19:25:54 +02:00
commit 9559f09ec7
2 files changed
+9 -8

No files matched your search

+3
View File
@@ -71,3 +71,6 @@ def gcode_command(path, speedx, speedy, speedz, offset, maxt, throttle, throttle
click.echo("DONE:{}s".format(time.time() - start_time))
click.echo("RESULTS:")
click.echo(yaml.safe_dump(interpreter.get_result(), default_flow_style=False, indent=" ", allow_unicode=True))
if __name__ == "__main__":
gcode_command()
+6 -8
View File
@@ -152,12 +152,12 @@ class MinMax3D(object):
self.max = Vector3D(None, None, None)
def record(self, coordinate):
for c in "xyz":
current_min = getattr(self.min, c)
current_max = getattr(self.max, c)
value = getattr(coordinate, c)
setattr(self.min, c, value if current_min is None or value < current_min else current_min)
setattr(self.max, c, value if current_max is None or value > current_max else current_max)
self.min.x = coordinate.x if not self.min.x else min(self.min.x, coordinate.x)
self.min.y = coordinate.y if not self.min.y else min(self.min.y, coordinate.y)
self.min.z = coordinate.z if not self.min.z else min(self.min.z, coordinate.z)
self.max.x = coordinate.x if not self.max.x else max(self.max.x, coordinate.x)
self.max.y = coordinate.y if not self.max.y else max(self.max.y, coordinate.y)
self.max.z = coordinate.z if not self.max.z else max(self.max.z, coordinate.z)
@property
def size(self):
@@ -498,7 +498,6 @@ def getCodeInt(line, code):
def getCodeFloat(line, code):
import math
n = line.find(code) + 1
if n < 1:
return None
@@ -511,4 +510,3 @@ def getCodeFloat(line, code):
return val if not (math.isnan(val) or math.isinf(val)) else None
except:
return None