tesseract  4.00.00dev
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 get_line (inT16 y, inT16 &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 BLOCK_LINE_IT::get_line ( inT16  y,
inT16 xext 
)

get a line

Parameters
yline to get
xextoutput extent

Definition at line 344 of file pdblock.cpp.

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

◆ 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:277

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