mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-17 19:57:55 -06:00
ENH: avoid overhang area when set the seam position
Signed-off-by: qing.zhang <qing.zhang@bambulab.com> Change-Id: I58eb8c091b68b8c64f44d21db88d2f9155e42e42
This commit is contained in:
parent
38406e3e59
commit
3a6f033794
2 changed files with 44 additions and 5 deletions
|
@ -697,8 +697,8 @@ struct SeamComparator
|
||||||
}
|
}
|
||||||
|
|
||||||
// the penalites are kept close to range [0-1.x] however, it should not be relied upon
|
// the penalites are kept close to range [0-1.x] however, it should not be relied upon
|
||||||
float penalty_a = a.overhang + a.visibility + angle_importance * compute_angle_penalty(a.local_ccw_angle) + distance_penalty_a;
|
float penalty_a = a.overhang + a.visibility + a.extend_overhang + angle_importance * compute_angle_penalty(a.local_ccw_angle) + distance_penalty_a;
|
||||||
float penalty_b = b.overhang + b.visibility + angle_importance * compute_angle_penalty(b.local_ccw_angle) + distance_penalty_b;
|
float penalty_b = b.overhang + b.visibility + b.extend_overhang + angle_importance * compute_angle_penalty(b.local_ccw_angle) + distance_penalty_b;
|
||||||
|
|
||||||
return penalty_a < penalty_b;
|
return penalty_a < penalty_b;
|
||||||
}
|
}
|
||||||
|
@ -731,8 +731,8 @@ struct SeamComparator
|
||||||
|
|
||||||
if (setup == SeamPosition::spRear) { return a.position.y() + SeamPlacer::seam_align_score_tolerance * 5.0f > b.position.y(); }
|
if (setup == SeamPosition::spRear) { return a.position.y() + SeamPlacer::seam_align_score_tolerance * 5.0f > b.position.y(); }
|
||||||
|
|
||||||
float penalty_a = a.overhang + a.visibility + angle_importance * compute_angle_penalty(a.local_ccw_angle);
|
float penalty_a = a.overhang + a.extend_overhang + a.visibility + angle_importance * compute_angle_penalty(a.local_ccw_angle);
|
||||||
float penalty_b = b.overhang + b.visibility + angle_importance * compute_angle_penalty(b.local_ccw_angle);
|
float penalty_b = b.overhang + b.extend_overhang + b.visibility + angle_importance * compute_angle_penalty(b.local_ccw_angle);
|
||||||
|
|
||||||
return penalty_a <= penalty_b || penalty_a - penalty_b < SeamPlacer::seam_align_score_tolerance;
|
return penalty_a <= penalty_b || penalty_a - penalty_b < SeamPlacer::seam_align_score_tolerance;
|
||||||
}
|
}
|
||||||
|
@ -968,12 +968,50 @@ void SeamPlacer::calculate_overhangs_and_layer_embedding(const PrintObject *po)
|
||||||
bool should_compute_layer_embedding = regions_with_perimeter > 1;
|
bool should_compute_layer_embedding = regions_with_perimeter > 1;
|
||||||
std::unique_ptr<PerimeterDistancer> current_layer_distancer = std::make_unique<PerimeterDistancer>(po->layers()[layer_idx]);
|
std::unique_ptr<PerimeterDistancer> current_layer_distancer = std::make_unique<PerimeterDistancer>(po->layers()[layer_idx]);
|
||||||
|
|
||||||
for (SeamCandidate &perimeter_point : layers[layer_idx].points) {
|
int points_size = layers[layer_idx].points.size();
|
||||||
|
for (size_t i = 0; i < points_size; i++) {
|
||||||
|
SeamCandidate &perimeter_point = layers[layer_idx].points[i];
|
||||||
Vec2f point = Vec2f{perimeter_point.position.head<2>()};
|
Vec2f point = Vec2f{perimeter_point.position.head<2>()};
|
||||||
if (prev_layer_distancer.get() != nullptr) {
|
if (prev_layer_distancer.get() != nullptr) {
|
||||||
perimeter_point.overhang = prev_layer_distancer->distance_from_perimeter(point) + 0.6f * perimeter_point.perimeter.flow_width -
|
perimeter_point.overhang = prev_layer_distancer->distance_from_perimeter(point) + 0.6f * perimeter_point.perimeter.flow_width -
|
||||||
tan(SeamPlacer::overhang_angle_threshold) * po->layers()[layer_idx]->height;
|
tan(SeamPlacer::overhang_angle_threshold) * po->layers()[layer_idx]->height;
|
||||||
perimeter_point.overhang = perimeter_point.overhang < 0.0f ? 0.0f : perimeter_point.overhang;
|
perimeter_point.overhang = perimeter_point.overhang < 0.0f ? 0.0f : perimeter_point.overhang;
|
||||||
|
if (perimeter_point.overhang > 0.0f) {
|
||||||
|
//BBS. extend overhang range
|
||||||
|
float dist = 0.0f;
|
||||||
|
size_t idx = i;
|
||||||
|
size_t start_index = layers[layer_idx].points[i].perimeter.start_index;
|
||||||
|
size_t end_index = layers[layer_idx].points[i].perimeter.end_index;
|
||||||
|
float lensLimit = 3.0f;
|
||||||
|
bool flage = true;
|
||||||
|
layers[layer_idx].points[i].extend_overhang += gauss(0.0f, 0.0f, 1.0f, 0.005f);
|
||||||
|
|
||||||
|
while (idx != i || flage) {
|
||||||
|
flage = false;
|
||||||
|
int prev = idx;
|
||||||
|
idx = idx == start_index ? end_index - 1 : idx - 1;
|
||||||
|
dist += sqrt((layers[layer_idx].points[idx].position.head<2>() - layers[layer_idx].points[prev].position.head<2>()).squaredNorm());
|
||||||
|
if (dist > lensLimit)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
layers[layer_idx].points[idx].extend_overhang += gauss(dist, 0.0f, 1.0f, 0.005f);
|
||||||
|
}
|
||||||
|
|
||||||
|
idx = i;
|
||||||
|
dist = 0.0f;
|
||||||
|
flage = true;
|
||||||
|
|
||||||
|
while (idx != i || flage) {
|
||||||
|
flage = false;
|
||||||
|
int prev = idx;
|
||||||
|
idx = idx == end_index - 1 ? start_index : idx + 1;
|
||||||
|
dist += sqrt((layers[layer_idx].points[idx].position.head<2>() - layers[layer_idx].points[prev].position.head<2>()).squaredNorm());
|
||||||
|
if (dist > lensLimit)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
layers[layer_idx].points[idx].extend_overhang += gauss(dist, 0.0f, 1.0f, 0.005f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_compute_layer_embedding) { // search for embedded perimeter points (points hidden inside the print ,e.g. multimaterial join, best position for seam)
|
if (should_compute_layer_embedding) { // search for embedded perimeter points (points hidden inside the print ,e.g. multimaterial join, best position for seam)
|
||||||
|
|
|
@ -76,6 +76,7 @@ struct SeamCandidate
|
||||||
Perimeter &perimeter;
|
Perimeter &perimeter;
|
||||||
float visibility;
|
float visibility;
|
||||||
float overhang;
|
float overhang;
|
||||||
|
float extend_overhang=0.0f;
|
||||||
// distance inside the merged layer regions, for detecting perimeter points which are hidden indside the print (e.g. multimaterial join)
|
// distance inside the merged layer regions, for detecting perimeter points which are hidden indside the print (e.g. multimaterial join)
|
||||||
// Negative sign means inside the print, comes from EdgeGrid structure
|
// Negative sign means inside the print, comes from EdgeGrid structure
|
||||||
float embedded_distance;
|
float embedded_distance;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue