tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
fpchop.h
1 /**********************************************************************
2  * File: fpchop.h (Formerly fp_chop.h)
3  * Description: Code to chop fixed pitch text into character cells.
4  * Author: Ray Smith
5  *
6  * (C) Copyright 1993, 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 FPCHOP_H
20 #define FPCHOP_H
21 
22 #include "params.h"
23 #include "blobbox.h"
24 
26 {
27  public:
28  C_OUTLINE_FRAG() { //empty constructor
29  steps = nullptr;
30  stepcount = 0;
31  }
33  delete [] steps;
34  }
35  //start coord
36  C_OUTLINE_FRAG(ICOORD start_pt,
37  ICOORD end_pt, //end coord
38  C_OUTLINE *outline, //source of steps
39  int16_t start_index,
40  int16_t end_index);
41  //other end
42  C_OUTLINE_FRAG(C_OUTLINE_FRAG *head, int16_t tail_y);
43  C_OUTLINE *close(); //copy to outline
44  C_OUTLINE_FRAG & operator= ( //assign
45  const C_OUTLINE_FRAG & src);
46 
47  ICOORD start; //start coord
48  ICOORD end; //end coord
49  DIR128 *steps; //step array
50  int32_t stepcount; //no of steps
51  C_OUTLINE_FRAG *other_end; //head if a tail
52  int16_t ycoord; //coord of cut pt
53 
54  private:
55  // Copy constructor (currently unused, therefore private).
56  C_OUTLINE_FRAG(const C_OUTLINE_FRAG& other);
57 };
58 
59 ELISTIZEH(C_OUTLINE_FRAG)
60 
61 extern
62 INT_VAR_H (textord_fp_chop_error, 2,
63 "Max allowed bending of chop cells");
64 extern
65 double_VAR_H (textord_fp_chop_snap, 0.5,
66 "Max distance of chop pt from vertex");
67 ROW *fixed_pitch_words( //find lines
68  TO_ROW *row, //row to do
69  FCOORD rotation //for drawing
70  );
71 WERD *add_repeated_word( //move repeated word
72  WERD_IT *rep_it, //repeated words
73  int16_t &rep_left, //left edge of word
74  int16_t &prev_chop_coord, //previous word end
75  uint8_t &blanks, //no of blanks
76  float pitch, //char cell size
77  WERD_IT *word_it //list of words
78  );
79 void split_to_blob( //split the blob
80  BLOBNBOX *blob, //blob to split
81  int16_t chop_coord, //place to chop
82  float pitch_error, //allowed deviation
83  C_OUTLINE_LIST *left_coutlines, //for cblobs
84  C_OUTLINE_LIST *right_coutlines);
85 void fixed_chop_cblob( //split the blob
86  C_BLOB *blob, //blob to split
87  int16_t chop_coord, //place to chop
88  float pitch_error, //allowed deviation
89  C_OUTLINE_LIST *left_outlines, //left half of chop
90  C_OUTLINE_LIST *right_outlines //right half of chop
91  );
92 void fixed_split_coutline( //chop the outline
93  C_OUTLINE *srcline, //source outline
94  int16_t chop_coord, //place to chop
95  float pitch_error, //allowed deviation
96  C_OUTLINE_IT *left_it, //left half of chop
97  C_OUTLINE_IT *right_it //right half of chop
98  );
99 bool fixed_chop_coutline( //chop the outline
100  C_OUTLINE* srcline, //source outline
101  int16_t chop_coord, //place to chop
102  float pitch_error, //allowed deviation
103  C_OUTLINE_FRAG_LIST* left_frags, //left half of chop
104  C_OUTLINE_FRAG_LIST* right_frags //right half of chop
105 );
106 void save_chop_cfragment( //chop the outline
107  int16_t head_index, //head of fragment
108  ICOORD head_pos, //head of fragment
109  int16_t tail_index, //tail of fragment
110  ICOORD tail_pos, //tail of fragment
111  C_OUTLINE *srcline, //source of edgesteps
112  C_OUTLINE_FRAG_LIST *frags //fragment list
113  );
114 void add_frag_to_list( //ordered add
115  C_OUTLINE_FRAG *frag, //fragment to add
116  C_OUTLINE_FRAG_LIST *frags //fragment list
117  );
118 void close_chopped_cfragments( //chop the outline
119  C_OUTLINE_FRAG_LIST *frags, //list to clear
120  C_OUTLINE_LIST *children, //potential children
121  float pitch_error, //allowed shrinkage
122  C_OUTLINE_IT *dest_it //output list
123  );
124 C_OUTLINE *join_chopped_fragments( //join pieces
125  C_OUTLINE_FRAG *bottom, //bottom of cut
126  C_OUTLINE_FRAG *top //top of cut
127  );
128 void join_segments( //join pieces
129  C_OUTLINE_FRAG *bottom, //bottom of cut
130  C_OUTLINE_FRAG *top //top of cut
131  );
132 #endif
Definition: werd.h:59
Definition: fpchop.h:25
ICOORD start
Definition: fpchop.h:47
Definition: blobbox.h:144
C_OUTLINE_FRAG * other_end
Definition: fpchop.h:51
C_OUTLINE * close()
Definition: fpchop.cpp:770
Definition: stepblob.h:37
C_OUTLINE_FRAG()
Definition: fpchop.h:28
ICOORD end
Definition: fpchop.h:48
Definition: blobbox.h:556
integer coordinate
Definition: points.h:32
Definition: ocrrow.h:36
~C_OUTLINE_FRAG()
Definition: fpchop.h:32
int32_t stepcount
Definition: fpchop.h:50
int16_t ycoord
Definition: fpchop.h:52
Definition: mod128.h:29
C_OUTLINE_FRAG & operator=(const C_OUTLINE_FRAG &src)
Definition: fpchop.cpp:804
Definition: points.h:189
DIR128 * steps
Definition: fpchop.h:49
Definition: coutln.h:72