tesseract  4.0.0-1-g2a2b
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...
 
bool cycled_rects ()
 test end More...
 
void bounding_box (ICOORD &bleft, ICOORD &tright)
 

Detailed Description

Definition at line 103 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 262 of file pdblock.cpp.

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

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 128 of file pdblock.h.

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

◆ cycled_rects()

bool BLOCK_RECT_IT::cycled_rects ( )
inline

test end

Definition at line 121 of file pdblock.h.

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

◆ forward()

void BLOCK_RECT_IT::forward ( )

next rectangle

Definition at line 316 of file pdblock.cpp.

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

◆ set_to_block()

void BLOCK_RECT_IT::set_to_block ( PDBLK blkptr)

start (new) block

Definition at line 280 of file pdblock.cpp.

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

◆ start_block()

void BLOCK_RECT_IT::start_block ( )

start iteration

Definition at line 297 of file pdblock.cpp.

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

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