tesseract  4.0.0-1-g2a2b
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 145 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 150 of file pdblock.h.

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

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

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

◆ set_to_block()

void BLOCK_LINE_IT::set_to_block ( PDBLK blkptr)
inline

start (new) block

Parameters
blkptrblock to start

Definition at line 157 of file pdblock.h.

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

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