Skip to content

Commit

Permalink
add and remove series/frame member functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lewardo committed Aug 23, 2023
1 parent c8aa44c commit 7c6575a
Showing 1 changed file with 44 additions and 9 deletions.
53 changes: 44 additions & 9 deletions include/data/FluidDataSeries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ class FluidDataSeries
if (pos == mIndex.end()) return false;

FluidTensorView<dataType, N + 1> bucket = mData[pos->second];

assert(time < bucket.rows());

frame <<= bucket.row(time);

return true;
Expand All @@ -140,29 +138,66 @@ class FluidDataSeries
return pos->second;
}

bool update(idType const& id, FluidTensorView<dataType, N> point)
bool updateSeries(idType const& id, FluidTensorView<dataType, N + 1> series)
{
auto pos = mIndex.find(id);
if (pos == mIndex.end())
return false;
else
mData.row(pos->second) <<= point;
mData[pos->second] <<= series;
return true;
}

bool remove(idType const& id)
bool updateFrame(idType const& id, index time, FluidTensorView<dataType, N> frame)
{
auto pos = mIndex.find(id);
if (pos == mIndex.end()) { return false; }
else
if (pos == mIndex.end()) return false;

FluidTensorView<dataType, N + 1> bucket = mData[pos->second];
assert(time < bucket.rows());
bucket.row(time) <<= frame;

return true;
}

bool removeSeries(idType const& id)
{
auto pos = mIndex.find(id);
if (pos == mIndex.end()) return false;

index current = pos->second;
mData.erase(mData.begin() + current);
mIds.deleteRow(current);
mIndex.erase(id);

for (auto& point : mIndex)
{
if (point.second > current) point.second--;
}

return true;
}

bool removeFrame(idType const& id, index time)
{
auto pos = mIndex.find(id);
if (pos == mIndex.end()) return false;

index current = pos->second;
FluidTensorView<dataType, N + 1> bucket = mData[current];
assert(time < bucket.rows())
bucket.deleteRow(time);

if(bucket.rows() == 0)
{
auto current = pos->second;
mData.deleteRow(current);
mIds.deleteRow(current);
mIndex.erase(id);
for (auto& point : mIndex)
{
if (point.second > current) point.second--;
}
}

return true;
}

Expand Down

0 comments on commit 7c6575a

Please sign in to comment.