mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 10:47:50 -06:00
Fix of #1812 (GCode Anayzer take in account extruder offsets for multiextruder printers)
This commit is contained in:
parent
de23725a1e
commit
219ea04c23
4 changed files with 12 additions and 33 deletions
|
@ -574,17 +574,16 @@ 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
|
// send extruder offset data to analyzer
|
||||||
std::vector<Vec2d> extruder_offsets;
|
GCodeAnalyzer::ExtruderOffsetsMap extruder_offsets;
|
||||||
for (unsigned int extruder_id : print.extruders())
|
for (unsigned int extruder_id : print.extruders())
|
||||||
{
|
{
|
||||||
extruder_offsets.push_back(print.config().extruder_offset.get_at(extruder_id));
|
Vec2d offset = print.config().extruder_offset.get_at(extruder_id);
|
||||||
|
if (!offset.isApprox(Vec2d::Zero()))
|
||||||
|
extruder_offsets[extruder_id] = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_analyzer.set_extruder_offsets(extruder_offsets);
|
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;
|
||||||
|
@ -855,9 +854,7 @@ 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);
|
||||||
#if !ENABLE_ANALYZER_EXTRUDER_OFFSET
|
|
||||||
s.translate(Point::new_scale(-extruder_offset(0), -extruder_offset(1)));
|
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,12 +101,10 @@ GCodeAnalyzer::GCodeAnalyzer()
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
|
void GCodeAnalyzer::set_extruder_offsets(const GCodeAnalyzer::ExtruderOffsetsMap& extruder_offsets)
|
||||||
void GCodeAnalyzer::set_extruder_offsets(const std::vector<Vec2d>& extruder_offsets)
|
|
||||||
{
|
{
|
||||||
m_extruder_offsets = extruder_offsets;
|
m_extruder_offsets = extruder_offsets;
|
||||||
}
|
}
|
||||||
#endif // ENABLE_ANALYZER_EXTRUDER_OFFSET
|
|
||||||
|
|
||||||
void GCodeAnalyzer::reset()
|
void GCodeAnalyzer::reset()
|
||||||
{
|
{
|
||||||
|
@ -125,9 +123,7 @@ 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();
|
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)
|
||||||
|
@ -664,24 +660,15 @@ 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();
|
Vec3d extruder_offset = Vec3d::Zero();
|
||||||
unsigned int extruder_id = _get_extruder_id();
|
unsigned int extruder_id = _get_extruder_id();
|
||||||
|
ExtruderOffsetsMap::iterator extr_it = m_extruder_offsets.find(extruder_id);
|
||||||
std::cout << extruder_id << std::endl;
|
if (extr_it != m_extruder_offsets.end())
|
||||||
|
extruder_offset = Vec3d(extr_it->second(0), extr_it->second(1), 0.0);
|
||||||
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 start_position = _get_start_position() + extruder_offset;
|
||||||
Vec3d end_position = _get_end_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());
|
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
|
bool GCodeAnalyzer::_is_valid_extrusion_role(int value) const
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
|
|
||||||
typedef std::vector<GCodeMove> GCodeMovesList;
|
typedef std::vector<GCodeMove> GCodeMovesList;
|
||||||
typedef std::map<GCodeMove::EType, GCodeMovesList> TypeToMovesMap;
|
typedef std::map<GCodeMove::EType, GCodeMovesList> TypeToMovesMap;
|
||||||
|
typedef std::map<unsigned int, Vec2d> ExtruderOffsetsMap;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct State
|
struct State
|
||||||
|
@ -104,9 +105,7 @@ 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
|
ExtruderOffsetsMap m_extruder_offsets;
|
||||||
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;
|
||||||
|
@ -114,9 +113,7 @@ private:
|
||||||
public:
|
public:
|
||||||
GCodeAnalyzer();
|
GCodeAnalyzer();
|
||||||
|
|
||||||
#if ENABLE_ANALYZER_EXTRUDER_OFFSET
|
void set_extruder_offsets(const ExtruderOffsetsMap& extruder_offsets);
|
||||||
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,7 +58,5 @@
|
||||||
|
|
||||||
// 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 (0 && ENABLE_1_42_0_ALPHA8)
|
|
||||||
|
|
||||||
#endif // _technologies_h_
|
#endif // _technologies_h_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue