local issues support generator fix

This commit is contained in:
PavelMikus 2023-01-11 12:44:42 +01:00 committed by Pavel Mikuš
parent 727e7cc4f1
commit d20f880124
5 changed files with 24 additions and 21 deletions

View File

@ -67,8 +67,8 @@ public:
class CurvatureEstimator
{
static const size_t sliders_count = 2;
SlidingWindowCurvatureAccumulator sliders[sliders_count] = {{4.0}, {10.0}};
static const size_t sliders_count = 3;
SlidingWindowCurvatureAccumulator sliders[sliders_count] = {{1.0},{4.0}, {10.0}};
public:
void add_point(float distance, float angle)

View File

@ -222,7 +222,6 @@ public:
all_regions.clear();
layer_ranges.clear();
cached_volume_ids.clear();
generated_support_points.reset();
}
private:

View File

@ -780,6 +780,9 @@ bool PrintObject::invalidate_state_by_config_options(
bool PrintObject::invalidate_step(PrintObjectStep step)
{
bool invalidated = Inherited::invalidate_step(step);
if (invalidated && step == posSupportSpotsSearch) {
this->m_shared_regions->generated_support_points.reset();
}
// propagate to dependent steps
if (step == posPerimeters) {

View File

@ -33,8 +33,8 @@
#include "libslic3r/ClipperUtils.hpp"
#include "Geometry/ConvexHull.hpp"
#define DETAILED_DEBUG_LOGS
#define DEBUG_FILES
// #define DETAILED_DEBUG_LOGS
// #define DEBUG_FILES
#ifdef DEBUG_FILES
#include <boost/nowide/cstdio.hpp>
@ -265,24 +265,23 @@ std::vector<ExtrusionLine> check_extrusion_entity_stability(const ExtrusionEntit
float sign = (prev_layer_boundary.distance_from_lines<true>(curr_point.position) + 0.5f * flow_width) < 0.0f ? -1.0f : 1.0f;
curr_point.distance *= sign;
float max_bridge_len = params.bridge_distance / (1.0f + std::abs(curr_point.curvature));
if (curr_point.distance > 0.9f * flow_width) {
line_out.form_quality = 0.7f;
if (curr_point.distance > 2.0f * flow_width) {
line_out.form_quality = 0.8f;
bridged_distance += line_len;
// if unsupported distance is larger than bridge distance linearly decreased by curvature, enforce supports.
bool in_layer_dist_condition = bridged_distance >
params.bridge_distance / (1.0f + std::abs(curr_point.curvature) *
params.bridge_distance_decrease_by_curvature_factor);
if (in_layer_dist_condition) {
if (bridged_distance > max_bridge_len) {
line_out.support_point_generated = true;
bridged_distance = 0.0f;
}
} else if (curr_point.distance > flow_width * (0.8 + std::clamp(curr_point.curvature, -0.2f, 0.2f))) {
} else if (curr_point.distance > flow_width * (1.0 + std::clamp(curr_point.curvature, -0.30f, 0.20f))) {
bridged_distance += line_len;
line_out.form_quality = nearest_prev_layer_line.form_quality - std::abs(curr_point.curvature);
if (line_out.form_quality < 0) {
line_out.form_quality = nearest_prev_layer_line.form_quality - 0.3f;
if (line_out.form_quality < 0 && bridged_distance > max_bridge_len) {
line_out.support_point_generated = true;
line_out.form_quality = 0.7f;
line_out.form_quality = 0.5f;
bridged_distance = 0.0f;
}
} else {
bridged_distance = 0.0f;
@ -773,14 +772,17 @@ SupportPoints check_stability(const PrintObject *po, const PrintTryCancel& cance
// and the support presence grid and add the point to the issues.
auto reckon_new_support_point = [&part, &weakest_conn, &supp_points, &supports_presence_grid, &params,
&layer_idx](const Vec3f &support_point, float force, const Vec2f &dir) {
if (supports_presence_grid.position_taken(support_point) || layer_idx <= 1) { return; }
if ((supports_presence_grid.position_taken(support_point) && force > 0) || layer_idx <= 1) {
return;
}
float area = params.support_points_interface_radius * params.support_points_interface_radius * float(PI);
part.add_support_point(support_point, area);
float radius = params.support_points_interface_radius;
supp_points.emplace_back(support_point, force, radius, dir);
supports_presence_grid.take_position(support_point);
if (force > 0) {
supports_presence_grid.take_position(support_point);
}
if (weakest_conn.area > EPSILON) { // Do not add it to the weakest connection if it is not valid - does not exist
weakest_conn.area += area;
weakest_conn.centroid_accumulator += support_point * area;

View File

@ -30,14 +30,13 @@ 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 = 12.0f; //mm
const float bridge_distance_decrease_by_curvature_factor = 10.0f; // allowed bridge distance = bridge_distance / (1 + this factor * curvature )
const std::pair<float,float> malformation_distance_factors = std::pair<float, float> { 0.4, 1.2 };
const float max_curled_height_factor = 10.0f;
const float min_distance_between_support_points = 3.0f; //mm
const float support_points_interface_radius = 1.5f; // mm
const float connections_min_considerable_area = 1.5f; //mm^2
const float min_distance_to_allow_local_supports = 2.0f; //mm
const float min_distance_to_allow_local_supports = 1.0f; //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.