comparison src/Finder.cpp @ 135:42381e437fcd refactors

The finder is supposed to use normalised path-cost when calculation expand direction (as in Java implementation). Also, provide a way to query the forward path.
author Chris Cannam
date Thu, 18 Dec 2014 17:56:54 +0000
parents 6b91e40b2c04
children cfba9aec7569
comparison
equal deleted inserted replaced
134:046f51a2ca25 135:42381e437fcd
52 pair<int, int> rowRange = m_m->getRowRange(col); 52 pair<int, int> rowRange = m_m->getRowRange(col);
53 if (rowRange.second > row+1) { 53 if (rowRange.second > row+1) {
54 rowRange.second = row+1; // don't cheat by looking at future :) 54 rowRange.second = row+1; // don't cheat by looking at future :)
55 } 55 }
56 for (int index = rowRange.first; index < rowRange.second; index++) { 56 for (int index = rowRange.first; index < rowRange.second; index++) {
57 double tmp = m_m->getPathCost(index, col); 57 double tmp = m_m->getNormalisedPathCost(index, col);
58 if (tmp < min) { 58 if (tmp < min) {
59 min = tmp; 59 min = tmp;
60 bestRow = index; 60 bestRow = index;
61 } 61 }
62 } 62 }
64 pair<int, int> colRange = m_m->getColRange(row); 64 pair<int, int> colRange = m_m->getColRange(row);
65 if (colRange.second > col+1) { 65 if (colRange.second > col+1) {
66 colRange.second = col+1; // don't cheat by looking at future :) 66 colRange.second = col+1; // don't cheat by looking at future :)
67 } 67 }
68 for (int index = colRange.first; index < colRange.second; index++) { 68 for (int index = colRange.first; index < colRange.second; index++) {
69 double tmp = m_m->getPathCost(row, index); 69 double tmp = m_m->getNormalisedPathCost(row, index);
70 if (tmp < min) { 70 if (tmp < min) {
71 min = tmp; 71 min = tmp;
72 bestCol = index; 72 bestCol = index;
73 bestRow = row; 73 bestRow = row;
74 } 74 }
75 } 75 }
76 76
77 // cerr << "at [" << row << "," << col << "] (cost " << m_m->getPathCost(row, col) << ") blocksize = " << m_m->getBlockSize() << " best is [" << bestRow << "," << bestCol << "] (cost " << min << ")" << endl;
78
77 if (bestRow == row) { 79 if (bestRow == row) {
78 if (bestCol == col) { 80 if (bestCol == col) {
79 return Matcher::AdvanceBoth; 81 return Matcher::AdvanceBoth;
80 } else { 82 } else {
81 return Matcher::AdvanceThis; 83 return Matcher::AdvanceThis;