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 343 of file polyblk.cpp.

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

◆ 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: