tesseract  4.00.00dev
BLOCK_RECT_IT Class Reference

#include <pdblock.h>

Public Member Functions

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

Detailed Description

Definition at line 102 of file pdblock.h.

Constructor & Destructor Documentation

◆ BLOCK_RECT_IT()

BLOCK_RECT_IT::BLOCK_RECT_IT ( PDBLK blkptr)

constructor

Parameters
blkptrblock to iterate

Definition at line 259 of file pdblock.cpp.

262  :left_it (&blkptr->leftside), right_it (&blkptr->rightside) {
263  block = blkptr; //remember block
264  //non empty list
265  if (!blkptr->leftside.empty ()) {
266  start_block(); //ready for iteration
267  }
268 }
ICOORDELT_LIST leftside
Definition: pdblock.h:96
ICOORDELT_LIST rightside
Definition: pdblock.h:97
void start_block()
start iteration
Definition: pdblock.cpp:294

Member Function Documentation

◆ bounding_box()

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

current rectangle

Parameters
bleftbottom left
trighttop right

Definition at line 127 of file pdblock.h.

128  {
129  //bottom left
130  bleft = ICOORD (left_it.data ()->x (), ymin);
131  //top right
132  tright = ICOORD (right_it.data ()->x (), ymax);
133  }
integer coordinate
Definition: points.h:30

◆ cycled_rects()

BOOL8 BLOCK_RECT_IT::cycled_rects ( )
inline

test end

Definition at line 120 of file pdblock.h.

120  {
121  return left_it.cycled_list () && right_it.cycled_list ();
122  }

◆ forward()

void BLOCK_RECT_IT::forward ( )

next rectangle

Definition at line 313 of file pdblock.cpp.

313  { //next rectangle
314  if (!left_it.empty ()) { //non-empty list
315  if (left_it.data_relative (1)->y () == ymax)
316  left_it.forward (); //move to meet top
317  if (right_it.data_relative (1)->y () == ymax)
318  right_it.forward ();
319  //last is special
320  if (left_it.at_last () || right_it.at_last ()) {
321  left_it.move_to_first (); //restart
322  right_it.move_to_first ();
323  //now at bottom
324  ymin = left_it.data ()->y ();
325  }
326  else {
327  ymin = ymax; //new bottom
328  }
329  //next point
330  ymax = left_it.data_relative (1)->y ();
331  if (right_it.data_relative (1)->y () < ymax)
332  //least step forward
333  ymax = right_it.data_relative (1)->y ();
334  }
335 }

◆ set_to_block()

void BLOCK_RECT_IT::set_to_block ( PDBLK blkptr)

start (new) block

Definition at line 277 of file pdblock.cpp.

278  { //block to start
279  block = blkptr; //remember block
280  //set iterators
281  left_it.set_to_list (&blkptr->leftside);
282  right_it.set_to_list (&blkptr->rightside);
283  if (!blkptr->leftside.empty ())
284  start_block(); //ready for iteration
285 }
ICOORDELT_LIST leftside
Definition: pdblock.h:96
ICOORDELT_LIST rightside
Definition: pdblock.h:97
void start_block()
start iteration
Definition: pdblock.cpp:294

◆ start_block()

void BLOCK_RECT_IT::start_block ( )

start iteration

Definition at line 294 of file pdblock.cpp.

294  { //start (new) block
295  left_it.move_to_first ();
296  right_it.move_to_first ();
297  left_it.mark_cycle_pt ();
298  right_it.mark_cycle_pt ();
299  ymin = left_it.data ()->y (); //bottom of first box
300  ymax = left_it.data_relative (1)->y ();
301  if (right_it.data_relative (1)->y () < ymax)
302  //smallest step
303  ymax = right_it.data_relative (1)->y ();
304 }

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