@@ -79,7 +79,7 @@ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor, int32_t word_count, PAGE_R
79
79
ROW_RES_IT row_res_it;
80
80
WERD_RES_IT word_res_it_from;
81
81
WERD_RES_IT word_res_it_to;
82
- WERD_RES * word_res;
82
+ std::shared_ptr< WERD_RES> word_res;
83
83
WERD_RES_LIST fuzzy_space_words;
84
84
int16_t new_length;
85
85
bool prevent_null_wd_fixsp; // DON'T process blobless wds
@@ -114,7 +114,7 @@ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor, int32_t word_count, PAGE_R
114
114
if (!word_res_it_from.at_last ()) {
115
115
word_res_it_to = word_res_it_from;
116
116
prevent_null_wd_fixsp = word_res->word ->cblob_list ()->empty ();
117
- if (check_debug_pt (word_res, 60 )) {
117
+ if (check_debug_pt (word_res. get () , 60 )) {
118
118
debug_fix_space_level.set_value (10 );
119
119
}
120
120
word_res_it_to.forward ();
@@ -131,15 +131,15 @@ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor, int32_t word_count, PAGE_R
131
131
while (!word_res_it_to.at_last () &&
132
132
(word_res_it_to.data_relative (1 )->word ->flag (W_FUZZY_NON) ||
133
133
word_res_it_to.data_relative (1 )->word ->flag (W_FUZZY_SP))) {
134
- if (check_debug_pt (word_res, 60 )) {
134
+ if (check_debug_pt (word_res. get () , 60 )) {
135
135
debug_fix_space_level.set_value (10 );
136
136
}
137
137
if (word_res->word ->cblob_list ()->empty ()) {
138
138
prevent_null_wd_fixsp = true ;
139
139
}
140
140
word_res = word_res_it_to.forward ();
141
141
}
142
- if (check_debug_pt (word_res, 60 )) {
142
+ if (check_debug_pt (word_res. get () , 60 )) {
143
143
debug_fix_space_level.set_value (10 );
144
144
}
145
145
if (word_res->word ->cblob_list ()->empty ()) {
@@ -203,12 +203,12 @@ void initialise_search(WERD_RES_LIST &src_list, WERD_RES_LIST &new_list) {
203
203
WERD_RES *new_wd;
204
204
205
205
for (src_it.mark_cycle_pt (); !src_it.cycled_list (); src_it.forward ()) {
206
- WERD_RES *src_wd = src_it.data ();
206
+ WERD_RES *src_wd = src_it.data (). get () ;
207
207
if (!src_wd->combination ) {
208
208
new_wd = WERD_RES::deep_copy (src_wd);
209
209
new_wd->combination = false ;
210
210
new_wd->part_of_combo = false ;
211
- new_it.add_after_then_move (new_wd);
211
+ new_it.add_after_then_move (std::shared_ptr<WERD_RES>( new_wd) );
212
212
}
213
213
}
214
214
}
@@ -220,7 +220,7 @@ void Tesseract::match_current_words(WERD_RES_LIST &words, ROW *row, BLOCK *block
220
220
// prev_word_best_choice_ before calling classify_word_pass2().
221
221
prev_word_best_choice_ = nullptr ;
222
222
for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) {
223
- word = word_it.data ();
223
+ word = word_it.data (). get () ;
224
224
if ((!word->part_of_combo ) && (word->box_word == nullptr )) {
225
225
WordData word_data (block, row, word);
226
226
SetupWordPassN (2 , &word_data);
@@ -269,7 +269,7 @@ int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) {
269
269
const char *punct_chars = " !\" `',.:;" ;
270
270
do {
271
271
// current word
272
- WERD_RES *word = word_res_it.data ();
272
+ WERD_RES *word = word_res_it.data (). get () ;
273
273
bool word_done = fixspace_thinks_word_done (word);
274
274
word_count++;
275
275
if (word->tess_failed ) {
@@ -396,7 +396,7 @@ void transform_to_next_perm(WERD_RES_LIST &words) {
396
396
int16_t min_gap = INT16_MAX;
397
397
398
398
for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) {
399
- word = word_it.data ();
399
+ word = word_it.data (). get () ;
400
400
if (!word->part_of_combo ) {
401
401
box = word->word ->bounding_box ();
402
402
if (prev_right > -INT16_MAX) {
@@ -413,13 +413,13 @@ void transform_to_next_perm(WERD_RES_LIST &words) {
413
413
word_it.set_to_list (&words);
414
414
// Note: we can't use cycle_pt due to inserted combos at start of list.
415
415
for (; (prev_right == -INT16_MAX) || !word_it.at_first (); word_it.forward ()) {
416
- word = word_it.data ();
416
+ word = word_it.data (). get () ;
417
417
if (!word->part_of_combo ) {
418
418
box = word->word ->bounding_box ();
419
419
if (prev_right > -INT16_MAX) {
420
420
gap = box.left () - prev_right;
421
421
if (gap <= min_gap) {
422
- prev_word = prev_word_it.data ();
422
+ prev_word = prev_word_it.data (). get () ;
423
423
WERD_RES *combo;
424
424
if (prev_word->combination ) {
425
425
combo = prev_word;
@@ -433,14 +433,14 @@ void transform_to_next_perm(WERD_RES_LIST &words) {
433
433
combo->combination = true ;
434
434
combo->x_height = prev_word->x_height ;
435
435
prev_word->part_of_combo = true ;
436
- prev_word_it.add_before_then_move (combo);
436
+ prev_word_it.add_before_then_move (std::shared_ptr<WERD_RES>( combo) );
437
437
}
438
438
combo->word ->set_flag (W_EOL, word->word ->flag (W_EOL));
439
439
if (word->combination ) {
440
440
combo->word ->join_on (word->word );
441
441
// Move blobs to combo
442
442
// old combo no longer needed
443
- delete word_it.extract ();
443
+ word_it.extract ();
444
444
} else {
445
445
// Copy current wd to combo
446
446
combo->copy_on (word);
@@ -545,7 +545,7 @@ void Tesseract::fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row, BLOCK *block)
545
545
int16_t new_length;
546
546
float junk;
547
547
548
- word_res = word_res_it.data ();
548
+ word_res = word_res_it.data (). get () ;
549
549
if (word_res->word ->flag (W_REP_CHAR) || word_res->combination || word_res->part_of_combo ||
550
550
!word_res->word ->flag (W_DONT_CHOP)) {
551
551
return ;
@@ -582,11 +582,11 @@ void Tesseract::fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK *
582
582
583
583
dump_words (best_perm, best_score, 1 , improved);
584
584
585
- old_word_res = best_perm_it.data ();
585
+ old_word_res = best_perm_it.data (). get () ;
586
586
// Even deep_copy doesn't copy the underlying WERD unless its combination
587
587
// flag is true!.
588
588
old_word_res->combination = true ; // Kludge to force deep copy
589
- current_perm_it.add_to_end (WERD_RES::deep_copy (old_word_res));
589
+ current_perm_it.add_to_end (std::shared_ptr< WERD_RES>( WERD_RES ::deep_copy (old_word_res) ));
590
590
old_word_res->combination = false ; // Undo kludge
591
591
592
592
break_noisiest_blob_word (current_perm);
@@ -630,7 +630,7 @@ void Tesseract::break_noisiest_blob_word(WERD_RES_LIST &words) {
630
630
int16_t i;
631
631
632
632
for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) {
633
- auto blob_index = worst_noise_blob (word_it.data (), &noise_score);
633
+ auto blob_index = worst_noise_blob (word_it.data (). get () , &noise_score);
634
634
if (blob_index > -1 && worst_noise_score > noise_score) {
635
635
worst_noise_score = noise_score;
636
636
worst_blob_index = blob_index;
@@ -644,7 +644,7 @@ void Tesseract::break_noisiest_blob_word(WERD_RES_LIST &words) {
644
644
645
645
/* Now split the worst_word_it */
646
646
647
- word_res = worst_word_it.data ();
647
+ word_res = worst_word_it.data (). get () ;
648
648
649
649
/* Move blobs before noise blob to a new bloblist */
650
650
@@ -671,7 +671,7 @@ void Tesseract::break_noisiest_blob_word(WERD_RES_LIST &words) {
671
671
672
672
auto *new_word_res = new WERD_RES (new_word);
673
673
new_word_res->combination = true ;
674
- worst_word_it.add_before_then_move (new_word_res);
674
+ worst_word_it.add_before_then_move (std::shared_ptr<WERD_RES>( new_word_res) );
675
675
676
676
word_res->ClearResults ();
677
677
}
@@ -834,7 +834,7 @@ int16_t Tesseract::fp_eval_word_spacing(WERD_RES_LIST &word_res_list) {
834
834
float small_limit = kBlnXHeight * fixsp_small_outlines_size;
835
835
836
836
for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) {
837
- word = word_it.data ();
837
+ word = word_it.data (). get () ;
838
838
if (word->rebuild_word == nullptr ) {
839
839
continue ; // Can't handle cube words.
840
840
}
0 commit comments