Tesseract  3.02
BLOCK_RECT_IT Class Reference

#include <pdblock.h>

List of all members.

Public Member Functions

 BLOCK_RECT_IT (PDBLK *blkptr)
void set_to_block (PDBLK *blkptr)
 start (new) block
void start_block ()
 start iteration
void forward ()
 next rectangle
BOOL8 cycled_rects ()
 test end
void bounding_box (ICOORD &bleft, ICOORD &tright)

Detailed Description

Definition at line 122 of file pdblock.h.


Constructor & Destructor Documentation

BLOCK_RECT_IT::BLOCK_RECT_IT ( PDBLK blkptr)

constructor

Parameters:
blkptrblock to iterate

Definition at line 290 of file pdblock.cpp.

 :left_it (&blkptr->leftside), right_it (&blkptr->rightside) {
  block = blkptr;                //remember block
                                 //non empty list
  if (!blkptr->leftside.empty ()) {
    start_block();  //ready for iteration
  }
}

Member Function Documentation

void BLOCK_RECT_IT::bounding_box ( ICOORD bleft,
ICOORD tright 
) [inline]

current rectangle

Parameters:
bleftbottom left
trighttop right

Definition at line 147 of file pdblock.h.

                                      {
                                 //bottom left
      bleft = ICOORD (left_it.data ()->x (), ymin);
                                 //top right
      tright = ICOORD (right_it.data ()->x (), ymax);
    }
BOOL8 BLOCK_RECT_IT::cycled_rects ( ) [inline]

test end

Definition at line 140 of file pdblock.h.

                         {
      return left_it.cycled_list () && right_it.cycled_list ();
    }
void BLOCK_RECT_IT::forward ( )

next rectangle

Definition at line 344 of file pdblock.cpp.

                            {  //next rectangle
  if (!left_it.empty ()) {       //non-empty list
    if (left_it.data_relative (1)->y () == ymax)
      left_it.forward ();        //move to meet top
    if (right_it.data_relative (1)->y () == ymax)
      right_it.forward ();
                                 //last is special
    if (left_it.at_last () || right_it.at_last ()) {
      left_it.move_to_first ();  //restart
      right_it.move_to_first ();
                                 //now at bottom
      ymin = left_it.data ()->y ();
    }
    else {
      ymin = ymax;               //new bottom
    }
                                 //next point
    ymax = left_it.data_relative (1)->y ();
    if (right_it.data_relative (1)->y () < ymax)
                                 //least step forward
      ymax = right_it.data_relative (1)->y ();
  }
}
void BLOCK_RECT_IT::set_to_block ( PDBLK blkptr)

start (new) block

Definition at line 308 of file pdblock.cpp.

                                                {  //block to start
  block = blkptr;                //remember block
                                 //set iterators
  left_it.set_to_list (&blkptr->leftside);
  right_it.set_to_list (&blkptr->rightside);
  if (!blkptr->leftside.empty ())
    start_block();  //ready for iteration
}
void BLOCK_RECT_IT::start_block ( )

start iteration

Definition at line 325 of file pdblock.cpp.

                                {  //start (new) block
  left_it.move_to_first ();
  right_it.move_to_first ();
  left_it.mark_cycle_pt ();
  right_it.mark_cycle_pt ();
  ymin = left_it.data ()->y ();  //bottom of first box
  ymax = left_it.data_relative (1)->y ();
  if (right_it.data_relative (1)->y () < ymax)
                                 //smallest step
    ymax = right_it.data_relative (1)->y ();
}

The documentation for this class was generated from the following files: