Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
werdit.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 * File: werdit.cpp (Formerly wordit.c)
3 * Description: An iterator for passing over all the words in a document.
4 * Author: Ray Smith
5 * Created: Mon Apr 27 08:51:22 BST 1992
6 *
7 * (C) Copyright 1992, Hewlett-Packard Ltd.
8 ** Licensed under the Apache License, Version 2.0 (the "License");
9 ** you may not use this file except in compliance with the License.
10 ** You may obtain a copy of the License at
11 ** http://www.apache.org/licenses/LICENSE-2.0
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
17 *
18 **********************************************************************/
19
20 #include "mfcpch.h"
21 #include "werdit.h"
22
23 /**********************************************************************
24 * make_pseudo_word
25 *
26 * Make all the blobs inside a selection into a single word.
27 * The word is always a copy and needs to be deleted.
28 **********************************************************************/
29
30 WERD *make_pseudo_word(PAGE_RES* page_res, // Blocks to check.
31 TBOX &selection_box,
32 BLOCK *&pseudo_block,
33 ROW *&pseudo_row) { // Row of selection.
34 PAGE_RES_IT pr_it(page_res);
35 C_BLOB_LIST new_blobs; // list of gathered blobs
36 C_BLOB_IT new_blob_it = &new_blobs; // iterator
37 WERD *pseudo_word; // fabricated word
38
39 for (WERD_RES* word_res = pr_it.word(); word_res != NULL;
40 word_res = pr_it.forward()) {
41 WERD* word = word_res->word;
42 if (word->bounding_box().overlap(selection_box)) {
43 C_BLOB_IT blob_it(word->cblob_list());
44 for (blob_it.mark_cycle_pt();
45 !blob_it.cycled_list(); blob_it.forward()) {
46 C_BLOB* blob = blob_it.data();
47 if (blob->bounding_box().overlap(selection_box)) {
48 new_blob_it.add_after_then_move(C_BLOB::deep_copy(blob));
49 pseudo_row = pr_it.row()->row;
50 pseudo_block = pr_it.block()->block;
51 }
52 }
53 }
54 }
55 if (!new_blobs.empty())
56 pseudo_word = new WERD(&new_blobs, 1, NULL);
57 else
58 pseudo_word = NULL;
59 return pseudo_word;
60 }