ENH: abnormal gap infill width gcodecheck

Jira: none

Signed-off-by: qing.zhang <qing.zhang@bambulab.com>
Change-Id: I96e269becf540a77fd10fb8c8b25a699e89eaf3f
This commit is contained in:
qing.zhang 2024-04-18 11:45:53 +08:00 committed by Lane.Wei
parent c46e304b94
commit b4faec8052
2 changed files with 25 additions and 4 deletions

View File

@ -24,6 +24,7 @@ const std::string nozzle_temperature_Tag = " nozzle_temperature =";
const std::string nozzle_temperature_initial_layer_Tag = " nozzle_temperature_initial_layer";
const std::string Z_HEIGHT_TAG = " Z_HEIGHT: ";
const std::string Initial_Layer_Ptint_Height_Tag = " initial_layer_print_height =";
const std::string Line_Width_Tag = " line_width =";
GCodeCheckResult GCodeChecker::parse_file(const std::string& path)
{
@ -110,8 +111,8 @@ GCodeCheckResult GCodeChecker::parse_comment(GCodeLine& line)
// extrusion role tag
if (starts_with(comment, Extrusion_Role_Tag)) {
m_role = string_to_role(comment.substr(Extrusion_Role_Tag.length()));
check_gap_infill_width = false;
if (m_role == erExternalPerimeter) {
if (z_height == initial_layer_height && nozzle_temp != nozzle_temperature_initial_layer[filament_id]) {
std::cout << "invalid filament nozzle initial layer temperature comment with invalid value!" << std::endl;
return GCodeCheckResult::ParseFailed;
@ -121,9 +122,11 @@ GCodeCheckResult GCodeChecker::parse_comment(GCodeLine& line)
std::cout << "invalid filament nozzle temperature comment with invalid value!" << std::endl;
return GCodeCheckResult::ParseFailed;
}
} else if (m_role == erGapFill) {
check_gap_infill_width = true;
}
} else if (starts_with(comment, Wipe_Start_Tag)) {
}else if (starts_with(comment, Wipe_Start_Tag)) {
m_wiping = true;
} else if (starts_with(comment, Wipe_End_Tag)) {
m_wiping = false;
@ -139,6 +142,15 @@ GCodeCheckResult GCodeChecker::parse_comment(GCodeLine& line)
std::cout << "invalid width comment with invalid value!" << std::endl;
return GCodeCheckResult::ParseFailed;
}
//check gap infill line width
if( check_gap_infill_width ) {
if (m_width > max_gap_infill_width) {
std::cout << "gap infill width has invalid value!" << std::endl;
std::cout << "allowed max gap width: " << max_gap_infill_width << std::endl;
return GCodeCheckResult::ParseFailed;
}
}
} else if (starts_with(comment, Layer_Change_Tag)) {
m_layer_num++;
} else if (starts_with(comment, filament_flow_ratio_tag))
@ -175,8 +187,15 @@ GCodeCheckResult GCodeChecker::parse_comment(GCodeLine& line)
std::cout << "invalid initial layer height comment with invalid value!" << std::endl;
return GCodeCheckResult::ParseFailed;
}
}
} else if (starts_with(comment, Line_Width_Tag)) {
std::string str = comment.substr(Line_Width_Tag.size());
double default_line_width = 0.0f;
if (!parse_double_from_str(str, default_line_width)) {
std::cout << "invalid initial layer height comment with invalid value!" << std::endl;
return GCodeCheckResult::ParseFailed;
}
max_gap_infill_width = 3 * default_line_width;
}
return GCodeCheckResult::Success;
}

View File

@ -209,6 +209,8 @@ private:
double m_width = 0.0;
double z_height=0.0f;
double initial_layer_height=0.0f;
double max_gap_infill_width = 0.0f;
bool check_gap_infill_width = false;
int filament_id;
double flow_ratio = 0;
double nozzle_temp = 0.0f;