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 "ExtrusionEntity.hpp"
|
||||
#include "EdgeGrid.hpp"
|
||||
@ -573,6 +574,17 @@ void GCode::_do_export(Print &print, FILE *file)
|
||||
|
||||
// resets analyzer
|
||||
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
|
||||
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()) {
|
||||
const Vec2d &extruder_offset = print.config().extruder_offset.get_at(extruder_id);
|
||||
Polygon s(outer_skirt);
|
||||
#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));
|
||||
}
|
||||
m_ooze_prevention.enable = true;
|
||||
|
@ -101,6 +101,13 @@ GCodeAnalyzer::GCodeAnalyzer()
|
||||
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()
|
||||
{
|
||||
_set_units(Millimeters);
|
||||
@ -118,6 +125,9 @@ void GCodeAnalyzer::reset()
|
||||
_reset_axes_position();
|
||||
|
||||
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)
|
||||
@ -654,7 +664,24 @@ void GCodeAnalyzer::_store_move(GCodeAnalyzer::GCodeMove::EType type)
|
||||
it = m_moves_map.insert(TypeToMovesMap::value_type(type, GCodeMovesList())).first;
|
||||
|
||||
// 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());
|
||||
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||
}
|
||||
|
||||
bool GCodeAnalyzer::_is_valid_extrusion_role(int value) const
|
||||
|
@ -104,6 +104,9 @@ private:
|
||||
State m_state;
|
||||
GCodeReader m_parser;
|
||||
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()
|
||||
std::string m_process_output;
|
||||
@ -111,6 +114,10 @@ private:
|
||||
public:
|
||||
GCodeAnalyzer();
|
||||
|
||||
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||
void set_extruder_offsets(const std::vector<Vec2d>& extruder_offsets);
|
||||
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
|
||||
|
||||
// Reinitialize the analyzer
|
||||
void reset();
|
||||
|
||||
|
@ -58,5 +58,7 @@
|
||||
|
||||
// Toolbars and Gizmos use icons imported from svg files
|
||||
#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_
|
||||
|
Loading…
Reference in New Issue
Block a user