tesseract  4.0.0-1-g2a2b
PB_LINE_IT Class Reference

#include <polyblk.h>

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_t y)
 

Detailed Description

Definition at line 91 of file polyblk.h.

Constructor & Destructor Documentation

◆ PB_LINE_IT()

PB_LINE_IT::PB_LINE_IT ( POLY_BLOCK blkptr)
inline

Definition at line 93 of file polyblk.h.

93  {
94  block = blkptr;
95  }

Member Function Documentation

◆ get_line()

ICOORDELT_LIST * PB_LINE_IT::get_line ( int16_t  y)

Definition at line 341 of file polyblk.cpp.

341  {
342  ICOORDELT_IT v, r;
343  ICOORDELT_LIST *result;
344  ICOORDELT *x, *current, *previous;
345  float fy = y + 0.5f;
346  result = new ICOORDELT_LIST ();
347  r.set_to_list (result);
348  v.set_to_list (block->points ());
349 
350  for (v.mark_cycle_pt (); !v.cycled_list (); v.forward ()) {
351  if (((v.data_relative (-1)->y () > y) && (v.data ()->y () <= y))
352  || ((v.data_relative (-1)->y () <= y) && (v.data ()->y () > y))) {
353  previous = v.data_relative (-1);
354  current = v.data ();
355  float fx = 0.5f + previous->x() +
356  (current->x() - previous->x()) * (fy - previous->y()) /
357  (current->y() - previous->y());
358  x = new ICOORDELT(static_cast<int16_t>(fx), 0);
359  r.add_to_end (x);
360  }
361  }
362 
363  if (!r.empty ()) {
364  r.sort (lessthan);
365  for (r.mark_cycle_pt (); !r.cycled_list (); r.forward ())
366  x = r.data ();
367  for (r.mark_cycle_pt (); !r.cycled_list (); r.forward ()) {
368  r.data ()->set_y (r.data_relative (1)->x () - r.data ()->x ());
369  r.forward ();
370  delete (r.extract ());
371  }
372  }
373 
374  return result;
375 }
int16_t y() const
access_function
Definition: points.h:57
int lessthan(const void *first, const void *second)
Definition: polyblk.cpp:378
int16_t x() const
access function
Definition: points.h:53
ICOORDELT_LIST * points()
Definition: polyblk.h:39

◆ set_to_block()

void PB_LINE_IT::set_to_block ( POLY_BLOCK blkptr)
inline

Definition at line 97 of file polyblk.h.

97  {
98  block = blkptr;
99  }

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