Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | Friends
PDBLK Class Reference

page block More...

`#include <pdblock.h>`

Inheritance diagram for PDBLK:

List of all members.

## Public Member Functions

| PDBLK ()
| empty constructor
| PDBLK (inT16 xmin, inT16 ymin, inT16 xmax, inT16 ymax)
| simple constructor
void | set_sides (ICOORDELT_LIST *left, ICOORDELT_LIST *right)
| ~PDBLK ()
| destructor
POLY_BLOCK * | poly_block () const
void | set_poly_block (POLY_BLOCK *blk)
| set the poly block
void | bounding_box (ICOORD &bottom_left, ICOORD &top_right) const
| get box
const TBOX & | bounding_box () const
| get real box
int | index () const
void | set_index (int value)
BOOL8 | contains (ICOORD pt)
| is pt inside block
void | move (const ICOORD vec)
| reposition block
Pix * | render_mask (const FCOORD &rerotation)
void | plot (ScrollView *window, inT32 serial, ScrollView::Color colour)
void | show (IMAGE *image, ScrollView *window)
PDBLK & | operator= (const PDBLK &source)

## Protected Attributes

POLY_BLOCK * | hand_poly
ICOORDELT_LIST | leftside
ICOORDELT_LIST | rightside
TBOX | box
int | index_

## Friends

class | BLOCK_RECT_IT

## Detailed Description

page block

Definition at line 35 of file pdblock.h.

## Constructor & Destructor Documentation

PDBLK::PDBLK | ( |  | ) |

inline

empty constructor

Definition at line 41 of file pdblock.h.

{
hand_poly = NULL;
index_ = 0;
}

PDBLK::PDBLK | ( | inT16 | xmin,
|  | inT16 | ymin,
|  | inT16 | xmax,
|  | inT16 | ymax
| ) |  |

simple constructor

Definition at line 42 of file pdblock.cpp.

: box (ICOORD (xmin, ymin), ICOORD (xmax, ymax)) {
//boundaries
ICOORDELT_IT left_it = &leftside;
ICOORDELT_IT right_it = &rightside;
hand_poly = NULL;
left_it.set_to_list (&leftside);
right_it.set_to_list (&rightside);
//make default box
left_it.add_to_end (new ICOORDELT (xmin, ymin));
left_it.add_to_end (new ICOORDELT (xmin, ymax));
right_it.add_to_end (new ICOORDELT (xmax, ymin));
right_it.add_to_end (new ICOORDELT (xmax, ymax));
index_ = 0;
}

PDBLK::~PDBLK | ( |  | ) |

inline

destructor

Definition at line 58 of file pdblock.h.

{
if (hand_poly) delete hand_poly;
}

## Member Function Documentation

void PDBLK::bounding_box | ( | ICOORD & | bottom_left,
|  | ICOORD & | top_right
| ) |  | const

inline

get box

Definition at line 70 of file pdblock.h.

{ //topright
bottom_left = box.botleft ();
top_right = box.topright ();
}

const TBOX& PDBLK::bounding_box | ( |  | ) | const

inline

get real box

Definition at line 76 of file pdblock.h.

{
return box;
}

BOOL8 PDBLK::contains | ( | ICOORD | pt | ) |

is pt inside block

Definition at line 91 of file pdblock.cpp.

{
BLOCK_RECT_IT it = this; //rectangle iterator
ICOORD bleft, tright; //corners of rectangle
for (it.start_block (); !it.cycled_rects (); it.forward ()) {
//get rectangle
it.bounding_box (bleft, tright);
//inside rect
if (pt.x () >= bleft.x () && pt.x () <= tright.x ()
&& pt.y () >= bleft.y () && pt.y () <= tright.y ())
return TRUE; //is inside
}
return FALSE; //not inside
}

int PDBLK::index | ( |  | ) | const

inline

Definition at line 80 of file pdblock.h.

{
return index_;
}

void PDBLK::move | ( | const ICOORD | vec | ) |

reposition block

Definition at line 115 of file pdblock.cpp.

{
ICOORDELT_IT it(&leftside);
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
*(it.data ()) += vec;
it.set_to_list (&rightside);
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
*(it.data ()) += vec;
box.move (vec);
}

PDBLK & PDBLK::operator= | ( | const PDBLK & | source | ) |

assignment

Parameters:

  source | from this

Definition at line 269 of file pdblock.cpp.

{
// this->ELIST_LINK::operator=(source);
if (!leftside.empty ())
leftside.clear ();
if (!rightside.empty ())
rightside.clear ();
leftside.deep_copy(&source.leftside, &ICOORDELT::deep_copy);
rightside.deep_copy(&source.rightside, &ICOORDELT::deep_copy);
box = source.box;
return *this;
}

void PDBLK::plot | ( | ScrollView * | window,
|  | inT32 | serial,
|  | ScrollView::Color | colour
| ) |  |

draw histogram

Parameters:

  window | window to draw in
  serial | serial number
  colour | colour to draw in

Definition at line 181 of file pdblock.cpp.

{
ICOORD startpt; //start of outline
ICOORD endpt; //end of outline
ICOORD prevpt; //previous point
ICOORDELT_IT it = &leftside; //iterator
//set the colour
window->Pen(colour);
window->TextAttributes("Times", BLOCK_LABEL_HEIGHT, false, false, false);
if (hand_poly != NULL) {
hand_poly->plot(window, serial);
} else if (!leftside.empty ()) {
startpt = *(it.data ()); //bottom left corner
// tprintf("Block %d bottom left is (%d,%d)\n",
// serial,startpt.x(),startpt.y());
char temp_buff[34];
#ifdef __UNIX__
sprintf(temp_buff, INT32FORMAT, serial);
#else
ultoa (serial, temp_buff, 10);
#endif
window->Text(startpt.x (), startpt.y (), temp_buff);
window->SetCursor(startpt.x (), startpt.y ());
do {
prevpt = *(it.data ()); //previous point
it.forward (); //move to next point
//draw round corner
window->DrawTo(prevpt.x (), it.data ()->y ());
window->DrawTo(it.data ()->x (), it.data ()->y ());
}
while (!it.at_last ()); //until end of list
endpt = *(it.data ()); //end point
//other side of boundary
window->SetCursor(startpt.x (), startpt.y ());
it.set_to_list (&rightside);
prevpt = startpt;
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
//draw round corner
window->DrawTo(prevpt.x (), it.data ()->y ());
window->DrawTo(it.data ()->x (), it.data ()->y ());
prevpt = *(it.data ()); //previous point
}
//close boundary
window->DrawTo(endpt.x(), endpt.y());
}
}

POLY_BLOCK* PDBLK::poly_block | ( |  | ) | const

inline

Definition at line 62 of file pdblock.h.

{
return hand_poly;
}

Pix * PDBLK::render_mask | ( | const FCOORD & | rerotation | ) |

Definition at line 133 of file pdblock.cpp.

{
TBOX rotated_box(box);
rotated_box.rotate(rerotation);
Pix* pix = pixCreate(rotated_box.width(), rotated_box.height(), 1);
if (hand_poly != NULL) {
// We are going to rotate, so get a deep copy of the points and
// make a new POLY_BLOCK with it.
ICOORDELT_LIST polygon;
polygon.deep_copy(hand_poly->points(), ICOORDELT::deep_copy);
POLY_BLOCK image_block(&polygon, hand_poly->isA());
image_block.rotate(rerotation);
// Block outline is a polygon, so use a PB_LINE_IT to get the
// rasterized interior. (Runs of interior pixels on a line.)
PB_LINE_IT *lines = new PB_LINE_IT(&image_block);
for (int y = box.bottom(); y < box.top(); ++y) {
ICOORDELT_LIST* segments = lines->get_line(y);
if (!segments->empty()) {
ICOORDELT_IT s_it(segments);
// Each element of segments is a start x and x size of the
// run of interior pixels.
for (s_it.mark_cycle_pt(); !s_it.cycled_list(); s_it.forward()) {
int start = s_it.data()->x();
int xext = s_it.data()->y();
// Set the run of pixels to 1.
pixRasterop(pix, start - rotated_box.left(),
rotated_box.height() - 1 - (y - rotated_box.bottom()),
xext, 1, PIX_SET, NULL, 0, 0);
}
}
delete segments;
}
delete lines;
} else {
// Just fill the whole block as there is only a bounding box.
pixRasterop(pix, 0, 0, rotated_box.width(), rotated_box.height(),
PIX_SET, NULL, 0, 0);
}
return pix;
}

void PDBLK::set_index | ( | int | value | ) |

inline

Definition at line 83 of file pdblock.h.

{
index_ = value;
}

void PDBLK::set_poly_block | ( | POLY_BLOCK * | blk | ) |

inline

set the poly block

Definition at line 66 of file pdblock.h.

{
hand_poly = blk;
}

void PDBLK::set_sides | ( | ICOORDELT_LIST * | left,
|  | ICOORDELT_LIST * | right
| ) |  |

set vertex lists

Parameters:

  left | list of left vertices
  right | list of right vertices

Definition at line 68 of file pdblock.cpp.

{
//boundaries
ICOORDELT_IT left_it = &leftside;
ICOORDELT_IT right_it = &rightside;
leftside.clear ();
left_it.move_to_first ();
left_it.add_list_before (left);
rightside.clear ();
right_it.move_to_first ();
right_it.add_list_before (right);
}

void PDBLK::show | ( | IMAGE * | image,
|  | ScrollView * | window
| ) |  |

show image

Parameters:

  image | image to show
  window | window to show in

Definition at line 244 of file pdblock.cpp.

{
BLOCK_RECT_IT it = this; //rectangle iterator
ICOORD bleft, tright; //corners of rectangle
for (it.start_block (); !it.cycled_rects (); it.forward ()) {
//get rectangle
it.bounding_box (bleft, tright);
// tprintf("Drawing a block with a bottom left of (%d,%d)\n",
// bleft.x(),bleft.y());
//show it
sv_show_sub_image (image, bleft.x (), bleft.y (), tright.x () - bleft.x (), tright.y () - bleft.y (), window, bleft.x (), bleft.y ());
}
}

## Friends And Related Function Documentation

friend class BLOCK_RECT_IT

friend

Reimplemented in BLOCK.

Definition at line 37 of file pdblock.h.

## Member Data Documentation

TBOX PDBLK::box

protected

Definition at line 120 of file pdblock.h.

POLY_BLOCK* PDBLK::hand_poly

protected

Definition at line 117 of file pdblock.h.

int PDBLK::index_

protected

Definition at line 121 of file pdblock.h.

ICOORDELT_LIST PDBLK::leftside

protected

Definition at line 118 of file pdblock.h.

ICOORDELT_LIST PDBLK::rightside

protected

Definition at line 119 of file pdblock.h.

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

- /mnt/data/src/tesseract-ocr/ccstruct/pdblock.h
- /mnt/data/src/tesseract-ocr/ccstruct/pdblock.cpp