From c74f4bbdabb8b7e2b11e824e1a42fce08d5da053 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 22 Nov 2023 10:27:07 +0100 Subject: [PATCH] Fixed variable initialization ordering warnings --- include/PathOrderOptimizer.h | 2 +- include/TreeSupportElement.h | 8 +- include/TreeSupportTipGenerator.h | 61 ++-- src/BeadingStrategy/BeadingStrategy.cpp | 8 +- src/SkeletalTrapezoidation.cpp | 2 +- src/TreeSupportTipGenerator.cpp | 388 ++++++++++++------------ src/pathPlanning/Comb.cpp | 2 +- 7 files changed, 234 insertions(+), 237 deletions(-) diff --git a/include/PathOrderOptimizer.h b/include/PathOrderOptimizer.h index 56212693d2..4dd1e47332 100644 --- a/include/PathOrderOptimizer.h +++ b/include/PathOrderOptimizer.h @@ -116,8 +116,8 @@ class PathOrderOptimizer , combing_boundary_((combing_boundary != nullptr && ! combing_boundary->empty()) ? combing_boundary : nullptr) , detect_loops_(detect_loops) , reverse_direction_(reverse_direction) - , order_requirements_(&order_requirements) , _group_outer_walls(group_outer_walls) + , order_requirements_(&order_requirements) { } diff --git a/include/TreeSupportElement.h b/include/TreeSupportElement.h index 3fa5c3eafd..3c160b1042 100644 --- a/include/TreeSupportElement.h +++ b/include/TreeSupportElement.h @@ -117,9 +117,9 @@ struct TreeSupportElement , missing_roof_layers_(elem.missing_roof_layers_) , skip_ovalisation_(elem.skip_ovalisation_) , all_tips_(elem.all_tips_) - , influence_area_limit_area_(elem.influence_area_limit_area_) - , influence_area_limit_range_(elem.influence_area_limit_range_) , influence_area_limit_active_(elem.influence_area_limit_active_) + , influence_area_limit_range_(elem.influence_area_limit_range_) + , influence_area_limit_area_(elem.influence_area_limit_area_) { parents_.insert(parents_.begin(), elem.parents_.begin(), elem.parents_.end()); } @@ -149,9 +149,9 @@ struct TreeSupportElement , missing_roof_layers_(element_above->missing_roof_layers_) , skip_ovalisation_(false) , all_tips_(element_above->all_tips_) - , influence_area_limit_area_(element_above->influence_area_limit_area_) - , influence_area_limit_range_(element_above->influence_area_limit_range_) , influence_area_limit_active_(element_above->influence_area_limit_active_) + , influence_area_limit_range_(element_above->influence_area_limit_range_) + , influence_area_limit_area_(element_above->influence_area_limit_area_) { parents_ = { element_above }; } diff --git a/include/TreeSupportTipGenerator.h b/include/TreeSupportTipGenerator.h index eaf85c0c3d..b6ffd3d351 100644 --- a/include/TreeSupportTipGenerator.h +++ b/include/TreeSupportTipGenerator.h @@ -176,138 +176,135 @@ class TreeSupportTipGenerator */ void removeUselessAddedPoints(std::vector>& move_bounds, SliceDataStorage& storage, std::vector& additional_support_areas); + /*! + * \brief Contains config settings to avoid loading them in every function. This was done to improve readability of the code. + */ + TreeSupportSettings config_; /*! * \brief If large areas should be supported by a roof out of regular support lines. */ - bool use_fake_roof; + bool use_fake_roof_; /*! * \brief Generator for model collision, avoidance and internal guide volumes. */ TreeModelVolumes& volumes_; - /*! - * \brief Contains config settings to avoid loading them in every function. This was done to improve readability of the code. - */ - TreeSupportSettings config; - - /*! * \brief Minimum area an overhang has to have to be supported. */ - const double minimum_support_area; + const double minimum_support_area_; /*! * \brief Minimum area an overhang has to have to become a roof. */ - const double minimum_roof_area; + const double minimum_roof_area_; /*! * \brief Amount of layers of roof. Zero if roof is disabled */ - const size_t support_roof_layers; + const size_t support_roof_layers_; /*! * \brief Distance between tips, so that the tips form a lime. Is smaller than Tip Diameter. */ - const coord_t connect_length; + const coord_t connect_length_; /*! * \brief Distance between tips, if the tips support an overhang. */ - const coord_t support_tree_branch_distance; + const coord_t support_tree_branch_distance_; /*! * \brief Distance between support roof lines. Is required for generating roof patterns. */ - const coord_t support_roof_line_distance; + const coord_t support_roof_line_distance_; /*! * \brief Amount of offset to each overhang for support with regular branches (as opposed to roof). */ - const coord_t support_outset; + const coord_t support_outset_; /*! * \brief Amount of offset to each overhang for support with roof (as opposed to regular branches). */ - const coord_t roof_outset; + const coord_t roof_outset_; /*! * \brief Whether tips should be printed as roof */ - const bool force_tip_to_roof; + const bool force_tip_to_roof_; /*! * \brief Whether the maximum distance a branch should from a point they support should be limited. Can be violated if required. */ - const bool support_tree_limit_branch_reach; + const bool support_tree_limit_branch_reach_; /*! * \brief Maximum distance a branch should from a point they support (in the xy plane). Can be violated if required. */ - const coord_t support_tree_branch_reach_limit; + const coord_t support_tree_branch_reach_limit_; /*! * \brief Distance in layers from the overhang to the first layer with support. This is the z distance in layers+1 */ - const size_t z_distance_delta; + const size_t z_distance_delta_; /*! * \brief Whether the Support Distance Priority is X/Y Overrides Z */ - const bool xy_overrides; + const bool xy_overrides_; /*! * \brief Amount of layers further down than required an overhang can be supported, when Support Distance Priority is X/Y Overrides Z */ - size_t max_overhang_insert_lag; + size_t max_overhang_insert_lag_; /*! * \brief Area of a tip. */ - const double tip_roof_size; + const double tip_roof_size_; /*! * \brief Whether only support that can rest on a flat surface should be supported. */ - const bool only_gracious = SUPPORT_TREE_ONLY_GRACIOUS_TO_MODEL; + const bool only_gracious_ = SUPPORT_TREE_ONLY_GRACIOUS_TO_MODEL; /*! * \brief Whether minimum_roof_area is a hard limit. If false the roof will be combined with roof above and below, to see if a part of this roof may be part of a valid roof * further up/down. */ - const bool force_minimum_roof_area = SUPPORT_TREE_MINIMUM_ROOF_AREA_HARD_LIMIT; + const bool force_minimum_roof_area_ = SUPPORT_TREE_MINIMUM_ROOF_AREA_HARD_LIMIT; /*! * \brief Distance between branches when the branches support a support pattern */ - coord_t support_supporting_branch_distance; + coord_t support_supporting_branch_distance_; /*! * \brief Required to generate cross infill patterns */ - std::shared_ptr cross_fill_provider; + std::shared_ptr cross_fill_provider_; /*! * \brief Map that saves locations of already inserted tips. Used to prevent tips far to close together from being added. */ - std::vector> already_inserted; + std::vector> already_inserted_; /*! * \brief Areas that will be saved as support roof */ - std::vector support_roof_drawn; + std::vector support_roof_drawn_; /*! * \brief Areas that will be saved as support roof, originating from tips being replaced with roof areas. */ - std::vector roof_tips_drawn; - + std::vector roof_tips_drawn_; - std::mutex critical_move_bounds; - std::mutex critical_roof_tips; + std::mutex critical_move_bounds_; + std::mutex critical_roof_tips_; }; } // namespace cura diff --git a/src/BeadingStrategy/BeadingStrategy.cpp b/src/BeadingStrategy/BeadingStrategy.cpp index 5b3f81583f..88b295b7ad 100644 --- a/src/BeadingStrategy/BeadingStrategy.cpp +++ b/src/BeadingStrategy/BeadingStrategy.cpp @@ -14,22 +14,22 @@ BeadingStrategy::BeadingStrategy( Ratio wall_add_middle_threshold, coord_t default_transition_length, double transitioning_angle) - : optimal_width_(optimal_width) + : name_("Unknown") + , optimal_width_(optimal_width) , wall_split_middle_threshold_(wall_split_middle_threshold) , wall_add_middle_threshold_(wall_add_middle_threshold) , default_transition_length_(default_transition_length) , transitioning_angle_(transitioning_angle) { - name_ = "Unknown"; } BeadingStrategy::BeadingStrategy(const BeadingStrategy& other) - : optimal_width_(other.optimal_width_) + : name_(other.name_) + , optimal_width_(other.optimal_width_) , wall_split_middle_threshold_(other.wall_split_middle_threshold_) , wall_add_middle_threshold_(other.wall_add_middle_threshold_) , default_transition_length_(other.default_transition_length_) , transitioning_angle_(other.transitioning_angle_) - , name_(other.name_) { } diff --git a/src/SkeletalTrapezoidation.cpp b/src/SkeletalTrapezoidation.cpp index 9cd04a3cbc..3aca0644db 100644 --- a/src/SkeletalTrapezoidation.cpp +++ b/src/SkeletalTrapezoidation.cpp @@ -387,9 +387,9 @@ SkeletalTrapezoidation::SkeletalTrapezoidation( , transition_filter_dist_(transition_filter_dist) , allowed_filter_deviation_(allowed_filter_deviation) , beading_propagation_transition_dist_(beading_propagation_transition_dist) - , beading_strategy_(beading_strategy) , layer_idx_(layer_idx) , section_type_(section_type) + , beading_strategy_(beading_strategy) { scripta::log("skeletal_trapezoidation_0", polys, section_type, layer_idx); constructFromPolygons(polys); diff --git a/src/TreeSupportTipGenerator.cpp b/src/TreeSupportTipGenerator.cpp index 5ec22f610c..c5292dbf2b 100644 --- a/src/TreeSupportTipGenerator.cpp +++ b/src/TreeSupportTipGenerator.cpp @@ -29,54 +29,54 @@ namespace cura { TreeSupportTipGenerator::TreeSupportTipGenerator(const SliceDataStorage& storage, const SliceMeshStorage& mesh, TreeModelVolumes& volumes_s) - : config(mesh.settings) - , use_fake_roof(! mesh.settings.get("support_roof_enable")) - , minimum_support_area(mesh.settings.get("minimum_support_area")) - , minimum_roof_area(! use_fake_roof ? mesh.settings.get("minimum_roof_area") : std::max(SUPPORT_TREE_MINIMUM_FAKE_ROOF_AREA, minimum_support_area)) - , support_roof_layers( - mesh.settings.get("support_roof_enable") ? round_divide(mesh.settings.get("support_roof_height"), config.layer_height) - : use_fake_roof ? SUPPORT_TREE_MINIMUM_FAKE_ROOF_LAYERS + : config_(mesh.settings) + , use_fake_roof_(! mesh.settings.get("support_roof_enable")) + , volumes_(volumes_s) + , minimum_support_area_(mesh.settings.get("minimum_support_area")) + , minimum_roof_area_(! use_fake_roof_ ? mesh.settings.get("minimum_roof_area") : std::max(SUPPORT_TREE_MINIMUM_FAKE_ROOF_AREA, minimum_support_area_)) + , support_roof_layers_( + mesh.settings.get("support_roof_enable") ? round_divide(mesh.settings.get("support_roof_height"), config_.layer_height) + : use_fake_roof_ ? SUPPORT_TREE_MINIMUM_FAKE_ROOF_LAYERS : 0) - , connect_length( - (config.support_line_width * 100 / mesh.settings.get("support_tree_top_rate")) + std::max(2 * config.min_radius - 1.0 * config.support_line_width, 0.0)) - , support_tree_branch_distance((config.support_pattern == EFillMethod::TRIANGLES ? 3 : (config.support_pattern == EFillMethod::GRID ? 2 : 1)) * connect_length) - , support_roof_line_distance( - use_fake_roof ? (config.support_pattern == EFillMethod::TRIANGLES ? 3 : (config.support_pattern == EFillMethod::GRID ? 2 : 1)) - * (config.support_line_width * 100 / mesh.settings.get("support_tree_top_rate")) - : mesh.settings.get("support_roof_line_distance")) + , connect_length_( + (config_.support_line_width * 100 / mesh.settings.get("support_tree_top_rate")) + std::max(2 * config_.min_radius - 1.0 * config_.support_line_width, 0.0)) + , support_tree_branch_distance_((config_.support_pattern == EFillMethod::TRIANGLES ? 3 : (config_.support_pattern == EFillMethod::GRID ? 2 : 1)) * connect_length_) + , support_roof_line_distance_( + use_fake_roof_ ? (config_.support_pattern == EFillMethod::TRIANGLES ? 3 : (config_.support_pattern == EFillMethod::GRID ? 2 : 1)) + * (config_.support_line_width * 100 / mesh.settings.get("support_tree_top_rate")) + : mesh.settings.get("support_roof_line_distance")) , // todo propper - support_outset(0) + support_outset_(0) , // Since we disable support offset when tree support is enabled we use an offset of 0 rather than the setting value mesh.settings.get("support_offset") - roof_outset(use_fake_roof ? support_outset : mesh.settings.get("support_roof_offset")) - , force_tip_to_roof((config.min_radius * config.min_radius * std::numbers::pi > minimum_roof_area * (1000 * 1000)) && support_roof_layers && ! use_fake_roof) - , support_tree_limit_branch_reach(mesh.settings.get("support_tree_limit_branch_reach")) - , support_tree_branch_reach_limit(support_tree_limit_branch_reach ? mesh.settings.get("support_tree_branch_reach_limit") : 0) - , z_distance_delta(std::min(config.z_distance_top_layers + 1, mesh.overhang_areas.size())) - , xy_overrides(config.support_overrides == SupportDistPriority::XY_OVERRIDES_Z) - , tip_roof_size(force_tip_to_roof ? config.min_radius * config.min_radius * std::numbers::pi : 0) - , already_inserted(mesh.overhang_areas.size()) - , support_roof_drawn(mesh.overhang_areas.size(), Polygons()) - , roof_tips_drawn(mesh.overhang_areas.size(), Polygons()) - , volumes_(volumes_s) - , force_minimum_roof_area(use_fake_roof || SUPPORT_TREE_MINIMUM_ROOF_AREA_HARD_LIMIT) + roof_outset_(use_fake_roof_ ? support_outset_ : mesh.settings.get("support_roof_offset")) + , force_tip_to_roof_((config_.min_radius * config_.min_radius * std::numbers::pi > minimum_roof_area_ * (1000 * 1000)) && support_roof_layers_ && ! use_fake_roof_) + , support_tree_limit_branch_reach_(mesh.settings.get("support_tree_limit_branch_reach")) + , support_tree_branch_reach_limit_(support_tree_limit_branch_reach_ ? mesh.settings.get("support_tree_branch_reach_limit") : 0) + , z_distance_delta_(std::min(config_.z_distance_top_layers + 1, mesh.overhang_areas.size())) + , xy_overrides_(config_.support_overrides == SupportDistPriority::XY_OVERRIDES_Z) + , tip_roof_size_(force_tip_to_roof_ ? config_.min_radius * config_.min_radius * std::numbers::pi : 0) + , force_minimum_roof_area_(use_fake_roof_ || SUPPORT_TREE_MINIMUM_ROOF_AREA_HARD_LIMIT) + , already_inserted_(mesh.overhang_areas.size()) + , support_roof_drawn_(mesh.overhang_areas.size(), Polygons()) + , roof_tips_drawn_(mesh.overhang_areas.size(), Polygons()) { const double support_overhang_angle = mesh.settings.get("support_angle"); - const coord_t max_overhang_speed = (support_overhang_angle < TAU / 4) ? (coord_t)(tan(support_overhang_angle) * config.layer_height) : std::numeric_limits::max(); + const coord_t max_overhang_speed = (support_overhang_angle < TAU / 4) ? (coord_t)(tan(support_overhang_angle) * config_.layer_height) : std::numeric_limits::max(); if (max_overhang_speed == 0) { - max_overhang_insert_lag = std::numeric_limits::max(); + max_overhang_insert_lag_ = std::numeric_limits::max(); } else { - max_overhang_insert_lag = std::max((size_t)round_up_divide(config.xy_distance, max_overhang_speed / 2), 2 * config.z_distance_top_layers); + max_overhang_insert_lag_ = std::max((size_t)round_up_divide(config_.xy_distance, max_overhang_speed / 2), 2 * config_.z_distance_top_layers); // ^^^ Cap for how much layer below the overhang a new support point may be added, as other than with regular support every new inserted point may cause extra material and // time cost. // Could also be an user setting or differently calculated. Idea is that if an overhang does not turn valid in double the amount of layers a slope of support angle // would take to travel xy_distance, nothing reasonable will come from it. The 2*z_distance_delta is only a catch for when the support angle is very high. } - cross_fill_provider = generateCrossFillProvider(mesh, support_tree_branch_distance, config.support_line_width); + cross_fill_provider_ = generateCrossFillProvider(mesh, support_tree_branch_distance_, config_.support_line_width); std::vector known_z(mesh.layers.size()); @@ -84,23 +84,23 @@ TreeSupportTipGenerator::TreeSupportTipGenerator(const SliceDataStorage& storage { known_z[z] = layer.printZ; } - config.setActualZ(known_z); + config_.setActualZ(known_z); coord_t dtt_when_tips_can_merge = 1; - if (config.branch_radius * config.diameter_angle_scale_factor < 2 * config.maximum_move_distance_slow) + if (config_.branch_radius * config_.diameter_angle_scale_factor < 2 * config_.maximum_move_distance_slow) { - while ((2 * config.maximum_move_distance_slow * dtt_when_tips_can_merge - config.support_line_width) < config.getRadius(dtt_when_tips_can_merge)) + while ((2 * config_.maximum_move_distance_slow * dtt_when_tips_can_merge - config_.support_line_width) < config_.getRadius(dtt_when_tips_can_merge)) { dtt_when_tips_can_merge++; } } else { - dtt_when_tips_can_merge = config.tip_layers; // arbitrary default for when there is no guarantee that the while loop above will terminate + dtt_when_tips_can_merge = config_.tip_layers; // arbitrary default for when there is no guarantee that the while loop above will terminate } - support_supporting_branch_distance = 2 * config.getRadius(dtt_when_tips_can_merge) + config.support_line_width + FUDGE_LENGTH; + support_supporting_branch_distance_ = 2 * config_.getRadius(dtt_when_tips_can_merge) + config_.support_line_width + FUDGE_LENGTH; } @@ -119,26 +119,26 @@ std::vector TreeSupportTipGenerator::c LineInformation res_line; for (const Point2LL& p : line) { - if (config.support_rest_preference == RestPreference::BUILDPLATE - && ! volumes_.getAvoidance(config.getRadius(0), layer_idx, AvoidanceType::FAST_SAFE, false, ! xy_overrides).inside(p, true)) + if (config_.support_rest_preference == RestPreference::BUILDPLATE + && ! volumes_.getAvoidance(config_.getRadius(0), layer_idx, AvoidanceType::FAST_SAFE, false, ! xy_overrides_).inside(p, true)) { res_line.emplace_back(p, LineStatus::TO_BP_SAFE); } else if ( - config.support_rest_preference == RestPreference::BUILDPLATE - && ! volumes_.getAvoidance(config.getRadius(0), layer_idx, AvoidanceType::FAST, false, ! xy_overrides).inside(p, true)) + config_.support_rest_preference == RestPreference::BUILDPLATE + && ! volumes_.getAvoidance(config_.getRadius(0), layer_idx, AvoidanceType::FAST, false, ! xy_overrides_).inside(p, true)) { res_line.emplace_back(p, LineStatus::TO_BP); } - else if (config.support_rests_on_model && ! volumes_.getAvoidance(config.getRadius(0), layer_idx, AvoidanceType::FAST_SAFE, true, ! xy_overrides).inside(p, true)) + else if (config_.support_rests_on_model && ! volumes_.getAvoidance(config_.getRadius(0), layer_idx, AvoidanceType::FAST_SAFE, true, ! xy_overrides_).inside(p, true)) { res_line.emplace_back(p, LineStatus::TO_MODEL_GRACIOUS_SAFE); } - else if (config.support_rests_on_model && ! volumes_.getAvoidance(config.getRadius(0), layer_idx, AvoidanceType::FAST, true, ! xy_overrides).inside(p, true)) + else if (config_.support_rests_on_model && ! volumes_.getAvoidance(config_.getRadius(0), layer_idx, AvoidanceType::FAST, true, ! xy_overrides_).inside(p, true)) { res_line.emplace_back(p, LineStatus::TO_MODEL_GRACIOUS); } - else if (config.support_rests_on_model && ! volumes_.getAvoidance(config.getRadius(0), layer_idx, AvoidanceType::COLLISION, true, ! xy_overrides).inside(p, true)) + else if (config_.support_rests_on_model && ! volumes_.getAvoidance(config_.getRadius(0), layer_idx, AvoidanceType::COLLISION, true, ! xy_overrides_).inside(p, true)) { res_line.emplace_back(p, LineStatus::TO_MODEL); } @@ -177,34 +177,34 @@ std::function)> Tr { std::function)> evaluatePoint = [this, current_layer](std::pair p) { - if (config.support_rest_preference != RestPreference::GRACEFUL + if (config_.support_rest_preference != RestPreference::GRACEFUL && ! volumes_ .getAvoidance( - config.getRadius(0), + config_.getRadius(0), current_layer - 1, p.second == LineStatus::TO_BP_SAFE ? AvoidanceType::FAST_SAFE : AvoidanceType::FAST, false, - ! xy_overrides) + ! xy_overrides_) .inside(p.first, true)) { return true; } - if (config.support_rests_on_model && (p.second != LineStatus::TO_BP && p.second != LineStatus::TO_BP_SAFE)) + if (config_.support_rests_on_model && (p.second != LineStatus::TO_BP && p.second != LineStatus::TO_BP_SAFE)) { if (p.second == LineStatus::TO_MODEL_GRACIOUS || p.second == LineStatus::TO_MODEL_GRACIOUS_SAFE) { return ! volumes_ .getAvoidance( - config.getRadius(0), + config_.getRadius(0), current_layer - 1, p.second == LineStatus::TO_MODEL_GRACIOUS_SAFE ? AvoidanceType::FAST_SAFE : AvoidanceType::FAST, true, - ! xy_overrides) + ! xy_overrides_) .inside(p.first, true); } else { - return ! volumes_.getAvoidance(config.getRadius(0), current_layer - 1, AvoidanceType::COLLISION, true, ! xy_overrides).inside(p.first, true); + return ! volumes_.getAvoidance(config_.getRadius(0), current_layer - 1, AvoidanceType::COLLISION, true, ! xy_overrides_).inside(p.first, true); } } return false; @@ -380,7 +380,7 @@ Polygons TreeSupportTipGenerator::ensureMaximumDistancePolyline(const Polygons& std::shared_ptr TreeSupportTipGenerator::generateCrossFillProvider(const SliceMeshStorage& mesh, coord_t line_distance, coord_t line_width) const { - if (config.support_pattern == EFillMethod::CROSS || config.support_pattern == EFillMethod::CROSS_3D) + if (config_.support_pattern == EFillMethod::CROSS || config_.support_pattern == EFillMethod::CROSS_3D) { AABB3D aabb; if (mesh.settings.get("infill_mesh") || mesh.settings.get("anti_overhang_mesh")) @@ -413,42 +413,42 @@ void TreeSupportTipGenerator::dropOverhangAreas(const SliceMeshStorage& mesh, st // this is ugly, but as far as i can see there is not way to ensure a parallel_for loop is calculated for each iteration up to a certain point before it continues; cura::parallel_for( 1, - mesh.overhang_areas.size() - z_distance_delta, + mesh.overhang_areas.size() - z_distance_delta_, [&](const LayerIndex layer_idx) { - if (mesh.overhang_areas[layer_idx + z_distance_delta].empty() || result.size() < layer_idx) + if (mesh.overhang_areas[layer_idx + z_distance_delta_].empty() || result.size() < layer_idx) { return; // This is a continue if imagined in a loop context. } - Polygons relevant_forbidden = volumes_.getCollision(roof ? 0 : config.getRadius(0), layer_idx, ! xy_overrides); + Polygons relevant_forbidden = volumes_.getCollision(roof ? 0 : config_.getRadius(0), layer_idx, ! xy_overrides_); // ^^^ Take the least restrictive avoidance possible // Technically this also makes support blocker smaller, which is wrong as they do not have a xy_distance, but it should be good enough. - Polygons model_outline = volumes_.getCollision(0, layer_idx, ! xy_overrides).offset(-config.xy_min_distance, ClipperLib::jtRound); + Polygons model_outline = volumes_.getCollision(0, layer_idx, ! xy_overrides_).offset(-config_.xy_min_distance, ClipperLib::jtRound); Polygons overhang_regular = TreeSupportUtils::safeOffsetInc( - mesh.overhang_areas[layer_idx + z_distance_delta], - roof ? roof_outset : support_outset, + mesh.overhang_areas[layer_idx + z_distance_delta_], + roof ? roof_outset_ : support_outset_, relevant_forbidden, - config.min_radius * 1.75 + config.xy_min_distance, + config_.min_radius * 1.75 + config_.xy_min_distance, 0, 1, - config.support_line_distance / 2, - &config.simplifier); - Polygons remaining_overhang = mesh.overhang_areas[layer_idx + z_distance_delta] - .offset(roof ? roof_outset : support_outset) + config_.support_line_distance / 2, + &config_.simplifier); + Polygons remaining_overhang = mesh.overhang_areas[layer_idx + z_distance_delta_] + .offset(roof ? roof_outset_ : support_outset_) .difference(overhang_regular) .intersection(relevant_forbidden) .difference(model_outline); - for (size_t lag_ctr = 1; lag_ctr <= max_overhang_insert_lag && layer_idx - coord_t(lag_ctr) >= 1 && ! remaining_overhang.empty(); lag_ctr++) + for (size_t lag_ctr = 1; lag_ctr <= max_overhang_insert_lag_ && layer_idx - coord_t(lag_ctr) >= 1 && ! remaining_overhang.empty(); lag_ctr++) { { std::lock_guard critical_section_storage(critical); result[layer_idx - lag_ctr].add(remaining_overhang); } - Polygons relevant_forbidden_below = volumes_.getCollision(roof ? 0 : config.getRadius(0), layer_idx - lag_ctr, ! xy_overrides).offset(EPSILON); + Polygons relevant_forbidden_below = volumes_.getCollision(roof ? 0 : config_.getRadius(0), layer_idx - lag_ctr, ! xy_overrides_).offset(EPSILON); remaining_overhang = remaining_overhang.intersection(relevant_forbidden_below).unionPolygons().difference(model_outline); } }); @@ -468,17 +468,17 @@ void TreeSupportTipGenerator::calculateRoofAreas(const cura::SliceMeshStorage& m std::mutex critical_potential_support_roofs; std::vector dropped_overhangs(mesh.overhang_areas.size(), Polygons()); - if (xy_overrides) + if (xy_overrides_) { dropOverhangAreas(mesh, dropped_overhangs, true); } cura::parallel_for( 0, - mesh.overhang_areas.size() - z_distance_delta, + mesh.overhang_areas.size() - z_distance_delta_, [&](const LayerIndex layer_idx) { - if (mesh.overhang_areas[layer_idx + z_distance_delta].empty()) + if (mesh.overhang_areas[layer_idx + z_distance_delta_].empty()) { return; // This is a continue if imagined in a loop context. } @@ -487,42 +487,42 @@ void TreeSupportTipGenerator::calculateRoofAreas(const cura::SliceMeshStorage& m // -radius. This is intentional here, as support roof is still valid if only a part of the tip may reach it. Polygons forbidden_here = volumes_ .getAvoidance( - config.getRadius(0), + config_.getRadius(0), layer_idx, - (only_gracious || ! config.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, - config.support_rests_on_model, - ! xy_overrides) - .offset(-config.getRadius(0), ClipperLib::jtRound); + (only_gracious_ || ! config_.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, + config_.support_rests_on_model, + ! xy_overrides_) + .offset(-config_.getRadius(0), ClipperLib::jtRound); // todo Since arachnea the assumption that an area smaller then line_width is not printed is no longer true all such safeOffset should have config.support_line_width // replaced with another setting. It should still work in most cases, but it should be possible to create a situation where a overhang outset lags though a wall. I will // take a look at this later. Polygons full_overhang_area = TreeSupportUtils::safeOffsetInc( - mesh.full_overhang_areas[layer_idx + z_distance_delta].unionPolygons(dropped_overhangs[layer_idx]), - roof_outset, + mesh.full_overhang_areas[layer_idx + z_distance_delta_].unionPolygons(dropped_overhangs[layer_idx]), + roof_outset_, forbidden_here, - config.support_line_width, + config_.support_line_width, 0, 1, - config.support_line_distance / 2, - &config.simplifier); + config_.support_line_distance / 2, + &config_.simplifier); - for (LayerIndex dtt_roof = 0; dtt_roof < support_roof_layers && layer_idx - dtt_roof >= 1; dtt_roof++) + for (LayerIndex dtt_roof = 0; dtt_roof < support_roof_layers_ && layer_idx - dtt_roof >= 1; dtt_roof++) { const Polygons forbidden_next = volumes_ .getAvoidance( - config.getRadius(0), + config_.getRadius(0), layer_idx - (dtt_roof + 1), - (only_gracious || ! config.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, - config.support_rests_on_model, - ! xy_overrides) - .offset(-config.getRadius(0), ClipperLib::jtRound); + (only_gracious_ || ! config_.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, + config_.support_rests_on_model, + ! xy_overrides_) + .offset(-config_.getRadius(0), ClipperLib::jtRound); full_overhang_area = full_overhang_area.difference(forbidden_next); - if (force_minimum_roof_area) + if (force_minimum_roof_area_) { - full_overhang_area.removeSmallAreas(minimum_roof_area); + full_overhang_area.removeSmallAreas(minimum_roof_area_); } if (full_overhang_area.area() > EPSILON) @@ -548,9 +548,9 @@ void TreeSupportTipGenerator::calculateRoofAreas(const cura::SliceMeshStorage& m // with using the default mitered here. Could be that i just have not encountered an issue with it yet though. potential_support_roofs[layer_idx] = potential_support_roofs[layer_idx] .unionPolygons() - .offset(config.xy_min_distance) + .offset(config_.xy_min_distance) .unionPolygons() - .offset(-config.xy_min_distance) + .offset(-config_.xy_min_distance) .unionPolygons(potential_support_roofs[layer_idx]); }); @@ -567,28 +567,28 @@ void TreeSupportTipGenerator::calculateRoofAreas(const cura::SliceMeshStorage& m // -radius. This is intentional here, as support roof is still valid if only a part of the tip may reach it. Polygons forbidden_here = volumes_ .getAvoidance( - config.getRadius(0), + config_.getRadius(0), layer_idx, - (only_gracious || ! config.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, - config.support_rests_on_model, - ! xy_overrides) - .offset(-(config.getRadius(0)), ClipperLib::jtRound); + (only_gracious_ || ! config_.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, + config_.support_rests_on_model, + ! xy_overrides_) + .offset(-(config_.getRadius(0)), ClipperLib::jtRound); - if (! force_minimum_roof_area) + if (! force_minimum_roof_area_) { Polygons fuzzy_area = Polygons(); // the roof will be combined with roof above and below, to see if a part of this roof may be part of a valid roof further up/down. // This prevents the situation where a roof gets removed even tough its area would contribute to a (better) printable roof area further down. for (const LayerIndex layer_offset : ranges::views::iota( - -LayerIndex{ std::min(layer_idx, LayerIndex{ support_roof_layers }) }, - LayerIndex{ std::min(LayerIndex{ potential_support_roofs.size() - layer_idx }, LayerIndex{ support_roof_layers + 1 }) })) + -LayerIndex{ std::min(layer_idx, LayerIndex{ support_roof_layers_ }) }, + LayerIndex{ std::min(LayerIndex{ potential_support_roofs.size() - layer_idx }, LayerIndex{ support_roof_layers_ + 1 }) })) { - fuzzy_area.add(support_roof_drawn[layer_idx + layer_offset]); + fuzzy_area.add(support_roof_drawn_[layer_idx + layer_offset]); fuzzy_area.add(potential_support_roofs[layer_idx + layer_offset]); } fuzzy_area = fuzzy_area.unionPolygons(); - fuzzy_area.removeSmallAreas(std::max(minimum_roof_area, tip_roof_size)); + fuzzy_area.removeSmallAreas(std::max(minimum_roof_area_, tip_roof_size_)); for (Polygons potential_roof : potential_support_roofs[layer_idx].difference(forbidden_here).splitIntoParts()) { @@ -601,7 +601,7 @@ void TreeSupportTipGenerator::calculateRoofAreas(const cura::SliceMeshStorage& m else { Polygons valid_roof = potential_support_roofs[layer_idx].difference(forbidden_here); - valid_roof.removeSmallAreas(std::max(minimum_roof_area, tip_roof_size)); + valid_roof.removeSmallAreas(std::max(minimum_roof_area_, tip_roof_size_)); additional_support_roofs[layer_idx].add(valid_roof); } } @@ -612,7 +612,7 @@ void TreeSupportTipGenerator::calculateRoofAreas(const cura::SliceMeshStorage& m additional_support_roofs.size(), [&](const LayerIndex layer_idx) { - support_roof_drawn[layer_idx] = support_roof_drawn[layer_idx].unionPolygons(additional_support_roofs[layer_idx]); + support_roof_drawn_[layer_idx] = support_roof_drawn_[layer_idx].unionPolygons(additional_support_roofs[layer_idx]); }); } @@ -630,7 +630,7 @@ void TreeSupportTipGenerator::addPointAsInfluenceArea( const bool to_bp = p.second == LineStatus::TO_BP || p.second == LineStatus::TO_BP_SAFE; const bool gracious = to_bp || p.second == LineStatus::TO_MODEL_GRACIOUS || p.second == LineStatus::TO_MODEL_GRACIOUS_SAFE; const bool safe_radius = p.second == LineStatus::TO_BP_SAFE || p.second == LineStatus::TO_MODEL_GRACIOUS_SAFE; - if (! config.support_rests_on_model && ! to_bp) + if (! config_.support_rests_on_model && ! to_bp) { spdlog::warn("Tried to add an invalid support point"); return; @@ -643,25 +643,25 @@ void TreeSupportTipGenerator::addPointAsInfluenceArea( } Polygons area = circle.offset(0); { - std::lock_guard critical_section_movebounds(critical_move_bounds); - if (! already_inserted[insert_layer].count(p.first / ((config.min_radius + 1) / 10))) + std::lock_guard critical_section_movebounds(critical_move_bounds_); + if (! already_inserted_[insert_layer].count(p.first / ((config_.min_radius + 1) / 10))) { // Normalize the point a bit to also catch points which are so close that inserting it would achieve nothing. - already_inserted[insert_layer].emplace(p.first / ((config.min_radius + 1) / 10)); + already_inserted_[insert_layer].emplace(p.first / ((config_.min_radius + 1) / 10)); TreeSupportElement* elem = new TreeSupportElement( dtt, insert_layer, p.first, to_bp, gracious, - ! xy_overrides, + ! xy_overrides_, dont_move_until, roof, safe_radius, - force_tip_to_roof, + force_tip_to_roof_, skip_ovalisation, - support_tree_limit_branch_reach, - support_tree_branch_reach_limit); + support_tree_limit_branch_reach_, + support_tree_branch_reach_limit_); elem->area_ = new Polygons(area); for (Point2LL target : additional_ovalization_targets) @@ -687,7 +687,7 @@ void TreeSupportTipGenerator::addLinesAsInfluenceAreas( // Add tip area as roof (happens when minimum roof area > minimum tip area) if possible. This is required as there is no guarantee that if support_roof_wall_count == 0 that a // certain roof area will actually have lines. size_t dtt_roof_tip = 0; - if (config.support_roof_wall_count == 0) + if (config_.support_roof_wall_count == 0) { for (dtt_roof_tip = 0; dtt_roof_tip < roof_tip_layers && insert_layer_idx - dtt_roof_tip >= 1; dtt_roof_tip++) { @@ -696,10 +696,10 @@ void TreeSupportTipGenerator::addLinesAsInfluenceAreas( Polygon roof_circle; for (Point2LL corner : TreeSupportBaseCircle::getBaseCircle()) { - roof_circle.add(p.first + corner * std::max(config.min_radius / TreeSupportBaseCircle::base_radius, coord_t(1))); + roof_circle.add(p.first + corner * std::max(config_.min_radius / TreeSupportBaseCircle::base_radius, coord_t(1))); } Polygons area = roof_circle.offset(0); - return ! TreeSupportUtils::generateSupportInfillLines(area, config, true, insert_layer_idx - dtt_roof_tip, support_roof_line_distance, cross_fill_provider, true) + return ! TreeSupportUtils::generateSupportInfillLines(area, config_, true, insert_layer_idx - dtt_roof_tip, support_roof_line_distance_, cross_fill_provider_, true) .empty(); }; @@ -735,16 +735,16 @@ void TreeSupportTipGenerator::addLinesAsInfluenceAreas( Polygon roof_circle; for (Point2LL corner : TreeSupportBaseCircle::getBaseCircle()) { - roof_circle.add(p.first + corner * std::max(config.min_radius / TreeSupportBaseCircle::base_radius, coord_t(1))); + roof_circle.add(p.first + corner * std::max(config_.min_radius / TreeSupportBaseCircle::base_radius, coord_t(1))); } added_roofs.add(roof_circle); } } added_roofs = added_roofs.unionPolygons(); { - std::lock_guard critical_section_roof(critical_roof_tips); + std::lock_guard critical_section_roof(critical_roof_tips_); - roof_tips_drawn[insert_layer_idx - dtt_roof_tip].add(added_roofs); + roof_tips_drawn_[insert_layer_idx - dtt_roof_tip].add(added_roofs); } } } @@ -754,7 +754,7 @@ void TreeSupportTipGenerator::addLinesAsInfluenceAreas( // If a line consists of enough tips, the assumption is that it is not a single tip, but part of a simulated support pattern. // Ovalisation should be disabled if they may be placed close to each other to prevent tip-areas merging. If the tips has to turn into roof, the area is most likely not // large enough for this to cause issues. - const bool disable_ovalization = ! connect_points && config.min_radius < 3 * config.support_line_width && roof_tip_layers == 0 && dtt_roof_tip == 0; + const bool disable_ovalization = ! connect_points && config_.min_radius < 3 * config_.support_line_width && roof_tip_layers == 0 && dtt_roof_tip == 0; for (auto [idx, point_data] : line | ranges::views::enumerate) { std::vector additional_ovalization_targets; @@ -796,10 +796,10 @@ void TreeSupportTipGenerator::removeUselessAddedPoints( if (layer_idx + 1 < storage.support.supportLayers.size()) { std::vector to_be_removed; - Polygons roof_on_layer_above = use_fake_roof ? support_roof_drawn[layer_idx + 1] - : storage.support.supportLayers[layer_idx + 1].support_roof.unionPolygons(additional_support_areas[layer_idx + 1]); + Polygons roof_on_layer_above = use_fake_roof_ ? support_roof_drawn_[layer_idx + 1] + : storage.support.supportLayers[layer_idx + 1].support_roof.unionPolygons(additional_support_areas[layer_idx + 1]); Polygons roof_on_layer - = use_fake_roof ? support_roof_drawn[layer_idx] : storage.support.supportLayers[layer_idx].support_roof.unionPolygons(additional_support_areas[layer_idx]); + = use_fake_roof_ ? support_roof_drawn_[layer_idx] : storage.support.supportLayers[layer_idx].support_roof.unionPolygons(additional_support_areas[layer_idx]); for (TreeSupportElement* elem : move_bounds[layer_idx]) { @@ -814,7 +814,7 @@ void TreeSupportTipGenerator::removeUselessAddedPoints( // Remove branches should have interface above them, but dont. Should never happen. if (roof_on_layer_above.empty() || (! roof_on_layer_above.inside(elem->result_on_layer_) - && vSize2(from - elem->result_on_layer_) > config.getRadius(0) * config.getRadius(0) + FUDGE_LENGTH * FUDGE_LENGTH)) + && vSize2(from - elem->result_on_layer_) > config_.getRadius(0) * config_.getRadius(0) + FUDGE_LENGTH * FUDGE_LENGTH)) { to_be_removed.emplace_back(elem); spdlog::warn("Removing already placed tip that should have roof above it?"); @@ -843,37 +843,37 @@ void TreeSupportTipGenerator::generateTips( std::vector> new_tips(move_bounds.size()); const coord_t circle_length_to_half_linewidth_change - = config.min_radius < config.support_line_width ? config.min_radius / 2 : sqrt(square(config.min_radius) - square(config.min_radius - config.support_line_width / 2)); + = config_.min_radius < config_.support_line_width ? config_.min_radius / 2 : sqrt(square(config_.min_radius) - square(config_.min_radius - config_.support_line_width / 2)); // ^^^ As r*r=x*x+y*y (circle equation): If a circle with center at (0,0) the top most point is at (0,r) as in y=r. This calculates how far one has to move on the x-axis so // that y=r-support_line_width/2. // In other words how far does one need to move on the x-axis to be support_line_width/2 away from the circle line. As a circle is round this length is identical for every // axis as long as the 90� angle between both remains. - const coord_t extra_outset = std::max(coord_t(0), config.min_radius - config.support_line_width / 2) + (xy_overrides ? 0 : config.support_line_width / 2); + const coord_t extra_outset = std::max(coord_t(0), config_.min_radius - config_.support_line_width / 2) + (xy_overrides_ ? 0 : config_.support_line_width / 2); // ^^^ Extra support offset to compensate for larger tip radiis. Also outset a bit more when z overwrites xy, because supporting something with a part of a support line is // better than not supporting it at all. - if (support_roof_layers) + if (support_roof_layers_) { calculateRoofAreas(mesh); } cura::parallel_for( 1, - mesh.overhang_areas.size() - z_distance_delta, + mesh.overhang_areas.size() - z_distance_delta_, [&](const LayerIndex layer_idx) { - if (mesh.overhang_areas[layer_idx + z_distance_delta].empty() && (layer_idx + 1 >= support_roof_drawn.size() || support_roof_drawn[layer_idx + 1].empty())) + if (mesh.overhang_areas[layer_idx + z_distance_delta_].empty() && (layer_idx + 1 >= support_roof_drawn_.size() || support_roof_drawn_[layer_idx + 1].empty())) { return; // This is a continue if imagined in a loop context. } Polygons relevant_forbidden = volumes_.getAvoidance( - config.getRadius(0), + config_.getRadius(0), layer_idx, - (only_gracious || ! config.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, - config.support_rests_on_model, - ! xy_overrides); + (only_gracious_ || ! config_.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, + config_.support_rests_on_model, + ! xy_overrides_); // ^^^ Take the least restrictive avoidance possible relevant_forbidden = relevant_forbidden.offset(EPSILON) @@ -881,17 +881,17 @@ void TreeSupportTipGenerator::generateTips( std::function generateLines = [&](const Polygons& area, bool roof, LayerIndex generate_layer_idx) { - coord_t upper_line_distance = support_supporting_branch_distance; - coord_t line_distance = std::max(roof ? support_roof_line_distance : support_tree_branch_distance, upper_line_distance); + coord_t upper_line_distance = support_supporting_branch_distance_; + coord_t line_distance = std::max(roof ? support_roof_line_distance_ : support_tree_branch_distance_, upper_line_distance); return TreeSupportUtils::generateSupportInfillLines( area, - config, - roof && ! use_fake_roof, + config_, + roof && ! use_fake_roof_, generate_layer_idx, line_distance, - cross_fill_provider, - roof && ! use_fake_roof, + cross_fill_provider_, + roof && ! use_fake_roof_, line_distance == upper_line_distance); }; @@ -902,14 +902,14 @@ void TreeSupportTipGenerator::generateTips( // horizontal expansion and it would not have a roof if the overhang is offset by support roof horizontal expansion instead. (At least this is the current behavior // of the regular support) - Polygons core_overhang = mesh.overhang_areas[layer_idx + z_distance_delta]; + Polygons core_overhang = mesh.overhang_areas[layer_idx + z_distance_delta_]; - if (support_roof_layers && layer_idx + 1 < support_roof_drawn.size()) + if (support_roof_layers_ && layer_idx + 1 < support_roof_drawn_.size()) { - core_overhang = core_overhang.difference(support_roof_drawn[layer_idx]); - for (Polygons roof_part : support_roof_drawn[layer_idx + 1] - .difference(support_roof_drawn[layer_idx]) + core_overhang = core_overhang.difference(support_roof_drawn_[layer_idx]); + for (Polygons roof_part : support_roof_drawn_[layer_idx + 1] + .difference(support_roof_drawn_[layer_idx]) .splitIntoParts(true)) // If there is a roof, the roof will be one layer above the tips. { //^^^Technically one should also subtract the avoidance of radius 0 (similarly how calculated in calculateRoofArea), as there can be some rounding errors @@ -920,65 +920,65 @@ void TreeSupportTipGenerator::generateTips( Polygons overhang_regular = TreeSupportUtils::safeOffsetInc( core_overhang, - support_outset, + support_outset_, relevant_forbidden, - config.min_radius * 1.75 + config.xy_min_distance, + config_.min_radius * 1.75 + config_.xy_min_distance, 0, 1, - config.support_line_distance / 2, - &config.simplifier); + config_.support_line_distance / 2, + &config_.simplifier); Polygons remaining_overhang - = core_overhang.offset(support_outset).difference(overhang_regular.offset(config.support_line_width * 0.5)).intersection(relevant_forbidden); + = core_overhang.offset(support_outset_).difference(overhang_regular.offset(config_.support_line_width * 0.5)).intersection(relevant_forbidden); // Offset ensures that areas that could be supported by a part of a support line, are not considered unsupported overhang coord_t extra_total_offset_acc = 0; // Offset the area to compensate for large tip radiis. Offset happens in multiple steps to ensure the tip is as close to the original overhang as possible. - while (extra_total_offset_acc + config.support_line_width / 8 + while (extra_total_offset_acc + config_.support_line_width / 8 < extra_outset) //+mesh_config.support_line_width / 8 to avoid calculating very small (useless) offsets because of rounding errors. { - coord_t offset_current_step = extra_total_offset_acc + 2 * config.support_line_width > config.min_radius - ? std::min(config.support_line_width / 8, extra_outset - extra_total_offset_acc) + coord_t offset_current_step = extra_total_offset_acc + 2 * config_.support_line_width > config_.min_radius + ? std::min(config_.support_line_width / 8, extra_outset - extra_total_offset_acc) : std::min(circle_length_to_half_linewidth_change, extra_outset - extra_total_offset_acc); extra_total_offset_acc += offset_current_step; Polygons overhang_offset = TreeSupportUtils::safeOffsetInc( overhang_regular, 1.5 * extra_total_offset_acc, volumes_.getCollision(0, layer_idx, true), - config.xy_min_distance + config.support_line_width, + config_.xy_min_distance + config_.support_line_width, 0, 1, - config.support_line_distance / 2, - &config.simplifier); - remaining_overhang = remaining_overhang.difference(overhang_offset.unionPolygons(support_roof_drawn[layer_idx].offset(1.5 * extra_total_offset_acc))) + config_.support_line_distance / 2, + &config_.simplifier); + remaining_overhang = remaining_overhang.difference(overhang_offset.unionPolygons(support_roof_drawn_[layer_idx].offset(1.5 * extra_total_offset_acc))) .unionPolygons(); // overhang_offset is combined with roof, as all area that has a roof, is already supported by said roof. Polygons next_overhang = TreeSupportUtils::safeOffsetInc( remaining_overhang, extra_total_offset_acc, volumes_.getCollision(0, layer_idx, true), - config.xy_min_distance + config.support_line_width, + config_.xy_min_distance + config_.support_line_width, 0, 1, - config.support_line_distance / 2, - &config.simplifier); + config_.support_line_distance / 2, + &config_.simplifier); overhang_regular = overhang_regular.unionPolygons(next_overhang.difference(relevant_forbidden)); } // If the xy distance overrides the z distance, some support needs to be inserted further down. //=> Analyze which support points do not fit on this layer and check if they will fit a few layers down // (while adding them an infinite amount of layers down would technically be closer the setting description, it would not produce reasonable results. ) - if (xy_overrides) + if (xy_overrides_) { for (Polygons& remaining_overhang_part : remaining_overhang.splitIntoParts(false)) { - if (remaining_overhang_part.area() <= MM2_2INT(minimum_support_area)) + if (remaining_overhang_part.area() <= MM2_2INT(minimum_support_area_)) { continue; } std::vector overhang_lines; - Polygons polylines = ensureMaximumDistancePolyline(generateLines(remaining_overhang_part, false, layer_idx), config.min_radius, 1, false); + Polygons polylines = ensureMaximumDistancePolyline(generateLines(remaining_overhang_part, false, layer_idx), config_.min_radius, 1, false); // ^^^ Support_line_width to form a line here as otherwise most will be unsupported. // Technically this violates branch distance, but not only is this the only reasonable choice, // but it ensures consistent behavior as some infill patterns generate each line segment as its own polyline part causing a similar line forming behavior. @@ -986,7 +986,7 @@ void TreeSupportTipGenerator::generateTips( if (polylines.pointCount() <= 3) { // Add the outer wall to ensure it is correct supported instead. - polylines = ensureMaximumDistancePolyline(TreeSupportUtils::toPolylines(remaining_overhang_part), connect_length, 3, true); + polylines = ensureMaximumDistancePolyline(TreeSupportUtils::toPolylines(remaining_overhang_part), connect_length_, 3, true); } for (auto line : polylines) @@ -999,15 +999,15 @@ void TreeSupportTipGenerator::generateTips( overhang_lines.emplace_back(res_line); } - for (size_t lag_ctr = 1; lag_ctr <= max_overhang_insert_lag && ! overhang_lines.empty() && layer_idx - coord_t(lag_ctr) >= 1; lag_ctr++) + for (size_t lag_ctr = 1; lag_ctr <= max_overhang_insert_lag_ && ! overhang_lines.empty() && layer_idx - coord_t(lag_ctr) >= 1; lag_ctr++) { // get least restricted avoidance for layer_idx-lag_ctr Polygons relevant_forbidden_below = volumes_.getAvoidance( - config.getRadius(0), + config_.getRadius(0), layer_idx - lag_ctr, - (only_gracious || ! config.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, - config.support_rests_on_model, - ! xy_overrides); + (only_gracious_ || ! config_.support_rests_on_model) ? AvoidanceType::FAST : AvoidanceType::COLLISION, + config_.support_rests_on_model, + ! xy_overrides_); // It is not required to offset the forbidden area here as the points won't change: // If points here are not inside the forbidden area neither will they be later when placing these points, as these are the same points. std::function)> evaluatePoint = [&](std::pair p) @@ -1015,12 +1015,12 @@ void TreeSupportTipGenerator::generateTips( return relevant_forbidden_below.inside(p.first, true); }; - if (support_roof_layers) + if (support_roof_layers_) { // Remove all points that are for some reason part of a roof area, as the point is already supported by roof std::function)> evaluatePartOfRoof = [&](std::pair p) { - return support_roof_drawn[layer_idx - lag_ctr].inside(p.first, true); + return support_roof_drawn_[layer_idx - lag_ctr].inside(p.first, true); }; overhang_lines = splitLines(overhang_lines, evaluatePartOfRoof).second; @@ -1034,16 +1034,16 @@ void TreeSupportTipGenerator::generateTips( addLinesAsInfluenceAreas( new_tips, fresh_valid_points, - (force_tip_to_roof && lag_ctr <= support_roof_layers) ? support_roof_layers : 0, + (force_tip_to_roof_ && lag_ctr <= support_roof_layers_) ? support_roof_layers_ : 0, layer_idx - lag_ctr, false, - support_roof_layers, + support_roof_layers_, false); } } } - overhang_regular.removeSmallAreas(minimum_support_area); + overhang_regular.removeSmallAreas(minimum_support_area_); for (Polygons support_part : overhang_regular.splitIntoParts(true)) { @@ -1054,7 +1054,7 @@ void TreeSupportTipGenerator::generateTips( { const bool roof_allowed_for_this_part = overhang_pair.second; Polygons overhang_outset = overhang_pair.first; - const size_t min_support_points = std::max(coord_t(1), std::min(coord_t(EPSILON), overhang_outset.polygonLength() / connect_length)); + const size_t min_support_points = std::max(coord_t(1), std::min(coord_t(EPSILON), overhang_outset.polygonLength() / connect_length_)); std::vector overhang_lines; bool only_lines = true; @@ -1063,9 +1063,9 @@ void TreeSupportTipGenerator::generateTips( // todo can cause inconsistent support density if a line exactly aligns with the model Polygons polylines = ensureMaximumDistancePolyline( generateLines(overhang_outset, roof_allowed_for_this_part, layer_idx + roof_allowed_for_this_part), - ! roof_allowed_for_this_part ? config.min_radius * 2 - : use_fake_roof ? support_supporting_branch_distance - : connect_length, + ! roof_allowed_for_this_part ? config_.min_radius * 2 + : use_fake_roof_ ? support_supporting_branch_distance_ + : connect_length_, 1, false); @@ -1080,33 +1080,33 @@ void TreeSupportTipGenerator::generateTips( only_lines = false; // Add the outer wall (of the overhang) to ensure it is correct supported instead. // Try placing the support points in a way that they fully support the outer wall, instead of just the with half of the support line width. - Polygons reduced_overhang_outset = overhang_outset.offset(-config.support_line_width / 2.2); + Polygons reduced_overhang_outset = overhang_outset.offset(-config_.support_line_width / 2.2); // ^^^ It's assumed that even small overhangs are over one line width wide, so lets try to place the support points in a way that the full support area // generated from them will support the overhang. // (If this is not done it may only be half). This WILL NOT be the case when supporting an angle of about < 60� so there is a fallback, as some support is // better than none.) if (! reduced_overhang_outset.empty() - && overhang_outset.difference(reduced_overhang_outset.offset(std::max(config.support_line_width, connect_length))).area() < 1) + && overhang_outset.difference(reduced_overhang_outset.offset(std::max(config_.support_line_width, connect_length_))).area() < 1) { - polylines = ensureMaximumDistancePolyline(TreeSupportUtils::toPolylines(reduced_overhang_outset), connect_length, min_support_points, true); + polylines = ensureMaximumDistancePolyline(TreeSupportUtils::toPolylines(reduced_overhang_outset), connect_length_, min_support_points, true); } else { - polylines = ensureMaximumDistancePolyline(TreeSupportUtils::toPolylines(overhang_outset), connect_length, min_support_points, true); + polylines = ensureMaximumDistancePolyline(TreeSupportUtils::toPolylines(overhang_outset), connect_length_, min_support_points, true); } } if (roof_allowed_for_this_part) // Some roof may only be supported by a part of a tip { - polylines = TreeSupportUtils::movePointsOutside(polylines, relevant_forbidden, config.getRadius(0) + FUDGE_LENGTH / 2); + polylines = TreeSupportUtils::movePointsOutside(polylines, relevant_forbidden, config_.getRadius(0) + FUDGE_LENGTH / 2); } overhang_lines = convertLinesToInternal(polylines, layer_idx); if (overhang_lines.empty()) // some error handling and logging { - Polygons enlarged_overhang_outset = overhang_outset.offset(config.getRadius(0) + FUDGE_LENGTH / 2, ClipperLib::jtRound).difference(relevant_forbidden); - polylines = ensureMaximumDistancePolyline(TreeSupportUtils::toPolylines(enlarged_overhang_outset), connect_length, min_support_points, true); + Polygons enlarged_overhang_outset = overhang_outset.offset(config_.getRadius(0) + FUDGE_LENGTH / 2, ClipperLib::jtRound).difference(relevant_forbidden); + polylines = ensureMaximumDistancePolyline(TreeSupportUtils::toPolylines(enlarged_overhang_outset), connect_length_, min_support_points, true); overhang_lines = convertLinesToInternal(polylines, layer_idx); if (! overhang_lines.empty()) @@ -1119,11 +1119,11 @@ void TreeSupportTipGenerator::generateTips( } } - size_t dont_move_for_layers = support_roof_layers ? (force_tip_to_roof ? support_roof_layers : (roof_allowed_for_this_part ? 0 : support_roof_layers)) : 0; + size_t dont_move_for_layers = support_roof_layers_ ? (force_tip_to_roof_ ? support_roof_layers_ : (roof_allowed_for_this_part ? 0 : support_roof_layers_)) : 0; addLinesAsInfluenceAreas( new_tips, overhang_lines, - force_tip_to_roof ? support_roof_layers : 0, + force_tip_to_roof_ ? support_roof_layers_ : 0, layer_idx, roof_allowed_for_this_part, dont_move_for_layers, @@ -1133,20 +1133,20 @@ void TreeSupportTipGenerator::generateTips( cura::parallel_for( 0, - support_roof_drawn.size(), + support_roof_drawn_.size(), [&](const LayerIndex layer_idx) { // Sometimes roofs could be empty as the pattern does not generate lines if the area is narrow enough. // If there is a roof could have zero lines in its area (as it has no wall), rand a support area would very likely be printed (because there are walls for the support // areas), replace non printable roofs with support - if (! use_fake_roof && config.support_wall_count > 0 && config.support_roof_wall_count == 0) + if (! use_fake_roof_ && config_.support_wall_count > 0 && config_.support_roof_wall_count == 0) { - for (auto roof_area : support_roof_drawn[layer_idx].unionPolygons(roof_tips_drawn[layer_idx]).splitIntoParts()) + for (auto roof_area : support_roof_drawn_[layer_idx].unionPolygons(roof_tips_drawn_[layer_idx]).splitIntoParts()) { // technically there is no guarantee that a drawn roof tip has lines, as it could be unioned with another roof area that has, but this has to be enough // hopefully. if (layer_idx < additional_support_areas.size() - && TreeSupportUtils::generateSupportInfillLines(roof_area, config, true, layer_idx, support_roof_line_distance, cross_fill_provider, false).empty()) + && TreeSupportUtils::generateSupportInfillLines(roof_area, config_, true, layer_idx, support_roof_line_distance_, cross_fill_provider_, false).empty()) { additional_support_areas[layer_idx].add(roof_area); } @@ -1161,31 +1161,31 @@ void TreeSupportTipGenerator::generateTips( } else { - if (use_fake_roof) + if (use_fake_roof_) { storage.support.supportLayers[layer_idx] - .fillInfillParts(layer_idx, support_roof_drawn, config.support_line_width, support_roof_line_distance, config.maximum_move_distance); + .fillInfillParts(layer_idx, support_roof_drawn_, config_.support_line_width, support_roof_line_distance_, config_.maximum_move_distance); placed_support_lines_support_areas[layer_idx].add(TreeSupportUtils::generateSupportInfillLines( - support_roof_drawn[layer_idx], - config, + support_roof_drawn_[layer_idx], + config_, false, layer_idx, - support_roof_line_distance, - cross_fill_provider, + support_roof_line_distance_, + cross_fill_provider_, false) - .offsetPolyLine(config.support_line_width / 2)); + .offsetPolyLine(config_.support_line_width / 2)); } else { - storage.support.supportLayers[layer_idx].support_roof.add(support_roof_drawn[layer_idx]); - storage.support.supportLayers[layer_idx].support_roof = storage.support.supportLayers[layer_idx].support_roof.unionPolygons(roof_tips_drawn[layer_idx]); + storage.support.supportLayers[layer_idx].support_roof.add(support_roof_drawn_[layer_idx]); + storage.support.supportLayers[layer_idx].support_roof = storage.support.supportLayers[layer_idx].support_roof.unionPolygons(roof_tips_drawn_[layer_idx]); } } }); cura::parallel_for( 1, - mesh.overhang_areas.size() - z_distance_delta, + mesh.overhang_areas.size() - z_distance_delta_, [&](const LayerIndex layer_idx) { if (layer_idx > 0) diff --git a/src/pathPlanning/Comb.cpp b/src/pathPlanning/Comb.cpp index be204cb197..d422f18b2e 100644 --- a/src/pathPlanning/Comb.cpp +++ b/src/pathPlanning/Comb.cpp @@ -68,6 +68,7 @@ Comb::Comb( coord_t move_inside_distance) : storage_(storage) , layer_nr_(layer_nr) + , travel_avoid_distance_(travel_avoid_distance) , offset_from_outlines_(comb_boundary_offset) // between second wall and infill / other walls , max_moveInside_distance2_(offset_from_outlines_ * offset_from_outlines_) , offset_from_inside_to_outside_(offset_from_outlines_ + travel_avoid_distance) @@ -81,7 +82,6 @@ Comb::Comb( , inside_loc_to_line_minimum_(PolygonUtils::createLocToLineGrid(boundary_inside_minimum_, comb_boundary_offset)) , inside_loc_to_line_optimal_(PolygonUtils::createLocToLineGrid(boundary_inside_optimal_, comb_boundary_offset)) , move_inside_distance_(move_inside_distance) - , travel_avoid_distance_(travel_avoid_distance) { }