Skip to content

Commit

Permalink
Better prime tower raft and fixed supports into raft
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Sep 25, 2023
1 parent e48316e commit 9bcfe21
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 12 deletions.
1 change: 1 addition & 0 deletions include/PrimeTower.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class PrimeTower

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_per_extruder_layer_raft; //!< For each extruder the pattern to print on the raft layers

public:
bool enabled; //!< Whether the prime tower is enabled.
Expand Down
4 changes: 2 additions & 2 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,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,
// total_layers + Raft::getFillerLayerCount() - 1,
total_layers,
[&storage, total_layers, this](int layer_nr)
{
return &processLayer(storage, layer_nr, total_layers);
Expand Down
79 changes: 70 additions & 9 deletions src/PrimeTower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ void PrimeTower::generatePaths_denseInfill()
const coord_t layer_height = mesh_group_settings.get<coord_t>("layer_height");
pattern_per_extruder.resize(extruder_count);
pattern_per_extruder_layer0.resize(extruder_count);
pattern_per_extruder_layer_raft.resize(extruder_count);

coord_t cumulative_inset = 0; // Each tower shape is going to be printed inside the other. This is the inset we're doing for each extruder.
for (size_t extruder_nr : extruder_order)
Expand Down Expand Up @@ -150,24 +151,37 @@ void PrimeTower::generatePaths_denseInfill()
{
// Generate the pattern for the first layer.
const coord_t line_width_layer0 = scene.extruders[extruder_nr].settings.get<coord_t>("raft_base_line_width");
ExtrusionMoves& pattern_layer0 = pattern_per_extruder_layer0[extruder_nr];
ExtrusionMoves& pattern_layer_raft = pattern_per_extruder_layer_raft[extruder_nr];

// Generate a concentric infill pattern in the form insets for the prime tower's first layer instead of using
// the infill pattern because the infill pattern tries to connect polygons in different insets which causes the
// first layer of the prime tower to not stick well.
Polygons inset = outer_poly.offset(-cumulative_inset - line_width_layer0 / 2);
while (! inset.empty())
{
pattern_layer0.polygons.add(inset);
pattern_layer_raft.polygons.add(inset);
inset = inset.offset(-line_width_layer0);
}

Polygons outset = outer_poly.offset(cumulative_inset + line_width_layer0 / 2);
for (int i = 0; i < 15; ++i)
{
pattern_layer0.polygons.add(outset);
pattern_layer_raft.polygons.add(outset);
outset = outset.offset(line_width_layer0);
}

// Generate the pattern for the raft layers
ExtrusionMoves& pattern_layer0 = pattern_per_extruder_layer0[extruder_nr];

// Generate a concentric infill pattern in the form insets for the prime tower's first layer instead of using
// the infill pattern because the infill pattern tries to connect polygons in different insets which causes the
// first layer of the prime tower to not stick well.
outset = outer_poly.offset(cumulative_inset + line_width / 2);
for (int i = 0; i < 15; ++i)
{
pattern_layer0.polygons.add(outset);
outset = outset.offset(line_width);
}
}
cumulative_inset += wall_nr * line_width;
}
Expand Down Expand Up @@ -235,24 +249,71 @@ void PrimeTower::addToGcode_denseInfill(LayerPlan& gcode_layer, const size_t ext
const GCodePathConfig& config
= gcode_layer.getLayerNr() < 0 ? gcode_layer.configs_storage.raft_base_config : gcode_layer.configs_storage.prime_tower_config_per_extruder[extruder_nr];


// if (gcode_layer.getLayerNr() == -static_cast<LayerIndex>(Raft::getTotalExtraLayers()))
if (gcode_layer.getLayerNr() < 0 && extruder_nr == 0)
if (gcode_layer.getLayerNr() == -Raft::getTotalExtraLayers() && extruder_nr == 0)
{
// Specific case for first layer => very high adhesion
const GCodePathConfig& config = gcode_layer.configs_storage.raft_base_config;

const ExtrusionMoves& pattern0 = pattern_per_extruder_layer0[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern0.polygons, config);
gcode_layer.addLinesByOptimizer(pattern0.lines, config, SpaceFillType::Lines);
const ExtrusionMoves& pattern_raft = pattern_per_extruder_layer_raft[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern_raft.polygons, config);
gcode_layer.addLinesByOptimizer(pattern_raft.lines, config, SpaceFillType::Lines);
}
else
{
const GCodePathConfig& config = gcode_layer.configs_storage.prime_tower_config_per_extruder[extruder_nr];

// Actual prime pattern
const ExtrusionMoves& pattern = pattern_per_extruder[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern.polygons, config);
gcode_layer.addLinesByOptimizer(pattern.lines, config, SpaceFillType::Lines);

if (gcode_layer.getLayerNr() < 0 && extruder_nr == 0)
{
const ExtrusionMoves& pattern0 = pattern_per_extruder_layer0[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern0.polygons, config);
gcode_layer.addLinesByOptimizer(pattern0.lines, config, SpaceFillType::Lines);
}
}

/*
if (gcode_layer.getLayerNr() > -static_cast<LayerIndex>(Raft::getTotalExtraLayers()))
{
const GCodePathConfig& config = gcode_layer.configs_storage.prime_tower_config_per_extruder[extruder_nr];
// Actual prime pattern
const ExtrusionMoves& pattern = pattern_per_extruder[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern.polygons, config);
gcode_layer.addLinesByOptimizer(pattern.lines, config, SpaceFillType::Lines);
if (gcode_layer.getLayerNr() < 0 && extruder_nr == 0)
{
const ExtrusionMoves& pattern0 = pattern_per_extruder_layer0[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern0.polygons, config);
gcode_layer.addLinesByOptimizer(pattern0.lines, config, SpaceFillType::Lines);
}
}
*/

// if (gcode_layer.getLayerNr() == -static_cast<LayerIndex>(Raft::getTotalExtraLayers()))
/*if (gcode_layer.getLayerNr() < 0 && extruder_nr == 0)
{
if (gcode_layer.getLayerNr() == -Raft::getTotalExtraLayers())
{
const GCodePathConfig& config = gcode_layer.configs_storage.raft_base_config;
const ExtrusionMoves& pattern0 = pattern_per_extruder_layer0[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern0.polygons, config);
gcode_layer.addLinesByOptimizer(pattern0.lines, config, SpaceFillType::Lines);
}
else
{
const GCodePathConfig& config = gcode_layer.configs_storage.prime_tower_config_per_extruder[extruder_nr];
const ExtrusionMoves& pattern_raft = pattern_per_extruder_layer_raft[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern_raft.polygons, config);
gcode_layer.addLinesByOptimizer(pattern_raft.lines, config, SpaceFillType::Lines);
}
}*/
}

void PrimeTower::subtractFromSupport(SliceDataStorage& storage)
Expand Down
2 changes: 1 addition & 1 deletion src/gcodeExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ void GCodeExport::writeTemperatureCommand(const size_t extruder, const Temperatu
*output_stream << " T" << extruder;
}
#ifdef ASSERT_INSANE_OUTPUT
// assert(temperature >= 0);
assert(temperature >= 0);
#endif // ASSERT_INSANE_OUTPUT
*output_stream << " S" << PrecisionedDouble{ 1, temperature } << new_line;
if (extruder != current_extruder && always_write_active_tool)
Expand Down

0 comments on commit 9bcfe21

Please sign in to comment.