tesseract
5.0.0-alpha-619-ge9db
polyblk.h
Go to the documentation of this file.
1
/**********************************************************************
2
* File: polyblk.h (Formerly poly_block.h)
3
* Description: Polygonal blocks
4
*
5
* (C) Copyright 1993, Hewlett-Packard Ltd.
6
** Licensed under the Apache License, Version 2.0 (the "License");
7
** you may not use this file except in compliance with the License.
8
** You may obtain a copy of the License at
9
** http://www.apache.org/licenses/LICENSE-2.0
10
** Unless required by applicable law or agreed to in writing, software
11
** distributed under the License is distributed on an "AS IS" BASIS,
12
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
** See the License for the specific language governing permissions and
14
** limitations under the License.
15
*
16
**********************************************************************/
17
18
#ifndef POLYBLK_H
19
#define POLYBLK_H
20
21
#include <
tesseract/publictypes.h
>
22
#include "
elst.h
"
23
#include "
points.h
"
24
#include "
rect.h
"
25
#include "
scrollview.h
"
26
27
class
DLLSYM
POLY_BLOCK
{
28
public
:
29
POLY_BLOCK
() =
default
;
30
// Initialize from box coordinates.
31
POLY_BLOCK
(
const
TBOX
& tbox,
PolyBlockType
type
);
32
POLY_BLOCK
(ICOORDELT_LIST *points,
PolyBlockType
type
);
33
~
POLY_BLOCK
() =
default
;
34
35
TBOX
*bounding_box() {
// access function
36
return
&box;
37
}
38
39
ICOORDELT_LIST *points() {
// access function
40
return
&vertices;
41
}
42
43
void
compute_bb();
44
45
PolyBlockType
isA()
const
{
46
return
type
;
47
}
48
49
bool
IsText()
const
{
50
return
PTIsTextType
(
type
);
51
}
52
53
// Rotate about the origin by the given rotation. (Analogous to
54
// multiplying by a complex number.
55
void
rotate(
FCOORD
rotation);
56
// Reflect the coords of the polygon in the y-axis. (Flip the sign of x.)
57
void
reflect_in_y_axis();
58
// Move by adding shift to all coordinates.
59
void
move(
ICOORD
shift);
60
61
void
plot(
ScrollView
* window, int32_t num);
62
63
#ifndef GRAPHICS_DISABLED
64
void
fill(
ScrollView
* window,
ScrollView::Color
colour);
65
#endif // GRAPHICS_DISABLED
66
67
// Returns true if other is inside this.
68
bool
contains(
POLY_BLOCK
*other);
69
70
// Returns true if the polygons of other and this overlap.
71
bool
overlap(
POLY_BLOCK
*other);
72
73
// Returns the winding number of this around the test_pt.
74
// Positive for anticlockwise, negative for clockwise, and zero for
75
// test_pt outside this.
76
int16_t winding_number(
const
ICOORD
&test_pt);
77
78
#ifndef GRAPHICS_DISABLED
79
// Static utility functions to handle the PolyBlockType.
80
// Returns a color to draw the given type.
81
static
ScrollView::Color
ColorForPolyBlockType(
PolyBlockType
type
);
82
#endif // GRAPHICS_DISABLED
83
84
private
:
85
ICOORDELT_LIST vertices;
// vertices
86
TBOX
box;
// bounding box
87
PolyBlockType
type
;
// Type of this region.
88
};
89
90
// Class to iterate the scanlines of a polygon.
91
class
DLLSYM
PB_LINE_IT
{
92
public
:
93
PB_LINE_IT
(
POLY_BLOCK
*blkptr) {
94
block = blkptr;
95
}
96
97
void
set_to_block(
POLY_BLOCK
* blkptr) {
98
block = blkptr;
99
}
100
101
// Returns a list of runs of pixels for the given y coord.
102
// Each element of the returned list is the start (x) and extent(y) of
103
// a run inside the region.
104
// Delete the returned list after use.
105
ICOORDELT_LIST *get_line(int16_t y);
106
107
private
:
108
POLY_BLOCK
* block;
109
};
110
#endif
ScrollView
Definition:
scrollview.h:97
elst.h
ICOORD
integer coordinate
Definition:
points.h:30
PB_LINE_IT
Definition:
polyblk.h:90
rect.h
FCOORD
Definition:
points.h:187
publictypes.h
DLLSYM
#define DLLSYM
Definition:
platform.h:21
PTIsTextType
bool PTIsTextType(PolyBlockType type)
Definition:
publictypes.h:81
tesstrain_utils.type
type
Definition:
tesstrain_utils.py:141
POLY_BLOCK
Definition:
polyblk.h:26
ScrollView::Color
Color
Definition:
scrollview.h:100
PolyBlockType
PolyBlockType
Definition:
publictypes.h:52
scrollview.h
points.h
TBOX
Definition:
rect.h:33
src
ccstruct
polyblk.h
Generated on Thu Jan 30 2020 14:22:20 for tesseract by
1.8.16