Tesseract  3.02
PB_LINE_IT Class Reference

#include <polyblk.h>

List of all members.

Public Member Functions

 PB_LINE_IT (POLY_BLOCK *blkptr)
void set_to_block (POLY_BLOCK *blkptr)
POLY_BLOCK::reflect_in_y_axis

Reflect the coords of the polygon in the y-axis. (Flip the sign of x.)

ICOORDELT_LIST * get_line (inT16 y)

Detailed Description

Definition at line 93 of file polyblk.h.


Constructor & Destructor Documentation

PB_LINE_IT::PB_LINE_IT ( POLY_BLOCK blkptr) [inline]

Definition at line 95 of file polyblk.h.

                                 {
    block = blkptr;
  }

Member Function Documentation

ICOORDELT_LIST * PB_LINE_IT::get_line ( inT16  y)

Definition at line 344 of file polyblk.cpp.

                                            {
  ICOORDELT_IT v, r;
  ICOORDELT_LIST *result;
  ICOORDELT *x, *current, *previous;
  float fy, fx;

  fy = (float) (y + 0.5);
  result = new ICOORDELT_LIST ();
  r.set_to_list (result);
  v.set_to_list (block->points ());

  for (v.mark_cycle_pt (); !v.cycled_list (); v.forward ()) {
    if (((v.data_relative (-1)->y () > y) && (v.data ()->y () <= y))
    || ((v.data_relative (-1)->y () <= y) && (v.data ()->y () > y))) {
      previous = v.data_relative (-1);
      current = v.data ();
      fx = (float) (0.5 + previous->x () +
        (current->x () - previous->x ()) * (fy -
        previous->y ()) /
        (current->y () - previous->y ()));
      x = new ICOORDELT ((inT16) fx, 0);
      r.add_to_end (x);
    }
  }

  if (!r.empty ()) {
    r.sort (lessthan);
    for (r.mark_cycle_pt (); !r.cycled_list (); r.forward ())
      x = r.data ();
    for (r.mark_cycle_pt (); !r.cycled_list (); r.forward ()) {
      r.data ()->set_y (r.data_relative (1)->x () - r.data ()->x ());
      r.forward ();
      delete (r.extract ());
    }
  }

  return result;
}
void PB_LINE_IT::set_to_block ( POLY_BLOCK blkptr) [inline]

Definition at line 99 of file polyblk.h.

                                         {
    block = blkptr;
  }

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