comparison data/model/Dense3DModelPeakCache.cpp @ 1153:ece369c5bb68 3.0-integration

Don't need ResizeableBitset, vector<bool> is already a compact format
author Chris Cannam
date Fri, 22 Jan 2016 12:46:42 +0000
parents 59e7fe1b1003
children 546d4e417346
comparison
equal deleted inserted replaced
1152:d73b4bac2dc4 1153:ece369c5bb68
20 Dense3DModelPeakCache::Dense3DModelPeakCache(DenseThreeDimensionalModel *source, 20 Dense3DModelPeakCache::Dense3DModelPeakCache(DenseThreeDimensionalModel *source,
21 int columnsPerPeak) : 21 int columnsPerPeak) :
22 m_source(source), 22 m_source(source),
23 m_resolution(columnsPerPeak) 23 m_resolution(columnsPerPeak)
24 { 24 {
25 m_coverage.resize(1); // otherwise it is simply invalid
26
27 m_cache = new EditableDenseThreeDimensionalModel 25 m_cache = new EditableDenseThreeDimensionalModel
28 (source->getSampleRate(), 26 (source->getSampleRate(),
29 getResolution(), 27 getResolution(),
30 source->getHeight(), 28 source->getHeight(),
31 EditableDenseThreeDimensionalModel::NoCompression, 29 EditableDenseThreeDimensionalModel::NoCompression,
79 { 77 {
80 if (!m_source) return; 78 if (!m_source) return;
81 if (m_coverage.size() > 0) { 79 if (m_coverage.size() > 0) {
82 // The last peak may have come from an incomplete read, which 80 // The last peak may have come from an incomplete read, which
83 // may since have been filled, so reset it 81 // may since have been filled, so reset it
84 m_coverage.reset(m_coverage.size()-1); 82 m_coverage[m_coverage.size()-1] = false;
85 } 83 }
86 m_coverage.resize(getWidth()); // retaining data 84 m_coverage.resize(getWidth(), false); // retaining data
87 } 85 }
88 86
89 void 87 void
90 Dense3DModelPeakCache::sourceModelAboutToBeDeleted() 88 Dense3DModelPeakCache::sourceModelAboutToBeDeleted()
91 { 89 {
93 } 91 }
94 92
95 bool 93 bool
96 Dense3DModelPeakCache::haveColumn(int column) const 94 Dense3DModelPeakCache::haveColumn(int column) const
97 { 95 {
98 return column < (int)m_coverage.size() && m_coverage.get(column); 96 return in_range_for(m_coverage, column) && m_coverage[column];
99 } 97 }
100 98
101 void 99 void
102 Dense3DModelPeakCache::fillColumn(int column) const 100 Dense3DModelPeakCache::fillColumn(int column) const
103 { 101 {
104 Profiler profiler("Dense3DModelPeakCache::fillColumn"); 102 Profiler profiler("Dense3DModelPeakCache::fillColumn");
105 103
106 if (column >= (int)m_coverage.size()) { 104 if (!in_range_for(m_coverage, column)) {
107 // see note in sourceModelChanged 105 // see note in sourceModelChanged
108 if (m_coverage.size() > 0) m_coverage.reset(m_coverage.size()-1); 106 if (m_coverage.size() > 0) m_coverage[m_coverage.size()-1] = false;
109 m_coverage.resize(column + 1); 107 m_coverage.resize(column + 1, false);
110 } 108 }
111 109
112 Column peak; 110 Column peak;
113 for (int i = 0; i < int(m_resolution); ++i) { 111 for (int i = 0; i < m_resolution; ++i) {
114 Column here = m_source->getColumn(column * m_resolution + i); 112 Column here = m_source->getColumn(column * m_resolution + i);
115 if (i == 0) { 113 if (i == 0) {
116 peak = here; 114 peak = here;
117 } else { 115 } else {
118 for (int j = 0; j < (int)peak.size() && j < (int)here.size(); ++j) { 116 for (int j = 0; in_range_for(peak, j) && in_range_for(here, j); ++j) {
119 if (here[j] > peak[j]) peak[j] = here[j]; 117 if (here[j] > peak[j]) peak[j] = here[j];
120 } 118 }
121 } 119 }
122 } 120 }
123 121
124 m_cache->setColumn(column, peak); 122 m_cache->setColumn(column, peak);
125 m_coverage.set(column); 123 m_coverage[column] = true;
126 } 124 }
127 125
128 126