comparison src/Finder.cpp @ 154:4159f6b71942 structure

More cost query methods
author Chris Cannam
date Fri, 23 Jan 2015 14:55:19 +0000
parents 3673e2dae6a7
children 2b61e0cb6847
comparison
equal deleted inserted replaced
153:fcf0dd0166b1 154:4159f6b71942
36 Finder::~Finder() 36 Finder::~Finder()
37 { 37 {
38 } 38 }
39 39
40 void 40 void
41 Finder::setMatcher(Matcher *pm)
42 {
43 m_m = pm;
44 }
45
46 void
41 Finder::setDurations(int d1, int d2) 47 Finder::setDurations(int d1, int d2)
42 { 48 {
43 #ifdef DEBUG_FINDER 49 #ifdef DEBUG_FINDER
44 cerr << "*** setDurations: " << d1 << ", " << d2 << endl; 50 cerr << "*** setDurations: " << d1 << ", " << d2 << endl;
45 #endif 51 #endif
46 m_duration1 = d1; 52 m_duration1 = d1;
47 m_duration2 = d2; 53 m_duration2 = d2;
48 } 54 }
55
56 bool
57 Finder::getBestRowCost(int row, int &bestCol, double &min)
58 {
59 if (!m_m->isRowAvailable(row)) {
60 cerr << "row not available: " << row << endl;
61 return false;
62 }
63 pair<int, int> colRange = m_m->getColRange(row);
64 if (colRange.first >= colRange.second) {
65 cerr << "row " << row << " has invalid col range " << colRange.first
66 << " -> " << colRange.second << endl;
67 return false;
68 }
69 for (int index = colRange.first; index < colRange.second; index++) {
70 double tmp = m_m->getNormalisedPathCost(row, index);
71 if (index == colRange.first || tmp < min) {
72 min = tmp;
73 bestCol = index;
74 }
75 }
76 return true;
77 }
78
79 bool
80 Finder::getBestColCost(int col, int &bestRow, double &min)
81 {
82 if (!m_m->isColAvailable(col)) return false;
83 pair<int, int> rowRange = m_m->getRowRange(col);
84 if (rowRange.first >= rowRange.second) return false;
85 for (int index = rowRange.first; index < rowRange.second; index++) {
86 double tmp = m_m->getNormalisedPathCost(index, col);
87 if (index == rowRange.first || tmp < min) {
88 min = tmp;
89 bestRow = index;
90 }
91 }
92 return true;
93 }
49 94
50 void 95 void
51 Finder::getBestEdgeCost(int row, int col, 96 Finder::getBestEdgeCost(int row, int col,
52 int &bestRow, int &bestCol, 97 int &bestRow, int &bestCol,
53 double &min) 98 double &min)