Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'xs/src/libslic3r/GCode/SpiralVase.cpp')
-rw-r--r--xs/src/libslic3r/GCode/SpiralVase.cpp47
1 files changed, 19 insertions, 28 deletions
diff --git a/xs/src/libslic3r/GCode/SpiralVase.cpp b/xs/src/libslic3r/GCode/SpiralVase.cpp
index fd300067f..892d3b4cc 100644
--- a/xs/src/libslic3r/GCode/SpiralVase.cpp
+++ b/xs/src/libslic3r/GCode/SpiralVase.cpp
@@ -4,17 +4,7 @@
namespace Slic3r {
-std::string
-_format_z(float z)
-{
- std::ostringstream ss;
- ss << std::fixed << std::setprecision(3)
- << z;
- return ss.str();
-}
-
-std::string
-SpiralVase::process_layer(const std::string &gcode)
+std::string SpiralVase::process_layer(const std::string &gcode)
{
/* This post-processor relies on several assumptions:
- all layers are processed through it, including those that are not supposed
@@ -38,16 +28,17 @@ SpiralVase::process_layer(const std::string &gcode)
bool set_z = false;
{
+ //FIXME Performance warning: This copies the GCodeConfig of the reader.
GCodeReader r = this->_reader; // clone
r.parse(gcode, [&total_layer_length, &layer_height, &z, &set_z]
- (GCodeReader &, const GCodeReader::GCodeLine &line) {
- if (line.cmd == "G1") {
- if (line.extruding()) {
- total_layer_length += line.dist_XY();
- } else if (line.has('Z')) {
- layer_height += line.dist_Z();
+ (GCodeReader &reader, const GCodeReader::GCodeLine &line) {
+ if (line.cmd_is("G1")) {
+ if (line.extruding(reader)) {
+ total_layer_length += line.dist_XY(reader);
+ } else if (line.has(Z)) {
+ layer_height += line.dist_Z(reader);
if (!set_z) {
- z = line.new_Z();
+ z = line.new_Z(reader);
set_z = true;
}
}
@@ -60,22 +51,22 @@ SpiralVase::process_layer(const std::string &gcode)
std::string new_gcode;
this->_reader.parse(gcode, [&new_gcode, &z, &layer_height, &total_layer_length]
- (GCodeReader &, GCodeReader::GCodeLine line) {
- if (line.cmd == "G1") {
- if (line.has('Z')) {
+ (GCodeReader &reader, GCodeReader::GCodeLine line) {
+ if (line.cmd_is("G1")) {
+ if (line.has_z()) {
// If this is the initial Z move of the layer, replace it with a
// (redundant) move to the last Z of previous layer.
- line.set('Z', _format_z(z));
- new_gcode += line.raw + '\n';
+ line.set(reader, Z, z);
+ new_gcode += line.raw() + '\n';
return;
} else {
- float dist_XY = line.dist_XY();
+ float dist_XY = line.dist_XY(reader);
if (dist_XY > 0) {
// horizontal move
- if (line.extruding()) {
+ if (line.extruding(reader)) {
z += dist_XY * layer_height / total_layer_length;
- line.set('Z', _format_z(z));
- new_gcode += line.raw + '\n';
+ line.set(reader, Z, z);
+ new_gcode += line.raw() + '\n';
}
return;
@@ -87,7 +78,7 @@ SpiralVase::process_layer(const std::string &gcode)
}
}
}
- new_gcode += line.raw + '\n';
+ new_gcode += line.raw() + '\n';
});
return new_gcode;