Fixed one more bug in Z chaining of layer islands.
This commit is contained in:
Vojtech Bubnik 2022-11-16 18:41:48 +01:00
parent 30fbdd1235
commit 3713f09a8e

View File

@ -175,18 +175,22 @@ static void connect_layer_slices(
if (lslice.bbox.contains(pt) && m_above.lslices[l].contains(pt)) { if (lslice.bbox.contains(pt) && m_above.lslices[l].contains(pt)) {
found = true; found = true;
j = l; j = l;
assert(i >= 0 && i < m_below.lslices_ex.size());
assert(j >= 0 && j < m_above.lslices_ex.size());
break; break;
} }
} }
} else { } else {
// Index of an island above. Look-it up in the island below. // Index of an island above. Look-it up in the island below.
assert(j < m_offset_end); assert(j < m_offset_end);
j -= m_offset_below; j -= m_offset_above;
for (int l = int(m_below.lslices_ex.size()) - 1; l >= 0; -- l) { for (int l = int(m_below.lslices_ex.size()) - 1; l >= 0; -- l) {
LayerSlice &lslice = m_below.lslices_ex[l]; LayerSlice &lslice = m_below.lslices_ex[l];
if (lslice.bbox.contains(pt) && m_below.lslices[l].contains(pt)) { if (lslice.bbox.contains(pt) && m_below.lslices[l].contains(pt)) {
found = true; found = true;
i = l; i = l;
assert(i >= 0 && i < m_below.lslices_ex.size());
assert(j >= 0 && j < m_above.lslices_ex.size());
break; break;
} }
} }
@ -197,6 +201,8 @@ static void connect_layer_slices(
std::swap(i, j); std::swap(i, j);
i -= m_offset_below; i -= m_offset_below;
j -= m_offset_above; j -= m_offset_above;
assert(i >= 0 && i < m_below.lslices_ex.size());
assert(j >= 0 && j < m_above.lslices_ex.size());
found = true; found = true;
} }
if (found) { if (found) {