1) New methods PrintObject::num_regions() and ::has_region() to make

the code more readable and to highlight where PrintObject::region_volumes
   are actually set and consumed.
2) Replaced Slic3r::clamp() with std::clamp(). They differ in the order
   of their parameters, thus hopefully no new bugs were introduced.
3) Some refactoring of MultiMaterialSegmentation for efficiency.
This commit is contained in:
Vojtech Bubnik 2021-04-22 11:41:26 +02:00
parent 4f950343c8
commit 38bb7d2950
19 changed files with 139 additions and 161 deletions

View file

@ -41,7 +41,7 @@ namespace detail {
// Degenerate to a single closest point.
t = - b / (2. * a);
assert(t >= - EPSILON && t <= 1. + EPSILON);
return Slic3r::clamp(0., 1., t);
return std::clamp(t, 0., 1.);
} else {
u = sqrt(u);
out.first = 2;
@ -1142,7 +1142,7 @@ std::vector<Vec2d> edge_offset_contour_intersections(
#endif // NDEBUG
if (! bisector || (dmin != dmax && offset_distance >= dmin)) {
double t = (offset_distance - dmin) / (dmax - dmin);
t = clamp(0., 1., t);
t = std::clamp(t, 0., 1.);
if (d1 < d0) {
out[edge_idx2] = Slic3r::lerp(vertex_point(v1), vertex_point(v0), t);
// mark visited