FIX: scarf angle only check seam point angle
Jira: 6681 Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: I2d7a3e76c2a307bef8d6816814e7fef4bb6909ff
This commit is contained in:
parent
dacd176962
commit
60bc535e59
|
@ -426,8 +426,8 @@ double ExtrusionLoop::min_mm3_per_mm() const
|
|||
}
|
||||
|
||||
// Orca: This function is used to check if the loop is smooth(continuous) or not.
|
||||
// TODO: the main logic is largly copied from the calculate_polygon_angles_at_vertices function in SeamPlacer file. Need to refactor the code in the future.
|
||||
bool ExtrusionLoop::is_smooth(double angle_threshold, double min_arm_length) const
|
||||
//BBS: only check angle of seam point while the seam has been decided.
|
||||
bool ExtrusionLoop::check_seam_point_angle(double angle_threshold, double min_arm_length) const
|
||||
{
|
||||
// go through all the points in the loop and check if the angle between two segments(AB and BC) is less than the threshold
|
||||
size_t idx_prev = 0;
|
||||
|
@ -450,31 +450,19 @@ bool ExtrusionLoop::is_smooth(double angle_threshold, double min_arm_length) con
|
|||
distance_to_prev += lengths[idx_prev];
|
||||
}
|
||||
|
||||
for (size_t _i = 0; _i < points.size(); ++_i) {
|
||||
// pull idx_prev to current as much as possible, while respecting the min_arm_length
|
||||
while (distance_to_prev - lengths[idx_prev] > min_arm_length) {
|
||||
distance_to_prev -= lengths[idx_prev];
|
||||
idx_prev = Slic3r::next_idx_modulo(idx_prev, points.size());
|
||||
}
|
||||
// push idx_next forward as far as needed
|
||||
while (distance_to_next < min_arm_length) {
|
||||
distance_to_next += lengths[idx_next];
|
||||
idx_next = Slic3r::next_idx_modulo(idx_next, points.size());
|
||||
}
|
||||
|
||||
// push idx_next forward as far as needed
|
||||
while (distance_to_next < min_arm_length) {
|
||||
distance_to_next += lengths[idx_next];
|
||||
idx_next = Slic3r::next_idx_modulo(idx_next, points.size());
|
||||
}
|
||||
|
||||
// Calculate angle between idx_prev, idx_curr, idx_next.
|
||||
const Point &p0 = points[idx_prev];
|
||||
const Point &p1 = points[idx_curr];
|
||||
const Point &p2 = points[idx_next];
|
||||
const auto a = angle(p0 - p1, p2 - p1);
|
||||
if (a > 0 ? a < angle_threshold : a > -angle_threshold) { return false; }
|
||||
|
||||
// increase idx_curr by one
|
||||
float curr_distance = lengths[idx_curr];
|
||||
idx_curr++;
|
||||
distance_to_prev += curr_distance;
|
||||
distance_to_next -= curr_distance;
|
||||
// Calculate angle between idx_prev, idx_curr, idx_next.
|
||||
const Point &p0 = points[idx_prev];
|
||||
const Point &p1 = points[idx_curr];
|
||||
const Point &p2 = points[idx_next];
|
||||
const auto a = angle(p0 - p1, p2 - p1);
|
||||
if (a > 0 ? a < angle_threshold : a > -angle_threshold) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -459,7 +459,7 @@ public:
|
|||
}
|
||||
double total_volume() const override { double volume =0.; for (const auto& path : paths) volume += path.total_volume(); return volume; }
|
||||
// check if the loop is smooth, angle_threshold is in radians, default is 10 degrees
|
||||
bool is_smooth(double angle_threshold = 0.174, double min_arm_length = 0.025) const;
|
||||
bool check_seam_point_angle(double angle_threshold = 0.174, double min_arm_length = 0.025) const;
|
||||
//static inline std::string role_to_string(ExtrusionLoopRole role);
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
|
|
@ -4037,7 +4037,8 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
|
|||
!on_first_layer();
|
||||
|
||||
if (enable_seam_slope && m_config.seam_slope_conditional.value) {
|
||||
enable_seam_slope = loop.is_smooth(m_config.scarf_angle_threshold.value * M_PI / 180., EXTRUDER_CONFIG(nozzle_diameter));
|
||||
//BBS: the seam has been decide, only check the seam position angle
|
||||
enable_seam_slope = loop.check_seam_point_angle(m_config.scarf_angle_threshold.value * M_PI / 180.0);
|
||||
}
|
||||
|
||||
// clip the path to avoid the extruder to get exactly on the first point of the loop;
|
||||
|
|
|
@ -2863,7 +2863,7 @@ void PrintConfigDef::init_fff_params()
|
|||
|
||||
def = this->add("scarf_angle_threshold", coInt);
|
||||
def->label = L("Conditional angle threshold");
|
||||
def->tooltip = L("This option sets the threshold angle for applying a conditional scarf joint seam.\nIf the maximum angle within the perimeter loop " "exceeds this value (indicating the absence of sharp corners), a scarf joint seam will be used. The default value is 155°.");
|
||||
def->tooltip = L("This option sets the threshold angle for applying a conditional scarf joint seam.\nIf the seam angle within the perimeter loop " "exceeds this value (indicating the absence of sharp corners), a scarf joint seam will be used. The default value is 155°.");
|
||||
def->mode = comAdvanced;
|
||||
def->sidetext = L("°");
|
||||
def->min = 0;
|
||||
|
|
Loading…
Reference in New Issue