From 3773de29575acb5880cbc9d7a1d6364c2ec01052 Mon Sep 17 00:00:00 2001 From: PavelMikus <pavel.mikus.mail@seznam.cz> Date: Tue, 16 Aug 2022 16:14:22 +0200 Subject: [PATCH] hardcode overhang angles, remove volumetric filtering (does not work correctly) --- src/libslic3r/PrintObject.cpp | 2 +- src/libslic3r/SupportSpotsGenerator.cpp | 11 +++++++--- src/libslic3r/SupportSpotsGenerator.hpp | 22 +++++++++++--------- src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp | 2 ++ 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 256cf7027..c96e23fe0 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -423,7 +423,7 @@ void PrintObject::generate_support_spots() std::all_of(this->model_object()->volumes.begin(), this->model_object()->volumes.end(), [](const ModelVolume* mv){return mv->supported_facets.empty();}) ) { - SupportSpotsGenerator::Params params{90.001f - this->m_config.support_material_threshold, this->print()->m_config.filament_type.values}; + SupportSpotsGenerator::Params params{this->print()->m_config.filament_type.values}; SupportSpotsGenerator::Issues issues = SupportSpotsGenerator::full_search(this, params); auto obj_transform = this->trafo_centered(); for (ModelVolume *model_volume : this->model_object()->volumes) { diff --git a/src/libslic3r/SupportSpotsGenerator.cpp b/src/libslic3r/SupportSpotsGenerator.cpp index 518c8cacc..c7fd7e882 100644 --- a/src/libslic3r/SupportSpotsGenerator.cpp +++ b/src/libslic3r/SupportSpotsGenerator.cpp @@ -364,6 +364,8 @@ void check_extrusion_entity_stability(const ExtrusionEntity *entity, return Vec3f(point.x(), point.y(), layer_z); }; float overhang_dist = tan(params.overhang_angle_deg * PI / 180.0f)*layer_region->layer()->height; + float min_malformation_dist = tan(params.malformation_angle_span_deg.first * PI / 180.0f)*layer_region->layer()->height; + float max_malformation_dist = tan(params.malformation_angle_span_deg.second * PI / 180.0f)*layer_region->layer()->height; Points points { }; entity->collect_points(points); @@ -387,8 +389,7 @@ void check_extrusion_entity_stability(const ExtrusionEntity *entity, ExtrusionPropertiesAccumulator bridging_acc { }; ExtrusionPropertiesAccumulator malformation_acc { }; - bridging_acc.add_distance(params.bridge_distance + 1.0f); // Initialise unsupported distance with larger than tolerable distance -> - // -> it prevents extruding perimeter starts and short loops into air. + bridging_acc.add_distance(params.bridge_distance); const float flow_width = get_flow_width(layer_region, entity->role()); for (size_t line_idx = 0; line_idx < lines.size(); ++line_idx) { @@ -430,7 +431,7 @@ void check_extrusion_entity_stability(const ExtrusionEntity *entity, const ExtrusionLine &nearest_line = prev_layer_lines.get_line(nearest_line_idx); current_line.malformation += 0.9 * nearest_line.malformation; } - if (dist_from_prev_layer > overhang_dist) { + if (dist_from_prev_layer > min_malformation_dist && dist_from_prev_layer < max_malformation_dist) { malformation_acc.add_distance(current_line.len); current_line.malformation += layer_region->layer()->height * (0.5f + 1.5f * (malformation_acc.max_curvature / PI) * gauss(malformation_acc.distance, 5.0f, 1.0f, 0.2f)); @@ -652,6 +653,10 @@ public: island.sticking_second_moment_of_area_covariance_accumulator; } + float get_volume() const { + return volume; + } + void add(const ObjectPart &other) { this->volume_centroid_accumulator += other.volume_centroid_accumulator; this->volume += other.volume; diff --git a/src/libslic3r/SupportSpotsGenerator.hpp b/src/libslic3r/SupportSpotsGenerator.hpp index b139ae098..a88b7a7be 100644 --- a/src/libslic3r/SupportSpotsGenerator.hpp +++ b/src/libslic3r/SupportSpotsGenerator.hpp @@ -9,15 +9,16 @@ namespace Slic3r { namespace SupportSpotsGenerator { struct Params { - Params(float overhang_angle_deg, const std::vector<std::string>& filament_types) : overhang_angle_deg(overhang_angle_deg) - { + Params(const std::vector<std::string> &filament_types) { if (filament_types.size() > 1) { - BOOST_LOG_TRIVIAL(warning) << "SupportSpotsGenerator does not currently handle different materials properly, only first will be used"; + BOOST_LOG_TRIVIAL(warning) + << "SupportSpotsGenerator does not currently handle different materials properly, only first will be used"; } if (filament_types.empty() || filament_types[0].empty()) { - BOOST_LOG_TRIVIAL(error) << "SupportSpotsGenerator error: empty filament_type"; + BOOST_LOG_TRIVIAL(error) + << "SupportSpotsGenerator error: empty filament_type"; filament_type = std::string("PLA"); - }else { + } else { filament_type = filament_types[0]; } } @@ -25,22 +26,23 @@ struct Params { // the algorithm should use the following units for all computations: distance [mm], mass [g], time [s], force [g*mm/s^2] const float bridge_distance = 15.0f; //mm const float bridge_distance_decrease_by_curvature_factor = 5.0f; // allowed bridge distance = bridge_distance / (this factor * (curvature / PI) ) - const float overhang_angle_deg = 50.0f; + const float overhang_angle_deg = 80.0f; + const std::pair<float,float> malformation_angle_span_deg = std::pair<float, float> { 45.0f, 80.0f }; const float min_distance_between_support_points = 3.0f; //mm const float support_points_interface_radius = 1.5f; // mm std::string filament_type; const float gravity_constant = 9806.65f; // mm/s^2; gravity acceleration on Earth's surface, algorithm assumes that printer is in upwards position. - const float max_acceleration = 9*1000.0f; // mm/s^2 ; max acceleration of object (bed) in XY (NOTE: The max hit is received by the object in the jerk phase, so the usual machine limits are too low) - const float filament_density = 1.25e-3f ; // g/mm^3 ; Common filaments are very lightweight, so precise number is not that important + const float max_acceleration = 9 * 1000.0f; // mm/s^2 ; max acceleration of object (bed) in XY (NOTE: The max hit is received by the object in the jerk phase, so the usual machine limits are too low) + const float filament_density = 1.25e-3f; // g/mm^3 ; Common filaments are very lightweight, so precise number is not that important const float material_yield_strength = 33.0f * 1e6f; // (g*mm/s^2)/mm^2; 33 MPa is yield strength of ABS, which has the lowest yield strength from common materials. const float standard_extruder_conflict_force = 20.0f * gravity_constant; // force that can occasionally push the model due to various factors (filament leaks, small curling, ... ); const float malformations_additive_conflict_extruder_force = 300.0f * gravity_constant; // for areas with possible high layered curled filaments // MPa * 1e^6 = (g*mm/s^2)/mm^2 = g/(mm*s^2); yield strength of the bed surface float get_bed_adhesion_yield_strength() const { - if (filament_type == "PLA"){ + if (filament_type == "PLA") { return 0.018f * 1e6f; } else if (filament_type == "PET" || filament_type == "PETG") { return 0.3f * 1e6f; @@ -51,7 +53,7 @@ struct Params { }; struct SupportPoint { - SupportPoint(const Vec3f &position, float force, const Vec3f& direction); + SupportPoint(const Vec3f &position, float force, const Vec3f &direction); Vec3f position; float force; Vec3f direction; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp index c193dbf90..2ed7ae679 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp @@ -332,6 +332,7 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l } update_model_object(); + this->waiting_for_autogenerated_supports = false; m_parent.set_as_dirty(); } @@ -379,6 +380,7 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool block) Plater::TakeSnapshot snapshot(wxGetApp().plater(), block ? _L("Block supports by angle") : _L("Add supports by angle")); update_model_object(); + this->waiting_for_autogenerated_supports = false; m_parent.set_as_dirty(); }