tesseract 4.1.1
Loading...
Searching...
No Matches
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 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}
constexpr ERRCODE BADBLOCKLINE("Y coordinate in block out of bounds")
constexpr ERRCODE LOSTBLOCKLINE("Can't find rectangle for line")
@ ABORT
Definition: errcode.h:29
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:59
void bounding_box(ICOORD &bleft, ICOORD &tright)
Definition: pdblock.h:127
void start_block()
start iteration
Definition: pdblock.cpp:297
bool cycled_rects()
test end
Definition: pdblock.h:120
void forward()
next rectangle
Definition: pdblock.cpp:316
integer coordinate
Definition: points.h:32
int16_t y() const
access_function
Definition: points.h:56
int16_t x() const
access function
Definition: points.h:52
void error(const char *caller, TessErrorLogCode action, const char *format,...) const
Definition: errcode.cpp:35

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

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