Skip to content

Commit a1b89a8

Browse files
committed
removeSeries/Frame and updateSeries/Frame member functions
1 parent c8aa44c commit a1b89a8

File tree

1 file changed

+44
-9
lines changed

1 file changed

+44
-9
lines changed

include/data/FluidDataSeries.hpp

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ class FluidDataSeries
115115
if (pos == mIndex.end()) return false;
116116

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

123121
return true;
@@ -140,29 +138,66 @@ class FluidDataSeries
140138
return pos->second;
141139
}
142140

143-
bool update(idType const& id, FluidTensorView<dataType, N> point)
141+
bool updateSeries(idType const& id, FluidTensorView<dataType, N + 1> series)
144142
{
145143
auto pos = mIndex.find(id);
146144
if (pos == mIndex.end())
147145
return false;
148146
else
149-
mData.row(pos->second) <<= point;
147+
mData[pos->second] <<= series;
150148
return true;
151149
}
152150

153-
bool remove(idType const& id)
151+
bool updateFrame(idType const& id, index time, FluidTensorView<dataType, N> frame)
154152
{
155153
auto pos = mIndex.find(id);
156-
if (pos == mIndex.end()) { return false; }
157-
else
154+
if (pos == mIndex.end()) return false;
155+
156+
FluidTensorView<dataType, N + 1> bucket = mData[pos->second];
157+
assert(time < bucket.rows());
158+
bucket.row(time) <<= frame;
159+
160+
return true;
161+
}
162+
163+
bool removeSeries(idType const& id)
164+
{
165+
auto pos = mIndex.find(id);
166+
if (pos == mIndex.end()) return false;
167+
168+
index current = pos->second;
169+
mData.erase(mData.begin() + current);
170+
mIds.deleteRow(current);
171+
mIndex.erase(id);
172+
173+
for (auto& point : mIndex)
174+
{
175+
if (point.second > current) point.second--;
176+
}
177+
178+
return true;
179+
}
180+
181+
bool removeFrame(idType const& id, index time)
182+
{
183+
auto pos = mIndex.find(id);
184+
if (pos == mIndex.end()) return false;
185+
186+
index current = pos->second;
187+
FluidTensorView<dataType, N + 1> bucket = mData[current];
188+
assert(time < bucket.rows())
189+
bucket.deleteRow(time);
190+
191+
if(bucket.rows() == 0)
158192
{
159-
auto current = pos->second;
160-
mData.deleteRow(current);
161193
mIds.deleteRow(current);
162194
mIndex.erase(id);
163195
for (auto& point : mIndex)
196+
{
164197
if (point.second > current) point.second--;
198+
}
165199
}
200+
166201
return true;
167202
}
168203

0 commit comments

Comments
 (0)