comparison data/model/SparseModel.h @ 1113:ed207f89aaef

Fix assignment of values to regions on import, in case where region model contains duplicate points
author Chris Cannam
date Fri, 03 Jul 2015 16:09:14 +0100
parents 882d448c8a6d
children 39019ce29178
comparison
equal deleted inserted replaced
1110:1517d4c60e88 1113:ed207f89aaef
131 * supplied one using Point::Comparator. Other identical points 131 * supplied one using Point::Comparator. Other identical points
132 * may remain in the model. 132 * may remain in the model.
133 */ 133 */
134 virtual void deletePoint(const PointType &point); 134 virtual void deletePoint(const PointType &point);
135 135
136 /**
137 * Return true if the given point is found in this model, false
138 * otherwise.
139 */
140 virtual bool containsPoint(const PointType &point);
141
136 virtual bool isReady(int *completion = 0) const { 142 virtual bool isReady(int *completion = 0) const {
137 bool ready = isOK() && (m_completion == 100); 143 bool ready = isOK() && (m_completion == 100);
138 if (completion) *completion = m_completion; 144 if (completion) *completion = m_completion;
139 return ready; 145 return ready;
140 } 146 }
769 if (m_sinceLastNotifyMax == -1 || 775 if (m_sinceLastNotifyMax == -1 ||
770 point.frame > m_sinceLastNotifyMax) { 776 point.frame > m_sinceLastNotifyMax) {
771 m_sinceLastNotifyMax = point.frame; 777 m_sinceLastNotifyMax = point.frame;
772 } 778 }
773 } 779 }
780 }
781
782 template <typename PointType>
783 bool
784 SparseModel<PointType>::containsPoint(const PointType &point)
785 {
786 {
787 QMutexLocker locker(&m_mutex);
788
789 PointListIterator i = m_points.lower_bound(point);
790 typename PointType::Comparator comparator;
791 while (i != m_points.end()) {
792 if (i->frame > point.frame) break;
793 if (!comparator(*i, point) && !comparator(point, *i)) {
794 return true;
795 }
796 ++i;
797 }
798 }
799
800 return false;
774 } 801 }
775 802
776 template <typename PointType> 803 template <typename PointType>
777 void 804 void
778 SparseModel<PointType>::deletePoint(const PointType &point) 805 SparseModel<PointType>::deletePoint(const PointType &point)