tesseract 4.1.1
Loading...
Searching...
No Matches
BLOCK_RECT_IT Class Reference

#include <pdblock.h>

Public Member Functions

 BLOCK_RECT_IT (PDBLK *blkptr)
 
void set_to_block (PDBLK *blkptr)
 start (new) block More...
 
void start_block ()
 start iteration More...
 
void forward ()
 next rectangle More...
 
bool cycled_rects ()
 test end More...
 
void bounding_box (ICOORD &bleft, ICOORD &tright)
 

Detailed Description

Definition at line 102 of file pdblock.h.

Constructor & Destructor Documentation

◆ BLOCK_RECT_IT()

BLOCK_RECT_IT::BLOCK_RECT_IT ( PDBLK blkptr)

constructor

Parameters
blkptrblock to iterate

Definition at line 262 of file pdblock.cpp.

265 :left_it (&blkptr->leftside), right_it (&blkptr->rightside) {
266 block = blkptr; //remember block
267 //non empty list
268 if (!blkptr->leftside.empty ()) {
269 start_block(); //ready for iteration
270 }
271}
ICOORDELT_LIST rightside
right side vertices
Definition: pdblock.h:97
ICOORDELT_LIST leftside
left side vertices
Definition: pdblock.h:96
void start_block()
start iteration
Definition: pdblock.cpp:297

Member Function Documentation

◆ bounding_box()

void BLOCK_RECT_IT::bounding_box ( ICOORD bleft,
ICOORD tright 
)
inline

current rectangle

Parameters
bleftbottom left
trighttop right

Definition at line 127 of file pdblock.h.

128 {
129 //bottom left
130 bleft = ICOORD (left_it.data ()->x (), ymin);
131 //top right
132 tright = ICOORD (right_it.data ()->x (), ymax);
133 }
integer coordinate
Definition: points.h:32

◆ cycled_rects()

bool BLOCK_RECT_IT::cycled_rects ( )
inline

test end

Definition at line 120 of file pdblock.h.

120 {
121 return left_it.cycled_list() && right_it.cycled_list();
122 }

◆ forward()

void BLOCK_RECT_IT::forward ( )

next rectangle

Definition at line 316 of file pdblock.cpp.

316 { //next rectangle
317 if (!left_it.empty ()) { //non-empty list
318 if (left_it.data_relative (1)->y () == ymax)
319 left_it.forward (); //move to meet top
320 if (right_it.data_relative (1)->y () == ymax)
321 right_it.forward ();
322 //last is special
323 if (left_it.at_last () || right_it.at_last ()) {
324 left_it.move_to_first (); //restart
325 right_it.move_to_first ();
326 //now at bottom
327 ymin = left_it.data ()->y ();
328 }
329 else {
330 ymin = ymax; //new bottom
331 }
332 //next point
333 ymax = left_it.data_relative (1)->y ();
334 if (right_it.data_relative (1)->y () < ymax)
335 //least step forward
336 ymax = right_it.data_relative (1)->y ();
337 }
338}

◆ set_to_block()

void BLOCK_RECT_IT::set_to_block ( PDBLK blkptr)

start (new) block

Definition at line 280 of file pdblock.cpp.

281 { //block to start
282 block = blkptr; //remember block
283 //set iterators
284 left_it.set_to_list (&blkptr->leftside);
285 right_it.set_to_list (&blkptr->rightside);
286 if (!blkptr->leftside.empty ())
287 start_block(); //ready for iteration
288}

◆ start_block()

void BLOCK_RECT_IT::start_block ( )

start iteration

Definition at line 297 of file pdblock.cpp.

297 { //start (new) block
298 left_it.move_to_first ();
299 right_it.move_to_first ();
300 left_it.mark_cycle_pt ();
301 right_it.mark_cycle_pt ();
302 ymin = left_it.data ()->y (); //bottom of first box
303 ymax = left_it.data_relative (1)->y ();
304 if (right_it.data_relative (1)->y () < ymax)
305 //smallest step
306 ymax = right_it.data_relative (1)->y ();
307}

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