WIP Extending the expressivity of ExtrusionRole
Changed GCodeExtrusionRole to enum class. Follow-up to5991850db1
e50e96bb26
This commit is contained in:
parent
e50e96bb26
commit
c64dbacf88
12 changed files with 216 additions and 213 deletions
|
@ -320,7 +320,7 @@ BuildVolume::ObjectState BuildVolume::volume_state_bbox(const BoundingBoxf3& vol
|
|||
bool BuildVolume::all_paths_inside(const GCodeProcessorResult& paths, const BoundingBoxf3& paths_bbox, bool ignore_bottom) const
|
||||
{
|
||||
auto move_valid = [](const GCodeProcessorResult::MoveVertex &move) {
|
||||
return move.type == EMoveType::Extrude && move.extrusion_role != erCustom && move.width != 0.f && move.height != 0.f;
|
||||
return move.type == EMoveType::Extrude && move.extrusion_role != GCodeExtrusionRole::Custom && move.width != 0.f && move.height != 0.f;
|
||||
};
|
||||
static constexpr const double epsilon = BedEpsilon;
|
||||
|
||||
|
|
|
@ -11,42 +11,42 @@ namespace Slic3r {
|
|||
// GCodeExtrusionRole is to be serialized into G-code and deserialized by G-code viewer,
|
||||
GCodeExtrusionRole extrusion_role_to_gcode_extrusion_role(ExtrusionRole role)
|
||||
{
|
||||
if (role == ExtrusionRole::None) return erNone;
|
||||
if (role == ExtrusionRole::Perimeter) return erPerimeter;
|
||||
if (role == ExtrusionRole::ExternalPerimeter) return erExternalPerimeter;
|
||||
if (role == ExtrusionRole::OverhangPerimeter) return erOverhangPerimeter;
|
||||
if (role == ExtrusionRole::InternalInfill) return erInternalInfill;
|
||||
if (role == ExtrusionRole::SolidInfill) return erSolidInfill;
|
||||
if (role == ExtrusionRole::TopSolidInfill) return erTopSolidInfill;
|
||||
if (role == ExtrusionRole::Ironing) return erIroning;
|
||||
if (role == ExtrusionRole::BridgeInfill) return erBridgeInfill;
|
||||
if (role == ExtrusionRole::GapFill) return erGapFill;
|
||||
if (role == ExtrusionRole::Skirt) return erSkirt;
|
||||
if (role == ExtrusionRole::SupportMaterial) return erSupportMaterial;
|
||||
if (role == ExtrusionRole::SupportMaterialInterface) return erSupportMaterialInterface;
|
||||
if (role == ExtrusionRole::WipeTower) return erWipeTower;
|
||||
if (role == ExtrusionRole::None) return GCodeExtrusionRole::None;
|
||||
if (role == ExtrusionRole::Perimeter) return GCodeExtrusionRole::Perimeter;
|
||||
if (role == ExtrusionRole::ExternalPerimeter) return GCodeExtrusionRole::ExternalPerimeter;
|
||||
if (role == ExtrusionRole::OverhangPerimeter) return GCodeExtrusionRole::OverhangPerimeter;
|
||||
if (role == ExtrusionRole::InternalInfill) return GCodeExtrusionRole::InternalInfill;
|
||||
if (role == ExtrusionRole::SolidInfill) return GCodeExtrusionRole::SolidInfill;
|
||||
if (role == ExtrusionRole::TopSolidInfill) return GCodeExtrusionRole::TopSolidInfill;
|
||||
if (role == ExtrusionRole::Ironing) return GCodeExtrusionRole::Ironing;
|
||||
if (role == ExtrusionRole::BridgeInfill) return GCodeExtrusionRole::BridgeInfill;
|
||||
if (role == ExtrusionRole::GapFill) return GCodeExtrusionRole::GapFill;
|
||||
if (role == ExtrusionRole::Skirt) return GCodeExtrusionRole::Skirt;
|
||||
if (role == ExtrusionRole::SupportMaterial) return GCodeExtrusionRole::SupportMaterial;
|
||||
if (role == ExtrusionRole::SupportMaterialInterface) return GCodeExtrusionRole::SupportMaterialInterface;
|
||||
if (role == ExtrusionRole::WipeTower) return GCodeExtrusionRole::WipeTower;
|
||||
assert(false);
|
||||
return erNone;
|
||||
return GCodeExtrusionRole::None;
|
||||
}
|
||||
|
||||
std::string gcode_extrusion_role_to_string(GCodeExtrusionRole role)
|
||||
{
|
||||
switch (role) {
|
||||
case erNone : return L("Unknown");
|
||||
case erPerimeter : return L("Perimeter");
|
||||
case erExternalPerimeter : return L("External perimeter");
|
||||
case erOverhangPerimeter : return L("Overhang perimeter");
|
||||
case erInternalInfill : return L("Internal infill");
|
||||
case erSolidInfill : return L("Solid infill");
|
||||
case erTopSolidInfill : return L("Top solid infill");
|
||||
case erIroning : return L("Ironing");
|
||||
case erBridgeInfill : return L("Bridge infill");
|
||||
case erGapFill : return L("Gap fill");
|
||||
case erSkirt : return L("Skirt/Brim");
|
||||
case erSupportMaterial : return L("Support material");
|
||||
case erSupportMaterialInterface : return L("Support material interface");
|
||||
case erWipeTower : return L("Wipe tower");
|
||||
case erCustom : return L("Custom");
|
||||
case GCodeExtrusionRole::None : return L("Unknown");
|
||||
case GCodeExtrusionRole::Perimeter : return L("Perimeter");
|
||||
case GCodeExtrusionRole::ExternalPerimeter : return L("External perimeter");
|
||||
case GCodeExtrusionRole::OverhangPerimeter : return L("Overhang perimeter");
|
||||
case GCodeExtrusionRole::InternalInfill : return L("Internal infill");
|
||||
case GCodeExtrusionRole::SolidInfill : return L("Solid infill");
|
||||
case GCodeExtrusionRole::TopSolidInfill : return L("Top solid infill");
|
||||
case GCodeExtrusionRole::Ironing : return L("Ironing");
|
||||
case GCodeExtrusionRole::BridgeInfill : return L("Bridge infill");
|
||||
case GCodeExtrusionRole::GapFill : return L("Gap fill");
|
||||
case GCodeExtrusionRole::Skirt : return L("Skirt/Brim");
|
||||
case GCodeExtrusionRole::SupportMaterial : return L("Support material");
|
||||
case GCodeExtrusionRole::SupportMaterialInterface : return L("Support material interface");
|
||||
case GCodeExtrusionRole::WipeTower : return L("Wipe tower");
|
||||
case GCodeExtrusionRole::Custom : return L("Custom");
|
||||
default : assert(false);
|
||||
}
|
||||
return {};
|
||||
|
@ -55,35 +55,35 @@ std::string gcode_extrusion_role_to_string(GCodeExtrusionRole role)
|
|||
GCodeExtrusionRole string_to_gcode_extrusion_role(const std::string_view role)
|
||||
{
|
||||
if (role == L("Perimeter"))
|
||||
return erPerimeter;
|
||||
return GCodeExtrusionRole::Perimeter;
|
||||
else if (role == L("External perimeter"))
|
||||
return erExternalPerimeter;
|
||||
return GCodeExtrusionRole::ExternalPerimeter;
|
||||
else if (role == L("Overhang perimeter"))
|
||||
return erOverhangPerimeter;
|
||||
return GCodeExtrusionRole::OverhangPerimeter;
|
||||
else if (role == L("Internal infill"))
|
||||
return erInternalInfill;
|
||||
return GCodeExtrusionRole::InternalInfill;
|
||||
else if (role == L("Solid infill"))
|
||||
return erSolidInfill;
|
||||
return GCodeExtrusionRole::SolidInfill;
|
||||
else if (role == L("Top solid infill"))
|
||||
return erTopSolidInfill;
|
||||
return GCodeExtrusionRole::TopSolidInfill;
|
||||
else if (role == L("Ironing"))
|
||||
return erIroning;
|
||||
return GCodeExtrusionRole::Ironing;
|
||||
else if (role == L("Bridge infill"))
|
||||
return erBridgeInfill;
|
||||
return GCodeExtrusionRole::BridgeInfill;
|
||||
else if (role == L("Gap fill"))
|
||||
return erGapFill;
|
||||
return GCodeExtrusionRole::GapFill;
|
||||
else if (role == L("Skirt") || role == L("Skirt/Brim")) // "Skirt" is for backward compatibility with 2.3.1 and earlier
|
||||
return erSkirt;
|
||||
return GCodeExtrusionRole::Skirt;
|
||||
else if (role == L("Support material"))
|
||||
return erSupportMaterial;
|
||||
return GCodeExtrusionRole::SupportMaterial;
|
||||
else if (role == L("Support material interface"))
|
||||
return erSupportMaterialInterface;
|
||||
return GCodeExtrusionRole::SupportMaterialInterface;
|
||||
else if (role == L("Wipe tower"))
|
||||
return erWipeTower;
|
||||
return GCodeExtrusionRole::WipeTower;
|
||||
else if (role == L("Custom"))
|
||||
return erCustom;
|
||||
return GCodeExtrusionRole::Custom;
|
||||
else
|
||||
return erNone;
|
||||
return GCodeExtrusionRole::None;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -114,25 +114,28 @@ inline bool is_bridge(ExtrusionRole role) {
|
|||
|| role == ExtrusionRole::OverhangPerimeter;
|
||||
}
|
||||
|
||||
enum GCodeExtrusionRole : uint8_t {
|
||||
erNone,
|
||||
erPerimeter,
|
||||
erExternalPerimeter,
|
||||
erOverhangPerimeter,
|
||||
erInternalInfill,
|
||||
erSolidInfill,
|
||||
erTopSolidInfill,
|
||||
erIroning,
|
||||
erBridgeInfill,
|
||||
erGapFill,
|
||||
erSkirt,
|
||||
erSupportMaterial,
|
||||
erSupportMaterialInterface,
|
||||
erWipeTower,
|
||||
// Be careful when editing this list as many parts of the code depend
|
||||
// on the values of these ordinars, for example
|
||||
// GCodeViewer::Extrusion_Role_Colors
|
||||
enum class GCodeExtrusionRole : uint8_t {
|
||||
None,
|
||||
Perimeter,
|
||||
ExternalPerimeter,
|
||||
OverhangPerimeter,
|
||||
InternalInfill,
|
||||
SolidInfill,
|
||||
TopSolidInfill,
|
||||
Ironing,
|
||||
BridgeInfill,
|
||||
GapFill,
|
||||
Skirt,
|
||||
SupportMaterial,
|
||||
SupportMaterialInterface,
|
||||
WipeTower,
|
||||
// Custom (user defined) G-code block, for example start / end G-code.
|
||||
erCustom,
|
||||
Custom,
|
||||
// Stopper to count number of enums.
|
||||
erCount
|
||||
Count
|
||||
};
|
||||
|
||||
// Convert a rich bitmask based ExtrusionRole to a less expressive ordinal GCodeExtrusionRole.
|
||||
|
|
|
@ -1271,7 +1271,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
this->_print_first_layer_extruder_temperatures(file, print, start_gcode, initial_extruder_id, false);
|
||||
|
||||
// adds tag for processor
|
||||
file.write_format(";%s%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role).c_str(), gcode_extrusion_role_to_string(erCustom).c_str());
|
||||
file.write_format(";%s%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role).c_str(), gcode_extrusion_role_to_string(GCodeExtrusionRole::Custom).c_str());
|
||||
|
||||
// Write the custom start G-code
|
||||
file.writeln(start_gcode);
|
||||
|
@ -1407,7 +1407,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||
file.write(m_writer.set_fan(0));
|
||||
|
||||
// adds tag for processor
|
||||
file.write_format(";%s%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role).c_str(), gcode_extrusion_role_to_string(erCustom).c_str());
|
||||
file.write_format(";%s%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role).c_str(), gcode_extrusion_role_to_string(GCodeExtrusionRole::Custom).c_str());
|
||||
|
||||
// Process filament-specific gcode in extruder order.
|
||||
{
|
||||
|
@ -2182,7 +2182,7 @@ LayerResult GCode::process_layer(
|
|||
|
||||
// let analyzer tag generator aware of a role type change
|
||||
if (layer_tools.has_wipe_tower && m_wipe_tower)
|
||||
m_last_processor_extrusion_role = erWipeTower;
|
||||
m_last_processor_extrusion_role = GCodeExtrusionRole::WipeTower;
|
||||
|
||||
if (auto loops_it = skirt_loops_per_extruder.find(extruder_id); loops_it != skirt_loops_per_extruder.end()) {
|
||||
const std::pair<size_t, size_t> loops = loops_it->second;
|
||||
|
@ -2941,8 +2941,8 @@ std::string GCode::_extrude(const ExtrusionPath &path, const std::string_view de
|
|||
|
||||
// adds processor tags and updates processor tracking data
|
||||
// PrusaMultiMaterial::Writer may generate GCodeProcessor::Height_Tag lines without updating m_last_height
|
||||
// so, if the last role was erWipeTower we force export of GCodeProcessor::Height_Tag lines
|
||||
bool last_was_wipe_tower = (m_last_processor_extrusion_role == erWipeTower);
|
||||
// so, if the last role was GCodeExtrusionRole::WipeTower we force export of GCodeProcessor::Height_Tag lines
|
||||
bool last_was_wipe_tower = (m_last_processor_extrusion_role == GCodeExtrusionRole::WipeTower);
|
||||
assert(is_decimal_separator_point());
|
||||
|
||||
if (GCodeExtrusionRole role = extrusion_role_to_gcode_extrusion_role(path.role()); role != m_last_processor_extrusion_role) {
|
||||
|
|
|
@ -137,14 +137,14 @@ public:
|
|||
m_enable_loop_clipping(true),
|
||||
m_enable_cooling_markers(false),
|
||||
m_enable_extrusion_role_markers(false),
|
||||
m_last_processor_extrusion_role(erNone),
|
||||
m_last_processor_extrusion_role(GCodeExtrusionRole::None),
|
||||
m_layer_count(0),
|
||||
m_layer_index(-1),
|
||||
m_layer(nullptr),
|
||||
m_object_layer_over_raft(false),
|
||||
m_volumetric_speed(0),
|
||||
m_last_pos_defined(false),
|
||||
m_last_extrusion_role(erNone),
|
||||
m_last_extrusion_role(GCodeExtrusionRole::None),
|
||||
m_last_width(0.0f),
|
||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
m_last_mm3_per_mm(0.0),
|
||||
|
|
|
@ -942,7 +942,7 @@ void GCodeProcessor::reset()
|
|||
m_fan_speed = 0.0f;
|
||||
m_z_offset = 0.0f;
|
||||
|
||||
m_extrusion_role = erNone;
|
||||
m_extrusion_role = GCodeExtrusionRole::None;
|
||||
m_extruder_id = 0;
|
||||
m_extruder_colors.resize(MIN_EXTRUDERS_COUNT);
|
||||
for (size_t i = 0; i < MIN_EXTRUDERS_COUNT; ++i) {
|
||||
|
@ -1646,7 +1646,7 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers
|
|||
// extrusion role tag
|
||||
if (boost::starts_with(comment, reserved_tag(ETags::Role))) {
|
||||
set_extrusion_role(string_to_gcode_extrusion_role(comment.substr(reserved_tag(ETags::Role).length())));
|
||||
if (m_extrusion_role == erExternalPerimeter)
|
||||
if (m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter)
|
||||
m_seams_detector.activate(true);
|
||||
return;
|
||||
}
|
||||
|
@ -1827,27 +1827,27 @@ bool GCodeProcessor::process_cura_tags(const std::string_view comment)
|
|||
if (pos != comment.npos) {
|
||||
const std::string_view type = comment.substr(pos + tag.length());
|
||||
if (type == "SKIRT")
|
||||
set_extrusion_role(erSkirt);
|
||||
set_extrusion_role(GCodeExtrusionRole::Skirt);
|
||||
else if (type == "WALL-OUTER")
|
||||
set_extrusion_role(erExternalPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::ExternalPerimeter);
|
||||
else if (type == "WALL-INNER")
|
||||
set_extrusion_role(erPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::Perimeter);
|
||||
else if (type == "SKIN")
|
||||
set_extrusion_role(erSolidInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::SolidInfill);
|
||||
else if (type == "FILL")
|
||||
set_extrusion_role(erInternalInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::InternalInfill);
|
||||
else if (type == "SUPPORT")
|
||||
set_extrusion_role(erSupportMaterial);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterial);
|
||||
else if (type == "SUPPORT-INTERFACE")
|
||||
set_extrusion_role(erSupportMaterialInterface);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterialInterface);
|
||||
else if (type == "PRIME-TOWER")
|
||||
set_extrusion_role(erWipeTower);
|
||||
set_extrusion_role(GCodeExtrusionRole::WipeTower);
|
||||
else {
|
||||
set_extrusion_role(erNone);
|
||||
set_extrusion_role(GCodeExtrusionRole::None);
|
||||
BOOST_LOG_TRIVIAL(warning) << "GCodeProcessor found unknown extrusion role: " << type;
|
||||
}
|
||||
|
||||
if (m_extrusion_role == erExternalPerimeter)
|
||||
if (m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter)
|
||||
m_seams_detector.activate(true);
|
||||
|
||||
return true;
|
||||
|
@ -1906,14 +1906,14 @@ bool GCodeProcessor::process_simplify3d_tags(const std::string_view comment)
|
|||
// ; skirt
|
||||
pos = cmt.find(" skirt");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erSkirt);
|
||||
set_extrusion_role(GCodeExtrusionRole::Skirt);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; outer perimeter
|
||||
pos = cmt.find(" outer perimeter");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erExternalPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::ExternalPerimeter);
|
||||
m_seams_detector.activate(true);
|
||||
return true;
|
||||
}
|
||||
|
@ -1921,77 +1921,77 @@ bool GCodeProcessor::process_simplify3d_tags(const std::string_view comment)
|
|||
// ; inner perimeter
|
||||
pos = cmt.find(" inner perimeter");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::Perimeter);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; gap fill
|
||||
pos = cmt.find(" gap fill");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erGapFill);
|
||||
set_extrusion_role(GCodeExtrusionRole::GapFill);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; infill
|
||||
pos = cmt.find(" infill");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erInternalInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::InternalInfill);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; solid layer
|
||||
pos = cmt.find(" solid layer");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erSolidInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::SolidInfill);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; bridge
|
||||
pos = cmt.find(" bridge");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erBridgeInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::BridgeInfill);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; support
|
||||
pos = cmt.find(" support");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erSupportMaterial);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterial);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; dense support
|
||||
pos = cmt.find(" dense support");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erSupportMaterialInterface);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterialInterface);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; prime pillar
|
||||
pos = cmt.find(" prime pillar");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erWipeTower);
|
||||
set_extrusion_role(GCodeExtrusionRole::WipeTower);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; ooze shield
|
||||
pos = cmt.find(" ooze shield");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erNone); // Missing mapping
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // Missing mapping
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; raft
|
||||
pos = cmt.find(" raft");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erSupportMaterial);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterial);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; internal single extrusion
|
||||
pos = cmt.find(" internal single extrusion");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erNone); // Missing mapping
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // Missing mapping
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2043,33 +2043,33 @@ bool GCodeProcessor::process_craftware_tags(const std::string_view comment)
|
|||
if (pos != comment.npos) {
|
||||
const std::string_view type = comment.substr(pos + tag.length());
|
||||
if (type == "Skirt")
|
||||
set_extrusion_role(erSkirt);
|
||||
set_extrusion_role(GCodeExtrusionRole::Skirt);
|
||||
else if (type == "Perimeter")
|
||||
set_extrusion_role(erExternalPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::ExternalPerimeter);
|
||||
else if (type == "HShell")
|
||||
set_extrusion_role(erNone); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
else if (type == "InnerHair")
|
||||
set_extrusion_role(erNone); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
else if (type == "Loop")
|
||||
set_extrusion_role(erNone); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
else if (type == "Infill")
|
||||
set_extrusion_role(erInternalInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::InternalInfill);
|
||||
else if (type == "Raft")
|
||||
set_extrusion_role(erSkirt);
|
||||
set_extrusion_role(GCodeExtrusionRole::Skirt);
|
||||
else if (type == "Support")
|
||||
set_extrusion_role(erSupportMaterial);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterial);
|
||||
else if (type == "SupportTouch")
|
||||
set_extrusion_role(erSupportMaterial);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterial);
|
||||
else if (type == "SoftSupport")
|
||||
set_extrusion_role(erSupportMaterialInterface);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterialInterface);
|
||||
else if (type == "Pillar")
|
||||
set_extrusion_role(erWipeTower);
|
||||
set_extrusion_role(GCodeExtrusionRole::WipeTower);
|
||||
else {
|
||||
set_extrusion_role(erNone);
|
||||
set_extrusion_role(GCodeExtrusionRole::None);
|
||||
BOOST_LOG_TRIVIAL(warning) << "GCodeProcessor found unknown extrusion role: " << type;
|
||||
}
|
||||
|
||||
if (m_extrusion_role == erExternalPerimeter)
|
||||
if (m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter)
|
||||
m_seams_detector.activate(true);
|
||||
|
||||
return true;
|
||||
|
@ -2093,25 +2093,25 @@ bool GCodeProcessor::process_ideamaker_tags(const std::string_view comment)
|
|||
if (pos != comment.npos) {
|
||||
const std::string_view type = comment.substr(pos + tag.length());
|
||||
if (type == "RAFT")
|
||||
set_extrusion_role(erSkirt);
|
||||
set_extrusion_role(GCodeExtrusionRole::Skirt);
|
||||
else if (type == "WALL-OUTER")
|
||||
set_extrusion_role(erExternalPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::ExternalPerimeter);
|
||||
else if (type == "WALL-INNER")
|
||||
set_extrusion_role(erPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::Perimeter);
|
||||
else if (type == "SOLID-FILL")
|
||||
set_extrusion_role(erSolidInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::SolidInfill);
|
||||
else if (type == "FILL")
|
||||
set_extrusion_role(erInternalInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::InternalInfill);
|
||||
else if (type == "BRIDGE")
|
||||
set_extrusion_role(erBridgeInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::BridgeInfill);
|
||||
else if (type == "SUPPORT")
|
||||
set_extrusion_role(erSupportMaterial);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterial);
|
||||
else {
|
||||
set_extrusion_role(erNone);
|
||||
set_extrusion_role(GCodeExtrusionRole::None);
|
||||
BOOST_LOG_TRIVIAL(warning) << "GCodeProcessor found unknown extrusion role: " << type;
|
||||
}
|
||||
|
||||
if (m_extrusion_role == erExternalPerimeter)
|
||||
if (m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter)
|
||||
m_seams_detector.activate(true);
|
||||
|
||||
return true;
|
||||
|
@ -2153,35 +2153,35 @@ bool GCodeProcessor::process_kissslicer_tags(const std::string_view comment)
|
|||
// ; 'Raft Path'
|
||||
size_t pos = comment.find(" 'Raft Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erSkirt);
|
||||
set_extrusion_role(GCodeExtrusionRole::Skirt);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Support Interface Path'
|
||||
pos = comment.find(" 'Support Interface Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erSupportMaterialInterface);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterialInterface);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Travel/Ironing Path'
|
||||
pos = comment.find(" 'Travel/Ironing Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erIroning);
|
||||
set_extrusion_role(GCodeExtrusionRole::Ironing);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Support (may Stack) Path'
|
||||
pos = comment.find(" 'Support (may Stack) Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erSupportMaterial);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterial);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Perimeter Path'
|
||||
pos = comment.find(" 'Perimeter Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erExternalPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::ExternalPerimeter);
|
||||
m_seams_detector.activate(true);
|
||||
return true;
|
||||
}
|
||||
|
@ -2189,56 +2189,56 @@ bool GCodeProcessor::process_kissslicer_tags(const std::string_view comment)
|
|||
// ; 'Pillar Path'
|
||||
pos = comment.find(" 'Pillar Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erNone); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Destring/Wipe/Jump Path'
|
||||
pos = comment.find(" 'Destring/Wipe/Jump Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erNone); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Prime Pillar Path'
|
||||
pos = comment.find(" 'Prime Pillar Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erNone); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Loop Path'
|
||||
pos = comment.find(" 'Loop Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erNone); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Crown Path'
|
||||
pos = comment.find(" 'Crown Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erNone); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
set_extrusion_role(GCodeExtrusionRole::None); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Solid Path'
|
||||
pos = comment.find(" 'Solid Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erNone);
|
||||
set_extrusion_role(GCodeExtrusionRole::None);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Stacked Sparse Infill Path'
|
||||
pos = comment.find(" 'Stacked Sparse Infill Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erInternalInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::InternalInfill);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ; 'Sparse Infill Path'
|
||||
pos = comment.find(" 'Sparse Infill Path'");
|
||||
if (pos == 0) {
|
||||
set_extrusion_role(erSolidInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::SolidInfill);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2263,45 +2263,45 @@ bool GCodeProcessor::process_bambustudio_tags(const std::string_view comment)
|
|||
if (pos != comment.npos) {
|
||||
const std::string_view type = comment.substr(pos + tag.length());
|
||||
if (type == "Custom")
|
||||
set_extrusion_role(erCustom);
|
||||
set_extrusion_role(GCodeExtrusionRole::Custom);
|
||||
else if (type == "Inner wall")
|
||||
set_extrusion_role(erPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::Perimeter);
|
||||
else if (type == "Outer wall")
|
||||
set_extrusion_role(erExternalPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::ExternalPerimeter);
|
||||
else if (type == "Overhang wall")
|
||||
set_extrusion_role(erOverhangPerimeter);
|
||||
set_extrusion_role(GCodeExtrusionRole::OverhangPerimeter);
|
||||
else if (type == "Gap infill")
|
||||
set_extrusion_role(erGapFill);
|
||||
set_extrusion_role(GCodeExtrusionRole::GapFill);
|
||||
else if (type == "Bridge")
|
||||
set_extrusion_role(erBridgeInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::BridgeInfill);
|
||||
else if (type == "Sparse infill")
|
||||
set_extrusion_role(erInternalInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::InternalInfill);
|
||||
else if (type == "Internal solid infill")
|
||||
set_extrusion_role(erSolidInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::SolidInfill);
|
||||
else if (type == "Top surface")
|
||||
set_extrusion_role(erTopSolidInfill);
|
||||
set_extrusion_role(GCodeExtrusionRole::TopSolidInfill);
|
||||
else if (type == "Bottom surface")
|
||||
set_extrusion_role(erNone);
|
||||
set_extrusion_role(GCodeExtrusionRole::None);
|
||||
else if (type == "Ironing")
|
||||
set_extrusion_role(erIroning);
|
||||
set_extrusion_role(GCodeExtrusionRole::Ironing);
|
||||
else if (type == "Skirt")
|
||||
set_extrusion_role(erSkirt);
|
||||
set_extrusion_role(GCodeExtrusionRole::Skirt);
|
||||
else if (type == "Brim")
|
||||
set_extrusion_role(erSkirt);
|
||||
set_extrusion_role(GCodeExtrusionRole::Skirt);
|
||||
else if (type == "Support")
|
||||
set_extrusion_role(erSupportMaterial);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterial);
|
||||
else if (type == "Support interface")
|
||||
set_extrusion_role(erSupportMaterialInterface);
|
||||
set_extrusion_role(GCodeExtrusionRole::SupportMaterialInterface);
|
||||
else if (type == "Support transition")
|
||||
set_extrusion_role(erNone);
|
||||
set_extrusion_role(GCodeExtrusionRole::None);
|
||||
else if (type == "Prime tower")
|
||||
set_extrusion_role(erWipeTower);
|
||||
set_extrusion_role(GCodeExtrusionRole::WipeTower);
|
||||
else {
|
||||
set_extrusion_role(erNone);
|
||||
set_extrusion_role(GCodeExtrusionRole::None);
|
||||
BOOST_LOG_TRIVIAL(warning) << "GCodeProcessor found unknown extrusion role: " << type;
|
||||
}
|
||||
|
||||
if (m_extrusion_role == erExternalPerimeter)
|
||||
if (m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter)
|
||||
m_seams_detector.activate(true);
|
||||
|
||||
return true;
|
||||
|
@ -2405,7 +2405,7 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
|||
if (m_height == 0.0f)
|
||||
m_height = DEFAULT_TOOLPATH_HEIGHT;
|
||||
|
||||
if (m_end_position[Z] == 0.0f || (m_extrusion_role == erCustom && m_layer_id == 0))
|
||||
if (m_end_position[Z] == 0.0f || (m_extrusion_role == GCodeExtrusionRole::Custom && m_layer_id == 0))
|
||||
m_end_position[Z] = m_height;
|
||||
|
||||
if (line.comment() != INTERNAL_G2G3_TAG)
|
||||
|
@ -2418,10 +2418,10 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
|||
|
||||
if (m_forced_width > 0.0f)
|
||||
m_width = m_forced_width;
|
||||
else if (m_extrusion_role == erExternalPerimeter)
|
||||
else if (m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter)
|
||||
// cross section: rectangle
|
||||
m_width = delta_pos[E] * static_cast<float>(M_PI * sqr(1.05f * filament_radius)) / (delta_xyz * m_height);
|
||||
else if (m_extrusion_role == erBridgeInfill || m_extrusion_role == erNone)
|
||||
else if (m_extrusion_role == GCodeExtrusionRole::BridgeInfill || m_extrusion_role == GCodeExtrusionRole::None)
|
||||
// cross section: circle
|
||||
m_width = static_cast<float>(m_result.filament_diameters[m_extruder_id]) * std::sqrt(delta_pos[E] / delta_xyz);
|
||||
else
|
||||
|
@ -2605,10 +2605,10 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
|||
|
||||
if (m_seams_detector.is_active()) {
|
||||
// check for seam starting vertex
|
||||
if (type == EMoveType::Extrude && m_extrusion_role == erExternalPerimeter && !m_seams_detector.has_first_vertex())
|
||||
if (type == EMoveType::Extrude && m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter && !m_seams_detector.has_first_vertex())
|
||||
m_seams_detector.set_first_vertex(m_result.moves.back().position - m_extruder_offsets[m_extruder_id]);
|
||||
// check for seam ending vertex and store the resulting move
|
||||
else if ((type != EMoveType::Extrude || (m_extrusion_role != erExternalPerimeter && m_extrusion_role != erOverhangPerimeter)) && m_seams_detector.has_first_vertex()) {
|
||||
else if ((type != EMoveType::Extrude || (m_extrusion_role != GCodeExtrusionRole::ExternalPerimeter && m_extrusion_role != GCodeExtrusionRole::OverhangPerimeter)) && m_seams_detector.has_first_vertex()) {
|
||||
auto set_end_position = [this](const Vec3f& pos) {
|
||||
m_end_position[X] = pos.x(); m_end_position[Y] = pos.y(); m_end_position[Z] = pos.z();
|
||||
};
|
||||
|
@ -2627,7 +2627,7 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
|||
m_seams_detector.activate(false);
|
||||
}
|
||||
}
|
||||
else if (type == EMoveType::Extrude && m_extrusion_role == erExternalPerimeter) {
|
||||
else if (type == EMoveType::Extrude && m_extrusion_role == GCodeExtrusionRole::ExternalPerimeter) {
|
||||
m_seams_detector.activate(true);
|
||||
m_seams_detector.set_first_vertex(m_result.moves.back().position - m_extruder_offsets[m_extruder_id]);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace Slic3r {
|
|||
{
|
||||
unsigned int gcode_id{ 0 };
|
||||
EMoveType type{ EMoveType::Noop };
|
||||
GCodeExtrusionRole extrusion_role{ erNone };
|
||||
GCodeExtrusionRole extrusion_role{ GCodeExtrusionRole::None };
|
||||
unsigned char extruder_id{ 0 };
|
||||
unsigned char cp_color_id{ 0 };
|
||||
Vec3f position{ Vec3f::Zero() }; // mm
|
||||
|
@ -238,7 +238,7 @@ namespace Slic3r {
|
|||
};
|
||||
|
||||
EMoveType move_type{ EMoveType::Noop };
|
||||
GCodeExtrusionRole role{ erNone };
|
||||
GCodeExtrusionRole role{ GCodeExtrusionRole::None };
|
||||
unsigned int g1_line_id{ 0 };
|
||||
unsigned int layer_id{ 0 };
|
||||
float distance{ 0.0f }; // mm
|
||||
|
@ -310,7 +310,7 @@ namespace Slic3r {
|
|||
std::vector<TimeBlock> blocks;
|
||||
std::vector<G1LinesCacheItem> g1_times_cache;
|
||||
std::array<float, static_cast<size_t>(EMoveType::Count)> moves_time;
|
||||
std::array<float, static_cast<size_t>(GCodeExtrusionRole::erCount)> roles_time;
|
||||
std::array<float, static_cast<size_t>(GCodeExtrusionRole::Count)> roles_time;
|
||||
std::vector<float> layers_time;
|
||||
|
||||
void reset();
|
||||
|
@ -455,7 +455,7 @@ namespace Slic3r {
|
|||
{}
|
||||
|
||||
void update(float value, GCodeExtrusionRole role) {
|
||||
if (role != erCustom) {
|
||||
if (role != GCodeExtrusionRole::Custom) {
|
||||
++count;
|
||||
if (last_tag_value != 0.0f) {
|
||||
if (std::abs(value - last_tag_value) / last_tag_value > threshold)
|
||||
|
|
|
@ -37,7 +37,7 @@ PressureEqualizer::PressureEqualizer(const Slic3r::GCodeConfig &config) : m_use_
|
|||
m_current_extruder = 0;
|
||||
// Zero the position of the XYZE axes + the current feed
|
||||
memset(m_current_pos, 0, sizeof(float) * 5);
|
||||
m_current_extrusion_role = erNone;
|
||||
m_current_extrusion_role = GCodeExtrusionRole::None;
|
||||
// Expect the first command to fill the nozzle (deretract).
|
||||
m_retracted = true;
|
||||
|
||||
|
@ -60,9 +60,9 @@ PressureEqualizer::PressureEqualizer(const Slic3r::GCodeConfig &config) : m_use_
|
|||
}
|
||||
|
||||
// Don't regulate the pressure before and after gap-fill and ironing.
|
||||
for (const GCodeExtrusionRole er : {erGapFill, erIroning}) {
|
||||
m_max_volumetric_extrusion_rate_slopes[er].negative = 0;
|
||||
m_max_volumetric_extrusion_rate_slopes[er].positive = 0;
|
||||
for (const GCodeExtrusionRole er : {GCodeExtrusionRole::GapFill, GCodeExtrusionRole::Ironing}) {
|
||||
m_max_volumetric_extrusion_rate_slopes[size_t(er)].negative = 0;
|
||||
m_max_volumetric_extrusion_rate_slopes[size_t(er)].positive = 0;
|
||||
}
|
||||
|
||||
opened_extrude_set_speed_block = false;
|
||||
|
@ -519,9 +519,9 @@ void PressureEqualizer::adjust_volumetric_rate()
|
|||
// Nothing to do, the last move is not extruding.
|
||||
return;
|
||||
|
||||
std::array<float, erCount> feedrate_per_extrusion_role{};
|
||||
std::array<float, size_t(GCodeExtrusionRole::Count)> feedrate_per_extrusion_role{};
|
||||
feedrate_per_extrusion_role.fill(std::numeric_limits<float>::max());
|
||||
feedrate_per_extrusion_role[m_gcode_lines[line_idx].extrusion_role] = m_gcode_lines[line_idx].volumetric_extrusion_rate_start;
|
||||
feedrate_per_extrusion_role[int(m_gcode_lines[line_idx].extrusion_role)] = m_gcode_lines[line_idx].volumetric_extrusion_rate_start;
|
||||
|
||||
while (line_idx != fist_line_idx) {
|
||||
size_t idx_prev = line_idx - 1;
|
||||
|
@ -529,7 +529,7 @@ void PressureEqualizer::adjust_volumetric_rate()
|
|||
if (!m_gcode_lines[idx_prev].extruding())
|
||||
break;
|
||||
// Don't decelerate before ironing and gap-fill.
|
||||
if (m_gcode_lines[line_idx].extrusion_role == erIroning || m_gcode_lines[line_idx].extrusion_role == erGapFill) {
|
||||
if (m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::Ironing || m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::GapFill) {
|
||||
line_idx = idx_prev;
|
||||
continue;
|
||||
}
|
||||
|
@ -539,23 +539,23 @@ void PressureEqualizer::adjust_volumetric_rate()
|
|||
line_idx = idx_prev;
|
||||
GCodeLine &line = m_gcode_lines[line_idx];
|
||||
|
||||
for (size_t iRole = 1; iRole < erCount; ++ iRole) {
|
||||
for (size_t iRole = 1; iRole < size_t(GCodeExtrusionRole::Count); ++ iRole) {
|
||||
const float &rate_slope = m_max_volumetric_extrusion_rate_slopes[iRole].negative;
|
||||
if (rate_slope == 0 || feedrate_per_extrusion_role[iRole] == std::numeric_limits<float>::max())
|
||||
continue; // The negative rate is unlimited or the rate for GCodeExtrusionRole iRole is unlimited.
|
||||
|
||||
float rate_end = feedrate_per_extrusion_role[iRole];
|
||||
if (iRole == line.extrusion_role && rate_succ < rate_end)
|
||||
if (iRole == size_t(line.extrusion_role) && rate_succ < rate_end)
|
||||
// Limit by the succeeding volumetric flow rate.
|
||||
rate_end = rate_succ;
|
||||
|
||||
if (!line.adjustable_flow || line.extrusion_role == erExternalPerimeter || line.extrusion_role == erGapFill || line.extrusion_role == erBridgeInfill || line.extrusion_role == erIroning) {
|
||||
if (!line.adjustable_flow || line.extrusion_role == GCodeExtrusionRole::ExternalPerimeter || line.extrusion_role == GCodeExtrusionRole::GapFill || line.extrusion_role == GCodeExtrusionRole::BridgeInfill || line.extrusion_role == GCodeExtrusionRole::Ironing) {
|
||||
rate_end = line.volumetric_extrusion_rate_end;
|
||||
} else if (line.volumetric_extrusion_rate_end > rate_end) {
|
||||
line.volumetric_extrusion_rate_end = rate_end;
|
||||
line.max_volumetric_extrusion_rate_slope_negative = rate_slope;
|
||||
line.modified = true;
|
||||
} else if (iRole == line.extrusion_role) {
|
||||
} else if (iRole == size_t(line.extrusion_role)) {
|
||||
rate_end = line.volumetric_extrusion_rate_end;
|
||||
} else {
|
||||
// Use the original, 'floating' extrusion rate as a starting point for the limiter.
|
||||
|
@ -573,13 +573,13 @@ void PressureEqualizer::adjust_volumetric_rate()
|
|||
}
|
||||
// feedrate_per_extrusion_role[iRole] = (iRole == line.extrusion_role) ? line.volumetric_extrusion_rate_start : rate_start;
|
||||
// Don't store feed rate for ironing and gap-fill.
|
||||
if (line.extrusion_role != erIroning && line.extrusion_role != erGapFill)
|
||||
if (line.extrusion_role != GCodeExtrusionRole::Ironing && line.extrusion_role != GCodeExtrusionRole::GapFill)
|
||||
feedrate_per_extrusion_role[iRole] = line.volumetric_extrusion_rate_start;
|
||||
}
|
||||
}
|
||||
|
||||
feedrate_per_extrusion_role.fill(std::numeric_limits<float>::max());
|
||||
feedrate_per_extrusion_role[m_gcode_lines[line_idx].extrusion_role] = m_gcode_lines[line_idx].volumetric_extrusion_rate_end;
|
||||
feedrate_per_extrusion_role[size_t(m_gcode_lines[line_idx].extrusion_role)] = m_gcode_lines[line_idx].volumetric_extrusion_rate_end;
|
||||
|
||||
assert(m_gcode_lines[line_idx].extruding());
|
||||
while (line_idx != last_line_idx) {
|
||||
|
@ -588,7 +588,7 @@ void PressureEqualizer::adjust_volumetric_rate()
|
|||
if (!m_gcode_lines[idx_next].extruding())
|
||||
break;
|
||||
// Don't accelerate after ironing and gap-fill.
|
||||
if (m_gcode_lines[line_idx].extrusion_role == erIroning || m_gcode_lines[line_idx].extrusion_role == erGapFill) {
|
||||
if (m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::Ironing || m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::GapFill) {
|
||||
line_idx = idx_next;
|
||||
continue;
|
||||
}
|
||||
|
@ -597,21 +597,21 @@ void PressureEqualizer::adjust_volumetric_rate()
|
|||
line_idx = idx_next;
|
||||
GCodeLine &line = m_gcode_lines[line_idx];
|
||||
|
||||
for (size_t iRole = 1; iRole < erCount; ++ iRole) {
|
||||
for (size_t iRole = 1; iRole < size_t(GCodeExtrusionRole::Count); ++ iRole) {
|
||||
const float &rate_slope = m_max_volumetric_extrusion_rate_slopes[iRole].positive;
|
||||
if (rate_slope == 0 || feedrate_per_extrusion_role[iRole] == std::numeric_limits<float>::max())
|
||||
continue; // The positive rate is unlimited or the rate for GCodeExtrusionRole iRole is unlimited.
|
||||
|
||||
float rate_start = feedrate_per_extrusion_role[iRole];
|
||||
if (!line.adjustable_flow || line.extrusion_role == erExternalPerimeter || line.extrusion_role == erGapFill || line.extrusion_role == erBridgeInfill || line.extrusion_role == erIroning) {
|
||||
if (!line.adjustable_flow || line.extrusion_role == GCodeExtrusionRole::ExternalPerimeter || line.extrusion_role == GCodeExtrusionRole::GapFill || line.extrusion_role == GCodeExtrusionRole::BridgeInfill || line.extrusion_role == GCodeExtrusionRole::Ironing) {
|
||||
rate_start = line.volumetric_extrusion_rate_start;
|
||||
} else if (iRole == line.extrusion_role && rate_prec < rate_start)
|
||||
} else if (iRole == size_t(line.extrusion_role) && rate_prec < rate_start)
|
||||
rate_start = rate_prec;
|
||||
if (line.volumetric_extrusion_rate_start > rate_start) {
|
||||
line.volumetric_extrusion_rate_start = rate_start;
|
||||
line.max_volumetric_extrusion_rate_slope_positive = rate_slope;
|
||||
line.modified = true;
|
||||
} else if (iRole == line.extrusion_role) {
|
||||
} else if (iRole == size_t(line.extrusion_role)) {
|
||||
rate_start = line.volumetric_extrusion_rate_start;
|
||||
} else {
|
||||
// Use the original, 'floating' extrusion rate as a starting point for the limiter.
|
||||
|
@ -629,7 +629,7 @@ void PressureEqualizer::adjust_volumetric_rate()
|
|||
}
|
||||
// feedrate_per_extrusion_role[iRole] = (iRole == line.extrusion_role) ? line.volumetric_extrusion_rate_end : rate_end;
|
||||
// Don't store feed rate for ironing and gap-fill.
|
||||
if (line.extrusion_role != erIroning && line.extrusion_role != erGapFill)
|
||||
if (line.extrusion_role != GCodeExtrusionRole::Ironing && line.extrusion_role != GCodeExtrusionRole::GapFill)
|
||||
feedrate_per_extrusion_role[iRole] = line.volumetric_extrusion_rate_end;
|
||||
}
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ void PressureEqualizer::push_line_to_output(const size_t line_idx, const float n
|
|||
GCodeG1Formatter feedrate_formatter;
|
||||
feedrate_formatter.emit_f(new_feedrate);
|
||||
feedrate_formatter.emit_string(std::string(EXTRUDE_SET_SPEED_TAG.data(), EXTRUDE_SET_SPEED_TAG.length()));
|
||||
if (line.extrusion_role == erExternalPerimeter)
|
||||
if (line.extrusion_role == GCodeExtrusionRole::ExternalPerimeter)
|
||||
feedrate_formatter.emit_string(std::string(EXTERNAL_PERIMETER_TAG.data(), EXTERNAL_PERIMETER_TAG.length()));
|
||||
push_to_output(feedrate_formatter);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ private:
|
|||
float positive;
|
||||
float negative;
|
||||
};
|
||||
ExtrusionRateSlope m_max_volumetric_extrusion_rate_slopes[erCount];
|
||||
ExtrusionRateSlope m_max_volumetric_extrusion_rate_slopes[size_t(GCodeExtrusionRole::Count)];
|
||||
float m_max_volumetric_extrusion_rate_slope_positive;
|
||||
float m_max_volumetric_extrusion_rate_slope_negative;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
// adds tag for analyzer:
|
||||
std::ostringstream str;
|
||||
str << ";" << GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Height) << m_layer_height << "\n"; // don't rely on GCodeAnalyzer knowing the layer height - it knows nothing at priming
|
||||
str << ";" << GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role) << gcode_extrusion_role_to_string(erWipeTower) << "\n";
|
||||
str << ";" << GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role) << gcode_extrusion_role_to_string(GCodeExtrusionRole::WipeTower) << "\n";
|
||||
m_gcode += str.str();
|
||||
change_analyzer_line_width(line_width);
|
||||
}
|
||||
|
|
|
@ -560,23 +560,22 @@ void GCodeViewer::SequentialView::render(float legend_height)
|
|||
gcode_window.render(legend_height, bottom, static_cast<uint64_t>(gcode_ids[current.last]));
|
||||
}
|
||||
|
||||
const std::vector<ColorRGBA> GCodeViewer::Extrusion_Role_Colors{ {
|
||||
{ 0.90f, 0.70f, 0.70f, 1.0f }, // erNone
|
||||
{ 1.00f, 0.90f, 0.30f, 1.0f }, // erPerimeter
|
||||
{ 1.00f, 0.49f, 0.22f, 1.0f }, // erExternalPerimeter
|
||||
{ 0.12f, 0.12f, 1.00f, 1.0f }, // erOverhangPerimeter
|
||||
{ 0.69f, 0.19f, 0.16f, 1.0f }, // erInternalInfill
|
||||
{ 0.59f, 0.33f, 0.80f, 1.0f }, // erSolidInfill
|
||||
{ 0.94f, 0.25f, 0.25f, 1.0f }, // erTopSolidInfill
|
||||
{ 1.00f, 0.55f, 0.41f, 1.0f }, // erIroning
|
||||
{ 0.30f, 0.50f, 0.73f, 1.0f }, // erBridgeInfill
|
||||
{ 1.00f, 1.00f, 1.00f, 1.0f }, // erGapFill
|
||||
{ 0.00f, 0.53f, 0.43f, 1.0f }, // erSkirt
|
||||
{ 0.00f, 1.00f, 0.00f, 1.0f }, // erSupportMaterial
|
||||
{ 0.00f, 0.50f, 0.00f, 1.0f }, // erSupportMaterialInterface
|
||||
{ 0.70f, 0.89f, 0.67f, 1.0f }, // erWipeTower
|
||||
{ 0.37f, 0.82f, 0.58f, 1.0f }, // erCustom
|
||||
{ 0.00f, 0.00f, 0.00f, 1.0f } // erMixed
|
||||
const std::array<ColorRGBA, static_cast<size_t>(GCodeExtrusionRole::Count)> GCodeViewer::Extrusion_Role_Colors{ {
|
||||
{ 0.90f, 0.70f, 0.70f, 1.0f }, // GCodeExtrusionRole::None
|
||||
{ 1.00f, 0.90f, 0.30f, 1.0f }, // GCodeExtrusionRole::Perimeter
|
||||
{ 1.00f, 0.49f, 0.22f, 1.0f }, // GCodeExtrusionRole::ExternalPerimeter
|
||||
{ 0.12f, 0.12f, 1.00f, 1.0f }, // GCodeExtrusionRole::OverhangPerimeter
|
||||
{ 0.69f, 0.19f, 0.16f, 1.0f }, // GCodeExtrusionRole::InternalInfill
|
||||
{ 0.59f, 0.33f, 0.80f, 1.0f }, // GCodeExtrusionRole::SolidInfill
|
||||
{ 0.94f, 0.25f, 0.25f, 1.0f }, // GCodeExtrusionRole::TopSolidInfill
|
||||
{ 1.00f, 0.55f, 0.41f, 1.0f }, // GCodeExtrusionRole::Ironing
|
||||
{ 0.30f, 0.50f, 0.73f, 1.0f }, // GCodeExtrusionRole::BridgeInfill
|
||||
{ 1.00f, 1.00f, 1.00f, 1.0f }, // GCodeExtrusionRole::GapFill
|
||||
{ 0.00f, 0.53f, 0.43f, 1.0f }, // GCodeExtrusionRole::Skirt
|
||||
{ 0.00f, 1.00f, 0.00f, 1.0f }, // GCodeExtrusionRole::SupportMaterial
|
||||
{ 0.00f, 0.50f, 0.00f, 1.0f }, // GCodeExtrusionRole::SupportMaterialInterface
|
||||
{ 0.70f, 0.89f, 0.67f, 1.0f }, // GCodeExtrusionRole::WipeTower
|
||||
{ 0.37f, 0.82f, 0.58f, 1.0f }, // GCodeExtrusionRole::Custom
|
||||
}};
|
||||
|
||||
const std::vector<ColorRGBA> GCodeViewer::Options_Colors{ {
|
||||
|
@ -840,7 +839,7 @@ void GCodeViewer::refresh(const GCodeProcessorResult& gcode_result, const std::v
|
|||
m_extrusions.ranges.width.update_from(round_to_bin(curr.width));
|
||||
m_extrusions.ranges.fan_speed.update_from(curr.fan_speed);
|
||||
m_extrusions.ranges.temperature.update_from(curr.temperature);
|
||||
if (curr.extrusion_role != erCustom || is_visible(erCustom))
|
||||
if (curr.extrusion_role != GCodeExtrusionRole::Custom || is_visible(GCodeExtrusionRole::Custom))
|
||||
m_extrusions.ranges.volumetric_rate.update_from(round_to_bin(curr.volumetric_rate()));
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
@ -1556,7 +1555,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||
// for the gcode viewer we need to take in account all moves to correctly size the printbed
|
||||
m_paths_bounding_box.merge(move.position.cast<double>());
|
||||
else {
|
||||
if (move.type == EMoveType::Extrude && move.extrusion_role != erCustom && move.width != 0.0f && move.height != 0.0f)
|
||||
if (move.type == EMoveType::Extrude && move.extrusion_role != GCodeExtrusionRole::Custom && move.width != 0.0f && move.height != 0.0f)
|
||||
m_paths_bounding_box.merge(move.position.cast<double>());
|
||||
}
|
||||
}
|
||||
|
@ -1603,11 +1602,11 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
|
|||
const GCodeProcessorResult::MoveVertex& prev = gcode_result.moves[i - 1];
|
||||
|
||||
if (curr.type == EMoveType::Extrude &&
|
||||
curr.extrusion_role != erSkirt &&
|
||||
curr.extrusion_role != erSupportMaterial &&
|
||||
curr.extrusion_role != erSupportMaterialInterface &&
|
||||
curr.extrusion_role != erWipeTower &&
|
||||
curr.extrusion_role != erCustom) {
|
||||
curr.extrusion_role != GCodeExtrusionRole::Skirt &&
|
||||
curr.extrusion_role != GCodeExtrusionRole::SupportMaterial &&
|
||||
curr.extrusion_role != GCodeExtrusionRole::SupportMaterialInterface &&
|
||||
curr.extrusion_role != GCodeExtrusionRole::WipeTower &&
|
||||
curr.extrusion_role != GCodeExtrusionRole::Custom) {
|
||||
const Vec3d curr_pos = curr.position.cast<double>();
|
||||
const Vec3d prev_pos = prev.position.cast<double>();
|
||||
m_cog.add_segment(curr_pos, prev_pos, curr.mm3_per_mm * (curr_pos - prev_pos).norm());
|
||||
|
@ -3494,8 +3493,8 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
if (m_view_type == EViewType::FeatureType) {
|
||||
// calculate offsets to align time/percentage data
|
||||
for (GCodeExtrusionRole role : m_roles) {
|
||||
assert(role < erCount);
|
||||
if (role < erCount) {
|
||||
assert(role < GCodeExtrusionRole::Count);
|
||||
if (role < GCodeExtrusionRole::Count) {
|
||||
labels.push_back(_u8L(gcode_extrusion_role_to_string(role)));
|
||||
auto [time, percent] = role_time_and_percent(role);
|
||||
times.push_back((time > 0.0f) ? short_time(get_time_dhms(time)) : "");
|
||||
|
@ -3610,12 +3609,12 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||
|
||||
for (size_t i = 0; i < m_roles.size(); ++i) {
|
||||
GCodeExtrusionRole role = m_roles[i];
|
||||
if (role >= erCount)
|
||||
if (role >= GCodeExtrusionRole::Count)
|
||||
continue;
|
||||
const bool visible = is_visible(role);
|
||||
append_item(EItemType::Rect, Extrusion_Role_Colors[static_cast<unsigned int>(role)], labels[i],
|
||||
visible, times[i], percents[i], max_time_percent, offsets, used_filaments_m[i], used_filaments_g[i], [this, role, visible]() {
|
||||
m_extrusions.role_visibility_flags = visible ? m_extrusions.role_visibility_flags & ~(1 << role) : m_extrusions.role_visibility_flags | (1 << role);
|
||||
m_extrusions.role_visibility_flags = visible ? m_extrusions.role_visibility_flags & ~(1 << int(role)) : m_extrusions.role_visibility_flags | (1 << int(role));
|
||||
// update buffers' render paths
|
||||
refresh_render_paths(false, false);
|
||||
wxGetApp().plater()->update_preview_moves_slider();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define slic3r_GCodeViewer_hpp_
|
||||
|
||||
#include "3DScene.hpp"
|
||||
#include "libslic3r/ExtrusionRole.hpp"
|
||||
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
||||
#include "GLModel.hpp"
|
||||
|
||||
|
@ -30,7 +31,7 @@ class GCodeViewer
|
|||
using InstanceIdBuffer = std::vector<size_t>;
|
||||
using InstancesOffsets = std::vector<Vec3f>;
|
||||
|
||||
static const std::vector<ColorRGBA> Extrusion_Role_Colors;
|
||||
static const std::array<ColorRGBA, static_cast<size_t>(GCodeExtrusionRole::Count)> Extrusion_Role_Colors;
|
||||
static const std::vector<ColorRGBA> Options_Colors;
|
||||
static const std::vector<ColorRGBA> Travel_Colors;
|
||||
static const std::vector<ColorRGBA> Range_Colors;
|
||||
|
@ -208,7 +209,7 @@ class GCodeViewer
|
|||
};
|
||||
|
||||
EMoveType type{ EMoveType::Noop };
|
||||
GCodeExtrusionRole role{ erNone };
|
||||
GCodeExtrusionRole role{ GCodeExtrusionRole::None };
|
||||
float delta_extruder{ 0.0f };
|
||||
float height{ 0.0f };
|
||||
float width{ 0.0f };
|
||||
|
@ -482,7 +483,7 @@ class GCodeViewer
|
|||
|
||||
void reset_role_visibility_flags() {
|
||||
role_visibility_flags = 0;
|
||||
for (unsigned int i = 0; i < erCount; ++i) {
|
||||
for (uint32_t i = 0; i < uint32_t(GCodeExtrusionRole::Count); ++i) {
|
||||
role_visibility_flags |= 1 << i;
|
||||
}
|
||||
}
|
||||
|
@ -850,7 +851,7 @@ private:
|
|||
void render_statistics();
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
bool is_visible(GCodeExtrusionRole role) const {
|
||||
return role < erCount && (m_extrusions.role_visibility_flags & (1 << role)) != 0;
|
||||
return role < GCodeExtrusionRole::Count && (m_extrusions.role_visibility_flags & (1 << int(role))) != 0;
|
||||
}
|
||||
bool is_visible(const Path& path) const { return is_visible(path.role); }
|
||||
void log_memory_used(const std::string& label, int64_t additional = 0) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue