mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
Fix of the Spiral Vase after the GCodeReader rework.
A patch of the GCodeTimeEstimator to avoid crashes. This is not a final fix though.
This commit is contained in:
parent
998157fc9b
commit
011281df86
4 changed files with 26 additions and 14 deletions
|
@ -17,7 +17,7 @@ std::string SpiralVase::process_layer(const std::string &gcode)
|
||||||
// If we're not going to modify G-code, just feed it to the reader
|
// If we're not going to modify G-code, just feed it to the reader
|
||||||
// in order to update positions.
|
// in order to update positions.
|
||||||
if (!this->enable) {
|
if (!this->enable) {
|
||||||
this->_reader.parse(gcode, {});
|
this->_reader.parse_buffer(gcode);
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ std::string SpiralVase::process_layer(const std::string &gcode)
|
||||||
{
|
{
|
||||||
//FIXME Performance warning: This copies the GCodeConfig of the reader.
|
//FIXME Performance warning: This copies the GCodeConfig of the reader.
|
||||||
GCodeReader r = this->_reader; // clone
|
GCodeReader r = this->_reader; // clone
|
||||||
r.parse(gcode, [&total_layer_length, &layer_height, &z, &set_z]
|
r.parse_buffer(gcode, [&total_layer_length, &layer_height, &z, &set_z]
|
||||||
(GCodeReader &reader, const GCodeReader::GCodeLine &line) {
|
(GCodeReader &reader, const GCodeReader::GCodeLine &line) {
|
||||||
if (line.cmd_is("G1")) {
|
if (line.cmd_is("G1")) {
|
||||||
if (line.extruding(reader)) {
|
if (line.extruding(reader)) {
|
||||||
|
@ -50,7 +50,7 @@ std::string SpiralVase::process_layer(const std::string &gcode)
|
||||||
z -= layer_height;
|
z -= layer_height;
|
||||||
|
|
||||||
std::string new_gcode;
|
std::string new_gcode;
|
||||||
this->_reader.parse(gcode, [&new_gcode, &z, &layer_height, &total_layer_length]
|
this->_reader.parse_buffer(gcode, [&new_gcode, &z, &layer_height, &total_layer_length]
|
||||||
(GCodeReader &reader, GCodeReader::GCodeLine line) {
|
(GCodeReader &reader, GCodeReader::GCodeLine line) {
|
||||||
if (line.cmd_is("G1")) {
|
if (line.cmd_is("G1")) {
|
||||||
if (line.has_z()) {
|
if (line.has_z()) {
|
||||||
|
|
|
@ -20,14 +20,6 @@ void GCodeReader::apply_config(const DynamicPrintConfig &config)
|
||||||
m_extrusion_axis = m_config.get_extrusion_axis()[0];
|
m_extrusion_axis = m_config.get_extrusion_axis()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeReader::parse(const std::string &gcode, callback_t callback)
|
|
||||||
{
|
|
||||||
std::istringstream ss(gcode);
|
|
||||||
std::string line;
|
|
||||||
while (std::getline(ss, line))
|
|
||||||
this->parse_line(line, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* GCodeReader::parse_line_internal(const char *ptr, GCodeLine &gline, std::pair<const char*, const char*> &command)
|
const char* GCodeReader::parse_line_internal(const char *ptr, GCodeLine &gline, std::pair<const char*, const char*> &command)
|
||||||
{
|
{
|
||||||
PROFILE_FUNC();
|
PROFILE_FUNC();
|
||||||
|
|
|
@ -73,7 +73,21 @@ public:
|
||||||
GCodeReader() : m_verbose(false), m_extrusion_axis('E') { memset(m_position, 0, sizeof(m_position)); }
|
GCodeReader() : m_verbose(false), m_extrusion_axis('E') { memset(m_position, 0, sizeof(m_position)); }
|
||||||
void apply_config(const GCodeConfig &config);
|
void apply_config(const GCodeConfig &config);
|
||||||
void apply_config(const DynamicPrintConfig &config);
|
void apply_config(const DynamicPrintConfig &config);
|
||||||
void parse(const std::string &gcode, callback_t callback);
|
|
||||||
|
template<typename Callback>
|
||||||
|
void parse_buffer(const std::string &buffer, Callback callback)
|
||||||
|
{
|
||||||
|
const char *ptr = buffer.c_str();
|
||||||
|
GCodeLine gline;
|
||||||
|
while (*ptr != 0) {
|
||||||
|
gline.reset();
|
||||||
|
ptr = this->parse_line(ptr, gline, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_buffer(const std::string &buffer)
|
||||||
|
{ this->parse_buffer(buffer, [](GCodeReader&, const GCodeReader::GCodeLine&){}); }
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
const char* parse_line(const char *ptr, GCodeLine &gline, Callback &callback)
|
const char* parse_line(const char *ptr, GCodeLine &gline, Callback &callback)
|
||||||
{
|
{
|
||||||
|
@ -83,9 +97,11 @@ public:
|
||||||
update_coordinates(gline, cmd);
|
update_coordinates(gline, cmd);
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void parse_line(const std::string &line, Callback callback)
|
void parse_line(const std::string &line, Callback callback)
|
||||||
{ GCodeLine gline; this->parse_line(line.c_str(), gline, callback); }
|
{ GCodeLine gline; this->parse_line(line.c_str(), gline, callback); }
|
||||||
|
|
||||||
void parse_file(const std::string &file, callback_t callback);
|
void parse_file(const std::string &file, callback_t callback);
|
||||||
|
|
||||||
float& x() { return m_position[X]; }
|
float& x() { return m_position[X]; }
|
||||||
|
|
|
@ -142,7 +142,9 @@ namespace Slic3r {
|
||||||
|
|
||||||
void GCodeTimeEstimator::calculate_time_from_text(const std::string& gcode)
|
void GCodeTimeEstimator::calculate_time_from_text(const std::string& gcode)
|
||||||
{
|
{
|
||||||
_parser.parse(gcode, boost::bind(&GCodeTimeEstimator::_process_gcode_line, this, _1, _2));
|
_parser.parse_buffer(gcode,
|
||||||
|
[this](GCodeReader &reader, const GCodeReader::GCodeLine &line)
|
||||||
|
{ this->_process_gcode_line(reader, line); });
|
||||||
_calculate_time();
|
_calculate_time();
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
@ -921,7 +923,9 @@ namespace Slic3r {
|
||||||
|
|
||||||
void GCodeTimeEstimator::_planner_forward_pass_kernel(Block* prev, Block* curr)
|
void GCodeTimeEstimator::_planner_forward_pass_kernel(Block* prev, Block* curr)
|
||||||
{
|
{
|
||||||
if (prev == nullptr)
|
if (prev == nullptr || curr == nullptr)
|
||||||
|
//FIXME something is fishy here. Review and compare with the firmware.
|
||||||
|
// if (prev == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If the previous block is an acceleration block, but it is not long enough to complete the
|
// If the previous block is an acceleration block, but it is not long enough to complete the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue