diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 90f4d0c06d..32a9031054 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -211,7 +211,7 @@ Wipe::wipe(GCode &gcodegen, bool toolchange) GCode::GCode() : placeholder_parser(NULL), enable_loop_clipping(true), - enable_cooling_markers(false), enable_extrusion_role_markers(false), + enable_cooling_markers(false), enable_extrusion_role_markers(false), enable_analyzer_markers(false), layer_count(0), layer_index(-1), layer(NULL), first_layer(false), elapsed_time(0.0), volumetric_speed(0), _last_pos_defined(false), @@ -303,6 +303,15 @@ GCode::change_layer(const Layer &layer) this->first_layer = (layer.id() == 0); delete this->_lower_layer_edge_grid; this->_lower_layer_edge_grid = NULL; + + std::string gcode; + + if (enable_analyzer_markers) { + // Store the binary pointer to the layer object directly into the G-code to be accessed by the GCodeAnalyzer. + char buf[64]; + sprintf(buf, ";_LAYEROBJ:%p\n", this->layer); + gcode += buf; + } // avoid computing islands and overhangs if they're not needed if (this->config.avoid_crossing_perimeters) { @@ -311,7 +320,6 @@ GCode::change_layer(const Layer &layer) this->avoid_crossing_perimeters.init_layer_mp(islands); } - std::string gcode; if (this->layer_count > 0) { gcode += this->writer.update_progress(this->layer_index, this->layer_count); } @@ -864,7 +872,7 @@ GCode::_extrude(ExtrusionPath path, std::string description, double speed) double F = speed * 60; // convert mm/sec to mm/min // extrude arc or line - if (this->enable_extrusion_role_markers) { + if (this->enable_extrusion_role_markers || this->enable_analyzer_markers) { if (path.role != this->_last_extrusion_role) { this->_last_extrusion_role = path.role; char buf[32]; diff --git a/xs/src/libslic3r/GCode.hpp b/xs/src/libslic3r/GCode.hpp index afd3051bdf..e1b6ad03c5 100644 --- a/xs/src/libslic3r/GCode.hpp +++ b/xs/src/libslic3r/GCode.hpp @@ -85,8 +85,16 @@ class GCode { // Markers for the Pressure Equalizer to recognize the extrusion type. // The Pressure Equalizer removes the markers from the final G-code. bool enable_extrusion_role_markers; + // Extended markers for the G-code Analyzer. + // The G-code Analyzer will remove these comments from the final G-code. + bool enable_analyzer_markers; + // How many times will change_layer() be called? + // change_layer() will update the progress bar. size_t layer_count; - int layer_index; // just a counter + // Progress bar indicator. Increments from -1 up to layer_count. + int layer_index; + // Current layer processed. Insequential printing mode, only a single copy will be printed. + // In non-sequential mode, all its copies will be printed. const Layer* layer; std::map _seam_position; // Distance Field structure to diff --git a/xs/src/libslic3r/GCodeSender.hpp b/xs/src/libslic3r/GCodeSender.hpp index cc0b298327..74583327f2 100644 --- a/xs/src/libslic3r/GCodeSender.hpp +++ b/xs/src/libslic3r/GCodeSender.hpp @@ -69,7 +69,7 @@ class GCodeSender : private boost::noncopyable { void send(); }; -} +} // namespace Slic3r -#endif -#endif +#endif /* BOOST_LIBS */ +#endif /* slic3r_GCodeSender_hpp_ */