tesseract  5.0.0-alpha-619-ge9db
fpchop.h
Go to the documentation of this file.
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 
25 class C_OUTLINE_FRAG:public ELIST_LINK
26 {
27  public:
28  C_OUTLINE_FRAG() { //empty constructor
29  steps = nullptr;
30  stepcount = 0;
31  }
32  ~C_OUTLINE_FRAG () {
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 
60 
61 extern
63 "Max allowed bending of chop cells");
64 extern
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
fixed_split_coutline
void fixed_split_coutline(C_OUTLINE *srcline, int16_t chop_coord, float pitch_error, C_OUTLINE_IT *left_it, C_OUTLINE_IT *right_it)
Definition: fpchop.cpp:306
add_frag_to_list
void add_frag_to_list(C_OUTLINE_FRAG *frag, C_OUTLINE_FRAG_LIST *frags)
Definition: fpchop.cpp:592
fixed_chop_coutline
bool fixed_chop_coutline(C_OUTLINE *srcline, int16_t chop_coord, float pitch_error, C_OUTLINE_FRAG_LIST *left_frags, C_OUTLINE_FRAG_LIST *right_frags)
Definition: fpchop.cpp:387
save_chop_cfragment
void save_chop_cfragment(int16_t head_index, ICOORD head_pos, int16_t tail_index, ICOORD tail_pos, C_OUTLINE *srcline, C_OUTLINE_FRAG_LIST *frags)
Definition: fpchop.cpp:503
DIR128
Definition: mod128.h:28
C_OUTLINE_FRAG::end
ICOORD end
Definition: fpchop.h:62
textord_fp_chop_error
int textord_fp_chop_error
Definition: fpchop.cpp:31
C_OUTLINE_FRAG
Definition: fpchop.h:24
blobbox.h
params.h
ICOORD
integer coordinate
Definition: points.h:30
C_OUTLINE_FRAG::start
ICOORD start
Definition: fpchop.h:61
fixed_pitch_words
ROW * fixed_pitch_words(TO_ROW *row, FCOORD rotation)
Definition: fpchop.cpp:42
FCOORD
Definition: points.h:187
BLOBNBOX
Definition: blobbox.h:142
double_VAR_H
#define double_VAR_H(name, val, comment)
Definition: params.h:298
ELISTIZEH
#define ELISTIZEH(CLASSNAME)
Definition: elst.h:907
C_OUTLINE_FRAG::other_end
C_OUTLINE_FRAG * other_end
Definition: fpchop.h:65
C_BLOB
Definition: stepblob.h:36
C_OUTLINE
Definition: coutln.h:71
C_OUTLINE_FRAG::~C_OUTLINE_FRAG
~C_OUTLINE_FRAG()
Definition: fpchop.h:46
close_chopped_cfragments
void close_chopped_cfragments(C_OUTLINE_FRAG_LIST *frags, C_OUTLINE_LIST *children, float pitch_error, C_OUTLINE_IT *dest_it)
Definition: fpchop.cpp:620
C_OUTLINE_FRAG::steps
DIR128 * steps
Definition: fpchop.h:63
C_OUTLINE_FRAG::operator=
C_OUTLINE_FRAG & operator=(const C_OUTLINE_FRAG &src)
Definition: fpchop.cpp:786
split_to_blob
void split_to_blob(BLOBNBOX *blob, int16_t chop_coord, float pitch_error, C_OUTLINE_LIST *left_coutlines, C_OUTLINE_LIST *right_coutlines)
Definition: fpchop.cpp:232
distance
UnicodeText::const_iterator::difference_type distance(const UnicodeText::const_iterator &first, const UnicodeText::const_iterator &last)
Definition: unicodetext.cc:44
INT_VAR_H
#define INT_VAR_H(name, val, comment)
Definition: params.h:292
fixed_chop_cblob
void fixed_chop_cblob(C_BLOB *blob, int16_t chop_coord, float pitch_error, C_OUTLINE_LIST *left_outlines, C_OUTLINE_LIST *right_outlines)
Definition: fpchop.cpp:261
C_OUTLINE_FRAG::ycoord
int16_t ycoord
Definition: fpchop.h:66
C_OUTLINE_FRAG::C_OUTLINE_FRAG
C_OUTLINE_FRAG()
Definition: fpchop.h:42
C_OUTLINE_FRAG::stepcount
int32_t stepcount
Definition: fpchop.h:64
WERD
Definition: werd.h:55
ROW
Definition: ocrrow.h:35
join_segments
void join_segments(C_OUTLINE_FRAG *bottom, C_OUTLINE_FRAG *top)
Definition: fpchop.cpp:716
of
EndParamDesc of
Definition: featdefs.cpp:98
textord_fp_chop_snap
double textord_fp_chop_snap
Definition: fpchop.cpp:33
TO_ROW
Definition: blobbox.h:543
ELIST_LINK
Definition: elst.h:74
add_repeated_word
WERD * add_repeated_word(WERD_IT *rep_it, int16_t &rep_left, int16_t &prev_chop_coord, uint8_t &blanks, float pitch, WERD_IT *word_it)
Definition: fpchop.cpp:197
join_chopped_fragments
C_OUTLINE * join_chopped_fragments(C_OUTLINE_FRAG *bottom, C_OUTLINE_FRAG *top)
Definition: fpchop.cpp:680
C_OUTLINE_FRAG::close
C_OUTLINE * close()
Definition: fpchop.cpp:753