GCode Anayzer take in account extruder offsets
This commit is contained in:
parent
4f122fed70
commit
8a29ec2204
@ -1,3 +1,4 @@
|
|||||||
|
#include "libslic3r.h"
|
||||||
#include "GCode.hpp"
|
#include "GCode.hpp"
|
||||||
#include "ExtrusionEntity.hpp"
|
#include "ExtrusionEntity.hpp"
|
||||||
#include "EdgeGrid.hpp"
|
#include "EdgeGrid.hpp"
|
||||||
@ -573,6 +574,17 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
|
|
||||||
// resets analyzer
|
// resets analyzer
|
||||||
m_analyzer.reset();
|
m_analyzer.reset();
|
||||||
|
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
// send extruder offset data to analyzer
|
||||||
|
std::vector<Vec2d> extruder_offsets;
|
||||||
|
for (unsigned int extruder_id : print.extruders())
|
||||||
|
{
|
||||||
|
extruder_offsets.push_back(print.config().extruder_offset.get_at(extruder_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_analyzer.set_extruder_offsets(extruder_offsets);
|
||||||
|
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
|
||||||
|
|
||||||
// resets analyzer's tracking data
|
// resets analyzer's tracking data
|
||||||
m_last_mm3_per_mm = GCodeAnalyzer::Default_mm3_per_mm;
|
m_last_mm3_per_mm = GCodeAnalyzer::Default_mm3_per_mm;
|
||||||
@ -843,7 +855,9 @@ void GCode::_do_export(Print &print, FILE *file)
|
|||||||
for (unsigned int extruder_id : print.extruders()) {
|
for (unsigned int extruder_id : print.extruders()) {
|
||||||
const Vec2d &extruder_offset = print.config().extruder_offset.get_at(extruder_id);
|
const Vec2d &extruder_offset = print.config().extruder_offset.get_at(extruder_id);
|
||||||
Polygon s(outer_skirt);
|
Polygon s(outer_skirt);
|
||||||
s.translate(Point::new_scale(- extruder_offset(0), - extruder_offset(1)));
|
#if !ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
s.translate(Point::new_scale(-extruder_offset(0), -extruder_offset(1)));
|
||||||
|
#endif // !ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
skirts.emplace_back(std::move(s));
|
skirts.emplace_back(std::move(s));
|
||||||
}
|
}
|
||||||
m_ooze_prevention.enable = true;
|
m_ooze_prevention.enable = true;
|
||||||
|
@ -101,6 +101,13 @@ GCodeAnalyzer::GCodeAnalyzer()
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
void GCodeAnalyzer::set_extruder_offsets(const std::vector<Vec2d>& extruder_offsets)
|
||||||
|
{
|
||||||
|
m_extruder_offsets = extruder_offsets;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
|
||||||
void GCodeAnalyzer::reset()
|
void GCodeAnalyzer::reset()
|
||||||
{
|
{
|
||||||
_set_units(Millimeters);
|
_set_units(Millimeters);
|
||||||
@ -118,6 +125,9 @@ void GCodeAnalyzer::reset()
|
|||||||
_reset_axes_position();
|
_reset_axes_position();
|
||||||
|
|
||||||
m_moves_map.clear();
|
m_moves_map.clear();
|
||||||
|
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
m_extruder_offsets.clear();
|
||||||
|
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& GCodeAnalyzer::process_gcode(const std::string& gcode)
|
const std::string& GCodeAnalyzer::process_gcode(const std::string& gcode)
|
||||||
@ -654,7 +664,24 @@ void GCodeAnalyzer::_store_move(GCodeAnalyzer::GCodeMove::EType type)
|
|||||||
it = m_moves_map.insert(TypeToMovesMap::value_type(type, GCodeMovesList())).first;
|
it = m_moves_map.insert(TypeToMovesMap::value_type(type, GCodeMovesList())).first;
|
||||||
|
|
||||||
// store move
|
// store move
|
||||||
|
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
Vec3d extruder_offset = Vec3d::Zero();
|
||||||
|
unsigned int extruder_id = _get_extruder_id();
|
||||||
|
|
||||||
|
std::cout << extruder_id << std::endl;
|
||||||
|
|
||||||
|
if (extruder_id < m_extruder_offsets.size())
|
||||||
|
{
|
||||||
|
Vec2d offset = m_extruder_offsets[extruder_id];
|
||||||
|
extruder_offset = Vec3d(offset(0), offset(1), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3d start_position = _get_start_position() + extruder_offset;
|
||||||
|
Vec3d end_position = _get_end_position() + extruder_offset;
|
||||||
|
it->second.emplace_back(type, _get_extrusion_role(), extruder_id, _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), start_position, end_position, _get_delta_extrusion(), _get_cp_color_id());
|
||||||
|
#else
|
||||||
it->second.emplace_back(type, _get_extrusion_role(), _get_extruder_id(), _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), _get_start_position(), _get_end_position(), _get_delta_extrusion(), _get_cp_color_id());
|
it->second.emplace_back(type, _get_extrusion_role(), _get_extruder_id(), _get_mm3_per_mm(), _get_width(), _get_height(), _get_feedrate(), _get_start_position(), _get_end_position(), _get_delta_extrusion(), _get_cp_color_id());
|
||||||
|
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GCodeAnalyzer::_is_valid_extrusion_role(int value) const
|
bool GCodeAnalyzer::_is_valid_extrusion_role(int value) const
|
||||||
|
@ -104,6 +104,9 @@ private:
|
|||||||
State m_state;
|
State m_state;
|
||||||
GCodeReader m_parser;
|
GCodeReader m_parser;
|
||||||
TypeToMovesMap m_moves_map;
|
TypeToMovesMap m_moves_map;
|
||||||
|
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
std::vector<Vec2d> m_extruder_offsets;
|
||||||
|
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
|
||||||
// The output of process_layer()
|
// The output of process_layer()
|
||||||
std::string m_process_output;
|
std::string m_process_output;
|
||||||
@ -111,6 +114,10 @@ private:
|
|||||||
public:
|
public:
|
||||||
GCodeAnalyzer();
|
GCodeAnalyzer();
|
||||||
|
|
||||||
|
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
void set_extruder_offsets(const std::vector<Vec2d>& extruder_offsets);
|
||||||
|
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||||
|
|
||||||
// Reinitialize the analyzer
|
// Reinitialize the analyzer
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
@ -58,5 +58,7 @@
|
|||||||
|
|
||||||
// Toolbars and Gizmos use icons imported from svg files
|
// Toolbars and Gizmos use icons imported from svg files
|
||||||
#define ENABLE_SVG_ICONS (1 && ENABLE_1_42_0_ALPHA8 && ENABLE_TEXTURES_FROM_SVG)
|
#define ENABLE_SVG_ICONS (1 && ENABLE_1_42_0_ALPHA8 && ENABLE_TEXTURES_FROM_SVG)
|
||||||
|
// G-Code Analyzer takes in account for extruder offsets
|
||||||
|
#define ENABLE_ANALYZER_EXTRUDER_OFFSET (1 && ENABLE_1_42_0_ALPHA8)
|
||||||
|
|
||||||
#endif // _technologies_h_
|
#endif // _technologies_h_
|
||||||
|
Loading…
Reference in New Issue
Block a user