remove global angle computation, wrong results

This commit is contained in:
Pavel Mikus 2022-07-11 18:44:34 +02:00
parent 4a9f9aa89b
commit f5efb0d0aa
2 changed files with 11 additions and 17 deletions

View File

@ -471,29 +471,24 @@ void process_perimeter_polygon(const Polygon &orig_polygon, float z_coord, const
lengths.push_back(std::max((unscale(polygon[0]) - unscale(polygon[polygon.size() - 1])).norm(), 0.1)); lengths.push_back(std::max((unscale(polygon[0]) - unscale(polygon[polygon.size() - 1])).norm(), 0.1));
std::vector<float> polygon_angles = calculate_polygon_angles_at_vertices(polygon, lengths, std::vector<float> polygon_angles = calculate_polygon_angles_at_vertices(polygon, lengths,
SeamPlacer::polygon_local_angles_arm_distance); SeamPlacer::polygon_local_angles_arm_distance);
std::vector<float> global_angles = calculate_polygon_angles_at_vertices(polygon, lengths,
SeamPlacer::polygon_global_angles_arm_distance);
for (size_t angle_index = 0; angle_index < polygon_angles.size(); ++angle_index) {
if (fabs(global_angles[angle_index] > fabs(polygon_angles[angle_index]))){
polygon_angles[angle_index] = global_angles[angle_index];
}
}
// resample smooth surfaces, so that alignment finds short path down, and does not create unnecesary curves // resample smooth surfaces, so that alignment finds short path down, and does not create unnecesary curves
if (std::all_of(polygon_angles.begin(), polygon_angles.end(), [](float angle) { if (std::all_of(polygon_angles.begin(), polygon_angles.end(), [](float angle) {
return fabs(angle) < SeamPlacer::sharp_angle_snapping_threshold; return fabs(angle) < SeamPlacer::sharp_angle_snapping_threshold;
})) { })) {
float avg_dist = std::accumulate(lengths.begin(), lengths.end(), 0.0f) / float(lengths.size()); float total_dist = std::accumulate(lengths.begin(), lengths.end(), 0.0f);
coord_t sampling_dist = scaled(avg_dist*0.2f); float avg_dist = total_dist / float(lengths.size());
if (avg_dist < SeamPlacer::seam_align_tolerable_dist * 2.0f){
coord_t sampling_dist = scaled(avg_dist*0.2f);
polygon.points = polygon.equally_spaced_points(sampling_dist); polygon.points = polygon.equally_spaced_points(sampling_dist);
lengths.clear(); lengths.clear();
for (size_t point_idx = 0; point_idx < polygon.size() - 1; ++point_idx) { for (size_t point_idx = 0; point_idx < polygon.size() - 1; ++point_idx) {
lengths.push_back((unscale(polygon[point_idx]) - unscale(polygon[point_idx + 1])).norm()); lengths.push_back((unscale(polygon[point_idx]) - unscale(polygon[point_idx + 1])).norm());
}
lengths.push_back(std::max((unscale(polygon[0]) - unscale(polygon[polygon.size() - 1])).norm(), 0.1));
polygon_angles = calculate_polygon_angles_at_vertices(polygon, lengths, avg_dist);
} }
lengths.push_back(std::max((unscale(polygon[0]) - unscale(polygon[polygon.size() - 1])).norm(), 0.1));
polygon_angles = calculate_polygon_angles_at_vertices(polygon, lengths,
SeamPlacer::polygon_global_angles_arm_distance);
} }

View File

@ -128,7 +128,6 @@ public:
// arm length used during angles computation // arm length used during angles computation
static constexpr float polygon_local_angles_arm_distance = 0.3f; static constexpr float polygon_local_angles_arm_distance = 0.3f;
static constexpr float polygon_global_angles_arm_distance = 1.5f;
static constexpr float sharp_angle_snapping_threshold = (60.0f / 180.0f) * float(PI); static constexpr float sharp_angle_snapping_threshold = (60.0f / 180.0f) * float(PI);
// max tolerable distance from the previous layer is overhang_distance_tolerance_factor * flow_width // max tolerable distance from the previous layer is overhang_distance_tolerance_factor * flow_width