diff --git a/include/InsetOrderOptimizer.h b/include/InsetOrderOptimizer.h index 90097205ec..47cd832fcb 100644 --- a/include/InsetOrderOptimizer.h +++ b/include/InsetOrderOptimizer.h @@ -55,7 +55,8 @@ class InsetOrderOptimizer const size_t wall_0_extruder_nr, const size_t wall_x_extruder_nr, const ZSeamConfig& z_seam_config, - const std::vector& paths); + const std::vector& paths, + const Polygons& disallowed_areas = {}); /*! * Adds the insets to the given layer plan. @@ -64,7 +65,7 @@ class InsetOrderOptimizer * class, so this optimize function needs no additional information. * \return Whether anything was added to the layer plan. */ - bool addToLayer(const bool is_support = false); + bool addToLayer(); /*! * Get the order constraints of the insets when printing walls per region / hole. @@ -106,7 +107,7 @@ class InsetOrderOptimizer const ZSeamConfig& z_seam_config_; const std::vector& paths_; const LayerIndex layer_nr_; - Polygons mesh_paths_; + Polygons disallowed_areas_; std::vector> inset_polys_; // vector of vectors holding the inset polygons Polygons retraction_region_; // After printing an outer wall, move into this region so that retractions do not leave visible blobs. Calculated lazily if needed (see diff --git a/include/PathOrderOptimizer.h b/include/PathOrderOptimizer.h index c8a8b05421..31eb58efb3 100644 --- a/include/PathOrderOptimizer.h +++ b/include/PathOrderOptimizer.h @@ -62,7 +62,7 @@ class PathOrderOptimizer public: using OrderablePath = PathOrdering; /* Areas defined here are not allowed to have the start the prints */ - Polygons disallowed_area{}; + Polygons disallowed_area; /*! * After optimizing, this contains the paths that need to be printed in the * correct order. @@ -112,7 +112,8 @@ class PathOrderOptimizer const Polygons* combing_boundary = nullptr, const bool reverse_direction = false, const std::unordered_multimap& order_requirements = no_order_requirements_, - const bool group_outer_walls = false) + const bool group_outer_walls = false, + const Polygons& disallowed_areas = {}) : start_point_(start_point) , seam_config_(seam_config) , combing_boundary_((combing_boundary != nullptr && ! combing_boundary->empty()) ? combing_boundary : nullptr) @@ -120,7 +121,7 @@ class PathOrderOptimizer , reverse_direction_(reverse_direction) , _group_outer_walls(group_outer_walls) , order_requirements_(&order_requirements) - , disallowed_area{} + , disallowed_area{disallowed_areas} { } diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index bf3c03dc96..2c1aac5858 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -3459,7 +3459,23 @@ bool FffGcodeWriter::processSupportInfill(const SliceDataStorage& storage, Layer constexpr coord_t wipe_dist = 0; ZSeamConfig z_seam_config = ZSeamConfig(EZSeamType::SHORTEST, gcode_layer.getLastPlannedPositionOrStartingPosition(), EZSeamCornerPrefType::Z_SEAM_CORNER_PREF_NONE, false); - + Polygons disallowed_area {}; + if (infill_extruder.settings_.get("support_z_seam_away_from_model")) + { + for (std::shared_ptr mesh_ptr : storage.meshes) + { + auto& mesh = *mesh_ptr; + for (auto& part : mesh.layers[gcode_layer.getLayerNr()].parts) + { + disallowed_area.add(part.print_outline); + } + } + if (! disallowed_area.empty()) + { + coord_t min_distance = infill_extruder.settings_.get("support_z_seam_min_distance"); + disallowed_area = disallowed_area.offset(min_distance, ClipperLib::jtRound); + } + } InsetOrderOptimizer wall_orderer( *this, @@ -3479,8 +3495,9 @@ bool FffGcodeWriter::processSupportInfill(const SliceDataStorage& storage, Layer extruder_nr, extruder_nr, z_seam_config, - wall_toolpaths); - added_something |= wall_orderer.addToLayer(true); + wall_toolpaths, + disallowed_area); + added_something |= wall_orderer.addToLayer(); } if ((default_support_line_distance <= 0 && support_structure != ESupportStructure::TREE) || part.infill_area_per_combine_per_density_.empty()) diff --git a/src/InsetOrderOptimizer.cpp b/src/InsetOrderOptimizer.cpp index 7e3eeb0ce0..57cfd32201 100644 --- a/src/InsetOrderOptimizer.cpp +++ b/src/InsetOrderOptimizer.cpp @@ -50,7 +50,8 @@ InsetOrderOptimizer::InsetOrderOptimizer( const size_t wall_0_extruder_nr, const size_t wall_x_extruder_nr, const ZSeamConfig& z_seam_config, - const std::vector& paths) + const std::vector& paths, + const Polygons& disallowed_areas) : gcode_writer_(gcode_writer) , storage_(storage) , gcode_layer_(gcode_layer) @@ -70,11 +71,11 @@ InsetOrderOptimizer::InsetOrderOptimizer( , z_seam_config_(z_seam_config) , paths_(paths) , layer_nr_(gcode_layer.getLayerNr()) - , mesh_paths_{} + , disallowed_areas_{disallowed_areas} { } -bool InsetOrderOptimizer::addToLayer(const bool is_support) +bool InsetOrderOptimizer::addToLayer() { // Settings & configs: const auto pack_by_inset = ! settings_.get("optimize_wall_printing_order"); @@ -100,7 +101,7 @@ bool InsetOrderOptimizer::addToLayer(const bool is_support) // When we alternate walls, also alternate the direction at which the first wall starts in. // On even layers we start with normal direction, on odd layers with inverted direction. PathOrderOptimizer - order_optimizer(gcode_layer_.getLastPlannedPositionOrStartingPosition(), z_seam_config_, detect_loops, combing_boundary, reverse, order, group_outer_walls); + order_optimizer(gcode_layer_.getLastPlannedPositionOrStartingPosition(), z_seam_config_, detect_loops, combing_boundary, reverse, order, group_outer_walls, disallowed_areas_); for (const auto& line : walls_to_be_added) { @@ -113,22 +114,6 @@ bool InsetOrderOptimizer::addToLayer(const bool is_support) order_optimizer.addPolyline(&line); } } - if (is_support && settings_.get("support_z_seam_away_from_model")) - { - for (std::shared_ptr mesh_ptr : storage_.meshes) - { - auto& mesh = *mesh_ptr; - for (auto& part : mesh.layers[layer_nr_].parts) - { - mesh_paths_.add(part.print_outline); - } - } - if (! mesh_paths_.empty()) - { - coord_t min_distance = settings_.get("support_z_seam_min_distance"); - order_optimizer.disallowed_area = mesh_paths_.offset(min_distance, ClipperLib::jtRound); - } - } order_optimizer.optimize();