diff 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
line wrap: on
line diff
--- a/data/model/EditableDenseThreeDimensionalModel.cpp	Fri Nov 04 14:57:03 2016 +0000
+++ b/data/model/EditableDenseThreeDimensionalModel.cpp	Fri Nov 04 16:01:37 2016 +0000
@@ -265,6 +265,17 @@
 }
 
 EditableDenseThreeDimensionalModel::Column
+EditableDenseThreeDimensionalModel::rightHeight(const Column &c) const
+{
+    if (int(c.size()) == m_yBinCount) return c;
+    else {
+        Column cc(c);
+        cc.resize(m_yBinCount, 0.0);
+        return cc;
+    }
+}
+
+EditableDenseThreeDimensionalModel::Column
 EditableDenseThreeDimensionalModel::expandAndRetrieve(int index) const
 {
     // See comment above m_trunc declaration in header
@@ -272,11 +283,11 @@
     assert(index >= 0 && index < int(m_data.size()));
     Column c = m_data.at(index);
     if (index == 0) {
-        return c;
+        return rightHeight(c);
     }
     int trunc = (int)m_trunc[index];
     if (trunc == 0) {
-        return c;
+        return rightHeight(c);
     }
     bool top = true;
     int tdist = trunc;
@@ -316,8 +327,6 @@
 
     bool allChange = false;
 
-//    if (values.size() > m_yBinCount) m_yBinCount = values.size();
-
     for (int i = 0; in_range_for(values, i); ++i) {
         float value = values[i];
         if (ISNAN(value) || ISINF(value)) {