mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-09-23 19:33:12 +08:00
Greatly reduce curling of Rear seams, revert previous ineffective change
SPE-1310
This commit is contained in:
parent
e7bc232a85
commit
bb993b8f94
@ -1,7 +1,7 @@
|
|||||||
#include "SeamPlacer.hpp"
|
#include "SeamPlacer.hpp"
|
||||||
|
|
||||||
#include "Point.hpp"
|
#include "Color.hpp"
|
||||||
#include "libslic3r.h"
|
#include "PrintConfig.hpp"
|
||||||
#include "tbb/parallel_for.h"
|
#include "tbb/parallel_for.h"
|
||||||
#include "tbb/blocked_range.h"
|
#include "tbb/blocked_range.h"
|
||||||
#include "tbb/parallel_reduce.h"
|
#include "tbb/parallel_reduce.h"
|
||||||
@ -731,9 +731,8 @@ void gather_enforcers_blockers(GlobalModelInfo &result, const PrintObject *po) {
|
|||||||
struct SeamComparator {
|
struct SeamComparator {
|
||||||
SeamPosition setup;
|
SeamPosition setup;
|
||||||
float angle_importance;
|
float angle_importance;
|
||||||
Vec2f rear_attractor;
|
explicit SeamComparator(SeamPosition setup) :
|
||||||
explicit SeamComparator(SeamPosition setup, const Vec2f& rear_attractor = Vec2f::Zero()) :
|
setup(setup) {
|
||||||
setup(setup), rear_attractor(rear_attractor) {
|
|
||||||
angle_importance =
|
angle_importance =
|
||||||
setup == spNearest ? SeamPlacer::angle_importance_nearest : SeamPlacer::angle_importance_aligned;
|
setup == spNearest ? SeamPlacer::angle_importance_nearest : SeamPlacer::angle_importance_aligned;
|
||||||
}
|
}
|
||||||
@ -764,9 +763,8 @@ struct SeamComparator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setup == SeamPosition::spRear) {
|
if (setup == SeamPosition::spRear && a.position.y() != b.position.y()) {
|
||||||
return (a.position.head<2>() - rear_attractor).squaredNorm() <
|
return a.position.y() > b.position.y();
|
||||||
(b.position.head<2>() - rear_attractor).squaredNorm();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float distance_penalty_a = 0.0f;
|
float distance_penalty_a = 0.0f;
|
||||||
@ -828,8 +826,7 @@ struct SeamComparator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setup == SeamPosition::spRear) {
|
if (setup == SeamPosition::spRear) {
|
||||||
return (a.position.head<2>() - rear_attractor).squaredNorm() - a.perimeter.flow_width <
|
return a.position.y() + SeamPlacer::seam_align_score_tolerance * 5.0f > b.position.y();
|
||||||
(b.position.head<2>() - rear_attractor).squaredNorm();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float penalty_a = a.overhang + a.visibility
|
float penalty_a = a.overhang + a.visibility
|
||||||
@ -1382,15 +1379,19 @@ void SeamPlacer::align_seam_points(const PrintObject *po, const SeamPlacerImpl::
|
|||||||
observations[index] = current.position.head<2>();
|
observations[index] = current.position.head<2>();
|
||||||
observation_points[index] = current.position.z();
|
observation_points[index] = current.position.z();
|
||||||
weights[index] = angle_weight(current.local_ccw_angle);
|
weights[index] = angle_weight(current.local_ccw_angle);
|
||||||
float sign = layer_angle > 2.0 * std::abs(current.local_ccw_angle) ? -0.8f : 1.0f;
|
float curling_influence = layer_angle > 2.0 * std::abs(current.local_ccw_angle) ? -0.8f : 1.0f;
|
||||||
if (current.type == EnforcedBlockedSeamPoint::Enforced) {
|
if (current.type == EnforcedBlockedSeamPoint::Enforced) {
|
||||||
sign = 1.0f;
|
curling_influence = 1.0f;
|
||||||
weights[index] += 3.0f;
|
weights[index] += 3.0f;
|
||||||
}
|
}
|
||||||
total_length += sign * (last_point_pos - current.position).norm();
|
total_length += curling_influence * (last_point_pos - current.position).norm();
|
||||||
last_point_pos = current.position;
|
last_point_pos = current.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comparator.setup == spRear) {
|
||||||
|
total_length *= 0.3f;
|
||||||
|
}
|
||||||
|
|
||||||
// Curve Fitting
|
// Curve Fitting
|
||||||
size_t number_of_segments = std::max(size_t(1),
|
size_t number_of_segments = std::max(size_t(1),
|
||||||
size_t(std::max(0.0f,total_length) / SeamPlacer::seam_align_mm_per_segment));
|
size_t(std::max(0.0f,total_length) / SeamPlacer::seam_align_mm_per_segment));
|
||||||
@ -1457,9 +1458,7 @@ void SeamPlacer::init(const Print &print, std::function<void(void)> throw_if_can
|
|||||||
for (const PrintObject *po : print.objects()) {
|
for (const PrintObject *po : print.objects()) {
|
||||||
throw_if_canceled_func();
|
throw_if_canceled_func();
|
||||||
SeamPosition configured_seam_preference = po->config().seam_position.value;
|
SeamPosition configured_seam_preference = po->config().seam_position.value;
|
||||||
Vec2f rear_attractor = unscaled(po->bounding_box().center()).cast<float>() +
|
SeamComparator comparator { configured_seam_preference };
|
||||||
1.5f * Vec2f(0.0f, unscale<float>(po->bounding_box().max.y()));
|
|
||||||
SeamComparator comparator{configured_seam_preference, rear_attractor};
|
|
||||||
|
|
||||||
{
|
{
|
||||||
GlobalModelInfo global_model_info { };
|
GlobalModelInfo global_model_info { };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user