mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Last wipe on layer accounts of border and sparse infill (ugly, yet working)
This commit is contained in:
		
							parent
							
								
									6c223c2f84
								
							
						
					
					
						commit
						af281e13db
					
				
					 2 changed files with 76 additions and 37 deletions
				
			
		|  | @ -613,7 +613,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo | |||
| 	box_coordinates cleaning_box( | ||||
| 		m_wipe_tower_pos + xy(m_perimeter_width / 2.f, m_perimeter_width / 2.f), | ||||
| 		m_wipe_tower_width - m_perimeter_width, | ||||
| 		(tool != (unsigned int)(-1) ? m_layer_info->depth : m_wipe_tower_depth-m_perimeter_width)); | ||||
| 		(tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5*m_perimeter_width | ||||
|                                     : m_wipe_tower_depth-m_perimeter_width)); | ||||
| 
 | ||||
| 	PrusaMultiMaterial::Writer writer; | ||||
| 	writer.set_extrusion_flow(m_extrusion_flow) | ||||
|  | @ -1049,11 +1050,10 @@ void WipeTowerPrusaMM::toolchange_Wipe( | |||
| 			writer.extrude(xr - (i % 4 == 0 ? 0 : 1.5*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); | ||||
| 		else | ||||
| 			writer.extrude(xl + (i % 4 == 1 ? 0 : 1.5*m_perimeter_width), writer.y(), wipe_speed * wipe_coeff); | ||||
| 		 | ||||
| 		/*if ((m_current_shape == SHAPE_NORMAL) ?		// in case next line would not fit
 | ||||
| 			(writer.y() > cleaning_box.lu.y - m_perimeter_width * 1.5f) : | ||||
| 			(writer.y() < cleaning_box.ld.y + m_perimeter_width * 1.5f)) | ||||
| 			break;*/ | ||||
| 
 | ||||
|         if (writer.y()+EPSILON > cleaning_box.lu.y-0.5f*m_perimeter_width) | ||||
|             break;		// in case next line would not fit
 | ||||
| 
 | ||||
| 		traversed_x -= writer.x(); | ||||
| 		x_to_wipe -= fabs(traversed_x); | ||||
| 		if (x_to_wipe < WT_EPSILON) { | ||||
|  | @ -1218,13 +1218,16 @@ void WipeTowerPrusaMM::plan_toolchange(float z_par, float layer_height_par, unsi | |||
| 										m_line_width * m_par.ramming_line_width_multiplicator[old_tool], | ||||
| 										layer_height_par); | ||||
| 	depth = (int(length_to_extrude / width) + 1) * (m_line_width * m_par.ramming_line_width_multiplicator[old_tool] * m_par.ramming_step_multiplicator[old_tool]); | ||||
| 	length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width; | ||||
| 	length_to_extrude += volume_to_length(m_par.wipe_volumes[old_tool][new_tool], m_line_width, layer_height_par); | ||||
| 	length_to_extrude = std::max(length_to_extrude,0.f); | ||||
| 	depth += (int(length_to_extrude / width) + 1) * m_line_width; | ||||
| 	depth *= m_extra_spacing;	 | ||||
|     float ramming_depth = depth; | ||||
|     length_to_extrude = width*((length_to_extrude / width)-int(length_to_extrude / width)) - width; | ||||
|     float first_wipe_line = -length_to_extrude; | ||||
|     length_to_extrude += volume_to_length(m_par.wipe_volumes[old_tool][new_tool], m_line_width, layer_height_par); | ||||
|     length_to_extrude = std::max(length_to_extrude,0.f); | ||||
| 
 | ||||
| 	m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth)); | ||||
| 	depth += (int(length_to_extrude / width) + 1) * m_line_width; | ||||
| 	depth *= m_extra_spacing; | ||||
| 
 | ||||
| 	m_plan.back().tool_changes.push_back(WipeTowerInfo::ToolChange(old_tool, new_tool, depth, ramming_depth,first_wipe_line)); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -1252,31 +1255,27 @@ void WipeTowerPrusaMM::plan_tower() | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void WipeTowerPrusaMM::make_wipe_tower_square() | ||||
| void WipeTowerPrusaMM::save_on_last_wipe() | ||||
| { | ||||
| 	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); | ||||
|     for (m_layer_info=m_plan.begin();m_layer_info<m_plan.end();++m_layer_info) { | ||||
|         set_layer(m_layer_info->z, m_layer_info->height, 0, m_layer_info->z == m_plan.front().z, m_layer_info->z == m_plan.back().z); | ||||
|         if (m_layer_info->tool_changes.size()==0)   // we have no way to save anything on an empty layer
 | ||||
|             continue; | ||||
| 
 | ||||
| 	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; | ||||
|         for (const auto &toolchange : m_layer_info->tool_changes) | ||||
|             tool_change(toolchange.new_tool, false, PURPOSE_EXTRUDE); | ||||
| 
 | ||||
| 		//lay.extra_spacing = width_ratio;
 | ||||
| 		for (auto &tch : lay.tool_changes) | ||||
| 			tch.required_depth *= width_ratio; | ||||
| 	} | ||||
|         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(PURPOSE_EXTRUDE).total_extrusion_length_in_plane() : 0.f); | ||||
|         float length_to_wipe = volume_to_length(m_par.wipe_volumes[m_layer_info->tool_changes.back().old_tool][m_layer_info->tool_changes.back().new_tool], | ||||
|                               m_line_width,m_layer_info->height)  - m_layer_info->tool_changes.back().first_wipe_line - length_to_save; | ||||
| 
 | ||||
