ccstruct/pdblock.h

Go to the documentation of this file.
00001 
00020 #ifndef           PDBLOCK_H
00021 #define           PDBLOCK_H
00022 
00023 #include          "img.h"
00024 #include          "strngs.h"
00025 #include          "pageblk.h"
00026 
00027 #include          "hpddef.h"     //must be last (handpd.dll)
00028 
00029 class DLLSYM PDBLK;              // forward decl
00030 
00031 CLISTIZEH (PDBLK)
00036 class DLLSYM PDBLK
00037 {
00038   friend class BLOCK_RECT_IT;    // block iterator
00039 
00040   friend void scan_hpd_blocks(const char *name, // block label
00041                               PAGE_BLOCK_LIST *page_blocks,// head of full pag
00042                               INT32 &block_no,             // no of blocks
00043                               PDBLK_C_IT *block_it);
00044   friend BOOL8 read_vec_file(              // read uscan output
00045                              STRING name,  // basename of file
00046                              INT32 xsize,  // page size //output list
00047                              INT32 ysize,
00048                              PDBLK_CLIST *blocks);
00049   friend BOOL8 read_pd_file(              // read uscan output
00050                             STRING name,  // basename of file
00051                             INT32 xsize,  // page size //output list
00052                             INT32 ysize,
00053                             PDBLK_CLIST *blocks);
00054 
00055   public:
00056     PDBLK() {  // empty constructor
00057       hand_block = NULL;
00058       hand_poly = NULL;
00059     }
00060     PDBLK(             // simple constructor
00061           INT16 xmin,  // bottom left
00062           INT16 ymin,
00063           INT16 xmax,  // top right
00064           INT16 ymax);
00065 
00066     void set_sides(                         // set vertex lists
00067                    ICOORDELT_LIST *left,    // list of left vertices
00068                    ICOORDELT_LIST *right);  // list of right vertices
00069 
00070     ~PDBLK () {                  // destructor
00071     }
00072 
00073     TEXT_REGION *text_region() { 
00074       return hand_block;
00075     }
00076     POLY_BLOCK *poly_block() { 
00077       return hand_poly;
00078     }
00079     void set_poly_block(  // set the poly block
00080                         POLY_BLOCK *blk) {
00081       hand_poly = blk;
00082     }
00083     void bounding_box(                            //get box
00084                       ICOORD &bottom_left,        //bottom left
00085                       ICOORD &top_right) const {  //topright
00086       bottom_left = box.botleft ();
00087       top_right = box.topright ();
00088     }
00089                                  //get real box
00090     const BOX &bounding_box() const { 
00091       return box;
00092     }
00093 
00094     BOOL8 contains(  //is pt inside block
00095                    ICOORD pt);
00096 
00097     void move(                    // reposition block
00098               const ICOORD vec);  // by vector
00099 
00100     void plot(                 // draw histogram
00101               WINDOW window,   // window to draw in
00102               INT32 serial,    // serial number
00103               COLOUR colour);  // colour to draw in
00104 
00105     void show(                 // show image
00106               IMAGE *image,    // image to show
00107               WINDOW window);  // window to show in
00108 
00109     PDBLK & operator= (          // assignment
00110       const PDBLK & source);     // from this
00111 
00112   protected:
00114     TEXT_REGION * hand_block;
00116     POLY_BLOCK *hand_poly;
00118     ICOORDELT_LIST leftside;
00120     ICOORDELT_LIST rightside;
00122     BOX box;
00123 };
00124 
00129 class DLLSYM BLOCK_RECT_IT
00130 {
00131   public:
00132     BLOCK_RECT_IT(                 // constructor
00133                   PDBLK *blkptr);  // block to iterate
00134 
00135     NEWDELETE2 (BLOCK_RECT_IT) void set_to_block ( // start (new) block
00136       PDBLK * blkptr);           // block to iterate
00137 
00138     void start_block();  // start iteration
00139 
00140     void forward();  // next rectangle
00141 
00142     BOOL8 cycled_rects() {  // test end
00143       return left_it.cycled_list () && right_it.cycled_list ();
00144     }
00145 
00146     void bounding_box(                   // current rectangle
00147                       ICOORD &bleft,     // bottom left
00148                       ICOORD &tright) {  // top right
00149       bleft = ICOORD (left_it.data ()->x (), ymin); // bottom left
00150       tright = ICOORD (right_it.data ()->x (), ymax); // top right
00151     }
00152 
00153   private:
00155     INT16 ymin;
00157     INT16 ymax;
00159     PDBLK *block;
00161     ICOORDELT_IT left_it;
00163     ICOORDELT_IT right_it;
00164 };
00165 
00170 class DLLSYM BLOCK_LINE_IT
00171 {
00172   public:
00173     BLOCK_LINE_IT (              // constructor
00174       PDBLK * blkptr)            // from block
00175     :rect_it (blkptr) {
00176       block = blkptr;            // remember block
00177     }
00178 
00179     NEWDELETE2 (BLOCK_LINE_IT) void set_to_block ( // start (new) block
00180     PDBLK * blkptr) {            // block to start
00181       block = blkptr;            // remember block
00182                                  // set iterator
00183       rect_it.set_to_block (blkptr);
00184     }
00185 
00186     INT16 get_line(               // get a line
00187                    INT16 y,       // line to get
00188                    INT16 &xext);  // output extent
00189 
00190   private:
00192     PDBLK * block;
00194     BLOCK_RECT_IT rect_it;
00195 };
00196 
00197 int decreasing_top_order(  //
00198                          const void *row1,
00199                          const void *row2);
00204 #endif

Generated on Wed Feb 28 19:49:08 2007 for Tesseract by  doxygen 1.5.1