Skip to content

Commit

Permalink
Handle flooring settings on the same basis as roofing
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Jan 27, 2025
1 parent 35a8c58 commit c841fb8
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 80 deletions.
10 changes: 6 additions & 4 deletions include/FffGcodeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class FffGcodeWriter : public NoCopy
const SkinPart& skin_part) const;

/*!
* Add the roofing which is the area inside the innermost skin inset which has air 'directly' above
* Add the roofing/flooring which is the area inside the innermost skin inset which has air 'directly' above or below
*
* \param[in] storage where the slice data is stored.
* \param gcode_layer The initial planning of the gcode of the layer.
Expand All @@ -511,13 +511,15 @@ class FffGcodeWriter : public NoCopy
* \param skin_part The skin part for which to create gcode
* \param[out] added_something Whether this function added anything to the layer plan
*/
void processRoofing(
void processRoofingFlooring(
const SliceDataStorage& storage,
LayerPlan& gcode_layer,
const SliceMeshStorage& mesh,
const size_t extruder_nr,
const MeshPathConfigs& mesh_config,
const SkinPart& skin_part,
const std::string& setting_prefix,
const Shape& fill,
const GCodePathConfig& config,
const std::vector<AngleDegrees>& angles,
bool& added_something) const;

/*!
Expand Down
4 changes: 4 additions & 0 deletions include/InsetOrderOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class InsetOrderOptimizer
const GCodePathConfig& inset_X_default_config,
const GCodePathConfig& inset_0_roofing_config,
const GCodePathConfig& inset_X_roofing_config,
const GCodePathConfig& inset_0_flooring_config,
const GCodePathConfig& inset_X_flooring_config,
const GCodePathConfig& inset_0_bridge_config,
const GCodePathConfig& inset_X_bridge_config,
const bool retract_before_outer_wall,
Expand Down Expand Up @@ -101,6 +103,8 @@ class InsetOrderOptimizer
const GCodePathConfig& inset_X_default_config_;
const GCodePathConfig& inset_0_roofing_config_;
const GCodePathConfig& inset_X_roofing_config_;
const GCodePathConfig& inset_0_flooring_config_;
const GCodePathConfig& inset_X_flooring_config_;
const GCodePathConfig& inset_0_bridge_config_;
const GCodePathConfig& inset_X_bridge_config_;
const bool retract_before_outer_wall_;
Expand Down
14 changes: 13 additions & 1 deletion include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class LayerPlan : public NoCopy
Shape bridge_wall_mask_; //!< The regions of a layer part that are not supported, used for bridging
Shape overhang_mask_; //!< The regions of a layer part where the walls overhang
Shape seam_overhang_mask_; //!< The regions of a layer part where the walls overhang, specifically as defined for the seam
Shape roofing_mask_; //!< The regions of a layer part where the walls are exposed to the air
Shape roofing_mask_; //!< The regions of a layer part where the walls are exposed to the air above
Shape flooring_mask_; //!< The regions of a layer part where the walls are exposed to the air below

bool min_layer_time_used = false; //!< Wether or not the minimum layer time (cool_min_layer_time) was actually used in this layerplan.

Expand Down Expand Up @@ -320,6 +321,13 @@ class LayerPlan : public NoCopy
*/
void setRoofingMask(const Shape& polys);

/*!
* Set flooring_mask.
*
* \param shape The areas of the part currently being processed that will require flooring.
*/
void setFlooringMask(const Shape& shape);

/*!
* Travel to a certain point, with all of the procedures necessary to do so.
*
Expand Down Expand Up @@ -491,6 +499,7 @@ class LayerPlan : public NoCopy
const Settings& settings,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& flooring_config,
const GCodePathConfig& bridge_config,
double flow,
const Ratio width_factor,
Expand Down Expand Up @@ -520,6 +529,7 @@ class LayerPlan : public NoCopy
const Settings& settings,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& flooring_config,
const GCodePathConfig& bridge_config,
coord_t wall_0_wipe_dist,
double flow_ratio,
Expand Down Expand Up @@ -554,6 +564,7 @@ class LayerPlan : public NoCopy
const Settings& settings,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& flooring_config,
const GCodePathConfig& bridge_config,
coord_t wall_0_wipe_dist,
double flow_ratio,
Expand Down Expand Up @@ -592,6 +603,7 @@ class LayerPlan : public NoCopy
const Settings& settings,
const GCodePathConfig& default_config,
const GCodePathConfig& roofing_config,
const GCodePathConfig& flooring_config,
const GCodePathConfig& bridge_config,
const ZSeamConfig& z_seam_config = ZSeamConfig(),
coord_t wall_0_wipe_dist = 0,
Expand Down
3 changes: 3 additions & 0 deletions include/settings/MeshPathConfigs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ struct MeshPathConfigs
GCodePathConfig insetX_config{};
GCodePathConfig inset0_roofing_config{};
GCodePathConfig insetX_roofing_config{};
GCodePathConfig inset0_flooring_config{};
GCodePathConfig insetX_flooring_config{};
GCodePathConfig bridge_inset0_config{};
GCodePathConfig bridge_insetX_config{};
GCodePathConfig skin_config{};
GCodePathConfig bridge_skin_config{}; // used for first bridge layer
GCodePathConfig bridge_skin_config2{}; // used for second bridge layer
GCodePathConfig bridge_skin_config3{}; // used for third bridge layer
GCodePathConfig roofing_config{};
GCodePathConfig flooring_config{};
std::vector<GCodePathConfig> infill_config{};
GCodePathConfig ironing_config{};

Expand Down
8 changes: 4 additions & 4 deletions include/skin.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ class SkinInfillAreaComputation
void generateInfill(SliceLayerPart& part);

/*!
* Remove the areas which are 'directly' under air from the \ref SkinPart::inner_infill and
* save them in the \ref SkinPart::roofing_fill of the \p part.
* Remove the areas which are 'directly' under/over air from the \ref SkinPart::inner_infill and
* save them in the \ref SkinPart::roofing_fill and \ref SkinPart::flooring_fill of the \p part.
*
* \param[in,out] part Where to get the SkinParts to get the outline info from and to store the roofing areas
* \param[in,out] part Where to get the SkinParts to get the outline info from and to store the roofing/flooring areas
*/
void generateRoofingFillAndSkinFill(SliceLayerPart& part);
void generateSkinRoofingFlooringFill(SliceLayerPart& part);

/*!
* Generate the top and bottom-most surfaces of the given \p part, i.e. the surfaces that have nothing above or below
Expand Down
2 changes: 2 additions & 0 deletions include/sliceDataStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SkinPart
//!< roofing and non-roofing.
Shape skin_fill; //!< The part of the skin which is not roofing.
Shape roofing_fill; //!< The inner infill which has air directly above
Shape flooring_fill; //!< The inner infill which has air directly below
};

/*!
Expand Down Expand Up @@ -309,6 +310,7 @@ class SliceMeshStorage

std::vector<AngleDegrees> infill_angles; //!< a list of angle values which is cycled through to determine the infill angle of each layer
std::vector<AngleDegrees> roofing_angles; //!< a list of angle values which is cycled through to determine the roofing angle of each layer
std::vector<AngleDegrees> flooring_angles; //!< a list of angle values which is cycled through to determine the flooring angle of each layer
std::vector<AngleDegrees> skin_angles; //!< a list of angle values which is cycled through to determine the skin angle of each layer
std::vector<Shape> overhang_areas; //!< For each layer the areas that are classified as overhang on this mesh.
std::vector<Shape> full_overhang_areas; //!< For each layer the full overhang without the tangent of the overhang angle removed, such that the overhang area adjoins the
Expand Down
102 changes: 75 additions & 27 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,17 @@ void FffGcodeWriter::setInfillAndSkinAngles(SliceMeshStorage& mesh)
}
}

if (mesh.flooring_angles.size() == 0)
{
mesh.flooring_angles = mesh.settings.get<std::vector<AngleDegrees>>("flooring_angles");
if (mesh.flooring_angles.size() == 0)
{
// user has not specified any infill angles so use defaults
mesh.flooring_angles.push_back(45);
mesh.flooring_angles.push_back(135);
}
}

if (mesh.skin_angles.size() == 0)
{
mesh.skin_angles = mesh.settings.get<std::vector<AngleDegrees>>("skin_angles");
Expand Down Expand Up @@ -705,6 +716,8 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
config,
config,
config,
config,
config,
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down Expand Up @@ -866,6 +879,8 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
config,
config,
config,
config,
config,
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down Expand Up @@ -1035,6 +1050,8 @@ void FffGcodeWriter::processRaft(const SliceDataStorage& storage)
config,
config,
config,
config,
config,
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down Expand Up @@ -2732,6 +2749,8 @@ bool FffGcodeWriter::processSingleLayerInfill(
mesh_config.infill_config[0],
mesh_config.infill_config[0],
mesh_config.infill_config[0],
mesh_config.infill_config[0],
mesh_config.infill_config[0],
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down Expand Up @@ -3098,6 +3117,8 @@ bool FffGcodeWriter::processInsets(
gcode_layer.setOverhangMask(get_overhang_region(mesh.settings.get<AngleDegrees>("wall_overhang_angle")));
gcode_layer.setSeamOverhangMask(get_overhang_region(mesh.settings.get<AngleDegrees>("seam_overhang_angle")));

const auto wall_line_width_0 = mesh.settings.get<coord_t>("wall_line_width_0");

const auto roofing_mask_fn = [&]() -> Shape
{
const size_t roofing_layer_count = std::min(mesh.settings.get<size_t>("roofing_layer_count"), mesh.settings.get<size_t>("top_layers"));
Expand All @@ -3109,7 +3130,6 @@ bool FffGcodeWriter::processInsets(
return roofing_mask;
}

const auto wall_line_width_0 = mesh.settings.get<coord_t>("wall_line_width_0");
for (const auto& layer_part : mesh.layers[gcode_layer.getLayerNr() + roofing_layer_count].parts)
{
if (boundaryBox.hit(layer_part.boundaryBox))
Expand All @@ -3118,9 +3138,32 @@ bool FffGcodeWriter::processInsets(
}
}
return roofing_mask;
}();
};

gcode_layer.setRoofingMask(roofing_mask_fn);
gcode_layer.setRoofingMask(roofing_mask_fn());

const auto flooring_mask_fn = [&]() -> Shape
{
const size_t flooring_layer_count = std::min(mesh.settings.get<size_t>("flooring_layer_count"), mesh.settings.get<size_t>("bottom_layers"));

auto flooring_mask = storage.getMachineBorder(mesh.settings.get<ExtruderTrain&>("wall_0_extruder_nr").extruder_nr_);

if (gcode_layer.getLayerNr() - flooring_layer_count < 0)
{
return flooring_mask;
}

for (const auto& layer_part : mesh.layers[gcode_layer.getLayerNr() - flooring_layer_count].parts)
{
if (boundaryBox.hit(layer_part.boundaryBox))
{
flooring_mask = flooring_mask.difference(layer_part.outline.offset(-wall_line_width_0 / 4));
}
}
return flooring_mask;
};

gcode_layer.setFlooringMask(flooring_mask_fn());
}
else
{
Expand All @@ -3132,6 +3175,8 @@ bool FffGcodeWriter::processInsets(
gcode_layer.setSeamOverhangMask(Shape());
// clear to disable use of roofing settings
gcode_layer.setRoofingMask(Shape());
// clear to disable use of flooring settings
gcode_layer.setFlooringMask(Shape());
}

if (spiralize && extruder_nr == mesh.settings.get<ExtruderTrain&>("wall_0_extruder_nr").extruder_nr_ && ! part.spiral_wall.empty())
Expand All @@ -3149,7 +3194,7 @@ bool FffGcodeWriter::processInsets(
else
{
// Print the spiral walls of other parts as single walls without Z gradient.
gcode_layer.addWalls(part.spiral_wall, mesh.settings, mesh_config.inset0_config, mesh_config.inset0_config, mesh_config.inset0_config);
gcode_layer.addWalls(part.spiral_wall, mesh.settings, mesh_config.inset0_config, mesh_config.inset0_config, mesh_config.inset0_config, mesh_config.inset0_config);
}
}
else
Expand All @@ -3174,6 +3219,8 @@ bool FffGcodeWriter::processInsets(
mesh_config.insetX_config,
mesh_config.inset0_roofing_config,
mesh_config.insetX_roofing_config,
mesh_config.inset0_flooring_config,
mesh_config.insetX_flooring_config,
mesh_config.bridge_inset0_config,
mesh_config.bridge_insetX_config,
mesh.settings.get<bool>("travel_retract_before_outer_wall"),
Expand Down Expand Up @@ -3273,51 +3320,42 @@ bool FffGcodeWriter::processSkinPart(

gcode_layer.mode_skip_agressive_merge_ = true;

processRoofing(storage, gcode_layer, mesh, extruder_nr, mesh_config, skin_part, added_something);
processRoofingFlooring(storage, gcode_layer, mesh, extruder_nr, "roofing", skin_part.roofing_fill, mesh_config.roofing_config, mesh.roofing_angles, added_something);
processRoofingFlooring(storage, gcode_layer, mesh, extruder_nr, "flooring", skin_part.flooring_fill, mesh_config.flooring_config, mesh.flooring_angles, added_something);
processTopBottom(storage, gcode_layer, mesh, extruder_nr, mesh_config, skin_part, added_something);

gcode_layer.mode_skip_agressive_merge_ = false;
return added_something;
}

void FffGcodeWriter::processRoofing(
void FffGcodeWriter::processRoofingFlooring(
const SliceDataStorage& storage,
LayerPlan& gcode_layer,
const SliceMeshStorage& mesh,
const size_t extruder_nr,
const MeshPathConfigs& mesh_config,
const SkinPart& skin_part,
const std::string& setting_prefix,
const Shape& fill,
const GCodePathConfig& config,
const std::vector<AngleDegrees>& angles,
bool& added_something) const
{
const size_t roofing_extruder_nr = mesh.settings.get<ExtruderTrain&>("roofing_extruder_nr").extruder_nr_;
if (extruder_nr != roofing_extruder_nr)
const size_t skin_extruder_nr = mesh.settings.get<ExtruderTrain&>(fmt::format("{}_extruder_nr", setting_prefix)).extruder_nr_;
if (extruder_nr != skin_extruder_nr)
{
return;
}

const EFillMethod pattern = mesh.settings.get<EFillMethod>("roofing_pattern");
const EFillMethod pattern = mesh.settings.get<EFillMethod>(fmt::format("{}_pattern", setting_prefix));
AngleDegrees roofing_angle = 45;
if (mesh.roofing_angles.size() > 0)
if (angles.size() > 0)
{
roofing_angle = mesh.roofing_angles.at(gcode_layer.getLayerNr() % mesh.roofing_angles.size());
roofing_angle = angles.at(gcode_layer.getLayerNr() % angles.size());
}

const Ratio skin_density = 1.0;
const coord_t skin_overlap = 0; // skinfill already expanded over the roofing areas; don't overlap with perimeters
const bool monotonic = mesh.settings.get<bool>("roofing_monotonic");
processSkinPrintFeature(
storage,
gcode_layer,
mesh,
extruder_nr,
skin_part.roofing_fill,
mesh_config.roofing_config,
pattern,
roofing_angle,
skin_overlap,
skin_density,
monotonic,
added_something);
const bool monotonic = mesh.settings.get<bool>(fmt::format("{}_monotonic", setting_prefix));
processSkinPrintFeature(storage, gcode_layer, mesh, extruder_nr, fill, config, pattern, roofing_angle, skin_overlap, skin_density, monotonic, added_something);
}

void FffGcodeWriter::processTopBottom(
Expand Down Expand Up @@ -3606,6 +3644,8 @@ void FffGcodeWriter::processSkinPrintFeature(
config,
config,
config,
config,
config,
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down Expand Up @@ -3898,6 +3938,8 @@ bool FffGcodeWriter::processSupportInfill(const SliceDataStorage& storage, Layer
config,
config,
config,
config,
config,
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down Expand Up @@ -4084,6 +4126,8 @@ bool FffGcodeWriter::processSupportInfill(const SliceDataStorage& storage, Layer
config,
config,
config,
config,
config,
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down Expand Up @@ -4220,6 +4264,8 @@ bool FffGcodeWriter::addSupportRoofsToGCode(const SliceDataStorage& storage, con
config,
config,
config,
config,
config,
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down Expand Up @@ -4334,6 +4380,8 @@ bool FffGcodeWriter::addSupportBottomsToGCode(const SliceDataStorage& storage, L
config,
config,
config,
config,
config,
retract_before_outer_wall,
wipe_dist,
wipe_dist,
Expand Down
Loading

0 comments on commit c841fb8

Please sign in to comment.