Skip to content

Commit

Permalink
Fixed branches generating not supporting overhang when z overrides xy…
Browse files Browse the repository at this point in the history
… distance
  • Loading branch information
ThomasRahm committed Apr 3, 2022
1 parent 143714a commit 8a75061
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/TreeSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ void TreeSupport::generateInitalAreas(const SliceMeshStorage& mesh, std::vector<
const coord_t circle_length_to_half_linewidth_change = mesh_config.min_radius < mesh_config.support_line_width ? mesh_config.min_radius / 2 : sqrt(square(mesh_config.min_radius) - square(mesh_config.min_radius - mesh_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 support_outset = mesh.settings.get<coord_t>("support_offset");
const coord_t roof_outset = mesh.settings.get<coord_t>("support_roof_offset");
const coord_t extra_outset = std::max(coord_t(0), mesh_config.min_radius - mesh_config.support_line_width) + (xy_overrides ? 0 : mesh_config.support_line_width); // 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.
const bool force_tip_to_roof = (mesh_config.min_radius * mesh_config.min_radius * M_PI > minimum_roof_area*(1000*1000)) && roof_enabled;
const coord_t extra_outset = std::max(coord_t(0), mesh_config.min_radius - mesh_config.support_line_width) + (xy_overrides ? 0 : mesh_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.
const bool force_tip_to_roof = (mesh_config.min_radius * mesh_config.min_radius * M_PI > minimum_roof_area * (1000 * 1000)) && roof_enabled;
const double support_overhang_angle = mesh.settings.get<AngleRadians>("support_angle");
const coord_t max_overhang_speed = (support_overhang_angle < TAU / 4) ? (coord_t)(tan(support_overhang_angle) * mesh_config.layer_height) : std::numeric_limits<coord_t>::max();
const size_t max_overhang_insert_lag = std::max((size_t)round_up_divide(mesh_config.xy_distance, max_overhang_speed / 2), 2 * mesh_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.
Expand Down Expand Up @@ -825,17 +825,16 @@ void TreeSupport::generateInitalAreas(const SliceMeshStorage& mesh, std::vector<
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 < extra_outset)
while (extra_total_offset_acc + mesh_config.support_line_width / 8 < extra_outset) //+mesh_config.support_line_width / 80 to avoid calculating very small (useless) offsets because of rounding errors.
{
coord_t offset_current_step = extra_total_offset_acc + 2 * mesh_config.support_line_width > mesh_config.min_radius ? mesh_config.support_line_width / 8 : std::min(circle_length_to_half_linewidth_change, extra_outset - extra_total_offset_acc);
coord_t offset_current_step = extra_total_offset_acc + 2 * mesh_config.support_line_width > mesh_config.min_radius ? std::min(mesh_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 = safeOffsetInc(overhang_regular, 1.5 * extra_total_offset_acc, volumes_.getCollision(0, layer_idx, true), mesh_config.xy_min_distance + mesh_config.support_line_width, mesh_config.xy_min_distance + mesh_config.support_line_width, 1);
remaining_overhang = remaining_overhang.difference(overhang_offset).unionPolygons();
Polygons next_overhang = safeOffsetInc(remaining_overhang, extra_total_offset_acc, volumes_.getCollision(0, layer_idx, true), mesh_config.xy_min_distance + mesh_config.support_line_width, mesh_config.xy_min_distance + mesh_config.support_line_width, 1);
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 the setting description, it would not produce reasonable results. )
if (xy_overrides)
Expand Down

0 comments on commit 8a75061

Please sign in to comment.