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
pdblock.h
Go to the documentation of this file.
1 /**********************************************************************
2 * File: pdblock.h (Formerly pdblk.h)
3 * Description: Page block class definition.
4 * Author: Ray Smith
5 * Created: Thu Mar 14 17:32:01 GMT 1991
6 *
7 * (C) Copyright 1991, 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 #ifndef PDBLOCK_H
21 #define PDBLOCK_H
22
23 #include "clst.h"
24 #include "img.h"
25 #include "strngs.h"
26 #include "polyblk.h"
27
28 #include "hpddef.h" //must be last (handpd.dll)
29
30 class DLLSYM PDBLK; //forward decl
31 struct Pix;
32
33 CLISTIZEH (PDBLK)
35 class PDBLK
36 {
37 friend class BLOCK_RECT_IT; //< block iterator
38
39 public:
41 PDBLK() {
42 hand_poly = NULL;
43 index_ = 0;
44 }
46 PDBLK(inT16 xmin, //< bottom left
47 inT16 ymin,
48 inT16 xmax, //< top right
49 inT16 ymax);
50
54 void set_sides(ICOORDELT_LIST *left,
55 ICOORDELT_LIST *right);
56
58 ~PDBLK () {
59 if (hand_poly) delete hand_poly;
60 }
61
62 POLY_BLOCK *poly_block() const {
63 return hand_poly;
64 }
66 void set_poly_block(POLY_BLOCK *blk) {
67 hand_poly = blk;
68 }
70 void bounding_box(ICOORD &bottom_left, //bottom left
71 ICOORD &top_right) const { //topright
72 bottom_left = box.botleft ();
73 top_right = box.topright ();
74 }
76 const TBOX &bounding_box() const {
77 return box;
78 }
79
80 int index() const {
81 return index_;
82 }
83 void set_index(int value) {
84 index_ = value;
85 }
86
88 BOOL8 contains(ICOORD pt);
89
91 void move(const ICOORD vec); // by vector
92
93 // Returns a binary Pix mask with a 1 pixel for every pixel within the
94 // block. Rotates the coordinate system by rerotation prior to rendering.
95 Pix* render_mask(const FCOORD& rerotation);
96
97 #ifndef GRAPHICS_DISABLED
98
99
100
101
102 void plot(ScrollView* window,
103 inT32 serial,
104 ScrollView::Color colour);
105 #endif // GRAPHICS_DISABLED
106
107
108
109 void show(IMAGE *image,
110 ScrollView* window);
111
114 PDBLK & operator= (const PDBLK & source);
115
116 protected:
117 POLY_BLOCK *hand_poly; //< wierd as well
118 ICOORDELT_LIST leftside; //< left side vertices
119 ICOORDELT_LIST rightside; //< right side vertices
120 TBOX box; //< bounding box
121 int index_; //< Serial number of this block.
122 };
123
124 class DLLSYM BLOCK_RECT_IT //rectangle iterator
125 {
126 public:
129 BLOCK_RECT_IT(PDBLK *blkptr);
130
132 void set_to_block (
133 PDBLK * blkptr); //block to iterate
134
136 void start_block();
137
139 void forward();
140
142 BOOL8 cycled_rects() {
143 return left_it.cycled_list () && right_it.cycled_list ();
144 }
145
149 void bounding_box(ICOORD &bleft,
150 ICOORD &tright) {
151 //bottom left
152 bleft = ICOORD (left_it.data ()->x (), ymin);
153 //top right
154 tright = ICOORD (right_it.data ()->x (), ymax);
155 }
156
157 private:
158 inT16 ymin; //< bottom of rectangle
159 inT16 ymax; //< top of rectangle
160 PDBLK *block; //< block to iterate
161 ICOORDELT_IT left_it; //< boundary iterators
162 ICOORDELT_IT right_it;
163 };
164
166 class DLLSYM BLOCK_LINE_IT
167 {
168 public:
171 BLOCK_LINE_IT (PDBLK * blkptr)
172 :rect_it (blkptr) {
173 block = blkptr; //remember block
174 }
175
178 void set_to_block (PDBLK * blkptr) {
179 block = blkptr; //remember block
180 //set iterator
181 rect_it.set_to_block (blkptr);
182 }
183
187 inT16 get_line(inT16 y,
188 inT16 &xext);
189
190 private:
191 PDBLK * block; //< block to iterate
192 BLOCK_RECT_IT rect_it; //< rectangle iterator
193 };
194
195 int decreasing_top_order(const void *row1,
196 const void *row2);
197 #endif