parameter fixes, alignemnt for enforcers simplified

This commit is contained in:
PavelMikus 2022-03-09 13:26:36 +01:00
parent c640fb854f
commit 6dbc7149be
2 changed files with 23 additions and 12 deletions

View file

@ -647,13 +647,15 @@ struct SeamComparator {
float distance_penalty_a = 1.0f;
float distance_penalty_b = 1.0f;
if (setup == spNearest) {
distance_penalty_a = 1.1f - gauss((a.position.head<2>() - preffered_location).norm(), 0.0f, 1.0f, 0.001f);
distance_penalty_b = 1.1f - gauss((a.position.head<2>() - preffered_location).norm(), 0.0f, 1.0f, 0.001f);
distance_penalty_a = 1.1f - gauss((a.position.head<2>() - preffered_location).norm(), 0.0f, 1.0f, 0.01f);
distance_penalty_b = 1.1f - gauss((a.position.head<2>() - preffered_location).norm(), 0.0f, 1.0f, 0.01f);
}
//ranges: [0 - 1] (0 - 1.3] [0.1 - 1.1) ; total range: (0 - 2.1]
float penalty_a = (a.visibility + 0.5f) * compute_angle_penalty(a.local_ccw_angle) * distance_penalty_a;
float penalty_b = (b.visibility + 0.5f) * compute_angle_penalty(b.local_ccw_angle) * distance_penalty_b;
//ranges: [0 - 1] (0 - 1.3] [0.1 - 1.1)
float penalty_a = (a.visibility + SeamPlacer::additional_angle_importance) * compute_angle_penalty(a.local_ccw_angle)
* distance_penalty_a;
float penalty_b = (b.visibility + SeamPlacer::additional_angle_importance) * compute_angle_penalty(b.local_ccw_angle)
* distance_penalty_b;
return penalty_a < penalty_b;
}
@ -662,6 +664,14 @@ struct SeamComparator {
// sema point of the perimeter, to find out if the aligned point is not much worse than the current seam
bool is_first_not_much_worse(const SeamCandidate &a, const SeamCandidate &b) const {
// Blockers/Enforcers discrimination, top priority
if (a.type == EnforcedBlockedSeamPoint::Enforced) {
return true;
}
if (a.type == EnforcedBlockedSeamPoint::Blocked) {
return false;
}
if (a.type > b.type) {
return true;
}
@ -682,9 +692,9 @@ struct SeamComparator {
return a.position.y() > b.position.y();
}
//ranges: [0 - 1] (0 - 1.3] ; total range: (0 - 1.95];
float penalty_a = (a.visibility + 0.5f) * compute_angle_penalty(a.local_ccw_angle);
float penalty_b = (b.visibility + 0.5f) * compute_angle_penalty(b.local_ccw_angle);
//ranges: [0 - 1] (0 - 1.3] ;
float penalty_a = (a.visibility + SeamPlacer::additional_angle_importance) * compute_angle_penalty(a.local_ccw_angle);
float penalty_b = (b.visibility + SeamPlacer::additional_angle_importance) * compute_angle_penalty(b.local_ccw_angle);
return penalty_a <= penalty_b || std::abs(penalty_a - penalty_b) < SeamPlacer::seam_align_score_tolerance;
}
@ -695,7 +705,7 @@ struct SeamComparator {
return a.position.y();
}
return (a.visibility + 0.5f) * compute_angle_penalty(a.local_ccw_angle);
return (a.visibility + SeamPlacer::additional_angle_importance) * compute_angle_penalty(a.local_ccw_angle);
}
}
;
@ -1130,7 +1140,7 @@ void SeamPlacer::align_seam_points(const PrintObject *po, const SeamPlacerImpl::
// points = new_points;
// }
//
// // find coefficients of polynomial fit. Z coord is treated as parameter along which to fit both X and Y coords.
// find coefficients of polynomial fit. Z coord is treated as parameter along which to fit both X and Y coords.
// std::vector<Vec2f> coefficients = polyfit(points, weights, 4);
//
// // Do alignment - compute fitted point for each point in the string from its Z coord, and store the position into

View file

@ -87,12 +87,13 @@ public:
using SeamCandidatesTree =
KDTreeIndirect<3, float, SeamPlacerImpl::SeamCandidateCoordinateFunctor>;
static constexpr float raycasting_decimation_target_error = 1.0f;
static constexpr float raycasting_subdivision_target_length = 1.0f;
static constexpr float raycasting_subdivision_target_length = 2.0f;
//square of number of rays per triangle
static constexpr size_t sqr_rays_per_triangle = 7;
// arm length used during angles computation
static constexpr float polygon_local_angles_arm_distance = 0.5f;
static constexpr float additional_angle_importance = 0.3f;
// 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.3f;
@ -101,7 +102,7 @@ public:
// When searching for seam clusters for alignment:
// following value describes, how much worse score can point have and still be picked into seam cluster instead of original seam point on the same layer
static constexpr float seam_align_score_tolerance = 0.6f;
static constexpr float seam_align_score_tolerance = 0.5f;
// seam_align_tolerable_dist - if seam is closer to the previous seam position projected to the current layer than this value,
//it belongs automaticaly to the cluster
static constexpr float seam_align_tolerable_dist = 0.5f;