tesseract  5.0.0
tesseract::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 () const
 test end More...
 
void bounding_box (ICOORD &bleft, ICOORD &tright)
 

Detailed Description

Definition at line 116 of file pdblock.h.

Constructor & Destructor Documentation

◆ BLOCK_RECT_IT()

tesseract::BLOCK_RECT_IT::BLOCK_RECT_IT ( PDBLK blkptr)

constructor

Parameters
blkptrblock to iterate

Definition at line 267 of file pdblock.cpp.

271  : left_it(&blkptr->leftside), right_it(&blkptr->rightside) {
272  block = blkptr; // remember block
273  // non empty list
274  if (!blkptr->leftside.empty()) {
275  start_block(); // ready for iteration
276  }
277 }
void start_block()
start iteration
Definition: pdblock.cpp:302

Member Function Documentation

◆ bounding_box()

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

current rectangle

Parameters
bleftbottom left
trighttop right

Definition at line 140 of file pdblock.h.

140  {
141  // bottom left
142  bleft = ICOORD(left_it.data()->x(), ymin);
143  // top right
144  tright = ICOORD(right_it.data()->x(), ymax);
145  }

◆ cycled_rects()

bool tesseract::BLOCK_RECT_IT::cycled_rects ( ) const
inline

test end

Definition at line 133 of file pdblock.h.

133  {
134  return left_it.cycled_list() && right_it.cycled_list();
135  }

◆ forward()

void tesseract::BLOCK_RECT_IT::forward ( )

next rectangle

Definition at line 321 of file pdblock.cpp.

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

◆ set_to_block()

void tesseract::BLOCK_RECT_IT::set_to_block ( PDBLK blkptr)

start (new) block

Definition at line 285 of file pdblock.cpp.

286  { // block to start
287  block = blkptr; // remember block
288  // set iterators
289  left_it.set_to_list(&blkptr->leftside);
290  right_it.set_to_list(&blkptr->rightside);
291  if (!blkptr->leftside.empty()) {
292  start_block(); // ready for iteration
293  }
294 }

◆ start_block()

void tesseract::BLOCK_RECT_IT::start_block ( )

start iteration

Definition at line 302 of file pdblock.cpp.

302  { // start (new) block
303  left_it.move_to_first();
304  right_it.move_to_first();
305  left_it.mark_cycle_pt();
306  right_it.mark_cycle_pt();
307  ymin = left_it.data()->y(); // bottom of first box
308  ymax = left_it.data_relative(1)->y();
309  if (right_it.data_relative(1)->y() < ymax) {
310  // smallest step
311  ymax = right_it.data_relative(1)->y();
312  }
313 }

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