data: Fixed collapse algorithm to not truncate intervals, only split

This commit is contained in:
Paul Beckingham 2016-04-28 23:43:10 -04:00
parent 60a015f945
commit 9840faa9ed

View file

@ -377,8 +377,23 @@ std::vector <Interval> collapse (
{ {
std::vector <Range> split_pieces; std::vector <Range> split_pieces;
for (auto& piece : pieces) for (auto& piece : pieces)
{
// If the exclusion is entirely within the piece, then collapse.
if (exclusion.start > piece.start &&
(exclusion.end < piece.end ||
piece.end.toEpoch () == 0))
{
for (auto& smaller_piece : piece.subtract (exclusion)) for (auto& smaller_piece : piece.subtract (exclusion))
split_pieces.push_back (smaller_piece); split_pieces.push_back (smaller_piece);
}
// If the exclusion merely overlap the piece, do nothing. This is because
// tracked time start and end is not clipped, but recorded faithfully.
else
{
split_pieces.push_back (piece);
}
}
pieces = split_pieces; pieces = split_pieces;
} }
@ -387,7 +402,7 @@ std::vector <Interval> collapse (
for (auto& piece : pieces) for (auto& piece : pieces)
all.push_back (clip (interval, piece)); all.push_back (clip (interval, piece));
std::cout << "# collapse:\n"; std::cout << "# results:\n";
for (auto& i : all) for (auto& i : all)
std::cout << "# " << i.dump () << "\n"; std::cout << "# " << i.dump () << "\n";
return all; return all;