add scarf seam

This commit is contained in:
Wang YB
2024-05-21 11:32:40 +08:00
parent 0b00c61781
commit e77259c80b
16 changed files with 555 additions and 21 deletions

View File

@@ -668,8 +668,14 @@ for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::
m_result.max_print_height = config.max_print_height;
const ConfigOptionBool* spiral_vase = config.option<ConfigOptionBool>("spiral_vase");
//w37
if (spiral_vase != nullptr)
m_spiral_vase_active = spiral_vase->value;
m_detect_layer_based_on_tag = spiral_vase->value;//m_spiral_vase_active = spiral_vase->value;
//w37
const ConfigOptionBool *has_scarf_joint_seam = config.option<ConfigOptionBool>("has_scarf_joint_seam");
if (has_scarf_joint_seam != nullptr)
m_detect_layer_based_on_tag = m_detect_layer_based_on_tag || has_scarf_joint_seam->value;
const ConfigOptionFloat* z_offset = config.option<ConfigOptionFloat>("z_offset");
if (z_offset != nullptr)
@@ -950,8 +956,14 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
m_result.max_print_height = max_print_height->value;
const ConfigOptionBool* spiral_vase = config.option<ConfigOptionBool>("spiral_vase");
//w37
if (spiral_vase != nullptr)
m_spiral_vase_active = spiral_vase->value;
m_detect_layer_based_on_tag = spiral_vase->value;//m_spiral_vase_active = spiral_vase->value;
//w37
const ConfigOptionBool *has_scarf_joint_seam = config.option<ConfigOptionBool>("has_scarf_joint_seam");
if (has_scarf_joint_seam != nullptr)
m_detect_layer_based_on_tag = m_detect_layer_based_on_tag || has_scarf_joint_seam->value;
const ConfigOptionFloat* z_offset = config.option<ConfigOptionFloat>("z_offset");
if (z_offset != nullptr)
@@ -1022,7 +1034,11 @@ void GCodeProcessor::reset()
m_options_z_corrector.reset();
m_spiral_vase_active = false;
//w37
//m_spiral_vase_active = false;
m_detect_layer_based_on_tag = false;
m_seams_count = 0;
m_kissslicer_toolchange_time_correction = 0.0f;
m_single_extruder_multi_material = false;
@@ -1989,12 +2005,14 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers
// layer change tag
if (comment == reserved_tag(ETags::Layer_Change)) {
++m_layer_id;
if (m_spiral_vase_active) {
//w37
if (m_detect_layer_based_on_tag) { // if (m_spiral_vase_active) {
if (m_result.moves.empty() || m_result.spiral_vase_layers.empty())
// add a placeholder for layer height. the actual value will be set inside process_G1() method
m_result.spiral_vase_layers.push_back({ FLT_MAX, { 0, 0 } });
else {
const size_t move_id = m_result.moves.size() - 1;
//w37
const size_t move_id = m_result.moves.size() - 1 - m_seams_count;//const size_t move_id = m_result.moves.size() - 1;
if (!m_result.spiral_vase_layers.empty())
m_result.spiral_vase_layers.back().second.second = move_id;
// add a placeholder for layer height. the actual value will be set inside process_G1() method
@@ -2880,7 +2898,8 @@ void GCodeProcessor::process_G1(const std::array<std::optional<double>, 4>& axes
m_seams_detector.set_first_vertex(m_result.moves.back().position - m_extruder_offsets[m_extruder_id]);
}
if (m_spiral_vase_active && !m_result.spiral_vase_layers.empty()) {
//w37
if (m_detect_layer_based_on_tag && !m_result.spiral_vase_layers.empty()) {//if (m_spiral_vase_active && !m_result.spiral_vase_layers.empty()) {
if (m_result.spiral_vase_layers.back().first == FLT_MAX && delta_pos[Z] >= 0.0)
// replace layer height placeholder with correct value
m_result.spiral_vase_layers.back().first = static_cast<float>(m_end_position[Z]);
@@ -4437,6 +4456,11 @@ void GCodeProcessor::store_move_vertex(EMoveType type, bool internal_only)
internal_only
});
//w37
if (type == EMoveType::Seam) {
m_seams_count++;
}
// stores stop time placeholders for later use
if (type == EMoveType::Color_change || type == EMoveType::Pause_Print) {
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {

View File

@@ -596,7 +596,10 @@ namespace Slic3r {
SeamsDetector m_seams_detector;
OptionsZCorrector m_options_z_corrector;
size_t m_last_default_color_id;
bool m_spiral_vase_active;
//w37
//bool m_spiral_vase_active;
bool m_detect_layer_based_on_tag{false};
int m_seams_count;
float m_kissslicer_toolchange_time_correction;
#if ENABLE_GCODE_VIEWER_STATISTICS
std::chrono::time_point<std::chrono::high_resolution_clock> m_start_time;
@@ -676,6 +679,10 @@ namespace Slic3r {
std::vector<std::pair<EMoveType, float>> get_moves_time(PrintEstimatedStatistics::ETimeMode mode) const;
std::vector<std::pair<GCodeExtrusionRole, float>> get_roles_time(PrintEstimatedStatistics::ETimeMode mode) const;
std::vector<float> get_layers_time(PrintEstimatedStatistics::ETimeMode mode) const;
//w37
void detect_layer_based_on_tag(bool enabled) {
m_detect_layer_based_on_tag = enabled;
}
private:
void apply_config(const DynamicPrintConfig& config);

View File

@@ -444,7 +444,8 @@ std::string GCodeWriter::extrude_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &i
return w.string();
}
#if 0
//w37
//#if 0
std::string GCodeWriter::extrude_to_xyz(const Vec3d &point, double dE, const std::string_view comment)
{
m_pos = point;
@@ -453,11 +454,12 @@ std::string GCodeWriter::extrude_to_xyz(const Vec3d &point, double dE, const std
GCodeG1Formatter w;
w.emit_xyz(point);
w.emit_e(m_extrusion_axis, m_extruder->E());
//w37
w.emit_e(m_extrusion_axis, m_extruder->extrude(dE).second);
w.emit_comment(this->config.gcode_comments, comment);
return w.string();
}
#endif
//#endif
std::string GCodeWriter::retract(bool before_wipe)
{

View File

@@ -84,7 +84,8 @@ public:
std::string travel_to_z(double z, const std::string_view comment = {});
std::string extrude_to_xy(const Vec2d &point, double dE, const std::string_view comment = {});
std::string extrude_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, double dE, const std::string_view comment);
// std::string extrude_to_xyz(const Vec3d &point, double dE, const std::string_view comment = {});
//w37
std::string extrude_to_xyz(const Vec3d &point, double dE, const std::string_view comment = {});
std::string retract(bool before_wipe = false);
std::string retract_for_toolchange(bool before_wipe = false);
std::string unretract();