Tesseract  3.02
tesseract-ocr/textord/fpchop.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        fpchop.h  (Formerly fp_chop.h)
00003  * Description: Code to chop fixed pitch text into character cells.
00004  * Author:              Ray Smith
00005  * Created:             Thu Sep 16 11:14:15 BST 1993
00006  *
00007  * (C) Copyright 1993, Hewlett-Packard Ltd.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 #ifndef           FPCHOP_H
00021 #define           FPCHOP_H
00022 
00023 #include          "params.h"
00024 #include          "blobbox.h"
00025 #include          "notdll.h"
00026 #include          "notdll.h"
00027 
00028 class C_OUTLINE_FRAG:public ELIST_LINK
00029 {
00030   public:
00031     C_OUTLINE_FRAG() {  //empty constructor
00032       steps = NULL;
00033       stepcount = 0;
00034     }
00035     ~C_OUTLINE_FRAG () {
00036       if (steps != NULL)
00037         delete [] steps;
00038     }
00039                                  //start coord
00040     C_OUTLINE_FRAG(ICOORD start_pt,
00041                    ICOORD end_pt,       //end coord
00042                    C_OUTLINE *outline,  //source of steps
00043                    inT16 start_index,
00044                    inT16 end_index);
00045                                  //other end
00046     C_OUTLINE_FRAG(C_OUTLINE_FRAG *head, inT16 tail_y);
00047     C_OUTLINE *close();  //copy to outline
00048     C_OUTLINE_FRAG & operator= ( //assign
00049       const C_OUTLINE_FRAG & src);
00050 
00051     ICOORD start;                //start coord
00052     ICOORD end;                  //end coord
00053     DIR128 *steps;                //step array
00054     inT32 stepcount;             //no of steps
00055     C_OUTLINE_FRAG *other_end;   //head if a tail
00056     inT16 ycoord;                //coord of cut pt
00057 
00058   private:
00059 };
00060 
00061 ELISTIZEH(C_OUTLINE_FRAG)
00062 
00063 extern
00064 INT_VAR_H (textord_fp_chop_error, 2,
00065 "Max allowed bending of chop cells");
00066 extern
00067 double_VAR_H (textord_fp_chop_snap, 0.5,
00068 "Max distance of chop pt from vertex");
00069 ROW *fixed_pitch_words(                 //find lines
00070                        TO_ROW *row,     //row to do
00071                        FCOORD rotation  //for drawing
00072                       );
00073 WERD *add_repeated_word(                         //move repeated word
00074                         WERD_IT *rep_it,         //repeated words
00075                         inT16 &rep_left,         //left edge of word
00076                         inT16 &prev_chop_coord,  //previous word end
00077                         uinT8 &blanks,           //no of blanks
00078                         float pitch,             //char cell size
00079                         WERD_IT *word_it         //list of words
00080                        );
00081 void split_to_blob(                                 //split the blob
00082                    BLOBNBOX *blob,                  //blob to split
00083                    inT16 chop_coord,                //place to chop
00084                    float pitch_error,               //allowed deviation
00085                    C_OUTLINE_LIST *left_coutlines,  //for cblobs
00086                    C_OUTLINE_LIST *right_coutlines);
00087 void fixed_chop_cblob(                                //split the blob
00088                       C_BLOB *blob,                   //blob to split
00089                       inT16 chop_coord,               //place to chop
00090                       float pitch_error,              //allowed deviation
00091                       C_OUTLINE_LIST *left_outlines,  //left half of chop
00092                       C_OUTLINE_LIST *right_outlines  //right half of chop
00093                      );
00094 void fixed_split_coutline(                        //chop the outline
00095                           C_OUTLINE *srcline,     //source outline
00096                           inT16 chop_coord,       //place to chop
00097                           float pitch_error,      //allowed deviation
00098                           C_OUTLINE_IT *left_it,  //left half of chop
00099                           C_OUTLINE_IT *right_it  //right half of chop
00100                          );
00101 BOOL8 fixed_chop_coutline(                                  //chop the outline
00102                           C_OUTLINE *srcline,               //source outline
00103                           inT16 chop_coord,                 //place to chop
00104                           float pitch_error,                //allowed deviation
00105                           C_OUTLINE_FRAG_LIST *left_frags,  //left half of chop
00106                           C_OUTLINE_FRAG_LIST *right_frags  //right half of chop
00107                          );
00108 inT16 next_anti_left_seg(                     //chop the outline
00109                          C_OUTLINE *srcline,  //source outline
00110                          inT16 tail_index,    //of tailpos
00111                          inT16 startindex,    //end of search
00112                          inT32 length,        //of outline
00113                          inT16 chop_coord,    //place to chop
00114                          float pitch_error,   //allowed deviation
00115                          ICOORD *tail_pos     //current position
00116                         );
00117 inT16 next_anti_right_seg(                     //chop the outline
00118                           C_OUTLINE *srcline,  //source outline
00119                           inT16 tail_index,    //of tailpos
00120                           inT16 startindex,    //end of search
00121                           inT32 length,        //of outline
00122                           inT16 chop_coord,    //place to chop
00123                           float pitch_error,   //allowed deviation
00124                           ICOORD *tail_pos     //current position
00125                          );
00126 inT16 next_clock_left_seg(                     //chop the outline
00127                           C_OUTLINE *srcline,  //source outline
00128                           inT16 tail_index,    //of tailpos
00129                           inT16 startindex,    //end of search
00130                           inT32 length,        //of outline
00131                           inT16 chop_coord,    //place to chop
00132                           float pitch_error,   //allowed deviation
00133                           ICOORD *tail_pos     //current position
00134                          );
00135 inT16 next_clock_right_seg(                     //chop the outline
00136                            C_OUTLINE *srcline,  //source outline
00137                            inT16 tail_index,    //of tailpos
00138                            inT16 startindex,    //end of search
00139                            inT32 length,        //of outline
00140                            inT16 chop_coord,    //place to chop
00141                            float pitch_error,   //allowed deviation
00142                            ICOORD *tail_pos     //current position
00143                           );
00144 void save_chop_cfragment(                            //chop the outline
00145                          inT16 head_index,           //head of fragment
00146                          ICOORD head_pos,            //head of fragment
00147                          inT16 tail_index,           //tail of fragment
00148                          ICOORD tail_pos,            //tail of fragment
00149                          C_OUTLINE *srcline,         //source of edgesteps
00150                          C_OUTLINE_FRAG_LIST *frags  //fragment list
00151                         );
00152 void add_frag_to_list(                            //ordered add
00153                       C_OUTLINE_FRAG *frag,       //fragment to add
00154                       C_OUTLINE_FRAG_LIST *frags  //fragment list
00155                      );
00156 void close_chopped_cfragments(                             //chop the outline
00157                               C_OUTLINE_FRAG_LIST *frags,  //list to clear
00158                               C_OUTLINE_LIST *children,    //potential children
00159                               float pitch_error,           //allowed shrinkage
00160                               C_OUTLINE_IT *dest_it        //output list
00161                              );
00162 C_OUTLINE *join_chopped_fragments(                         //join pieces
00163                                   C_OUTLINE_FRAG *bottom,  //bottom of cut
00164                                   C_OUTLINE_FRAG *top      //top of cut
00165                                  );
00166 void join_segments(                         //join pieces
00167                    C_OUTLINE_FRAG *bottom,  //bottom of cut
00168                    C_OUTLINE_FRAG *top      //top of cut
00169                   );
00170 #endif