tesseract
3.03
|
page block More...
#include <pdblock.h>
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) |
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 |
PDBLK::PDBLK | ( | ) | [inline] |
PDBLK::PDBLK | ( | inT16 | xmin, |
inT16 | ymin, | ||
inT16 | xmax, | ||
inT16 | ymax | ||
) |
simple constructor
Definition at line 38 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] |
void PDBLK::bounding_box | ( | ICOORD & | bottom_left, |
ICOORD & | top_right | ||
) | const [inline] |
const TBOX& PDBLK::bounding_box | ( | ) | const [inline] |
BOOL8 PDBLK::contains | ( | ICOORD | pt | ) |
is pt inside block
Definition at line 87 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] |
void PDBLK::move | ( | const ICOORD | vec | ) |
reposition block
Definition at line 111 of file pdblock.cpp.
void PDBLK::plot | ( | ScrollView * | window, |
inT32 | serial, | ||
ScrollView::Color | colour | ||
) |
draw histogram
window | window to draw in |
serial | serial number |
colour | colour to draw in |
Definition at line 177 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]; #if defined(__UNIX__) || defined(MINGW) 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] |
Pix * PDBLK::render_mask | ( | const FCOORD & | rerotation | ) |
Definition at line 129 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] |
void PDBLK::set_poly_block | ( | POLY_BLOCK * | blk | ) | [inline] |
void PDBLK::set_sides | ( | ICOORDELT_LIST * | left, |
ICOORDELT_LIST * | right | ||
) |
set vertex lists
left | list of left vertices |
right | list of right vertices |
Definition at line 64 of file pdblock.cpp.
friend class BLOCK_RECT_IT [friend] |
TBOX PDBLK::box [protected] |
POLY_BLOCK* PDBLK::hand_poly [protected] |
int PDBLK::index_ [protected] |
ICOORDELT_LIST PDBLK::leftside [protected] |
ICOORDELT_LIST PDBLK::rightside [protected] |