Skip to content

Commit

Permalink
fix: CBaseStream::ReduceTimePoints for boundary cases
Browse files Browse the repository at this point in the history
  • Loading branch information
vasylskorych committed May 28, 2024
1 parent b0faf47 commit 46cca34
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ModelsAPI/BaseStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,16 @@ void CBaseStream::ReduceTimePoints(double _timeBeg, double _timeEnd, double _ste
{
std::vector<double> timePoints = GetTimePoints(_timeBeg, _timeEnd);
if (timePoints.size() <= 3) return;
timePoints.pop_back();

auto itBeg = timePoints.begin();
const auto itEnd = timePoints.end();
while (itBeg != itEnd)
{
auto it = std::find_if(itBeg, itEnd, [&](double t) { return std::fabs(*itBeg - t) >= _step; });
if (std::distance(itBeg, it) > 2)
if (it != itEnd)
RemoveTimePoints(*itBeg, *it, false);
else
RemoveTimePoints(*itBeg, *(it - 1), false);
itBeg = it;
}
}
Expand Down

0 comments on commit 46cca34

Please sign in to comment.