tesseract v5.3.3.20231005
tesseract::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)
 
TDimension get_line (TDimension y, TDimension &xext)
 

Detailed Description

rectangle iterator

Definition at line 156 of file pdblock.h.

Constructor & Destructor Documentation

◆ BLOCK_LINE_IT()

tesseract::BLOCK_LINE_IT::BLOCK_LINE_IT ( PDBLK blkptr)
inline

constructor

Parameters
blkptrfrom block

Definition at line 160 of file pdblock.h.

160 : rect_it(blkptr) {
161 block = blkptr; // remember block
162 }

Member Function Documentation

◆ get_line()

TDimension tesseract::BLOCK_LINE_IT::get_line ( TDimension  y,
TDimension xext 
)

get a line

Parameters
yline to get
xextoutput extent

Definition at line 353 of file pdblock.cpp.

356 {
357 ICOORD bleft; // bounding box
358 ICOORD tright; // of block & rect
359
360 // get block box
361 block->bounding_box(bleft, tright);
362 if (y < bleft.y() || y >= tright.y()) {
363 // block->print(stderr,false);
364 BADBLOCKLINE.error("BLOCK_LINE_IT::get_line", ABORT, "Y=%d", y);
365 }
366
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 for (rect_it.start_block(); !rect_it.cycled_rects(); rect_it.forward()) {
376 // get rectangle box
377 rect_it.bounding_box(bleft, tright);
378 // inside rectangle
379 if (y >= bleft.y() && y < tright.y()) {
380 // width of line
381 xext = tright.x() - bleft.x();
382 return bleft.x(); // start of line
383 }
384 }
385 LOSTBLOCKLINE.error("BLOCK_LINE_IT::get_line", ABORT, "Y=%d", y);
386 return 0; // dummy to stop warning
387}
const double y
constexpr ERRCODE BADBLOCKLINE("Y coordinate in block out of bounds")
constexpr ERRCODE LOSTBLOCKLINE("Can't find rectangle for line")
@ ABORT
Definition: errcode.h:31
void bounding_box(ICOORD &bottom_left, ICOORD &top_right) const
get box
Definition: pdblock.h:67
void forward()
next rectangle
Definition: pdblock.cpp:321
void start_block()
start iteration
Definition: pdblock.cpp:302
bool cycled_rects() const
test end
Definition: pdblock.h:133
void bounding_box(ICOORD &bleft, ICOORD &tright)
Definition: pdblock.h:140
void error(const char *caller, TessErrorLogCode action, const char *format,...) const __attribute__((format(gnu_printf
Definition: errcode.cpp:40

◆ set_to_block()

void tesseract::BLOCK_LINE_IT::set_to_block ( PDBLK blkptr)
inline

start (new) block

Parameters
blkptrblock to start

Definition at line 166 of file pdblock.h.

166 {
167 block = blkptr; // remember block
168 // set iterator
169 rect_it.set_to_block(blkptr);
170 }
void set_to_block(PDBLK *blkptr)
start (new) block
Definition: pdblock.cpp:285

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