tesseract  4.0.0-1-g2a2b
werdit.cpp File Reference
#include "werdit.h"
#include "errcode.h"
#include "pageres.h"
#include "stepblob.h"
#include "werd.h"

Go to the source code of this file.

Functions

PAGE_RES_ITmake_pseudo_word (PAGE_RES *page_res, const TBOX &selection_box)
 

Function Documentation

◆ make_pseudo_word()

PAGE_RES_IT* make_pseudo_word ( PAGE_RES page_res,
const TBOX selection_box 
)

Definition at line 35 of file werdit.cpp.

35  {
36  PAGE_RES_IT pr_it(page_res);
37  C_BLOB_LIST new_blobs; // list of gathered blobs
38  C_BLOB_IT new_blob_it = &new_blobs; // iterator
39 
40  for (WERD_RES* word_res = pr_it.word(); word_res != nullptr;
41  word_res = pr_it.forward()) {
42  WERD* word = word_res->word;
43  if (word->bounding_box().overlap(selection_box)) {
44  C_BLOB_IT blob_it(word->cblob_list());
45  for (blob_it.mark_cycle_pt();
46  !blob_it.cycled_list(); blob_it.forward()) {
47  C_BLOB* blob = blob_it.data();
48  if (blob->bounding_box().overlap(selection_box)) {
49  new_blob_it.add_after_then_move(C_BLOB::deep_copy(blob));
50  }
51  }
52  if (!new_blobs.empty()) {
53  WERD* pseudo_word = new WERD(&new_blobs, 1, nullptr);
54  word_res = pr_it.InsertSimpleCloneWord(*word_res, pseudo_word);
55  PAGE_RES_IT* it = new PAGE_RES_IT(page_res);
56  while (it->word() != word_res && it->word() != nullptr) it->forward();
57  ASSERT_HOST(it->word() == word_res);
58  return it;
59  }
60  }
61  }
62  return nullptr;
63 }
TBOX bounding_box() const
Definition: werd.cpp:159
WERD_RES * word() const
Definition: pageres.h:751
Definition: werd.h:59
C_BLOB_LIST * cblob_list()
Definition: werd.h:98
bool overlap(const TBOX &box) const
Definition: rect.h:355
TBOX bounding_box() const
Definition: stepblob.cpp:255
WERD_RES * forward()
Definition: pageres.h:731
static C_BLOB * deep_copy(const C_BLOB *src)
Definition: stepblob.h:119
#define ASSERT_HOST(x)
Definition: errcode.h:84
WERD * word
Definition: pageres.h:189