mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Merge branch 'lm_wipe_tower_improvements'
This commit is contained in:
		
						commit
						7fb9610d3a
					
				
					 6 changed files with 286 additions and 308 deletions
				
			
		|  | @ -435,19 +435,18 @@ namespace Slic3r { | ||||||
|     { |     { | ||||||
|         std::string gcode; |         std::string gcode; | ||||||
|         assert(m_layer_idx >= 0); |         assert(m_layer_idx >= 0); | ||||||
|         if (!m_brim_done || gcodegen.writer().need_toolchange(extruder_id) || finish_layer) { |         if (gcodegen.writer().need_toolchange(extruder_id) || finish_layer) { | ||||||
|             if (m_layer_idx < (int)m_tool_changes.size()) { |             if (m_layer_idx < (int)m_tool_changes.size()) { | ||||||
|                 if (!(size_t(m_tool_change_idx) < m_tool_changes[m_layer_idx].size())) |                 if (!(size_t(m_tool_change_idx) < m_tool_changes[m_layer_idx].size())) | ||||||
|                     throw Slic3r::RuntimeError("Wipe tower generation failed, possibly due to empty first layer."); |                     throw Slic3r::RuntimeError("Wipe tower generation failed, possibly due to empty first layer."); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|                 // Calculate where the wipe tower layer will be printed. -1 means that print z will not change,
 |                 // Calculate where the wipe tower layer will be printed. -1 means that print z will not change,
 | ||||||
|                 // resulting in a wipe tower with sparse layers.
 |                 // resulting in a wipe tower with sparse layers.
 | ||||||
|                 double wipe_tower_z = -1; |                 double wipe_tower_z = -1; | ||||||
|                 bool ignore_sparse = false; |                 bool ignore_sparse = false; | ||||||
|                 if (gcodegen.config().wipe_tower_no_sparse_layers.value) { |                 if (gcodegen.config().wipe_tower_no_sparse_layers.value) { | ||||||
|                     wipe_tower_z = m_last_wipe_tower_print_z; |                     wipe_tower_z = m_last_wipe_tower_print_z; | ||||||
|                     ignore_sparse = (m_brim_done && m_tool_changes[m_layer_idx].size() == 1 && m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool); |                     ignore_sparse = (m_tool_changes[m_layer_idx].size() == 1 && m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool); | ||||||
|                     if (m_tool_change_idx == 0 && !ignore_sparse) |                     if (m_tool_change_idx == 0 && !ignore_sparse) | ||||||
|                         wipe_tower_z = m_last_wipe_tower_print_z + m_tool_changes[m_layer_idx].front().layer_height; |                         wipe_tower_z = m_last_wipe_tower_print_z + m_tool_changes[m_layer_idx].front().layer_height; | ||||||
|                 } |                 } | ||||||
|  | @ -457,7 +456,6 @@ namespace Slic3r { | ||||||
|                     m_last_wipe_tower_print_z = wipe_tower_z; |                     m_last_wipe_tower_print_z = wipe_tower_z; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             m_brim_done = true; |  | ||||||
|         } |         } | ||||||
|         return gcode; |         return gcode; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -75,8 +75,8 @@ public: | ||||||
|         m_tool_changes(tool_changes), |         m_tool_changes(tool_changes), | ||||||
|         m_final_purge(final_purge), |         m_final_purge(final_purge), | ||||||
|         m_layer_idx(-1), |         m_layer_idx(-1), | ||||||
|         m_tool_change_idx(0), |         m_tool_change_idx(0) | ||||||
|         m_brim_done(false) {} |     {} | ||||||
| 
 | 
 | ||||||
|     std::string prime(GCode &gcodegen); |     std::string prime(GCode &gcodegen); | ||||||
|     void next_layer() { ++ m_layer_idx; m_tool_change_idx = 0; } |     void next_layer() { ++ m_layer_idx; m_tool_change_idx = 0; } | ||||||
|  | @ -105,8 +105,6 @@ private: | ||||||
|     // Current layer index.
 |     // Current layer index.
 | ||||||
|     int                                                          m_layer_idx; |     int                                                          m_layer_idx; | ||||||
|     int                                                          m_tool_change_idx; |     int                                                          m_tool_change_idx; | ||||||
|     bool                                                         m_brim_done; |  | ||||||
|     bool                                                         i_have_brim = false; |  | ||||||
|     double                                                       m_last_wipe_tower_print_z = 0.f; |     double                                                       m_last_wipe_tower_print_z = 0.f; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -329,6 +329,16 @@ void ToolOrdering::reorder_extruders(unsigned int last_extruder_id) | ||||||
|                     lt.extruders.front() = last_extruder_id; |                     lt.extruders.front() = last_extruder_id; | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|  | 
 | ||||||
|  |             // On first layer with wipe tower, prefer a soluble extruder
 | ||||||
|  |             // at the beginning, so it is not wiped on the first layer.
 | ||||||
|  |             if (lt == m_layer_tools[0] && m_print_config_ptr && m_print_config_ptr->wipe_tower) { | ||||||
|  |                 for (size_t i = 0; i<lt.extruders.size(); ++i) | ||||||
|  |                     if (m_print_config_ptr->filament_soluble.get_at(lt.extruders[i]-1)) { // 1-based...
 | ||||||
|  |                         std::swap(lt.extruders[i], lt.extruders.front()); | ||||||
|  |                         break; | ||||||
|  |                     } | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|         last_extruder_id = lt.extruders.back(); |         last_extruder_id = lt.extruders.back(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -9,17 +9,6 @@ | ||||||
| #include "BoundingBox.hpp" | #include "BoundingBox.hpp" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // Experimental "Peter's wipe tower" feature was partially implemented, inspired by
 |  | ||||||
| // PJR's idea of alternating two perpendicular wiping directions on a square tower.
 |  | ||||||
| // It is probably never going to be finished, there are multiple remaining issues
 |  | ||||||
| // and there is probably no need to go down this way. m_peters_wipe_tower variable
 |  | ||||||
| // turns this on, maybe it should just be removed. Anyway, the issues are
 |  | ||||||
| // - layer's are not exactly square
 |  | ||||||
| // - variable width for higher levels
 |  | ||||||
| // - make sure it is not too sparse (apply max_bridge_distance and make last wipe longer)
 |  | ||||||
| // - enable enhanced first layer adhesion
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| namespace Slic3r | namespace Slic3r | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
|  | @ -122,8 +111,10 @@ public: | ||||||
| 
 | 
 | ||||||
| 	WipeTowerWriter& 			 feedrate(float f) | 	WipeTowerWriter& 			 feedrate(float f) | ||||||
| 	{ | 	{ | ||||||
| 		if (f != m_current_feedrate) |         if (f != m_current_feedrate) { | ||||||
| 			m_gcode += "G1" + set_format_F(f) + "\n"; | 			m_gcode += "G1" + set_format_F(f) + "\n"; | ||||||
|  |             m_current_feedrate = f; | ||||||
|  |         } | ||||||
| 		return *this; | 		return *this; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -242,6 +233,14 @@ public: | ||||||
|         return (*this); |         return (*this); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     WipeTowerWriter& rectangle(const WipeTower::box_coordinates& box, const float f = 0.f) | ||||||
|  |     { | ||||||
|  |         rectangle(Vec2f(box.ld.x(), box.ld.y()), | ||||||
|  |                   box.ru.x() - box.lu.x(), | ||||||
|  |                   box.ru.y() - box.rd.y(), f); | ||||||
|  |         return (*this); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| 	WipeTowerWriter& load(float e, float f = 0.f) | 	WipeTowerWriter& load(float e, float f = 0.f) | ||||||
| 	{ | 	{ | ||||||
| 		if (e == 0.f && (f == 0.f || f == m_current_feedrate)) | 		if (e == 0.f && (f == 0.f || f == m_current_feedrate)) | ||||||
|  | @ -523,13 +522,21 @@ WipeTower::WipeTower(const PrintConfig& config, const std::vector<std::vector<fl | ||||||
|     m_wipe_tower_brim_width(float(config.wipe_tower_brim_width)), |     m_wipe_tower_brim_width(float(config.wipe_tower_brim_width)), | ||||||
|     m_y_shift(0.f), |     m_y_shift(0.f), | ||||||
|     m_z_pos(0.f), |     m_z_pos(0.f), | ||||||
|     m_is_first_layer(false), |  | ||||||
|     m_bridging(float(config.wipe_tower_bridging)), |     m_bridging(float(config.wipe_tower_bridging)), | ||||||
|     m_no_sparse_layers(config.wipe_tower_no_sparse_layers), |     m_no_sparse_layers(config.wipe_tower_no_sparse_layers), | ||||||
|     m_gcode_flavor(config.gcode_flavor), |     m_gcode_flavor(config.gcode_flavor), | ||||||
|  |     m_travel_speed(config.travel_speed), | ||||||
|     m_current_tool(initial_tool), |     m_current_tool(initial_tool), | ||||||
|     wipe_volumes(wiping_matrix) |     wipe_volumes(wiping_matrix) | ||||||
| { | { | ||||||
|  |     // Read absolute value of first layer speed, if given as percentage,
 | ||||||
|  |     // it is taken over following default. Speeds from config are not
 | ||||||
|  |     // easily accessible here.
 | ||||||
|  |     const float default_speed = 60.f; | ||||||
|  |     m_first_layer_speed = config.get_abs_value("first_layer_speed", default_speed); | ||||||
|  |     if (m_first_layer_speed == 0.f) // just to make sure autospeed doesn't break it.
 | ||||||
|  |         m_first_layer_speed = default_speed / 2.f; | ||||||
|  | 
 | ||||||
|     // If this is a single extruder MM printer, we will use all the SE-specific config values.
 |     // If this is a single extruder MM printer, we will use all the SE-specific config values.
 | ||||||
|     // Otherwise, the defaults will be used to turn off the SE stuff.
 |     // Otherwise, the defaults will be used to turn off the SE stuff.
 | ||||||
|     if (m_semm) { |     if (m_semm) { | ||||||
|  | @ -556,6 +563,7 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config) | ||||||
|     m_filpar.push_back(FilamentParameters()); |     m_filpar.push_back(FilamentParameters()); | ||||||
| 
 | 
 | ||||||
|     m_filpar[idx].material = config.filament_type.get_at(idx); |     m_filpar[idx].material = config.filament_type.get_at(idx); | ||||||
|  |     m_filpar[idx].is_soluble = config.filament_soluble.get_at(idx); | ||||||
|     m_filpar[idx].temperature = config.temperature.get_at(idx); |     m_filpar[idx].temperature = config.temperature.get_at(idx); | ||||||
|     m_filpar[idx].first_layer_temperature = config.first_layer_temperature.get_at(idx); |     m_filpar[idx].first_layer_temperature = config.first_layer_temperature.get_at(idx); | ||||||
| 
 | 
 | ||||||
|  | @ -680,7 +688,7 @@ std::vector<WipeTower::ToolChangeResult> WipeTower::prime( | ||||||
|             if (m_set_extruder_trimpot) |             if (m_set_extruder_trimpot) | ||||||
|                 writer.set_extruder_trimpot(550); |                 writer.set_extruder_trimpot(550); | ||||||
|             writer.speed_override_restore() |             writer.speed_override_restore() | ||||||
|                   .feedrate(6000) |                   .feedrate(m_travel_speed * 60.f) | ||||||
|                   .flush_planner_queue() |                   .flush_planner_queue() | ||||||
|                   .reset_extruder() |                   .reset_extruder() | ||||||
|                   .append("; CP PRIMING END\n" |                   .append("; CP PRIMING END\n" | ||||||
|  | @ -694,21 +702,14 @@ std::vector<WipeTower::ToolChangeResult> WipeTower::prime( | ||||||
|     m_old_temperature = -1; // If the priming is turned off in config, the temperature changing commands will not actually appear
 |     m_old_temperature = -1; // If the priming is turned off in config, the temperature changing commands will not actually appear
 | ||||||
|                             // in the output gcode - we should not remember emitting them (we will output them twice in the worst case)
 |                             // in the output gcode - we should not remember emitting them (we will output them twice in the worst case)
 | ||||||
| 
 | 
 | ||||||
| 	// so that tool_change() will know to extrude the wipe tower brim:
 |  | ||||||
| 	m_print_brim = true; |  | ||||||
| 
 |  | ||||||
| 	return results; | 	return results; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool) | WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool) | ||||||
| { | { | ||||||
| 	if ( m_print_brim ) |  | ||||||
| 		return toolchange_Brim(); |  | ||||||
| 
 |  | ||||||
|     size_t old_tool = m_current_tool; |     size_t old_tool = m_current_tool; | ||||||
| 
 | 
 | ||||||
|     float wipe_area = 0.f; |     float wipe_area = 0.f; | ||||||
| 	bool last_change_in_layer = false; |  | ||||||
| 	float wipe_volume = 0.f; | 	float wipe_volume = 0.f; | ||||||
| 	 | 	 | ||||||
| 	// Finds this toolchange info
 | 	// Finds this toolchange info
 | ||||||
|  | @ -717,8 +718,6 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool) | ||||||
| 		for (const auto &b : m_layer_info->tool_changes) | 		for (const auto &b : m_layer_info->tool_changes) | ||||||
| 			if ( b.new_tool == tool ) { | 			if ( b.new_tool == tool ) { | ||||||
|                 wipe_volume = b.wipe_volume; |                 wipe_volume = b.wipe_volume; | ||||||
| 				if (tool == m_layer_info->tool_changes.back().new_tool) |  | ||||||
| 					last_change_in_layer = true; |  | ||||||
| 				wipe_area = b.required_depth * m_layer_info->extra_spacing; | 				wipe_area = b.required_depth * m_layer_info->extra_spacing; | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
|  | @ -730,14 +729,14 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool) | ||||||
|     box_coordinates cleaning_box( |     box_coordinates cleaning_box( | ||||||
| 		Vec2f(m_perimeter_width / 2.f, m_perimeter_width / 2.f), | 		Vec2f(m_perimeter_width / 2.f, m_perimeter_width / 2.f), | ||||||
| 		m_wipe_tower_width - m_perimeter_width, | 		m_wipe_tower_width - m_perimeter_width, | ||||||
|         (tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5f*m_perimeter_width |         (tool != (unsigned int)(-1) ? wipe_area+m_depth_traversed-0.5f*m_perimeter_width | ||||||
|                                     : m_wipe_tower_depth-m_perimeter_width)); |                                     : m_wipe_tower_depth-m_perimeter_width)); | ||||||
| 
 | 
 | ||||||
| 	WipeTowerWriter writer(m_layer_height, m_perimeter_width, m_gcode_flavor, m_filpar); | 	WipeTowerWriter writer(m_layer_height, m_perimeter_width, m_gcode_flavor, m_filpar); | ||||||
| 	writer.set_extrusion_flow(m_extrusion_flow) | 	writer.set_extrusion_flow(m_extrusion_flow) | ||||||
| 		.set_z(m_z_pos) | 		.set_z(m_z_pos) | ||||||
| 		.set_initial_tool(m_current_tool) | 		.set_initial_tool(m_current_tool) | ||||||
| 		.set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) |         .set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) | ||||||
| 		.append(";--------------------\n" | 		.append(";--------------------\n" | ||||||
| 				"; CP TOOLCHANGE START\n") | 				"; CP TOOLCHANGE START\n") | ||||||
| 		.comment_with_value(" toolchange #", m_num_tool_changes + 1); // the number is zero-based
 | 		.comment_with_value(" toolchange #", m_num_tool_changes + 1); // the number is zero-based
 | ||||||
|  | @ -759,7 +758,7 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool) | ||||||
|     // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
 |     // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
 | ||||||
|     if (tool != (unsigned int)-1){ 			// This is not the last change.
 |     if (tool != (unsigned int)-1){ 			// This is not the last change.
 | ||||||
|         toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, |         toolchange_Unload(writer, cleaning_box, m_filpar[m_current_tool].material, | ||||||
|                           m_is_first_layer ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature); |                           is_first_layer() ? m_filpar[tool].first_layer_temperature : m_filpar[tool].temperature); | ||||||
|         toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials.
 |         toolchange_Change(writer, tool, m_filpar[tool].material); // Change the tool, set a speed override for soluble and flex materials.
 | ||||||
|         toolchange_Load(writer, cleaning_box); |         toolchange_Load(writer, cleaning_box); | ||||||
|         writer.travel(writer.x(), writer.y()-m_perimeter_width); // cooling and loading were done a bit down the road
 |         writer.travel(writer.x(), writer.y()-m_perimeter_width); // cooling and loading were done a bit down the road
 | ||||||
|  | @ -770,24 +769,10 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool) | ||||||
| 
 | 
 | ||||||
|     m_depth_traversed += wipe_area; |     m_depth_traversed += wipe_area; | ||||||
| 
 | 
 | ||||||
|     if (last_change_in_layer) {// draw perimeter line
 |  | ||||||
|         writer.set_y_shift(m_y_shift); |  | ||||||
|         if (m_peters_wipe_tower) |  | ||||||
|             writer.rectangle(Vec2f::Zero(), m_layer_info->depth + 3*m_perimeter_width, m_wipe_tower_depth); |  | ||||||
|         else { |  | ||||||
|             writer.rectangle(Vec2f::Zero(), m_wipe_tower_width, m_layer_info->depth + m_perimeter_width); |  | ||||||
|             if (layer_finished()) { // no finish_layer will be called, we must wipe the nozzle
 |  | ||||||
|                 writer.add_wipe_point(writer.x(), writer.y()) |  | ||||||
|                       .add_wipe_point(writer.x()> m_wipe_tower_width / 2.f ? 0.f : m_wipe_tower_width, writer.y()); |  | ||||||
| 
 |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| 	if (m_set_extruder_trimpot) | 	if (m_set_extruder_trimpot) | ||||||
| 		writer.set_extruder_trimpot(550);    // Reset the extruder current to a normal value.
 | 		writer.set_extruder_trimpot(550);    // Reset the extruder current to a normal value.
 | ||||||
| 	writer.speed_override_restore(); | 	writer.speed_override_restore(); | ||||||
|     writer.feedrate(6000) |     writer.feedrate(m_travel_speed * 60.f) | ||||||
|           .flush_planner_queue() |           .flush_planner_queue() | ||||||
|           .reset_extruder() |           .reset_extruder() | ||||||
|           .append("; CP TOOLCHANGE END\n" |           .append("; CP TOOLCHANGE END\n" | ||||||
|  | @ -801,66 +786,6 @@ WipeTower::ToolChangeResult WipeTower::tool_change(size_t tool) | ||||||
|    return construct_tcr(writer, false, old_tool); |    return construct_tcr(writer, false, old_tool); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| WipeTower::ToolChangeResult WipeTower::toolchange_Brim(bool sideOnly, float y_offset) |  | ||||||
| { |  | ||||||
|     size_t old_tool = m_current_tool; |  | ||||||
| 
 |  | ||||||
| 	const box_coordinates wipeTower_box( |  | ||||||
| 		Vec2f::Zero(), |  | ||||||
| 		m_wipe_tower_width, |  | ||||||
| 		m_wipe_tower_depth); |  | ||||||
| 
 |  | ||||||
| 	WipeTowerWriter writer(m_layer_height, m_perimeter_width, m_gcode_flavor, m_filpar); |  | ||||||
| 	writer.set_extrusion_flow(m_extrusion_flow * 1.1f) |  | ||||||
| 		  .set_z(m_z_pos) // Let the writer know the current Z position as a base for Z-hop.
 |  | ||||||
| 		  .set_initial_tool(m_current_tool) |  | ||||||
| 		  .append(";-------------------------------------\n" |  | ||||||
| 				  "; CP WIPE TOWER FIRST LAYER BRIM START\n"); |  | ||||||
| 
 |  | ||||||
|     Vec2f initial_position = wipeTower_box.lu - Vec2f(m_wipe_tower_brim_width + 2*m_perimeter_width, 0); |  | ||||||
| 	writer.set_initial_position(initial_position, m_wipe_tower_width, m_wipe_tower_depth, m_internal_rotation); |  | ||||||
| 
 |  | ||||||
|     // Prime the extruder left of the wipe tower.
 |  | ||||||
|     writer.extrude_explicit(wipeTower_box.ld - Vec2f(m_wipe_tower_brim_width + 2*m_perimeter_width, 0), |  | ||||||
|         1.5f * m_extrusion_flow * (wipeTower_box.lu.y() - wipeTower_box.ld.y()), 2400); |  | ||||||
| 
 |  | ||||||
|     // The tool is supposed to be active and primed at the time when the wipe tower brim is extruded.
 |  | ||||||
|     // Extrude brim around the future wipe tower ('normal' spacing with no extra void space).
 |  | ||||||
|     box_coordinates box(wipeTower_box);     |  | ||||||
|     float spacing = m_perimeter_width - m_layer_height*float(1.-M_PI_4); |  | ||||||
| 
 |  | ||||||
|     // How many perimeters shall the brim have?
 |  | ||||||
|     size_t loops_num = (m_wipe_tower_brim_width + spacing/2.f) / spacing; |  | ||||||
| 
 |  | ||||||
|     for (size_t i = 0; i < loops_num; ++ i) { |  | ||||||
|         box.expand(spacing); |  | ||||||
|         writer.travel (box.ld, 7000) |  | ||||||
|               .extrude(box.lu, 2100).extrude(box.ru) |  | ||||||
|               .extrude(box.rd      ).extrude(box.ld); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     // Save actual brim width to be later passed to the Print object, which will use it
 |  | ||||||
|     // for skirt calculation and pass it to GLCanvas for precise preview box
 |  | ||||||
|     m_wipe_tower_brim_width_real = wipeTower_box.ld.x() - box.ld.x() + spacing/2.f; |  | ||||||
| 
 |  | ||||||
|     box.expand(-spacing); |  | ||||||
|     writer.add_wipe_point(writer.x(), writer.y()) |  | ||||||
|           .add_wipe_point(box.ld) |  | ||||||
|           .add_wipe_point(box.rd); |  | ||||||
| 
 |  | ||||||
|     writer.append("; CP WIPE TOWER FIRST LAYER BRIM END\n" |  | ||||||
|                   ";-----------------------------------\n"); |  | ||||||
| 
 |  | ||||||
|     m_print_brim = false;  // Mark the brim as extruded
 |  | ||||||
| 
 |  | ||||||
|     // Ask our writer about how much material was consumed:
 |  | ||||||
|     if (m_current_tool < m_used_filament_length.size()) |  | ||||||
|     	m_used_filament_length[m_current_tool] += writer.get_and_reset_used_filament_length(); |  | ||||||
| 
 |  | ||||||
|     return construct_tcr(writer, false, old_tool); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
 | // Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
 | ||||||
| void WipeTower::toolchange_Unload( | void WipeTower::toolchange_Unload( | ||||||
|  | @ -957,7 +882,7 @@ void WipeTower::toolchange_Unload( | ||||||
|     // be already set and there is no need to change anything. Also, the temperature could be changed
 |     // be already set and there is no need to change anything. Also, the temperature could be changed
 | ||||||
|     // for wrong extruder.
 |     // for wrong extruder.
 | ||||||
|     if (m_semm) { |     if (m_semm) { | ||||||
|         if (new_temperature != 0 && (new_temperature != m_old_temperature || m_is_first_layer) ) { 	// Set the extruder temperature, but don't wait.
 |         if (new_temperature != 0 && (new_temperature != m_old_temperature || is_first_layer()) ) { 	// Set the extruder temperature, but don't wait.
 | ||||||
|             // If the required temperature is the same as last time, don't emit the M104 again (if user adjusted the value, it would be reset)
 |             // If the required temperature is the same as last time, don't emit the M104 again (if user adjusted the value, it would be reset)
 | ||||||
|             // However, always change temperatures on the first layer (this is to avoid issues with priming lines turned off).
 |             // However, always change temperatures on the first layer (this is to avoid issues with priming lines turned off).
 | ||||||
|             writer.set_extruder_temp(new_temperature, false); |             writer.set_extruder_temp(new_temperature, false); | ||||||
|  | @ -1017,7 +942,10 @@ void WipeTower::toolchange_Change( | ||||||
|     // gcode could have left the extruder somewhere, we cannot just start extruding. We should also inform the
 |     // gcode could have left the extruder somewhere, we cannot just start extruding. We should also inform the
 | ||||||
|     // postprocessor that we absolutely want to have this in the gcode, even if it thought it is the same as before.
 |     // postprocessor that we absolutely want to have this in the gcode, even if it thought it is the same as before.
 | ||||||
|     Vec2f current_pos = writer.pos_rotated(); |     Vec2f current_pos = writer.pos_rotated(); | ||||||
|     writer.append(std::string("G1 X") + std::to_string(current_pos.x()) +  " Y" + std::to_string(current_pos.y()) + never_skip_tag() + "\n"); |     writer.feedrate(m_travel_speed * 60.f) // see https://github.com/prusa3d/PrusaSlicer/issues/5483
 | ||||||
|  |           .append(std::string("G1 X") + std::to_string(current_pos.x()) | ||||||
|  |                              +  " Y"  + std::to_string(current_pos.y()) | ||||||
|  |                              + never_skip_tag() + "\n"); | ||||||
| 
 | 
 | ||||||
|     // The toolchange Tn command will be inserted later, only in case that the user does
 |     // The toolchange Tn command will be inserted later, only in case that the user does
 | ||||||
|     // not provide a custom toolchange gcode.
 |     // not provide a custom toolchange gcode.
 | ||||||
|  | @ -1063,9 +991,8 @@ void WipeTower::toolchange_Wipe( | ||||||
| 	float wipe_volume) | 	float wipe_volume) | ||||||
| { | { | ||||||
| 	// Increase flow on first layer, slow down print.
 | 	// Increase flow on first layer, slow down print.
 | ||||||
| 	writer.set_extrusion_flow(m_extrusion_flow * (m_is_first_layer ? 1.18f : 1.f)) |     writer.set_extrusion_flow(m_extrusion_flow * (is_first_layer() ? 1.18f : 1.f)) | ||||||
| 		  .append("; CP TOOLCHANGE WIPE\n"); | 		  .append("; CP TOOLCHANGE WIPE\n"); | ||||||
| 	float wipe_coeff = m_is_first_layer ? 0.5f : 1.f; |  | ||||||
| 	const float& xl = cleaning_box.ld.x(); | 	const float& xl = cleaning_box.ld.x(); | ||||||
| 	const float& xr = cleaning_box.rd.x(); | 	const float& xr = cleaning_box.rd.x(); | ||||||
| 
 | 
 | ||||||
|  | @ -1075,7 +1002,9 @@ void WipeTower::toolchange_Wipe( | ||||||
| 
 | 
 | ||||||
| 	float x_to_wipe = volume_to_length(wipe_volume, m_perimeter_width, m_layer_height); | 	float x_to_wipe = volume_to_length(wipe_volume, m_perimeter_width, m_layer_height); | ||||||
| 	float dy = m_extra_spacing*m_perimeter_width; | 	float dy = m_extra_spacing*m_perimeter_width; | ||||||
| 	float wipe_speed = 1600.f; | 
 | ||||||
|  |     const float target_speed = is_first_layer() ? m_first_layer_speed * 60.f : 4800.f; | ||||||
|  |     float wipe_speed = 0.33f * target_speed; | ||||||
| 
 | 
 | ||||||
|     // if there is less than 2.5*m_perimeter_width to the edge, advance straightaway (there is likely a blob anyway)
 |     // if there is less than 2.5*m_perimeter_width to the edge, advance straightaway (there is likely a blob anyway)
 | ||||||
|     if ((m_left_to_right ? xr-writer.x() : writer.x()-xl) < 2.5f*m_perimeter_width) { |     if ((m_left_to_right ? xr-writer.x() : writer.x()-xl) < 2.5f*m_perimeter_width) { | ||||||
|  | @ -1086,17 +1015,17 @@ void WipeTower::toolchange_Wipe( | ||||||
|     // now the wiping itself:
 |     // now the wiping itself:
 | ||||||
| 	for (int i = 0; true; ++i)	{ | 	for (int i = 0; true; ++i)	{ | ||||||
| 		if (i!=0) { | 		if (i!=0) { | ||||||
| 			if (wipe_speed < 1610.f) wipe_speed = 1800.f; |             if      (wipe_speed < 0.34f * target_speed) wipe_speed = 0.375f * target_speed; | ||||||
| 			else if (wipe_speed < 1810.f) wipe_speed = 2200.f; |             else if (wipe_speed < 0.377 * target_speed) wipe_speed = 0.458f * target_speed; | ||||||
| 			else if (wipe_speed < 2210.f) wipe_speed = 4200.f; |             else if (wipe_speed < 0.46f * target_speed) wipe_speed = 0.875f * target_speed; | ||||||
| 			else wipe_speed = std::min(4800.f, wipe_speed + 50.f); |             else wipe_speed = std::min(target_speed, wipe_speed + 50.f); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		float traversed_x = writer.x(); | 		float traversed_x = writer.x(); | ||||||
| 		if (m_left_to_right) | 		if (m_left_to_right) | ||||||
|             writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); |             writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed); | ||||||
| 		else | 		else | ||||||
|             writer.extrude(xl + (i % 4 == 1 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); |             writer.extrude(xl + (i % 4 == 1 ? 0 : 1.5f*m_perimeter_width), writer.y(), wipe_speed); | ||||||
| 
 | 
 | ||||||
|         if (writer.y()+float(EPSILON) > cleaning_box.lu.y()-0.5f*m_perimeter_width) |         if (writer.y()+float(EPSILON) > cleaning_box.lu.y()-0.5f*m_perimeter_width) | ||||||
|             break;		// in case next line would not fit
 |             break;		// in case next line would not fit
 | ||||||
|  | @ -1112,15 +1041,14 @@ void WipeTower::toolchange_Wipe( | ||||||
| 		m_left_to_right = !m_left_to_right; | 		m_left_to_right = !m_left_to_right; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|     // this is neither priming nor not the last toolchange on this layer - we are
 |     // We may be going back to the model - wipe the nozzle. If this is followed
 | ||||||
|     // going back to the model - wipe the nozzle.
 |     // by finish_layer, this wipe path will be overwritten.
 | ||||||
|     if (m_layer_info != m_plan.end() && m_current_tool != m_layer_info->tool_changes.back().new_tool) { |  | ||||||
|         m_left_to_right = !m_left_to_right; |  | ||||||
|     writer.add_wipe_point(writer.x(), writer.y()) |     writer.add_wipe_point(writer.x(), writer.y()) | ||||||
|           .add_wipe_point(writer.x(), writer.y() - dy) |           .add_wipe_point(writer.x(), writer.y() - dy) | ||||||
|               .add_wipe_point(m_left_to_right ? m_wipe_tower_width : 0.f, writer.y() - dy); |           .add_wipe_point(! m_left_to_right ? m_wipe_tower_width : 0.f, writer.y() - dy); | ||||||
| 
 | 
 | ||||||
|     } |     if (m_layer_info != m_plan.end() && m_current_tool != m_layer_info->tool_changes.back().new_tool) | ||||||
|  |         m_left_to_right = !m_left_to_right; | ||||||
| 
 | 
 | ||||||
|     writer.set_extrusion_flow(m_extrusion_flow); // Reset the extrusion flow.
 |     writer.set_extrusion_flow(m_extrusion_flow); // Reset the extrusion flow.
 | ||||||
| } | } | ||||||
|  | @ -1130,9 +1058,8 @@ void WipeTower::toolchange_Wipe( | ||||||
| 
 | 
 | ||||||
| WipeTower::ToolChangeResult WipeTower::finish_layer() | WipeTower::ToolChangeResult WipeTower::finish_layer() | ||||||
| { | { | ||||||
| 	// This should only be called if the layer is not finished yet.
 |  | ||||||
| 	// Otherwise the caller would likely travel to the wipe tower in vain.
 |  | ||||||
| 	assert(! this->layer_finished()); | 	assert(! this->layer_finished()); | ||||||
|  |     m_current_layer_finished = true; | ||||||
| 
 | 
 | ||||||
|     size_t old_tool = m_current_tool; |     size_t old_tool = m_current_tool; | ||||||
| 
 | 
 | ||||||
|  | @ -1140,15 +1067,14 @@ WipeTower::ToolChangeResult WipeTower::finish_layer() | ||||||
| 	writer.set_extrusion_flow(m_extrusion_flow) | 	writer.set_extrusion_flow(m_extrusion_flow) | ||||||
| 		.set_z(m_z_pos) | 		.set_z(m_z_pos) | ||||||
| 		.set_initial_tool(m_current_tool) | 		.set_initial_tool(m_current_tool) | ||||||
| 		.set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f)) |         .set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED ? m_layer_info->toolchanges_depth() : 0.f)); | ||||||
| 		.append(";--------------------\n" | 
 | ||||||
| 				"; CP EMPTY GRID START\n") |  | ||||||
| 		.comment_with_value(" layer #", m_num_layer_changes + 1); |  | ||||||
| 
 | 
 | ||||||
| 	// Slow down on the 1st layer.
 | 	// Slow down on the 1st layer.
 | ||||||
| 	float speed_factor = m_is_first_layer ? 0.5f : 1.f; |     bool first_layer = is_first_layer(); | ||||||
|  |     float feedrate = first_layer ? m_first_layer_speed * 60.f : 2900.f; | ||||||
| 	float current_depth = m_layer_info->depth - m_layer_info->toolchanges_depth(); | 	float current_depth = m_layer_info->depth - m_layer_info->toolchanges_depth(); | ||||||
| 	box_coordinates fill_box(Vec2f(m_perimeter_width, m_depth_traversed + m_perimeter_width), |     box_coordinates fill_box(Vec2f(m_perimeter_width, m_layer_info->depth-(current_depth-m_perimeter_width)), | ||||||
|                              m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width); |                              m_wipe_tower_width - 2 * m_perimeter_width, current_depth-m_perimeter_width); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -1156,45 +1082,60 @@ WipeTower::ToolChangeResult WipeTower::finish_layer() | ||||||
|                                  m_wipe_tower_width, m_wipe_tower_depth, m_internal_rotation); |                                  m_wipe_tower_width, m_wipe_tower_depth, m_internal_rotation); | ||||||
| 
 | 
 | ||||||
|     bool toolchanges_on_layer = m_layer_info->toolchanges_depth() > WT_EPSILON; |     bool toolchanges_on_layer = m_layer_info->toolchanges_depth() > WT_EPSILON; | ||||||
| 	box_coordinates box = fill_box; |     box_coordinates wt_box(Vec2f(0.f, (m_current_shape == SHAPE_REVERSED ? m_layer_info->toolchanges_depth() : 0.f)), | ||||||
|     for (int i=0;i<2;++i) { |                         m_wipe_tower_width, m_layer_info->depth + m_perimeter_width); | ||||||
|         if (! toolchanges_on_layer) { | 
 | ||||||
|             if (i==0) box.expand(m_perimeter_width); |     // inner perimeter of the sparse section, if there is space for it:
 | ||||||
|             else box.expand(-m_perimeter_width); |     if (fill_box.ru.y() - fill_box.rd.y() > m_perimeter_width - WT_EPSILON) | ||||||
|         } |         writer.rectangle(fill_box.ld, fill_box.rd.x()-fill_box.ld.x(), fill_box.ru.y()-fill_box.rd.y(), feedrate); | ||||||
|         else i=2;	// only draw the inner perimeter, outer has been already drawn by tool_change(...)
 |  | ||||||
|         writer.rectangle(box.ld, box.rd.x()-box.ld.x(), box.ru.y()-box.rd.y(), 2900*speed_factor); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // we are in one of the corners, travel to ld along the perimeter:
 |     // we are in one of the corners, travel to ld along the perimeter:
 | ||||||
|     if (writer.x() > fill_box.ld.x()+EPSILON) writer.travel(fill_box.ld.x(),writer.y()); |     if (writer.x() > fill_box.ld.x()+EPSILON) writer.travel(fill_box.ld.x(),writer.y()); | ||||||
|     if (writer.y() > fill_box.ld.y()+EPSILON) writer.travel(writer.x(),fill_box.ld.y()); |     if (writer.y() > fill_box.ld.y()+EPSILON) writer.travel(writer.x(),fill_box.ld.y()); | ||||||
| 
 | 
 | ||||||
|     if (m_is_first_layer && m_adhesion) { |     // Extrude infill to support the material to be printed above.
 | ||||||
|         // Extrude a dense infill at the 1st layer to improve 1st layer adhesion of the wipe tower.
 |  | ||||||
|         box.expand(-m_perimeter_width/2.f); |  | ||||||
|         int nsteps = int(floor((box.lu.y() - box.ld.y()) / (2*m_perimeter_width))); |  | ||||||
|         float step   = (box.lu.y() - box.ld.y()) / nsteps; |  | ||||||
|         writer.travel(box.ld - Vec2f(m_perimeter_width/2.f, m_perimeter_width/2.f)); |  | ||||||
|         if (nsteps >= 0) |  | ||||||
|             for (int i = 0; i < nsteps; ++i)	{ |  | ||||||
|                 writer.extrude(box.ld.x()+m_perimeter_width/2.f, writer.y() + 0.5f * step); |  | ||||||
|                 writer.extrude(box.rd.x() - m_perimeter_width / 2.f, writer.y()); |  | ||||||
|                 writer.extrude(box.rd.x() - m_perimeter_width / 2.f, writer.y() + 0.5f * step); |  | ||||||
|                 writer.extrude(box.ld.x() + m_perimeter_width / 2.f, writer.y()); |  | ||||||
|             } |  | ||||||
|         writer.add_wipe_point(writer.x(), writer.y()) |  | ||||||
|               .add_wipe_point(box.rd.x()-m_perimeter_width/2.f,writer.y()); |  | ||||||
|     } |  | ||||||
|     else {  // Extrude a sparse infill to support the material to be printed above.
 |  | ||||||
|     const float dy = (fill_box.lu.y() - fill_box.ld.y() - m_perimeter_width); |     const float dy = (fill_box.lu.y() - fill_box.ld.y() - m_perimeter_width); | ||||||
|         const float left = fill_box.lu.x() + 2*m_perimeter_width; |     float left = fill_box.lu.x() + 2*m_perimeter_width; | ||||||
|         const float right = fill_box.ru.x() - 2 * m_perimeter_width; |     float right = fill_box.ru.x() - 2 * m_perimeter_width; | ||||||
|     if (dy > m_perimeter_width) |     if (dy > m_perimeter_width) | ||||||
|     { |     { | ||||||
|             // Extrude an inverse U at the left of the region.
 |  | ||||||
|         writer.travel(fill_box.ld + Vec2f(m_perimeter_width * 2, 0.f)) |         writer.travel(fill_box.ld + Vec2f(m_perimeter_width * 2, 0.f)) | ||||||
|                   .extrude(fill_box.lu + Vec2f(m_perimeter_width * 2, 0.f), 2900 * speed_factor); |               .append(";--------------------\n" | ||||||
|  |                       "; CP EMPTY GRID START\n") | ||||||
|  |               .comment_with_value(" layer #", m_num_layer_changes + 1); | ||||||
|  | 
 | ||||||
|  |         // Is there a soluble filament wiped/rammed at the next layer?
 | ||||||
|  |         // If so, the infill should not be sparse.
 | ||||||
|  |         bool solid_infill = m_layer_info+1 == m_plan.end() | ||||||
|  |                           ? false | ||||||
|  |                           : std::any_of((m_layer_info+1)->tool_changes.begin(), | ||||||
|  |                                         (m_layer_info+1)->tool_changes.end(), | ||||||
|  |                                    [this](const WipeTowerInfo::ToolChange& tch) { | ||||||
|  |                                        return m_filpar[tch.new_tool].is_soluble | ||||||
|  |                                            || m_filpar[tch.old_tool].is_soluble; | ||||||
|  |                                    }); | ||||||
|  |         solid_infill |= first_layer && m_adhesion; | ||||||
|  | 
 | ||||||
|  |         if (solid_infill) { | ||||||
|  |             float sparse_factor = 1.5f; // 1=solid, 2=every other line, etc.
 | ||||||
|  |             if (first_layer) { // the infill should touch perimeters
 | ||||||
|  |                 left  -= m_perimeter_width; | ||||||
|  |                 right += m_perimeter_width; | ||||||
|  |                 sparse_factor = 1.f; | ||||||
|  |             } | ||||||
|  |             float y = fill_box.ld.y() + m_perimeter_width; | ||||||
|  |             int n = dy / (m_perimeter_width * sparse_factor); | ||||||
|  |             float spacing = (dy-m_perimeter_width)/(n-1); | ||||||
|  |             int i=0; | ||||||
|  |             for (i=0; i<n; ++i) { | ||||||
|  |                 writer.extrude(writer.x(), y, feedrate) | ||||||
|  |                       .extrude(i%2 ? left : right, y); | ||||||
|  |                 y = y + spacing; | ||||||
|  |             } | ||||||
|  |             writer.extrude(writer.x(), fill_box.lu.y()); | ||||||
|  |         } else { | ||||||
|  |             // Extrude an inverse U at the left of the region and the sparse infill.
 | ||||||
|  |             writer.extrude(fill_box.lu + Vec2f(m_perimeter_width * 2, 0.f), feedrate); | ||||||
| 
 | 
 | ||||||
|             const int n = 1+int((right-left)/m_bridging); |             const int n = 1+int((right-left)/m_bridging); | ||||||
|             const float dx = (right-left)/n; |             const float dx = (right-left)/n; | ||||||
|  | @ -1203,18 +1144,40 @@ WipeTower::ToolChangeResult WipeTower::finish_layer() | ||||||
|                 writer.travel(x,writer.y()); |                 writer.travel(x,writer.y()); | ||||||
|                 writer.extrude(x,i%2 ? fill_box.rd.y() : fill_box.ru.y()); |                 writer.extrude(x,i%2 ? fill_box.rd.y() : fill_box.ru.y()); | ||||||
|             } |             } | ||||||
|             writer.add_wipe_point(Vec2f(writer.x(), writer.y())) |  | ||||||
|                   .add_wipe_point(Vec2f(left, writer.y())); |  | ||||||
|         } |  | ||||||
|         else { |  | ||||||
|             writer.add_wipe_point(Vec2f(writer.x(), writer.y())) |  | ||||||
|                   .add_wipe_point(Vec2f(right, writer.y())); |  | ||||||
|         } |  | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|         writer.append("; CP EMPTY GRID END\n" |         writer.append("; CP EMPTY GRID END\n" | ||||||
|                       ";------------------\n\n\n\n\n\n\n"); |                       ";------------------\n\n\n\n\n\n\n"); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     m_depth_traversed = m_wipe_tower_depth-m_perimeter_width; |     // outer perimeter (always):
 | ||||||
|  |     writer.rectangle(wt_box, feedrate); | ||||||
|  | 
 | ||||||
|  |     // brim (first layer only)
 | ||||||
|  |     if (first_layer) { | ||||||
|  |         box_coordinates box = wt_box; | ||||||
|  |         float spacing = m_perimeter_width - m_layer_height*float(1.-M_PI_4); | ||||||
|  |         // How many perimeters shall the brim have?
 | ||||||
|  |         size_t loops_num = (m_wipe_tower_brim_width + spacing/2.f) / spacing; | ||||||
|  | 
 | ||||||
|  |         for (size_t i = 0; i < loops_num; ++ i) { | ||||||
|  |             box.expand(spacing); | ||||||
|  |             writer.rectangle(box); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         // Save actual brim width to be later passed to the Print object, which will use it
 | ||||||
|  |         // for skirt calculation and pass it to GLCanvas for precise preview box
 | ||||||
|  |         m_wipe_tower_brim_width_real = wt_box.ld.x() - box.ld.x() + spacing/2.f; | ||||||
|  |         wt_box = box; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Now prepare future wipe. box contains rectangle that was extruded last (ccw).
 | ||||||
|  |     Vec2f target = (writer.pos() == wt_box.ld ? wt_box.rd : | ||||||
|  |                    (writer.pos() == wt_box.rd ? wt_box.ru : | ||||||
|  |                    (writer.pos() == wt_box.ru ? wt_box.lu : | ||||||
|  |                     wt_box.ld))); | ||||||
|  |     writer.add_wipe_point(writer.pos()) | ||||||
|  |           .add_wipe_point(target); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     // Ask our writer about how much material was consumed.
 |     // Ask our writer about how much material was consumed.
 | ||||||
|  | @ -1227,17 +1190,16 @@ WipeTower::ToolChangeResult WipeTower::finish_layer() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Appends a toolchange into m_plan and calculates neccessary depth of the corresponding box
 | // Appends a toolchange into m_plan and calculates neccessary depth of the corresponding box
 | ||||||
| void WipeTower::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool, bool brim, float wipe_volume) | void WipeTower::plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, | ||||||
|  |                                 unsigned int new_tool, float wipe_volume) | ||||||
| { | { | ||||||
| 	assert(m_plan.empty() || m_plan.back().z <= z_par + WT_EPSILON);	// refuses to add a layer below the last one
 | 	assert(m_plan.empty() || m_plan.back().z <= z_par + WT_EPSILON);	// refuses to add a layer below the last one
 | ||||||
| 
 | 
 | ||||||
| 	if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan first
 | 	if (m_plan.empty() || m_plan.back().z + WT_EPSILON < z_par) // if we moved to a new layer, we'll add it to m_plan first
 | ||||||
| 		m_plan.push_back(WipeTowerInfo(z_par, layer_height_par)); | 		m_plan.push_back(WipeTowerInfo(z_par, layer_height_par)); | ||||||
| 
 | 
 | ||||||
| 	if (brim) {	// this toolchange prints brim - we must add it to m_plan, but not to count its depth
 |     if (m_first_layer_idx == size_t(-1) && (! m_no_sparse_layers || old_tool != new_tool)) | ||||||
| 		m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool)); |         m_first_layer_idx = m_plan.size() - 1; | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
|     if (old_tool == new_tool)	// new layer without toolchanges - we are done
 |     if (old_tool == new_tool)	// new layer without toolchanges - we are done
 | ||||||
|         return; |         return; | ||||||
|  | @ -1293,28 +1255,65 @@ void WipeTower::save_on_last_wipe() | ||||||
|         if (m_layer_info->tool_changes.size()==0)   // we have no way to save anything on an empty layer
 |         if (m_layer_info->tool_changes.size()==0)   // we have no way to save anything on an empty layer
 | ||||||
|             continue; |             continue; | ||||||
| 
 | 
 | ||||||
|         for (const auto &toolchange : m_layer_info->tool_changes) |         // Which toolchange will finish_layer extrusions be subtracted from?
 | ||||||
|  |         int idx = first_toolchange_to_nonsoluble(m_layer_info->tool_changes); | ||||||
|  | 
 | ||||||
|  |         for (int i=0; i<int(m_layer_info->tool_changes.size()); ++i) { | ||||||
|  |             auto& toolchange = m_layer_info->tool_changes[i]; | ||||||
|             tool_change(toolchange.new_tool); |             tool_change(toolchange.new_tool); | ||||||
| 
 | 
 | ||||||
|  |             if (i == idx) { | ||||||
|                 float width = m_wipe_tower_width - 3*m_perimeter_width; // width we draw into
 |                 float width = m_wipe_tower_width - 3*m_perimeter_width; // width we draw into
 | ||||||
|         float length_to_save = 2*(m_wipe_tower_width+m_wipe_tower_depth) + (!layer_finished() ? finish_layer().total_extrusion_length_in_plane() : 0.f); |                 float length_to_save = finish_layer().total_extrusion_length_in_plane(); | ||||||
|         float length_to_wipe = volume_to_length(m_layer_info->tool_changes.back().wipe_volume, |                 float length_to_wipe = volume_to_length(toolchange.wipe_volume, | ||||||
|                               m_perimeter_width,m_layer_info->height)  - m_layer_info->tool_changes.back().first_wipe_line - length_to_save; |                                       m_perimeter_width, m_layer_info->height)  - toolchange.first_wipe_line - length_to_save; | ||||||
| 
 | 
 | ||||||
|                 length_to_wipe = std::max(length_to_wipe,0.f); |                 length_to_wipe = std::max(length_to_wipe,0.f); | ||||||
|                 float depth_to_wipe = m_perimeter_width * (std::floor(length_to_wipe/width) + ( length_to_wipe > 0.f ? 1.f : 0.f ) ) * m_extra_spacing; |                 float depth_to_wipe = m_perimeter_width * (std::floor(length_to_wipe/width) + ( length_to_wipe > 0.f ? 1.f : 0.f ) ) * m_extra_spacing; | ||||||
| 
 | 
 | ||||||
|         //depth += (int(length_to_extrude / width) + 1) * m_perimeter_width;
 |                 toolchange.required_depth = toolchange.ramming_depth + depth_to_wipe; | ||||||
|         m_layer_info->tool_changes.back().required_depth = m_layer_info->tool_changes.back().ramming_depth + depth_to_wipe; |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // Return index of first toolchange that switches to non-soluble extruder
 | ||||||
|  | // ot -1 if there is no such toolchange.
 | ||||||
|  | int WipeTower::first_toolchange_to_nonsoluble( | ||||||
|  |         const std::vector<WipeTowerInfo::ToolChange>& tool_changes) const | ||||||
|  | { | ||||||
|  |     for (size_t idx=0; idx<tool_changes.size(); ++idx) | ||||||
|  |         if (! m_filpar[tool_changes[idx].new_tool].is_soluble) | ||||||
|  |             return idx; | ||||||
|  |     return -1; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static WipeTower::ToolChangeResult merge_tcr(WipeTower::ToolChangeResult& first, | ||||||
|  |                                              WipeTower::ToolChangeResult& second) | ||||||
|  | { | ||||||
|  |     assert(first.new_tool == second.initial_tool); | ||||||
|  |     WipeTower::ToolChangeResult out = first; | ||||||
|  |     if (first.end_pos != second.start_pos) { | ||||||
|  |         char buf[2048];     // Add a travel move from tc1.end_pos to tc2.start_pos.
 | ||||||
|  |         sprintf(buf, "G1 X%.3f Y%.3f F7200\n", second.start_pos.x(), second.start_pos.y()); | ||||||
|  |         out.gcode += buf; | ||||||
|  |     } | ||||||
|  |     out.gcode += second.gcode; | ||||||
|  |     out.extrusions.insert(out.extrusions.end(), second.extrusions.begin(), second.extrusions.end()); | ||||||
|  |     out.end_pos = second.end_pos; | ||||||
|  |     out.wipe_path = second.wipe_path; | ||||||
|  |     out.initial_tool = first.initial_tool; | ||||||
|  |     out.new_tool = second.new_tool; | ||||||
|  |     return out; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| // Processes vector m_plan and calls respective functions to generate G-code for the wipe tower
 | // Processes vector m_plan and calls respective functions to generate G-code for the wipe tower
 | ||||||
| // Resulting ToolChangeResults are appended into vector "result"
 | // Resulting ToolChangeResults are appended into vector "result"
 | ||||||
| void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &result) | void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &result) | ||||||
| { | { | ||||||
| 	if (m_plan.empty()) | 	if (m_plan.empty()) | ||||||
| 
 |  | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|     m_extra_spacing = 1.f; |     m_extra_spacing = 1.f; | ||||||
|  | @ -1325,9 +1324,6 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> & | ||||||
|         plan_tower(); |         plan_tower(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 	if (m_peters_wipe_tower) |  | ||||||
| 			make_wipe_tower_square(); |  | ||||||
| 
 |  | ||||||
|     m_layer_info = m_plan.begin(); |     m_layer_info = m_plan.begin(); | ||||||
| 
 | 
 | ||||||
|     // we don't know which extruder to start with - we'll set it according to the first toolchange
 |     // we don't know which extruder to start with - we'll set it according to the first toolchange
 | ||||||
|  | @ -1346,65 +1342,41 @@ void WipeTower::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> & | ||||||
|     std::vector<WipeTower::ToolChangeResult> layer_result; |     std::vector<WipeTower::ToolChangeResult> layer_result; | ||||||
| 	for (auto layer : m_plan) | 	for (auto layer : m_plan) | ||||||
| 	{ | 	{ | ||||||
| 		set_layer(layer.z,layer.height,0,layer.z == m_plan.front().z,layer.z == m_plan.back().z); |         set_layer(layer.z, layer.height, 0, false/*layer.z == m_plan.front().z*/, layer.z == m_plan.back().z); | ||||||
| 		if (m_peters_wipe_tower) |  | ||||||
| 			m_internal_rotation += 90.f; |  | ||||||
| 		else |  | ||||||
|         m_internal_rotation += 180.f; |         m_internal_rotation += 180.f; | ||||||
| 
 | 
 | ||||||
| 		if (!m_peters_wipe_tower && m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width) |         if (m_layer_info->depth < m_wipe_tower_depth - m_perimeter_width) | ||||||
| 			m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f; | 			m_y_shift = (m_wipe_tower_depth-m_layer_info->depth-m_perimeter_width)/2.f; | ||||||
| 
 | 
 | ||||||
| 		for (const auto &toolchange : layer.tool_changes) |         int idx = first_toolchange_to_nonsoluble(layer.tool_changes); | ||||||
|             layer_result.emplace_back(tool_change(toolchange.new_tool)); |         ToolChangeResult finish_layer_tcr; | ||||||
| 
 | 
 | ||||||
| 		if (! layer_finished()) { |         if (idx == -1) { | ||||||
|             auto finish_layer_toolchange = finish_layer(); |             // if there is no toolchange switching to non-soluble, finish layer
 | ||||||
|             if ( ! layer.tool_changes.empty() ) { // we will merge it to the last toolchange
 |             // will be called at the very beginning. That's the last possibility
 | ||||||
|                 auto& last_toolchange = layer_result.back(); |             // where a nonsoluble tool can be.
 | ||||||
|                 if (last_toolchange.end_pos != finish_layer_toolchange.start_pos) { |             finish_layer_tcr = finish_layer(); | ||||||
|                     char buf[2048];     // Add a travel move from tc1.end_pos to tc2.start_pos.
 |  | ||||||
| 					sprintf(buf, "G1 X%.3f Y%.3f F7200\n", finish_layer_toolchange.start_pos.x(), finish_layer_toolchange.start_pos.y()); |  | ||||||
| 					last_toolchange.gcode += buf; |  | ||||||
|         } |         } | ||||||
|                 last_toolchange.gcode += finish_layer_toolchange.gcode; | 
 | ||||||
|                 last_toolchange.extrusions.insert(last_toolchange.extrusions.end(), finish_layer_toolchange.extrusions.begin(), finish_layer_toolchange.extrusions.end()); |         for (int i=0; i<int(layer.tool_changes.size()); ++i) { | ||||||
|                 last_toolchange.end_pos = finish_layer_toolchange.end_pos; |             layer_result.emplace_back(tool_change(layer.tool_changes[i].new_tool)); | ||||||
|                 last_toolchange.wipe_path = finish_layer_toolchange.wipe_path; |             if (i == idx) // finish_layer will be called after this toolchange
 | ||||||
|  |                 finish_layer_tcr = finish_layer(); | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|  |         if (layer_result.empty()) { | ||||||
|  |             // there is nothing to merge finish_layer with
 | ||||||
|  |             layer_result.emplace_back(std::move(finish_layer_tcr)); | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             if (idx == -1) | ||||||
|  |                 layer_result[0] = merge_tcr(finish_layer_tcr, layer_result[0]); | ||||||
|             else |             else | ||||||
|                 layer_result.emplace_back(std::move(finish_layer_toolchange)); |                 layer_result[idx] = merge_tcr(layer_result[idx], finish_layer_tcr); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 		result.emplace_back(std::move(layer_result)); | 		result.emplace_back(std::move(layer_result)); | ||||||
| 		m_is_first_layer = false; |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void WipeTower::make_wipe_tower_square() |  | ||||||
| { |  | ||||||
| 	const float width = m_wipe_tower_width - 3 * m_perimeter_width; |  | ||||||
| 	const float depth = m_wipe_tower_depth - m_perimeter_width; |  | ||||||
| 	// area that we actually print into is width*depth
 |  | ||||||
| 	float side = sqrt(depth * width); |  | ||||||
| 
 |  | ||||||
| 	m_wipe_tower_width = side + 3 * m_perimeter_width; |  | ||||||
| 	m_wipe_tower_depth = side + 2 * m_perimeter_width; |  | ||||||
| 	// For all layers, find how depth changed and update all toolchange depths
 |  | ||||||
| 	for (auto &lay : m_plan) |  | ||||||
| 	{ |  | ||||||
| 		side = sqrt(lay.depth * width); |  | ||||||
| 		float width_ratio = width / side; |  | ||||||
| 
 |  | ||||||
| 		//lay.extra_spacing = width_ratio;
 |  | ||||||
| 		for (auto &tch : lay.tool_changes) |  | ||||||
| 			tch.required_depth *= width_ratio; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	plan_tower();				// propagates depth downwards again (width has changed)
 |  | ||||||
| 	for (auto& lay : m_plan)	// depths set, now the spacing
 |  | ||||||
| 		lay.extra_spacing = lay.depth / lay.toolchanges_depth(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| } // namespace Slic3r
 | } // namespace Slic3r
 | ||||||
|  |  | ||||||
|  | @ -84,6 +84,37 @@ public: | ||||||
| 		} | 		} | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  |     struct box_coordinates | ||||||
|  |     { | ||||||
|  |         box_coordinates(float left, float bottom, float width, float height) : | ||||||
|  |             ld(left        , bottom         ), | ||||||
|  |             lu(left        , bottom + height), | ||||||
|  |             rd(left + width, bottom         ), | ||||||
|  |             ru(left + width, bottom + height) {} | ||||||
|  |         box_coordinates(const Vec2f &pos, float width, float height) : box_coordinates(pos(0), pos(1), width, height) {} | ||||||
|  |         void translate(const Vec2f &shift) { | ||||||
|  |             ld += shift; lu += shift; | ||||||
|  |             rd += shift; ru += shift; | ||||||
|  |         } | ||||||
|  |         void translate(const float dx, const float dy) { translate(Vec2f(dx, dy)); } | ||||||
|  |         void expand(const float offset) { | ||||||
|  |             ld += Vec2f(- offset, - offset); | ||||||
|  |             lu += Vec2f(- offset,   offset); | ||||||
|  |             rd += Vec2f(  offset, - offset); | ||||||
|  |             ru += Vec2f(  offset,   offset); | ||||||
|  |         } | ||||||
|  |         void expand(const float offset_x, const float offset_y) { | ||||||
|  |             ld += Vec2f(- offset_x, - offset_y); | ||||||
|  |             lu += Vec2f(- offset_x,   offset_y); | ||||||
|  |             rd += Vec2f(  offset_x, - offset_y); | ||||||
|  |             ru += Vec2f(  offset_x,   offset_y); | ||||||
|  |         } | ||||||
|  |         Vec2f ld;  // left down
 | ||||||
|  |         Vec2f lu;	// left upper
 | ||||||
|  |         Vec2f rd;	// right lower
 | ||||||
|  |         Vec2f ru;  // right upper
 | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|     // Construct ToolChangeResult from current state of WipeTower and WipeTowerWriter.
 |     // Construct ToolChangeResult from current state of WipeTower and WipeTowerWriter.
 | ||||||
|     // WipeTowerWriter is moved from !
 |     // WipeTowerWriter is moved from !
 | ||||||
|     ToolChangeResult construct_tcr(WipeTowerWriter& writer, |     ToolChangeResult construct_tcr(WipeTowerWriter& writer, | ||||||
|  | @ -102,7 +133,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// Appends into internal structure m_plan containing info about the future wipe tower
 | 	// Appends into internal structure m_plan containing info about the future wipe tower
 | ||||||
| 	// to be used before building begins. The entries must be added ordered in z.
 | 	// to be used before building begins. The entries must be added ordered in z.
 | ||||||
| 	void plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool, bool brim, float wipe_volume = 0.f); |     void plan_toolchange(float z_par, float layer_height_par, unsigned int old_tool, unsigned int new_tool, float wipe_volume = 0.f); | ||||||
| 
 | 
 | ||||||
| 	// Iterates through prepared m_plan, generates ToolChangeResults and appends them to "result"
 | 	// Iterates through prepared m_plan, generates ToolChangeResults and appends them to "result"
 | ||||||
| 	void generate(std::vector<std::vector<ToolChangeResult>> &result); | 	void generate(std::vector<std::vector<ToolChangeResult>> &result); | ||||||
|  | @ -129,9 +160,8 @@ public: | ||||||
| 	{ | 	{ | ||||||
| 		m_z_pos 				= print_z; | 		m_z_pos 				= print_z; | ||||||
| 		m_layer_height			= layer_height; | 		m_layer_height			= layer_height; | ||||||
| 		m_is_first_layer 		= is_first_layer; |  | ||||||
| 		m_print_brim = is_first_layer; |  | ||||||
| 		m_depth_traversed  = 0.f; | 		m_depth_traversed  = 0.f; | ||||||
|  |         m_current_layer_finished = false; | ||||||
| 		m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL; | 		m_current_shape = (! is_first_layer && m_current_shape == SHAPE_NORMAL) ? SHAPE_REVERSED : SHAPE_NORMAL; | ||||||
| 		if (is_first_layer) { | 		if (is_first_layer) { | ||||||
|             this->m_num_layer_changes 	= 0; |             this->m_num_layer_changes 	= 0; | ||||||
|  | @ -175,7 +205,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// Is the current layer finished?
 | 	// Is the current layer finished?
 | ||||||
| 	bool 			 layer_finished() const { | 	bool 			 layer_finished() const { | ||||||
| 		return ( (m_is_first_layer ? m_wipe_tower_depth - m_perimeter_width : m_layer_info->depth) - WT_EPSILON < m_depth_traversed); |         return m_current_layer_finished; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|     std::vector<float> get_used_filament() const { return m_used_filament_length; } |     std::vector<float> get_used_filament() const { return m_used_filament_length; } | ||||||
|  | @ -183,6 +213,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     struct FilamentParameters { |     struct FilamentParameters { | ||||||
|         std::string 	    material = "PLA"; |         std::string 	    material = "PLA"; | ||||||
|  |         bool                is_soluble = false; | ||||||
|         int  			    temperature = 0; |         int  			    temperature = 0; | ||||||
|         int  			    first_layer_temperature = 0; |         int  			    first_layer_temperature = 0; | ||||||
|         float               loading_speed = 0.f; |         float               loading_speed = 0.f; | ||||||
|  | @ -208,7 +239,6 @@ private: | ||||||
| 		SHAPE_REVERSED = -1 | 		SHAPE_REVERSED = -1 | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|     const bool  m_peters_wipe_tower   = false; // sparse wipe tower inspired by Peter's post processor - not finished yet
 |  | ||||||
|     const float Width_To_Nozzle_Ratio = 1.25f; // desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust
 |     const float Width_To_Nozzle_Ratio = 1.25f; // desired line width (oval) in multiples of nozzle diameter - may not be actually neccessary to adjust
 | ||||||
|     const float WT_EPSILON            = 1e-3f; |     const float WT_EPSILON            = 1e-3f; | ||||||
|     float filament_area() const { |     float filament_area() const { | ||||||
|  | @ -228,8 +258,10 @@ private: | ||||||
| 	float  m_z_pos 				= 0.f;  // Current Z position.
 | 	float  m_z_pos 				= 0.f;  // Current Z position.
 | ||||||
| 	float  m_layer_height 		= 0.f; 	// Current layer height.
 | 	float  m_layer_height 		= 0.f; 	// Current layer height.
 | ||||||
| 	size_t m_max_color_changes 	= 0; 	// Maximum number of color changes per layer.
 | 	size_t m_max_color_changes 	= 0; 	// Maximum number of color changes per layer.
 | ||||||
| 	bool   m_is_first_layer 	= false;// Is this the 1st layer of the print? If so, print the brim around the waste tower.
 |  | ||||||
|     int    m_old_temperature    = -1;   // To keep track of what was the last temp that we set (so we don't issue the command when not neccessary)
 |     int    m_old_temperature    = -1;   // To keep track of what was the last temp that we set (so we don't issue the command when not neccessary)
 | ||||||
|  |     float  m_travel_speed       = 0.f; | ||||||
|  |     float  m_first_layer_speed  = 0.f; | ||||||
|  |     size_t m_first_layer_idx    = size_t(-1); | ||||||
| 
 | 
 | ||||||
| 	// G-code generator parameters.
 | 	// G-code generator parameters.
 | ||||||
|     float           m_cooling_tube_retraction   = 0.f; |     float           m_cooling_tube_retraction   = 0.f; | ||||||
|  | @ -268,9 +300,12 @@ private: | ||||||
|     const std::vector<std::vector<float>> wipe_volumes; |     const std::vector<std::vector<float>> wipe_volumes; | ||||||
| 
 | 
 | ||||||
| 	float           m_depth_traversed = 0.f; // Current y position at the wipe tower.
 | 	float           m_depth_traversed = 0.f; // Current y position at the wipe tower.
 | ||||||
|  |     bool            m_current_layer_finished = false; | ||||||
| 	bool 			m_left_to_right   = true; | 	bool 			m_left_to_right   = true; | ||||||
| 	float			m_extra_spacing   = 1.f; | 	float			m_extra_spacing   = 1.f; | ||||||
| 
 | 
 | ||||||
|  |     bool is_first_layer() const { return size_t(m_layer_info - m_plan.begin()) == m_first_layer_idx; } | ||||||
|  | 
 | ||||||
| 	// Calculates extrusion flow needed to produce required line width for given layer height
 | 	// Calculates extrusion flow needed to produce required line width for given layer height
 | ||||||
| 	float extrusion_flow(float layer_height = -1.f) const	// negative layer_height - return current m_extrusion_flow
 | 	float extrusion_flow(float layer_height = -1.f) const	// negative layer_height - return current m_extrusion_flow
 | ||||||
| 	{ | 	{ | ||||||
|  | @ -294,38 +329,6 @@ private: | ||||||
|     void save_on_last_wipe(); |     void save_on_last_wipe(); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	struct box_coordinates |  | ||||||
| 	{ |  | ||||||
| 		box_coordinates(float left, float bottom, float width, float height) : |  | ||||||
| 			ld(left        , bottom         ), |  | ||||||
| 			lu(left        , bottom + height), |  | ||||||
| 			rd(left + width, bottom         ), |  | ||||||
| 			ru(left + width, bottom + height) {} |  | ||||||
| 		box_coordinates(const Vec2f &pos, float width, float height) : box_coordinates(pos(0), pos(1), width, height) {} |  | ||||||
| 		void translate(const Vec2f &shift) { |  | ||||||
| 			ld += shift; lu += shift; |  | ||||||
| 			rd += shift; ru += shift; |  | ||||||
| 		} |  | ||||||
| 		void translate(const float dx, const float dy) { translate(Vec2f(dx, dy)); } |  | ||||||
| 		void expand(const float offset) { |  | ||||||
| 			ld += Vec2f(- offset, - offset); |  | ||||||
| 			lu += Vec2f(- offset,   offset); |  | ||||||
| 			rd += Vec2f(  offset, - offset); |  | ||||||
| 			ru += Vec2f(  offset,   offset); |  | ||||||
| 		} |  | ||||||
| 		void expand(const float offset_x, const float offset_y) { |  | ||||||
| 			ld += Vec2f(- offset_x, - offset_y); |  | ||||||
| 			lu += Vec2f(- offset_x,   offset_y); |  | ||||||
| 			rd += Vec2f(  offset_x, - offset_y); |  | ||||||
| 			ru += Vec2f(  offset_x,   offset_y); |  | ||||||
| 		} |  | ||||||
| 		Vec2f ld;  // left down
 |  | ||||||
| 		Vec2f lu;	// left upper 
 |  | ||||||
| 		Vec2f rd;	// right lower
 |  | ||||||
| 		Vec2f ru;  // right upper
 |  | ||||||
| 	}; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     // to store information about tool changes for a given layer
 |     // to store information about tool changes for a given layer
 | ||||||
| 	struct WipeTowerInfo{ | 	struct WipeTowerInfo{ | ||||||
| 		struct ToolChange { | 		struct ToolChange { | ||||||
|  | @ -356,11 +359,10 @@ private: | ||||||
|     // Stores information about used filament length per extruder:
 |     // Stores information about used filament length per extruder:
 | ||||||
|     std::vector<float> m_used_filament_length; |     std::vector<float> m_used_filament_length; | ||||||
| 
 | 
 | ||||||
| 
 |     // Return index of first toolchange that switches to non-soluble extruder
 | ||||||
| 	// Returns gcode for wipe tower brim
 |     // ot -1 if there is no such toolchange.
 | ||||||
| 	// sideOnly			-- set to false -- experimental, draw brim on sides of wipe tower
 |     int first_toolchange_to_nonsoluble( | ||||||
| 	// offset			-- set to 0		-- experimental, offset to replace brim in front / rear of wipe tower
 |             const std::vector<WipeTowerInfo::ToolChange>& tool_changes) const; | ||||||
| 	ToolChangeResult toolchange_Brim(bool sideOnly = false, float y_offset = 0.f); |  | ||||||
| 
 | 
 | ||||||
| 	void toolchange_Unload( | 	void toolchange_Unload( | ||||||
| 		WipeTowerWriter &writer, | 		WipeTowerWriter &writer, | ||||||
|  | @ -386,6 +388,6 @@ private: | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| }; // namespace Slic3r
 | } // namespace Slic3r
 | ||||||
| 
 | 
 | ||||||
| #endif // WipeTowerPrusaMM_hpp_ 
 | #endif // WipeTowerPrusaMM_hpp_ 
 | ||||||
|  |  | ||||||
|  | @ -100,7 +100,6 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n | ||||||
|         "filament_spool_weight", |         "filament_spool_weight", | ||||||
|         "first_layer_acceleration", |         "first_layer_acceleration", | ||||||
|         "first_layer_bed_temperature", |         "first_layer_bed_temperature", | ||||||
|         "first_layer_speed", |  | ||||||
|         "gcode_comments", |         "gcode_comments", | ||||||
|         "gcode_label_objects", |         "gcode_label_objects", | ||||||
|         "infill_acceleration", |         "infill_acceleration", | ||||||
|  | @ -139,7 +138,6 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n | ||||||
|         "start_filament_gcode", |         "start_filament_gcode", | ||||||
|         "toolchange_gcode", |         "toolchange_gcode", | ||||||
|         "threads", |         "threads", | ||||||
|         "travel_speed", |  | ||||||
|         "use_firmware_retraction", |         "use_firmware_retraction", | ||||||
|         "use_relative_e_distances", |         "use_relative_e_distances", | ||||||
|         "use_volumetric_e", |         "use_volumetric_e", | ||||||
|  | @ -210,6 +208,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n | ||||||
|             || opt_key == "cooling_tube_retraction" |             || opt_key == "cooling_tube_retraction" | ||||||
|             || opt_key == "cooling_tube_length" |             || opt_key == "cooling_tube_length" | ||||||
|             || opt_key == "extra_loading_move" |             || opt_key == "extra_loading_move" | ||||||
|  |             || opt_key == "travel_speed" | ||||||
|  |             || opt_key == "first_layer_speed" | ||||||
|             || opt_key == "z_offset") { |             || opt_key == "z_offset") { | ||||||
|             steps.emplace_back(psWipeTower); |             steps.emplace_back(psWipeTower); | ||||||
|             steps.emplace_back(psSkirt); |             steps.emplace_back(psSkirt); | ||||||
|  | @ -1987,9 +1987,7 @@ void Print::_make_wipe_tower() | ||||||
| 
 | 
 | ||||||
|     // Set the extruder & material properties at the wipe tower object.
 |     // Set the extruder & material properties at the wipe tower object.
 | ||||||
|     for (size_t i = 0; i < number_of_extruders; ++ i) |     for (size_t i = 0; i < number_of_extruders; ++ i) | ||||||
| 
 |         wipe_tower.set_extruder(i, m_config); | ||||||
|         wipe_tower.set_extruder( |  | ||||||
|             i, m_config); |  | ||||||
| 
 | 
 | ||||||
|     m_wipe_tower_data.priming = Slic3r::make_unique<std::vector<WipeTower::ToolChangeResult>>( |     m_wipe_tower_data.priming = Slic3r::make_unique<std::vector<WipeTower::ToolChangeResult>>( | ||||||
|         wipe_tower.prime((float)this->skirt_first_layer_height(), m_wipe_tower_data.tool_ordering.all_extruders(), false)); |         wipe_tower.prime((float)this->skirt_first_layer_height(), m_wipe_tower_data.tool_ordering.all_extruders(), false)); | ||||||
|  | @ -2015,8 +2013,8 @@ void Print::_make_wipe_tower() | ||||||
|                     volume_to_wipe += (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id); |                     volume_to_wipe += (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id); | ||||||
| 
 | 
 | ||||||
|                     // request a toolchange at the wipe tower with at least volume_to_wipe purging amount
 |                     // request a toolchange at the wipe tower with at least volume_to_wipe purging amount
 | ||||||
|                     wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height, current_extruder_id, extruder_id, |                     wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height, | ||||||
|                                                first_layer && extruder_id == m_wipe_tower_data.tool_ordering.all_extruders().back(), volume_to_wipe); |                                                current_extruder_id, extruder_id, volume_to_wipe); | ||||||
|                     current_extruder_id = extruder_id; |                     current_extruder_id = extruder_id; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Matena
						Lukas Matena