ENH: add wrapping detection

jira: STUDIO-13192
Change-Id: I0fb5692b18cdb3b7af624a831dcfb0f635b165f0
(cherry picked from commit 89a8b6ea5e34340cba3750416ce3100dcc39f5c2)
(cherry picked from commit 50bc8c10a7b4ddc0b2dfe9cbab438b9d307b7fc0)
This commit is contained in:
zhimin.zeng
2025-07-05 14:52:21 +08:00
committed by Noisyfox
parent 070a8e62a1
commit 1ccdf7b43b
31 changed files with 323 additions and 50 deletions

View File

@@ -75,4 +75,33 @@ int get_index_for_extruder_parameter(const DynamicPrintConfig &config, const std
return variant_index;
}
std::vector<Vec2d> get_wrapping_detection_area(const std::vector<Vec2d> &wrapping_detection_path, double avoidance_radius)
{
if (wrapping_detection_path.empty())
return std::vector<Vec2d>();
double min_x = wrapping_detection_path[0](0);
double max_x = wrapping_detection_path[0](0);
double min_y = wrapping_detection_path[0](1);
double max_y = wrapping_detection_path[0](1);
for (const Vec2d& pt : wrapping_detection_path) {
if (pt(0) < min_x)
min_x = pt(0);
if (pt(0) > max_x)
max_x = pt(0);
if (pt(1) < min_y)
min_y = pt(1);
if (pt(1) > max_y)
max_y = pt(1);
}
min_x = min_x - avoidance_radius;
min_y = min_y - avoidance_radius;
max_x = max_x + avoidance_radius;
max_y = max_y + avoidance_radius;
return {{min_x, min_y}, {max_x, min_y}, {max_x, max_y}, {min_x, max_y}};
}
}; // namespace Slic3r