tesseract  4.00.00dev
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 y)
 

Detailed Description

Definition at line 94 of file polyblk.h.

Constructor & Destructor Documentation

◆ PB_LINE_IT()

PB_LINE_IT::PB_LINE_IT ( POLY_BLOCK blkptr)
inline

Definition at line 96 of file polyblk.h.

96  {
97  block = blkptr;
98  }

Member Function Documentation

◆ get_line()

ICOORDELT_LIST * PB_LINE_IT::get_line ( inT16  y)

Definition at line 344 of file polyblk.cpp.

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

◆ set_to_block()

void PB_LINE_IT::set_to_block ( POLY_BLOCK blkptr)
inline

Definition at line 100 of file polyblk.h.

100  {
101  block = blkptr;
102  }

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