| 	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(); | ||||
|         length_to_wipe = std::max(length_to_wipe,0.f); | ||||
|         float depth_to_wipe = m_line_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_line_width;
 | ||||
|         m_layer_info->tool_changes.back().required_depth = m_layer_info->tool_changes.back().ramming_depth + depth_to_wipe; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -1285,14 +1284,20 @@ void WipeTowerPrusaMM::make_wipe_tower_square() | |||
| void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeResult>> &result) | ||||
| { | ||||
| 	if (m_plan.empty())	return; | ||||
| 	else m_layer_info = m_plan.begin(); | ||||
| 
 | ||||
| 	m_extra_spacing = 1.f; | ||||
|     m_extra_spacing = 1.f; | ||||
| 
 | ||||
| 	plan_tower(); | ||||
|     for (int i=0;i<5;++i) { | ||||
|         save_on_last_wipe(); | ||||
|         plan_tower(); | ||||
|     } | ||||
| 
 | ||||
| 	if (peters_wipe_tower) | ||||
| 			make_wipe_tower_square(); | ||||
| 
 | ||||
|     m_layer_info = m_plan.begin(); | ||||
| 
 | ||||
| 	std::vector<WipeTower::ToolChangeResult> layer_result; | ||||
| 	for (auto layer : m_plan) | ||||
| 	{ | ||||
|  | @ -1306,8 +1311,6 @@ void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeRes | |||
| 		if (!peters_wipe_tower && 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; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 		for (const auto &toolchange : layer.tool_changes) | ||||
| 			layer_result.emplace_back(tool_change(toolchange.new_tool, false, WipeTower::PURPOSE_EXTRUDE)); | ||||
| 
 | ||||
|  | @ -1336,4 +1339,34 @@ void WipeTowerPrusaMM::generate(std::vector<std::vector<WipeTower::ToolChangeRes | |||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| void WipeTowerPrusaMM::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
 | ||||
|  |  | |||
|  | @ -250,6 +250,9 @@ public: | |||
| 	// Goes through m_plan and recalculates depths and width of the WT to make it exactly square - experimental
 | ||||
| 	void make_wipe_tower_square(); | ||||
| 
 | ||||
|     // Goes through m_plan, calculates border and finish_layer extrusions and subtracts them from last wipe
 | ||||
|     void save_on_last_wipe(); | ||||
| 
 | ||||
| 	// Switch to a next layer.
 | ||||
| 	virtual void set_layer( | ||||
| 		// Print height of this layer.
 | ||||
|  | @ -427,7 +430,10 @@ private: | |||
| 			unsigned int old_tool; | ||||
| 			unsigned int new_tool; | ||||
| 			float required_depth; | ||||
| 			ToolChange(unsigned int old,unsigned int newtool,float depth=0.f) : old_tool{old}, new_tool{newtool}, required_depth{depth} {} | ||||
|             float ramming_depth; | ||||
|             float first_wipe_line; | ||||
| 			ToolChange(unsigned int old,unsigned int newtool,float depth=0.f,float ramming_depth=0.f,float fwl=0.f) | ||||
|             : old_tool{old}, new_tool{newtool}, required_depth{depth}, ramming_depth{ramming_depth},first_wipe_line{fwl} {} | ||||
| 		}; | ||||
| 		float z;		// z position of the layer
 | ||||
| 		float height;	// layer height
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Matena
						Lukas Matena