00001
00020 #ifndef OCRBLOCK_H
00021 #define OCRBLOCK_H
00022
00023 #include "img.h"
00024 #include "ocrrow.h"
00025 #include "pageblk.h"
00026 #include "pdblock.h"
00027
00028 class BLOCK;
00029
00030 ELISTIZEH_S (BLOCK)
00035 class BLOCK:public ELIST_LINK, public PDBLK
00036 {
00037 friend class BLOCK_RECT_IT;
00038
00039
00040 friend void scan_hpd_blocks(const char *name,
00041 PAGE_BLOCK_LIST *page_blocks,
00042 INT32 &block_no,
00043 BLOCK_IT *block_it);
00044 friend BOOL8 read_vec_file(
00045 STRING name,
00046 INT32 xsize,
00047 INT32 ysize,
00048 BLOCK_LIST *blocks);
00049 friend BOOL8 read_pd_file(
00050 STRING name,
00051 INT32 xsize,
00052 INT32 ysize,
00053 BLOCK_LIST *blocks);
00054
00055 public:
00056 BLOCK() {
00057 hand_block = NULL;
00058 hand_poly = NULL;
00059 }
00060 BLOCK(
00061 const char *name,
00062 BOOL8 prop,
00063 INT16 kern,
00064 INT16 space,
00065 INT16 xmin,
00066 INT16 ymin,
00067 INT16 xmax,
00068 INT16 ymax);
00069
00070
00071
00072
00073
00074 ~BLOCK () {
00075 }
00076
00077 void set_stats(
00078 BOOL8 prop,
00079 INT16 kern,
00080 INT16 space,
00081 INT16 ch_pitch) {
00082 proportional = prop;
00083 kerning = (INT8) kern;
00084 spacing = space;
00085 pitch = ch_pitch;
00086 }
00087 void set_xheight(
00088 INT32 height) {
00089 xheight = height;
00090 }
00091 void set_font_class(
00092 INT16 font) {
00093 font_class = font;
00094 }
00095
00096
00097
00098
00099
00100
00101
00102
00103 BOOL8 prop() const {
00104 return proportional;
00105 }
00106 INT32 fixed_pitch() const {
00107 return pitch;
00108 }
00109 INT16 kern() const {
00110 return kerning;
00111 }
00112 INT16 font() const {
00113 return font_class;
00114 }
00115 INT16 space() const {
00116 return spacing;
00117 }
00118 const char *name() const {
00119 return filename.string ();
00120 }
00121 INT32 x_height() const {
00122 return xheight;
00123 }
00124 ROW_LIST *row_list() {
00125 return &rows;
00126 }
00127 C_BLOB_LIST *blob_list() {
00128 return &c_blobs;
00129 }
00130 C_BLOB_LIST *reject_blobs() {
00131 return &rej_blobs;
00132 }
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 void sort_rows();
00152
00153 void compress();
00154
00155 void check_pitch();
00156
00157 void compress(
00158 const ICOORD vec);
00159
00160 void print(
00161 FILE *fp,
00162 BOOL8 dump);
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 void prep_serialise() {
00174 filename.prep_serialise ();
00175 rows.prep_serialise ();
00176 c_blobs.prep_serialise ();
00177 rej_blobs.prep_serialise ();
00178 leftside.prep_serialise ();
00179 rightside.prep_serialise ();
00180 }
00181
00182 void dump(
00183 FILE *f) {
00184 filename.dump (f);
00185 rows.dump (f);
00186 c_blobs.dump (f);
00187 rej_blobs.dump (f);
00188 leftside.dump (f);
00189 rightside.dump (f);
00190 if (hand_block != NULL)
00191 hand_block->serialise (f);
00192 }
00193
00194 void de_dump(
00195 FILE *f) {
00196 filename.de_dump (f);
00197 rows.de_dump (f);
00198 c_blobs.de_dump (f);
00199 rej_blobs.de_dump (f);
00200 leftside.de_dump (f);
00201 rightside.de_dump (f);
00202 if (hand_block != NULL)
00203 hand_block = TEXT_REGION::de_serialise (f);
00204 }
00205
00206
00207 make_serialise (BLOCK) BLOCK & operator= (
00208 const BLOCK & source);
00209
00210 private:
00212 BOOL8 proportional;
00214 INT8 kerning;
00216 INT16 spacing;
00218 INT16 pitch;
00220 INT16 font_class;
00222 INT32 xheight;
00224 STRING filename;
00225
00226
00227
00228
00230 ROW_LIST rows;
00232 C_BLOB_LIST c_blobs;
00234 C_BLOB_LIST rej_blobs;
00235
00236
00237
00238
00239 };
00240
00241 int decreasing_top_order(
00242 const void *row1,
00243 const void *row2);
00244 #endif