Skip to content

Commit

Permalink
Merge branch 'CURA-10993_simple_prime_tower_raft' into CURA-10561-mak…
Browse files Browse the repository at this point in the history
…erbot-plugin
  • Loading branch information
casperlamboo committed Oct 10, 2023
2 parents 5659e99 + 6de64a2 commit 4f9c15c
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 107 deletions.
23 changes: 11 additions & 12 deletions include/PrimeTower.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//Copyright (c) 2022 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
// Copyright (c) 2022 Ultimaker B.V.
// CuraEngine is released under the terms of the AGPLv3 or higher.

#ifndef PRIME_TOWER_H
#define PRIME_TOWER_H

#include <vector>

#include "utils/polygon.h" // Polygons
#include "utils/polygonUtils.h"

namespace cura
#include <vector>

namespace cura
{

class SliceDataStorage;
Expand Down Expand Up @@ -40,7 +40,7 @@ class PrimeTower
const unsigned int number_of_prime_tower_start_locations = 21; //!< The required size of \ref PrimeTower::wipe_locations

std::vector<ExtrusionMoves> pattern_per_extruder; //!< For each extruder the pattern to print on all layers of the prime tower.
std::vector<ExtrusionMoves> pattern_per_extruder_layer0; //!< For each extruder the pattern to print on the first layer
std::vector<ExtrusionMoves> pattern_extra_brim_per_layer; //!< For each layer with an extra brim, the pattern to be added

public:
bool enabled; //!< Whether the prime tower is enabled.
Expand Down Expand Up @@ -72,7 +72,7 @@ class PrimeTower

/*!
* Generate the prime tower area to be used on each layer
*
*
* Fills \ref PrimeTower::inner_poly and sets \ref PrimeTower::middle
*/
void generateGroundpoly();
Expand All @@ -84,7 +84,7 @@ class PrimeTower

/*!
* Add path plans for the prime tower to the \p gcode_layer
*
*
* \param storage where to get settings from; where to get the maximum height of the prime tower from
* \param[in,out] gcode_layer Where to get the current extruder from; where to store the generated layer paths
* \param prev_extruder The previous extruder with which paths were planned; from which extruder a switch was made
Expand All @@ -101,10 +101,11 @@ class PrimeTower
void subtractFromSupport(SliceDataStorage& storage);

private:
ExtrusionMoves generatePaths_extraBrim(const Polygons& outer_poly, coord_t extra_radius, coord_t line_width, bool add_inset);

/*!
* \see WipeTower::generatePaths
*
*
* Generate the extrude paths for each extruder on even and odd layers
* Fill the ground poly with dense infill.
*/
Expand Down Expand Up @@ -138,8 +139,6 @@ class PrimeTower
};




}//namespace cura
} // namespace cura

#endif // PRIME_TOWER_H
14 changes: 11 additions & 3 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ void FffGcodeWriter::writeGCode(SliceDataStorage& storage, TimeKeeper& time_keep

run_multiple_producers_ordered_consumer(
process_layer_starting_layer_nr,
//-Raft::getTotalExtraLayers(),
// total_layers + Raft::getFillerLayerCount() - 1,
total_layers,
[&storage, total_layers, this](int layer_nr)
{
Expand Down Expand Up @@ -685,6 +687,8 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
raftLines.clear();
}

setExtruder_addPrime(storage, gcode_layer, storage.primeTower.extruder_order.front());

layer_plan_buffer.handle(gcode_layer, gcode);
last_planned_position = gcode_layer.getLastPlannedPositionOrStartingPosition();
}
Expand Down Expand Up @@ -788,6 +792,8 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
raft_lines.clear();
}

setExtruder_addPrime(storage, gcode_layer, storage.primeTower.extruder_order.front());

layer_plan_buffer.handle(gcode_layer, gcode);
last_planned_position = gcode_layer.getLastPlannedPositionOrStartingPosition();
}
Expand Down Expand Up @@ -893,6 +899,8 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
raft_lines.clear();
}

setExtruder_addPrime(storage, gcode_layer, storage.primeTower.extruder_order.front());

layer_plan_buffer.handle(gcode_layer, gcode);
}
}
Expand Down Expand Up @@ -1014,7 +1022,7 @@ LayerPlan& FffGcodeWriter::processLayer(const SliceDataStorage& storage, LayerIn
// later in the print a prime tower is needed.
// - prime tower is already printed this layer (only applicable for more than 2 extruders).
// The setExtruder_addPrime takes care of this.
if (extruder_nr != extruder_order.front() || extruder_order.size() == 1)
if (extruder_nr != extruder_order.front() || (extruder_order.size() == 1 && layer_nr >= 0) || extruder_nr == 0)
{
setExtruder_addPrime(storage, gcode_layer, extruder_nr);
}
Expand Down Expand Up @@ -1045,7 +1053,7 @@ LayerPlan& FffGcodeWriter::processLayer(const SliceDataStorage& storage, LayerIn
// Always print a prime tower before switching extruder. Unless:
// - The prime tower is already printed this layer (setExtruder_addPrime takes care of this).
// - this is the last extruder of the layer, since the next layer will start with the same extruder.
if (extruder_nr != extruder_order.back())
if (extruder_nr != extruder_order.back() && layer_nr >= 0)
{
setExtruder_addPrime(storage, gcode_layer, extruder_nr);
}
Expand Down Expand Up @@ -1347,7 +1355,7 @@ std::vector<size_t> FffGcodeWriter::getUsedExtrudersOnLayerExcludingStartingExtr
std::vector<bool> extruder_is_used_on_this_layer = storage.getExtrudersUsed(layer_nr);

// The outermost prime tower extruder is always used if there is a prime tower, apart on layers with negative index (e.g. for the raft)
if (mesh_group_settings.get<bool>("prime_tower_enable") && layer_nr >= 0 && layer_nr <= storage.max_print_height_second_to_last_extruder)
if (mesh_group_settings.get<bool>("prime_tower_enable") && /*layer_nr >= 0 &&*/ layer_nr <= storage.max_print_height_second_to_last_extruder)
{
extruder_is_used_on_this_layer[storage.primeTower.extruder_order[0]] = true;
}
Expand Down
Loading

0 comments on commit 4f9c15c

Please sign in to comment.