Mercurial > hg > svcore
comparison data/model/EditableDenseThreeDimensionalModel.cpp @ 1252:2ff5e411151d 3.0-integration
Ensure columns all have correct height when retrieved (to avoid e.g. empty columns because a feature extractor's start time was >0)
author | Chris Cannam |
---|---|
date | Fri, 04 Nov 2016 16:01:37 +0000 |
parents | aa588c391d1a |
children | 667e369cfeab |
comparison
equal
deleted
inserted
replaced
1251:67aee57e32c8 | 1252:2ff5e411151d |
---|---|
263 m_data[index] = values; | 263 m_data[index] = values; |
264 return; | 264 return; |
265 } | 265 } |
266 | 266 |
267 EditableDenseThreeDimensionalModel::Column | 267 EditableDenseThreeDimensionalModel::Column |
268 EditableDenseThreeDimensionalModel::rightHeight(const Column &c) const | |
269 { | |
270 if (int(c.size()) == m_yBinCount) return c; | |
271 else { | |
272 Column cc(c); | |
273 cc.resize(m_yBinCount, 0.0); | |
274 return cc; | |
275 } | |
276 } | |
277 | |
278 EditableDenseThreeDimensionalModel::Column | |
268 EditableDenseThreeDimensionalModel::expandAndRetrieve(int index) const | 279 EditableDenseThreeDimensionalModel::expandAndRetrieve(int index) const |
269 { | 280 { |
270 // See comment above m_trunc declaration in header | 281 // See comment above m_trunc declaration in header |
271 | 282 |
272 assert(index >= 0 && index < int(m_data.size())); | 283 assert(index >= 0 && index < int(m_data.size())); |
273 Column c = m_data.at(index); | 284 Column c = m_data.at(index); |
274 if (index == 0) { | 285 if (index == 0) { |
275 return c; | 286 return rightHeight(c); |
276 } | 287 } |
277 int trunc = (int)m_trunc[index]; | 288 int trunc = (int)m_trunc[index]; |
278 if (trunc == 0) { | 289 if (trunc == 0) { |
279 return c; | 290 return rightHeight(c); |
280 } | 291 } |
281 bool top = true; | 292 bool top = true; |
282 int tdist = trunc; | 293 int tdist = trunc; |
283 if (trunc < 0) { top = false; tdist = -trunc; } | 294 if (trunc < 0) { top = false; tdist = -trunc; } |
284 Column p = expandAndRetrieve(index - tdist); | 295 Column p = expandAndRetrieve(index - tdist); |
313 m_data.push_back(Column()); | 324 m_data.push_back(Column()); |
314 m_trunc.push_back(0); | 325 m_trunc.push_back(0); |
315 } | 326 } |
316 | 327 |
317 bool allChange = false; | 328 bool allChange = false; |
318 | |
319 // if (values.size() > m_yBinCount) m_yBinCount = values.size(); | |
320 | 329 |
321 for (int i = 0; in_range_for(values, i); ++i) { | 330 for (int i = 0; in_range_for(values, i); ++i) { |
322 float value = values[i]; | 331 float value = values[i]; |
323 if (ISNAN(value) || ISINF(value)) { | 332 if (ISNAN(value) || ISINF(value)) { |
324 continue; | 333 continue; |