Builds the rebuild_word and sets the best_state from the chopped_word and the best_choice->state.
| 798 | // Builds the rebuild_word and sets the best_state from the chopped_word and |
| 799 | // the best_choice->state. |
| 800 | void WERD_RES::RebuildBestState() { |
| 801 | ASSERT_HOST(best_choice != NULL); |
| 802 | if (rebuild_word != NULL) |
| 803 | delete rebuild_word; |
| 804 | rebuild_word = new TWERD; |
| 805 | if (seam_array.empty()) |
| 806 | start_seam_list(chopped_word, &seam_array); |
| 807 | best_state.truncate(0); |
| 808 | int start = 0; |
| 809 | for (int i = 0; i < best_choice->length(); ++i) { |
| 810 | int length = best_choice->state(i); |
| 811 | best_state.push_back(length); |
| 812 | if (length > 1) { |
| 813 | SEAM::JoinPieces(seam_array, chopped_word->blobs, start, |
| 814 | start + length - 1); |
| 815 | } |
| 816 | TBLOB* blob = chopped_word->blobs[start]; |
| 817 | rebuild_word->blobs.push_back(new TBLOB(*blob)); |
| 818 | if (length > 1) { |
| 819 | SEAM::BreakPieces(seam_array, chopped_word->blobs, start, |
| 820 | start + length - 1); |
| 821 | } |
| 822 | start += length; |
| 823 | } |
| 824 | } |
| 825 | |
| 826 | // Copies the chopped_word to the rebuild_word, faking a best_state as well. |
| 827 | // Also sets up the output box_word. |
no test coverage detected