diff options
author | Lukas Matena <lukasmatena@seznam.cz> | 2018-06-05 13:50:34 +0300 |
---|---|---|
committer | Lukas Matena <lukasmatena@seznam.cz> | 2018-06-05 13:50:34 +0300 |
commit | 4830593cacbe5d81ee499eda9581d616df5f0898 (patch) | |
tree | 34d99718e3f0eacaaf824858e072daceeddd957d /xs | |
parent | 7c9d594ff60090337b8661bcbb6337b94841ec99 (diff) |
Started to work on the 'wipe into dedicated object feature'
Diffstat (limited to 'xs')
-rw-r--r-- | xs/src/libslic3r/GCode.cpp | 40 | ||||
-rw-r--r-- | xs/src/libslic3r/GCode.hpp | 3 | ||||
-rw-r--r-- | xs/src/libslic3r/Print.cpp | 20 |
3 files changed, 55 insertions, 8 deletions
diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 7d4ecf0b4..28a8d2e52 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -1224,7 +1224,7 @@ void GCode::process_layer( if (layerm == nullptr) continue; const PrintRegion ®ion = *print.regions[region_id]; - + // process perimeters for (const ExtrusionEntity *ee : layerm->perimeters.entities) { // perimeter_coll represents perimeter extrusions of a single island. @@ -1246,6 +1246,17 @@ void GCode::process_layer( if (islands[i].by_region.empty()) islands[i].by_region.assign(print.regions.size(), ObjectByExtruder::Island::Region()); islands[i].by_region[region_id].perimeters.append(perimeter_coll->entities); + + // We just added perimeter_coll->entities.size() entities, if they are not to be printed before the main object (during infill wiping), + // we will note their indices (for each copy separately): + unsigned int last_added_entity_index = islands[i].by_region[region_id].perimeters.entities.size()-1; + for (unsigned copy_id = 0; copy_id < layer_to_print.object()->_shifted_copies.size(); ++copy_id) { + if (islands[i].by_region[region_id].perimeters_per_copy_ids.size() < copy_id + 1) // if this copy isn't in the list yet + islands[i].by_region[region_id].perimeters_per_copy_ids.push_back(std::vector<unsigned int>()); + if (!perimeter_coll->is_extruder_overridden(copy_id)) + for (int j=0; j<perimeter_coll->entities.size(); ++j) + islands[i].by_region[region_id].perimeters_per_copy_ids[copy_id].push_back(last_added_entity_index - j); + } break; } } @@ -1362,14 +1373,29 @@ void GCode::process_layer( 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(copy_id) == extruder_id) + if (fill->get_extruder_override(copy_id) == (unsigned int)extruder_id) overridden.back().infills.append(*fill); } + for (ExtrusionEntity *ee : (*layer_to_print.object_layer).regions[region_id]->perimeters.entities) { + auto *fill = dynamic_cast<ExtrusionEntityCollection*>(ee); + if (fill->get_extruder_override(copy_id) == (unsigned int)extruder_id) + overridden.back().perimeters.append((*fill).entities); + } } Point copy = (layer_to_print.object_layer)->object()->_shifted_copies[copy_id]; this->set_origin(unscale(copy.x), unscale(copy.y)); - gcode += this->extrude_infill(print, overridden); + + + std::unique_ptr<EdgeGrid::Grid> u; + if (print.config.infill_first) { + gcode += this->extrude_infill(print, overridden); + gcode += this->extrude_perimeters(print, overridden, u); + } + else { + gcode += this->extrude_perimeters(print, overridden, u); + gcode += this->extrude_infill(print, overridden); + } } } } @@ -1417,9 +1443,9 @@ void GCode::process_layer( for (const ObjectByExtruder::Island &island : object_by_extruder.islands) { if (print.config.infill_first) { gcode += this->extrude_infill(print, island.by_region_per_copy(copy_id)); - gcode += this->extrude_perimeters(print, island.by_region, lower_layer_edge_grids[layer_id]); + gcode += this->extrude_perimeters(print, island.by_region_per_copy(copy_id), lower_layer_edge_grids[layer_id]); } else { - gcode += this->extrude_perimeters(print, island.by_region, lower_layer_edge_grids[layer_id]); + gcode += this->extrude_perimeters(print, island.by_region_per_copy(copy_id), lower_layer_edge_grids[layer_id]); gcode += this->extrude_infill(print, island.by_region_per_copy(copy_id)); } } @@ -2492,11 +2518,13 @@ std::vector<GCode::ObjectByExtruder::Island::Region> GCode::ObjectByExtruder::Is std::vector<ObjectByExtruder::Island::Region> out; for (auto& reg : by_region) { out.push_back(ObjectByExtruder::Island::Region()); - out.back().perimeters.append(reg.perimeters); // we will print all perimeters there are + //out.back().perimeters.append(reg.perimeters); // we will print all perimeters there are if (!reg.infills_per_copy_ids.empty()) { for (unsigned int i=0; i<reg.infills_per_copy_ids[copy].size(); ++i) out.back().infills.append(*(reg.infills.entities[reg.infills_per_copy_ids[copy][i]])); + for (unsigned int i=0; i<reg.perimeters_per_copy_ids[copy].size(); ++i) + out.back().perimeters.append(*(reg.perimeters.entities[reg.perimeters_per_copy_ids[copy][i]])); } } return out; diff --git a/xs/src/libslic3r/GCode.hpp b/xs/src/libslic3r/GCode.hpp index ec5d8f101..1f5e800ea 100644 --- a/xs/src/libslic3r/GCode.hpp +++ b/xs/src/libslic3r/GCode.hpp @@ -215,7 +215,8 @@ protected: struct Region { ExtrusionEntityCollection perimeters; ExtrusionEntityCollection infills; - std::vector<std::vector<unsigned int>> infills_per_copy_ids; // indices of infill.entities that are not part of infill wiping (an element for each object copy) + std::vector<std::vector<unsigned int>> infills_per_copy_ids; // indices of infill.entities that are not part of infill wiping (an element for each object copy) + std::vector<std::vector<unsigned int>> perimeters_per_copy_ids; // indices of infill.entities that are not part of infill wiping (an element for each object copy) }; std::vector<Region> by_region; std::vector<Region> by_region_per_copy(unsigned int copy) const; // returns only extrusions that are NOT printed during wiping into infill for this copy diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index e5a4f5dc7..4b52e2507 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -1209,11 +1209,29 @@ float Print::mark_wiping_infill(const ToolOrdering::LayerTools& layer_tools, uns if (unused_yet) continue; } + + //if (object.wipe_into_perimeters) + { + ExtrusionEntityCollection& eec = this_layer->regions[region_id]->perimeters; + for (ExtrusionEntity* ee : eec.entities) { // iterate through all perimeter Collections + auto* fill = dynamic_cast<ExtrusionEntityCollection*>(ee); + if (volume_to_wipe <= 0.f) + break; + if (!fill->is_extruder_overridden(copy) && fill->total_volume() > min_infill_volume) { + fill->set_extruder_override(copy, new_extruder); + volume_to_wipe -= fill->total_volume(); + } + } + } + + ExtrusionEntityCollection& eec = this_layer->regions[region_id]->fills; for (ExtrusionEntity* ee : eec.entities) { // iterate through all infill Collections auto* fill = dynamic_cast<ExtrusionEntityCollection*>(ee); if (fill->role() == erTopSolidInfill || fill->role() == erGapFill) continue; // these cannot be changed - it is / may be visible - if (volume_to_wipe > 0.f && !fill->is_extruder_overridden(copy) && fill->total_volume() > min_infill_volume) { // this infill will be used to wipe this extruder + if (volume_to_wipe <= 0.f) + break; + if (!fill->is_extruder_overridden(copy) && fill->total_volume() > min_infill_volume) { // this infill will be used to wipe this extruder fill->set_extruder_override(copy, new_extruder); volume_to_wipe -= fill->total_volume(); } |