Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURA-12023 Fix ghost prime tower #2115

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/PrimeTower/PrimeTowerNormal.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ namespace cura
*/
class PrimeTowerNormal : public PrimeTower
{
private:
const std::vector<size_t> used_extruders_;

public:
PrimeTowerNormal();
PrimeTowerNormal(const std::vector<size_t>& used_extruders);

virtual ExtruderPrime getExtruderPrime(
const std::vector<bool>& extruder_is_used_on_this_layer,
Expand Down
22 changes: 15 additions & 7 deletions src/PrimeTower/PrimeTower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,28 @@ void PrimeTower::processExtrudersUse(LayerVector<std::vector<ExtruderUse>>& extr
PrimeTower* PrimeTower::createPrimeTower(SliceDataStorage& storage)
{
PrimeTower* prime_tower = nullptr;
const Scene& scene = Application::getInstance().current_slice_->scene;
const Settings& settings = Application::getInstance().current_slice_->scene.current_mesh_group->settings;
const size_t raft_total_extra_layers = Raft::getTotalExtraLayers();
const std::vector<bool> extruders_used = storage.getExtrudersUsed();

std::vector<size_t> used_extruders_nrs;
for (size_t extruder_nr = 0; extruder_nr < extruders_used.size(); extruder_nr++)
{
if (extruders_used[extruder_nr])
{
used_extruders_nrs.push_back(extruder_nr);
}
}

if (scene.extruders.size() > 1 && scene.current_mesh_group->settings.get<bool>("prime_tower_enable")
&& scene.current_mesh_group->settings.get<coord_t>("prime_tower_min_volume") > 10 && scene.current_mesh_group->settings.get<coord_t>("prime_tower_size") > 10
&& storage.max_print_height_second_to_last_extruder >= -static_cast<int>(raft_total_extra_layers))
if (used_extruders_nrs.size() > 1 && settings.get<bool>("prime_tower_enable") && settings.get<coord_t>("prime_tower_min_volume") > 10
&& settings.get<coord_t>("prime_tower_size") > 10 && storage.max_print_height_second_to_last_extruder >= -static_cast<int>(raft_total_extra_layers))
{
const Settings& mesh_group_settings = scene.current_mesh_group->settings;
const PrimeTowerMode method = mesh_group_settings.get<PrimeTowerMode>("prime_tower_mode");
const PrimeTowerMode method = settings.get<PrimeTowerMode>("prime_tower_mode");

switch (method)
{
case PrimeTowerMode::NORMAL:
prime_tower = new PrimeTowerNormal();
prime_tower = new PrimeTowerNormal(used_extruders_nrs);
break;
case PrimeTowerMode::INTERLEAVED:
prime_tower = new PrimeTowerInterleaved();
Expand Down
12 changes: 4 additions & 8 deletions src/PrimeTower/PrimeTowerNormal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
namespace cura
{

PrimeTowerNormal::PrimeTowerNormal()
PrimeTowerNormal::PrimeTowerNormal(const std::vector<size_t>& used_extruders)
: PrimeTower()
, used_extruders_(used_extruders)
{
}

Expand Down Expand Up @@ -45,13 +46,8 @@ std::map<LayerIndex, std::vector<PrimeTower::ExtruderToolPaths>> PrimeTowerNorma
const coord_t tower_radius = mesh_group_settings.get<coord_t>("prime_tower_size") / 2;
std::map<LayerIndex, std::vector<ExtruderToolPaths>> toolpaths;

// First make a basic list of used extruders numbers
std::vector<size_t> extruder_order;
extruder_order.reserve(scene.extruders.size());
for (const ExtruderTrain& extruder : scene.extruders)
{
extruder_order.push_back(extruder.extruder_nr_);
}
// First take all the used extruders numbers, unsorted
std::vector<size_t> extruder_order = used_extruders_;

// Then sort from high adhesion to low adhesion. This will give us the outside to inside extruder processing order.
std::sort(
Expand Down
Loading