tesseract  4.0.0-beta.1-59-g2cc4
BLOCK_LINE_IT Class Reference

rectangle iterator More...

#include <pdblock.h>

Public Member Functions

 BLOCK_LINE_IT (PDBLK *blkptr)
 
void set_to_block (PDBLK *blkptr)
 
int16_t get_line (int16_t y, int16_t &xext)
 

Detailed Description

rectangle iterator

Definition at line 144 of file pdblock.h.

Constructor & Destructor Documentation

◆ BLOCK_LINE_IT()

BLOCK_LINE_IT::BLOCK_LINE_IT ( PDBLK blkptr)
inline

constructor

Parameters
blkptrfrom block

Definition at line 149 of file pdblock.h.

150  :rect_it (blkptr) {
151  block = blkptr; //remember block
152  }

Member Function Documentation

◆ get_line()

int16_t BLOCK_LINE_IT::get_line ( int16_t  y,
int16_t &  xext 
)

get a line

Parameters
yline to get
xextoutput extent

Definition at line 345 of file pdblock.cpp.

348  {
349  ICOORD bleft; //bounding box
350  ICOORD tright; //of block & rect
351 
352  //get block box
353  block->bounding_box (bleft, tright);
354  if (y < bleft.y () || y >= tright.y ()) {
355  // block->print(stderr,FALSE);
356  BADBLOCKLINE.error ("BLOCK_LINE_IT::get_line", ABORT, "Y=%d", y);
357  }
358 
359  //get rectangle box
360  rect_it.bounding_box (bleft, tright);
361  //inside rectangle
362  if (y >= bleft.y () && y < tright.y ()) {
363  //width of line
364  xext = tright.x () - bleft.x ();
365  return bleft.x (); //start of line
366  }
367  for (rect_it.start_block (); !rect_it.cycled_rects (); rect_it.forward ()) {
368  //get rectangle box
369  rect_it.bounding_box (bleft, tright);
370  //inside rectangle
371  if (y >= bleft.y () && y < tright.y ()) {
372  //width of line
373  xext = tright.x () - bleft.x ();
374  return bleft.x (); //start of line
375  }
376  }
377  LOSTBLOCKLINE.error ("BLOCK_LINE_IT::get_line", ABORT, "Y=%d", y);
378  return 0; //dummy to stop warning
379 }
const ERRCODE BADBLOCKLINE
Definition: blckerr.h:25
void start_block()
start iteration
Definition: pdblock.cpp:295
int16_t y() const
access_function
Definition: points.h:56
int16_t x() const
access function
Definition: points.h:52
void bounding_box(ICOORD &bleft, ICOORD &tright)
Definition: pdblock.h:127
const ERRCODE LOSTBLOCKLINE
Definition: blckerr.h:26
integer coordinate
Definition: points.h:30
Definition: errcode.h:30
BOOL8 cycled_rects()
test end
Definition: pdblock.h:120
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:59
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:40
void forward()
next rectangle
Definition: pdblock.cpp:314

◆ set_to_block()

void BLOCK_LINE_IT::set_to_block ( PDBLK blkptr)
inline

start (new) block

Parameters
blkptrblock to start

Definition at line 156 of file pdblock.h.

156  {
157  block = blkptr; //remember block
158  //set iterator
159  rect_it.set_to_block (blkptr);
160  }
void set_to_block(PDBLK *blkptr)
start (new) block
Definition: pdblock.cpp:278

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