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 260 of file pdblock.cpp.

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

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 314 of file pdblock.cpp.

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

◆ set_to_block()

void BLOCK_RECT_IT::set_to_block ( PDBLK blkptr)

start (new) block

Definition at line 278 of file pdblock.cpp.

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

◆ start_block()

void BLOCK_RECT_IT::start_block ( )

start iteration

Definition at line 295 of file pdblock.cpp.

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

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