tesseract 4.1.1
Loading...
Searching...
No Matches
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 *
6 * (C) Copyright 1991, Hewlett-Packard Ltd.
7 ** Licensed under the Apache License, Version 2.0 (the "License");
8 ** you may not use this file except in compliance with the License.
9 ** You may obtain a copy of the License at
10 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 *
17 **********************************************************************/
18
19#ifndef PDBLOCK_H
20#define PDBLOCK_H
21
22#include "clst.h"
23#include "strngs.h"
24#include "polyblk.h"
25
26class DLLSYM PDBLK; //forward decl
27struct Pix;
28
31class PDBLK {
32 friend class BLOCK_RECT_IT;
33 friend class BLOCK;
34
35 public:
38 hand_poly = nullptr;
39 index_ = 0;
40 }
42 PDBLK(int16_t xmin,
43 int16_t ymin,
44 int16_t xmax,
45 int16_t ymax);
46
50 void set_sides(ICOORDELT_LIST *left, ICOORDELT_LIST *right);
51
53 ~PDBLK() { delete hand_poly; }
54
55 POLY_BLOCK *poly_block() const { return hand_poly; }
57 void set_poly_block(POLY_BLOCK *blk) { hand_poly = blk; }
59 void bounding_box(ICOORD &bottom_left, // bottom left
60 ICOORD &top_right) const { // topright
61 bottom_left = box.botleft();
62 top_right = box.topright();
63 }
65 const TBOX &bounding_box() const { return box; }
66
67 int index() const { return index_; }
68 void set_index(int value) { index_ = value; }
69
71 bool contains(ICOORD pt);
72
74 void move(const ICOORD vec); // by vector
75
76 // Returns a binary Pix mask with a 1 pixel for every pixel within the
77 // block. Rotates the coordinate system by rerotation prior to rendering.
78 // If not nullptr, mask_box is filled with the position box of the returned
79 // mask image.
80 Pix *render_mask(const FCOORD &rerotation, TBOX *mask_box);
81
82#ifndef GRAPHICS_DISABLED
87 void plot(ScrollView *window, int32_t serial, ScrollView::Color colour);
88#endif // GRAPHICS_DISABLED
89
92 PDBLK &operator=(const PDBLK &source);
93
94 protected:
96 ICOORDELT_LIST leftside;
97 ICOORDELT_LIST rightside;
99 int index_;
100};
101
102class DLLSYM BLOCK_RECT_IT //rectangle iterator
103{
104 public:
107 BLOCK_RECT_IT(PDBLK *blkptr);
108
110 void set_to_block (
111 PDBLK * blkptr); //block to iterate
112
114 void start_block();
115
117 void forward();
118
121 return left_it.cycled_list() && right_it.cycled_list();
122 }
123
127 void bounding_box(ICOORD &bleft,
128 ICOORD &tright) {
129 //bottom left
130 bleft = ICOORD (left_it.data ()->x (), ymin);
131 //top right
132 tright = ICOORD (right_it.data ()->x (), ymax);
133 }
134
135 private:
136 int16_t ymin = 0;
137 int16_t ymax = 0;
138 PDBLK* block = nullptr;
139 ICOORDELT_IT left_it;
140 ICOORDELT_IT right_it;
141};
142
145{
146 public:
150 :rect_it (blkptr) {
151 block = blkptr; //remember block
152 }
153
156 void set_to_block (PDBLK * blkptr) {
157 block = blkptr; //remember block
158 //set iterator
159 rect_it.set_to_block (blkptr);
160 }
161
165 int16_t get_line(int16_t y,
166 int16_t &xext);
167
168 private:
169 PDBLK * block;
170 BLOCK_RECT_IT rect_it;
171};
172
173#endif
#define CLISTIZEH(CLASSNAME)
Definition: clst.h:879
#define DLLSYM
Definition: platform.h:21
Definition: ocrblock.h:31
BLOCK & operator=(const BLOCK &source)
Definition: ocrblock.cpp:222
Pix * render_mask(TBOX *mask_box)
Definition: ocrblock.h:160
page block
Definition: pdblock.h:31
~PDBLK()
destructor
Definition: pdblock.h:53
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:59
POLY_BLOCK * hand_poly
weird as well
Definition: pdblock.h:95
void set_poly_block(POLY_BLOCK *blk)
set the poly block
Definition: pdblock.h:57
int index() const
Definition: pdblock.h:67
void set_index(int value)
Definition: pdblock.h:68
ICOORDELT_LIST rightside
right side vertices
Definition: pdblock.h:97
int index_
Serial number of this block.
Definition: pdblock.h:99
POLY_BLOCK * poly_block() const
Definition: pdblock.h:55
const TBOX & bounding_box() const
get real box
Definition: pdblock.h:65
TBOX box
bounding box
Definition: pdblock.h:98
PDBLK()
empty constructor
Definition: pdblock.h:37
ICOORDELT_LIST leftside
left side vertices
Definition: pdblock.h:96
void bounding_box(ICOORD &bleft, ICOORD &tright)
Definition: pdblock.h:127
bool cycled_rects()
test end
Definition: pdblock.h:120
rectangle iterator
Definition: pdblock.h:145
BLOCK_LINE_IT(PDBLK *blkptr)
Definition: pdblock.h:149
void set_to_block(PDBLK *blkptr)
Definition: pdblock.h:156
integer coordinate
Definition: points.h:32
Definition: points.h:189
Definition: rect.h:34