mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Calculation of wipe tower reduction corrected, new config option (wipe into infill)
This commit is contained in:
		
							parent
							
								
									132a67edb2
								
							
						
					
					
						commit
						bfe4350a89
					
				
					 6 changed files with 56 additions and 36 deletions
				
			
		|  | @ -1338,26 +1338,31 @@ void GCode::process_layer( | |||
|             m_avoid_crossing_perimeters.disable_once = true; | ||||
|         } | ||||
| 
 | ||||
|         for (const auto& layer_to_print : layers) {   // iterate through all objects
 | ||||
|             if (layer_to_print.object_layer == nullptr) | ||||
|                 continue; | ||||
|             std::vector<ObjectByExtruder::Island::Region> overridden; | ||||
|             for (size_t region_id = 0; region_id < print.regions.size(); ++ region_id) { | ||||
|                 ObjectByExtruder::Island::Region new_region; | ||||
|                 overridden.push_back(new_region); | ||||
|                 for (ExtrusionEntity *ee : (*layer_to_print.object_layer).regions[region_id]->fills.entities) { | ||||
|                     auto *fill = dynamic_cast<ExtrusionEntityCollection*>(ee); | ||||
|                     if (fill->get_extruder_override() == extruder_id) { | ||||
|                         overridden.back().infills.append(*fill); | ||||
|                         fill->set_extruder_override(-1); | ||||
|                     } | ||||
|                } | ||||
|                 m_config.apply((layer_to_print.object_layer)->object()->config, true); | ||||
|                 Point copy = (layer_to_print.object_layer)->object()->_shifted_copies.front(); | ||||
|                 this->set_origin(unscale(copy.x), unscale(copy.y)); | ||||
|                 gcode += this->extrude_infill(print, overridden); | ||||
|         gcode += "; INFILL WIPING STARTS\n"; | ||||
| 
 | ||||
|         if (extruder_id != layer_tools.extruders.front()) { // if this is the first extruder on this layer, there was no toolchange
 | ||||
|             for (const auto& layer_to_print : layers) {     // iterate through all objects
 | ||||
|                 if (layer_to_print.object_layer == nullptr) | ||||
|                     continue; | ||||
|                 std::vector<ObjectByExtruder::Island::Region> overridden; | ||||
|                 for (size_t region_id = 0; region_id < print.regions.size(); ++ region_id) { | ||||
|                     ObjectByExtruder::Island::Region new_region; | ||||
|                     overridden.push_back(new_region); | ||||
|                     for (ExtrusionEntity *ee : (*layer_to_print.object_layer).regions[region_id]->fills.entities) { | ||||
|                         auto *fill = dynamic_cast<ExtrusionEntityCollection*>(ee); | ||||
|                         if (fill->get_extruder_override() == extruder_id) { | ||||
|                             overridden.back().infills.append(*fill); | ||||
|                             fill->set_extruder_override(-1); | ||||
|                         } | ||||
|                    } | ||||
|                     m_config.apply((layer_to_print.object_layer)->object()->config, true); | ||||
|                     Point copy = (layer_to_print.object_layer)->object()->_shifted_copies.front(); | ||||
|                     this->set_origin(unscale(copy.x), unscale(copy.y)); | ||||
|                     gcode += this->extrude_infill(print, overridden); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         gcode += "; WIPING FINISHED\n"; | ||||
| 
 | ||||
| 
 | ||||
|         auto objects_by_extruder_it = by_extruder.find(extruder_id); | ||||
|  |  | |||
|  | @ -1142,28 +1142,31 @@ void Print::_make_wipe_tower() | |||
|                     // we run out of the volume (or infills)
 | ||||
|                     const float min_infill_volume = 0.f; | ||||
| 
 | ||||
|                     if (config.filament_soluble.get_at(extruder_id)) // soluble filament cannot be wiped in a random infill
 | ||||
|                         continue; | ||||
| 
 | ||||
|                     float volume_to_wipe = wipe_volumes[current_extruder_id][extruder_id]; | ||||
|                     float saved_material = 0.f; | ||||
| 
 | ||||
|                     for (size_t i = 0; i < objects.size(); ++ i) {                    // Let's iterate through all objects...
 | ||||
|                         for (Layer* lay : objects[i]->layers) { | ||||
|                             for (LayerRegion* reg : lay->regions) {                         // and all regions
 | ||||
|                                 ExtrusionEntityCollection& eec = reg->fills; | ||||
|                                 for (ExtrusionEntity* ee : eec.entities) {                  // and all infill Collections
 | ||||
|                                         auto* fill = dynamic_cast<ExtrusionEntityCollection*>(ee); | ||||
|                                         if (volume_to_wipe > 0.f && !fill->is_extruder_overridden() && fill->total_volume() > min_infill_volume) {     // this infill will be used to wipe this extruder
 | ||||
|                                             fill->set_extruder_override(extruder_id); | ||||
|                                             volume_to_wipe -= fill->total_volume(); | ||||
|                                         } | ||||
|                     // soluble filament cannot be wiped in a random infill, first layer is potentionally visible too
 | ||||
|                     if (!first_layer && !config.filament_soluble.get_at(extruder_id)) { | ||||
|                         for (size_t i = 0; i < objects.size(); ++ i) {                    // Let's iterate through all objects...
 | ||||
|                             for (Layer* lay : objects[i]->layers) { | ||||
|                                 if (std::abs(layer_tools.print_z - lay->print_z) > EPSILON) continue; | ||||
|                                 for (LayerRegion* reg : lay->regions) {                         // and all regions
 | ||||
|                                     ExtrusionEntityCollection& eec = reg->fills; | ||||
|                                     for (ExtrusionEntity* ee : eec.entities) {                  // and all infill Collections
 | ||||
|                                             auto* fill = dynamic_cast<ExtrusionEntityCollection*>(ee); | ||||
|                                             if (fill->role() == erTopSolidInfill) continue; | ||||
|                                             if (volume_to_wipe > 0.f && !fill->is_extruder_overridden() && fill->total_volume() > min_infill_volume) {     // this infill will be used to wipe this extruder
 | ||||
|                                                 fill->set_extruder_override(extruder_id); | ||||
|                                                 volume_to_wipe -= fill->total_volume(); | ||||
|                                             } | ||||
|                                     } | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                     float saved_material = wipe_volumes[current_extruder_id][extruder_id] - std::max(0.f, volume_to_wipe); | ||||
|                     std::cout << volume_to_wipe << "\t(saved " << saved_material << ")" << std::endl; | ||||
|                     saved_material = wipe_volumes[current_extruder_id][extruder_id] - std::max(0.f, volume_to_wipe); | ||||
|                     std::cout << layer_tools.print_z << "\t" << extruder_id << "\t" << wipe_volumes[current_extruder_id][extruder_id] - volume_to_wipe << "\n"; | ||||
| 
 | ||||
|                     wipe_tower.plan_toolchange(layer_tools.print_z, layer_tools.wipe_tower_layer_height, current_extruder_id, extruder_id, first_layer && extruder_id == m_tool_ordering.all_extruders().back(), saved_material); | ||||
|                     current_extruder_id = extruder_id; | ||||
|  |  | |||
|  | @ -1884,7 +1884,15 @@ PrintConfigDef::PrintConfigDef() | |||
|     def->sidetext = L("degrees"); | ||||
|     def->cli = "wipe-tower-rotation-angle=f"; | ||||
|     def->default_value = new ConfigOptionFloat(0.); | ||||
|      | ||||
| 
 | ||||
|     def = this->add("wipe_into_infill", coBool); | ||||
|     def->label = L("Wiping into infill"); | ||||
|     def->tooltip = L("Wiping after toolchange will be preferentially done inside infills. " | ||||
|                      "This lowers the amount of waste but may result in longer print time " | ||||
|                      " due to additional travel moves."); | ||||
|     def->cli = "wipe-into-infill!"; | ||||
|     def->default_value = new ConfigOptionBool(true); | ||||
| 
 | ||||
|     def = this->add("wipe_tower_bridging", coFloat); | ||||
|     def->label = L("Maximal bridging distance"); | ||||
|     def->tooltip = L("Maximal distance between supports on sparse infill sections. "); | ||||
|  |  | |||
|  | @ -642,6 +642,7 @@ public: | |||
|     ConfigOptionFloat               wipe_tower_per_color_wipe; | ||||
|     ConfigOptionFloat               wipe_tower_rotation_angle; | ||||
|     ConfigOptionFloat               wipe_tower_bridging; | ||||
|     ConfigOptionBool                wipe_into_infill; | ||||
|     ConfigOptionFloats              wiping_volumes_matrix; | ||||
|     ConfigOptionFloats              wiping_volumes_extruders; | ||||
|     ConfigOptionFloat               z_offset; | ||||
|  | @ -710,6 +711,7 @@ protected: | |||
|         OPT_PTR(wipe_tower_width); | ||||
|         OPT_PTR(wipe_tower_per_color_wipe); | ||||
|         OPT_PTR(wipe_tower_rotation_angle); | ||||
|         OPT_PTR(wipe_into_infill); | ||||
|         OPT_PTR(wipe_tower_bridging); | ||||
|         OPT_PTR(wiping_volumes_matrix); | ||||
|         OPT_PTR(wiping_volumes_extruders); | ||||
|  |  | |||
|  | @ -298,7 +298,8 @@ const std::vector<std::string>& Preset::print_options() | |||
|         "perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width",  | ||||
|         "top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "bridge_flow_ratio", "clip_multipart_objects",  | ||||
|         "elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y", | ||||
|         "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging", "compatible_printers", "compatible_printers_condition","inherits" | ||||
|         "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging", "wipe_into_infill", "compatible_printers", | ||||
|         "compatible_printers_condition","inherits" | ||||
|     }; | ||||
|     return s_opts; | ||||
| } | ||||
|  |  | |||
|  | @ -945,6 +945,7 @@ void TabPrint::build() | |||
| 		optgroup->append_single_option_line("wipe_tower_width"); | ||||
| 		optgroup->append_single_option_line("wipe_tower_rotation_angle"); | ||||
|         optgroup->append_single_option_line("wipe_tower_bridging"); | ||||
|         optgroup->append_single_option_line("wipe_into_infill"); | ||||
| 
 | ||||
| 		optgroup = page->new_optgroup(_(L("Advanced"))); | ||||
| 		optgroup->append_single_option_line("interface_shells"); | ||||
|  | @ -1233,7 +1234,7 @@ void TabPrint::update() | |||
| 	get_field("standby_temperature_delta")->toggle(have_ooze_prevention); | ||||
| 
 | ||||
| 	bool have_wipe_tower = m_config->opt_bool("wipe_tower"); | ||||
| 	for (auto el : { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_bridging"}) | ||||
| 	for (auto el : { "wipe_tower_x", "wipe_tower_y", "wipe_tower_width", "wipe_tower_rotation_angle", "wipe_into_infill", "wipe_tower_bridging"}) | ||||
| 		get_field(el)->toggle(have_wipe_tower); | ||||
| 
 | ||||
| 	m_recommended_thin_wall_thickness_description_line->SetText( | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Matena
						Lukas Matena