Fixed parsing of g-code files generated by newer versions of Simplify3D

This commit is contained in:
enricoturri1966 2021-03-24 11:36:16 +01:00
parent 8bc23c90fc
commit 9c951b3108

View file

@ -1491,89 +1491,109 @@ bool GCodeProcessor::process_simplify3d_tags(const std::string_view comment)
{ {
// extrusion roles // extrusion roles
// in older versions the comments did not contain the key 'feature'
std::string_view cmt = comment;
size_t pos = cmt.find(" feature");
if (pos == 0)
cmt.remove_prefix(8);
// ; skirt // ; skirt
size_t pos = comment.find(" skirt"); pos = cmt.find(" skirt");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erSkirt; m_extrusion_role = erSkirt;
return true; return true;
} }
// ; outer perimeter // ; outer perimeter
pos = comment.find(" outer perimeter"); pos = cmt.find(" outer perimeter");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erExternalPerimeter; m_extrusion_role = erExternalPerimeter;
return true; return true;
} }
// ; inner perimeter // ; inner perimeter
pos = comment.find(" inner perimeter"); pos = cmt.find(" inner perimeter");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erPerimeter; m_extrusion_role = erPerimeter;
return true; return true;
} }
// ; gap fill // ; gap fill
pos = comment.find(" gap fill"); pos = cmt.find(" gap fill");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erGapFill; m_extrusion_role = erGapFill;
return true; return true;
} }
// ; infill // ; infill
pos = comment.find(" infill"); pos = cmt.find(" infill");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erInternalInfill; m_extrusion_role = erInternalInfill;
return true; return true;
} }
// ; solid layer // ; solid layer
pos = comment.find(" solid layer"); pos = cmt.find(" solid layer");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erNone; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< m_extrusion_role = erSolidInfill;
return true; return true;
} }
// ; bridge // ; bridge
pos = comment.find(" bridge"); pos = cmt.find(" bridge");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erBridgeInfill; m_extrusion_role = erBridgeInfill;
return true; return true;
} }
// ; support // ; support
pos = comment.find(" support"); pos = cmt.find(" support");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erSupportMaterial; m_extrusion_role = erSupportMaterial;
return true; return true;
} }
// ; dense support
pos = cmt.find(" dense support");
if (pos == 0) {
m_extrusion_role = erSupportMaterialInterface;
return true;
}
// ; prime pillar // ; prime pillar
pos = comment.find(" prime pillar"); pos = cmt.find(" prime pillar");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erWipeTower; m_extrusion_role = erWipeTower;
return true; return true;
} }
// ; ooze shield // ; ooze shield
pos = comment.find(" ooze shield"); pos = cmt.find(" ooze shield");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erNone; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< m_extrusion_role = erNone; // Missing mapping
return true; return true;
} }
// ; raft // ; raft
pos = comment.find(" raft"); pos = cmt.find(" raft");
if (pos == 0) { if (pos == 0) {
m_extrusion_role = erSkirt; m_extrusion_role = erSupportMaterial;
return true;
}
// ; internal single extrusion
pos = cmt.find(" internal single extrusion");
if (pos == 0) {
m_extrusion_role = erNone; // Missing mapping
return true; return true;
} }
// geometry // geometry
// ; tool // ; tool
std::string tag = " tool"; std::string tag = " tool";
pos = comment.find(tag); pos = cmt.find(tag);
if (pos == 0) { if (pos == 0) {
const std::string_view data = comment.substr(pos + tag.length()); const std::string_view data = cmt.substr(pos + tag.length());
std::string h_tag = "H"; std::string h_tag = "H";
size_t h_start = data.find(h_tag); size_t h_start = data.find(h_tag);
size_t h_end = data.find_first_of(' ', h_start); size_t h_end = data.find_first_of(' ', h_start);
@ -1594,10 +1614,10 @@ bool GCodeProcessor::process_simplify3d_tags(const std::string_view comment)
// ; layer // ; layer
tag = " layer"; tag = " layer";
pos = comment.find(tag); pos = cmt.find(tag);
if (pos == 0) { if (pos == 0) {
// skip lines "; layer end" // skip lines "; layer end"
const std::string_view data = comment.substr(pos + tag.length()); const std::string_view data = cmt.substr(pos + tag.length());
size_t end_start = data.find("end"); size_t end_start = data.find("end");
if (end_start == data.npos) if (end_start == data.npos)
++m_layer_id; ++m_layer_id;