All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
werdit.h File Reference
#include "pageres.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

PAGE_RES_IT* make_pseudo_word ( PAGE_RES page_res,
const TBOX selection_box 
)

Definition at line 31 of file werdit.cpp.

31  {
32  PAGE_RES_IT pr_it(page_res);
33  C_BLOB_LIST new_blobs; // list of gathered blobs
34  C_BLOB_IT new_blob_it = &new_blobs; // iterator
35 
36  for (WERD_RES* word_res = pr_it.word(); word_res != NULL;
37  word_res = pr_it.forward()) {
38  WERD* word = word_res->word;
39  if (word->bounding_box().overlap(selection_box)) {
40  C_BLOB_IT blob_it(word->cblob_list());
41  for (blob_it.mark_cycle_pt();
42  !blob_it.cycled_list(); blob_it.forward()) {
43  C_BLOB* blob = blob_it.data();
44  if (blob->bounding_box().overlap(selection_box)) {
45  new_blob_it.add_after_then_move(C_BLOB::deep_copy(blob));
46  }
47  }
48  if (!new_blobs.empty()) {
49  WERD* pseudo_word = new WERD(&new_blobs, 1, NULL);
50  word_res = pr_it.InsertSimpleCloneWord(*word_res, pseudo_word);
51  PAGE_RES_IT* it = new PAGE_RES_IT(page_res);
52  while (it->word() != word_res && it->word() != NULL) it->forward();
53  ASSERT_HOST(it->word() == word_res);
54  return it;
55  }
56  }
57  }
58  return NULL;
59 }
static C_BLOB * deep_copy(const C_BLOB *src)
Definition: stepblob.h:113
TBOX bounding_box() const
Definition: werd.cpp:160
#define ASSERT_HOST(x)
Definition: errcode.h:84
WERD_RES * forward()
Definition: pageres.h:713
Definition: werd.h:60
WERD * word
Definition: pageres.h:175
TBOX bounding_box() const
Definition: stepblob.cpp:250
#define NULL
Definition: host.h:144
bool overlap(const TBOX &box) const
Definition: rect.h:345
C_BLOB_LIST * cblob_list()
Definition: werd.h:100
WERD_RES * word() const
Definition: pageres.h:733