Skip to content

Commit

Permalink
Better prime tower raft
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Sep 25, 2023
1 parent 48e8371 commit e48316e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,28 +143,28 @@ void FffGcodeWriter::writeGCode(SliceDataStorage& storage, TimeKeeper& time_keep
findLayerSeamsForSpiralize(storage, total_layers);
}

// int process_layer_starting_layer_nr = 0;
int process_layer_starting_layer_nr = 0;
const bool has_raft = scene.current_mesh_group->settings.get<EPlatformAdhesion>("adhesion_type") == EPlatformAdhesion::RAFT;
if (has_raft)
{
processRaft(storage);
// process filler layers to fill the airgap with helper object (support etc) so that they stick better to the raft.
// only process the filler layers if there is anything to print in them.
/*for (bool extruder_is_used_in_filler_layers : storage.getExtrudersUsed(-1))
for (bool extruder_is_used_in_filler_layers : storage.getExtrudersUsed(-1))
{
if (extruder_is_used_in_filler_layers)
{
process_layer_starting_layer_nr = -Raft::getFillerLayerCount();
break;
}
}*/
}
}

run_multiple_producers_ordered_consumer(
// process_layer_starting_layer_nr,
-Raft::getTotalExtraLayers(),
// total_layers + Raft::getFillerLayerCount() - 1,
total_layers,
process_layer_starting_layer_nr,
//-Raft::getTotalExtraLayers(),
total_layers + Raft::getFillerLayerCount() - 1,
// total_layers,
[&storage, total_layers, this](int layer_nr)
{
return &processLayer(storage, layer_nr, total_layers);
Expand Down
30 changes: 20 additions & 10 deletions src/PrimeTower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,24 @@ void PrimeTower::generatePaths_denseInfill()
else
{
// Generate the pattern for the first layer.
coord_t line_width_layer0 = line_width * scene.extruders[extruder_nr].settings.get<Ratio>("initial_layer_line_width_factor");
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];

// 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())
Polygons inset = outer_poly.offset(-cumulative_inset - line_width_layer0 / 2);
while (! inset.empty())
{
pattern_layer0.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(inset);
inset = inset.offset(line_width_layer0);
pattern_layer0.polygons.add(outset);
outset = outset.offset(line_width_layer0);
}
}
cumulative_inset += wall_nr * line_width;
Expand Down Expand Up @@ -230,19 +232,27 @@ void PrimeTower::addToGcode(const SliceDataStorage& storage, LayerPlan& gcode_la

void PrimeTower::addToGcode_denseInfill(LayerPlan& gcode_layer, const size_t extruder_nr) const
{
const GCodePathConfig& config = gcode_layer.configs_storage.prime_tower_config_per_extruder[extruder_nr];
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];

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() == -static_cast<LayerIndex>(Raft::getTotalExtraLayers()))
if (gcode_layer.getLayerNr() < 0 && extruder_nr == 0)
{
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 = pattern_per_extruder[extruder_nr];
gcode_layer.addPolygonsByOptimizer(pattern.polygons, config);
gcode_layer.addLinesByOptimizer(pattern.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
10 changes: 9 additions & 1 deletion src/raft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,15 @@ coord_t Raft::getFillerLayerHeight()
const coord_t normal_layer_height = mesh_group_settings.get<coord_t>("layer_height");
return normal_layer_height;
}
return round_divide(getZdiffBetweenRaftAndLayer0(), getFillerLayerCount());

if (getFillerLayerCount() != 0)
{
return round_divide(getZdiffBetweenRaftAndLayer0(), getFillerLayerCount());
}
else
{
return mesh_group_settings.get<coord_t>("layer_height");
}
}


Expand Down

0 comments on commit e48316e

Please sign in to comment.