mergeBandsHorizontally method
void
mergeBandsHorizontally()
Groups artifacts into horizontal bands based on their vertical positions.
This method organizes artifacts into bands, which are horizontal groupings of artifacts that are vertically close to each other. The process involves:
- Sorting artifacts by their top y-position.
- Iterating through sorted artifacts and assigning them to existing bands or creating new bands as necessary.
The method uses a vertical tolerance to determine if an artifact belongs to an existing band.
Implementation
void mergeBandsHorizontally() {
final List<List<Band>> rowOfBands = getBandsOnTheSameRelativeRow();
for (final bands in rowOfBands) {
// ensure that we are looking from left to right
bands.sort(
(a, b) => a.rectangleAdjusted.left.compareTo(b.rectangleAdjusted.left),
);
while (tryMergeBands(bands)) {
continue;
}
}
}