mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 04:35:54 +08:00
implemented smooth angle penalty function
This commit is contained in:
parent
a92d5038bd
commit
ab3c8d0fe8
@ -682,13 +682,12 @@ struct SeamComparator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO "bump function": e^[1 / ( (x-0.3)^2 +1 )] -1 << =ℯ^(((1)/((x-0.3)^(2)+1)))-1
|
//"gaussian bump function": e^(1/((x-0.15)^2+1))-1
|
||||||
float compute_angle_penalty(float ccw_angle) const {
|
float compute_angle_penalty(float ccw_angle) const {
|
||||||
if (ccw_angle >= -0.4) {
|
float shifted = ccw_angle - 0.15;
|
||||||
return PI * PI - ccw_angle * ccw_angle;
|
float pow2 = shifted*shifted;
|
||||||
} else {
|
float exponent = 1.0f / (pow2 +1);
|
||||||
return (PI * PI - ccw_angle * ccw_angle) * 0.7f;
|
return std::exp(exponent) - 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Standard comparator, must respect the requirements of comparators (e.g. give same result on same inputs) for sorting usage
|
// Standard comparator, must respect the requirements of comparators (e.g. give same result on same inputs) for sorting usage
|
||||||
@ -1068,9 +1067,9 @@ void SeamPlacer::align_seam_points(const PrintObject *po, const Comparator &comp
|
|||||||
perimeter->aligned = true;
|
perimeter->aligned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (Vec3f& p : points){
|
for (Vec3f& p : points){
|
||||||
// p = get_fitted_point(coefficients, p.z());
|
p = get_fitted_point(coefficients, p.z());
|
||||||
// }
|
}
|
||||||
|
|
||||||
// for (size_t iteration = 0; iteration < 20; ++iteration) {
|
// for (size_t iteration = 0; iteration < 20; ++iteration) {
|
||||||
// std::vector<Vec3f> new_points(seam_string.size());
|
// std::vector<Vec3f> new_points(seam_string.size());
|
||||||
@ -1079,8 +1078,8 @@ void SeamPlacer::align_seam_points(const PrintObject *po, const Comparator &comp
|
|||||||
// size_t next_idx = point_index < points.size() - 1 ? point_index + 1 : point_index;
|
// size_t next_idx = point_index < points.size() - 1 ? point_index + 1 : point_index;
|
||||||
//
|
//
|
||||||
// new_points[point_index] = (points[prev_idx] * weights[prev_idx]
|
// new_points[point_index] = (points[prev_idx] * weights[prev_idx]
|
||||||
// + points[next_idx] * weights[next_idx]) /
|
// +points[point_index] * weights[point_index]+ points[next_idx] * weights[next_idx]) /
|
||||||
// (weights[prev_idx] + weights[next_idx]);
|
// (weights[prev_idx] + weights[point_index]+ weights[next_idx]);
|
||||||
// }
|
// }
|
||||||
// points = new_points;
|
// points = new_points;
|
||||||
// }
|
// }
|
||||||
|
@ -108,10 +108,10 @@ public:
|
|||||||
static constexpr float cosine_hemisphere_sampling_power = 5.0f;
|
static constexpr float cosine_hemisphere_sampling_power = 5.0f;
|
||||||
|
|
||||||
// arm length used during angles computation
|
// arm length used during angles computation
|
||||||
static constexpr float polygon_local_angles_arm_distance = 1.0f;
|
static constexpr float polygon_local_angles_arm_distance = 0.4f;
|
||||||
|
|
||||||
// If enforcer or blocker is closer to the seam candidate than this limit, the seam candidate is set to Blocker or Enforcer
|
// If enforcer or blocker is closer to the seam candidate than this limit, the seam candidate is set to Blocker or Enforcer
|
||||||
static constexpr float enforcer_blocker_distance_tolerance = 0.1f;
|
static constexpr float enforcer_blocker_distance_tolerance = 0.2f;
|
||||||
|
|
||||||
// When searching for seam clusters for alignment:
|
// When searching for seam clusters for alignment:
|
||||||
// seam_align_tolerable_dist - if seam is closer to the previous seam position projected to the current layer than this value,
|
// seam_align_tolerable_dist - if seam is closer to the previous seam position projected to the current layer than this value,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user