tesseract  5.0.0-alpha-619-ge9db
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 90 of file polyblk.h.

Constructor & Destructor Documentation

◆ PB_LINE_IT()

PB_LINE_IT::PB_LINE_IT ( POLY_BLOCK blkptr)
inline

Definition at line 92 of file polyblk.h.

92  :
93  PB_LINE_IT(POLY_BLOCK *blkptr) {
94  block = blkptr;

Member Function Documentation

◆ get_line()

ICOORDELT_LIST * PB_LINE_IT::get_line ( int16_t  y)

Definition at line 341 of file polyblk.cpp.

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

◆ set_to_block()

void PB_LINE_IT::set_to_block ( POLY_BLOCK blkptr)
inline

Definition at line 96 of file polyblk.h.

97  {
98  block = blkptr;

The documentation for this class was generated from the following files:
lessthan
int lessthan(const void *first, const void *second)
Definition: polyblk.cpp:378
PB_LINE_IT::PB_LINE_IT
PB_LINE_IT(POLY_BLOCK *blkptr)
Definition: polyblk.h:92
ICOORD::x
int16_t x() const
access function
Definition: points.h:51
POLY_BLOCK::points
ICOORDELT_LIST * points()
Definition: polyblk.h:52
POLY_BLOCK
Definition: polyblk.h:26
ICOORDELT
Definition: points.h:160
ICOORD::y
int16_t y() const
access_function
Definition: points.h:55