tesseract  5.0.0
tesseract::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 (TDimension y)
 

Detailed Description

Definition at line 95 of file polyblk.h.

Constructor & Destructor Documentation

◆ PB_LINE_IT()

tesseract::PB_LINE_IT::PB_LINE_IT ( POLY_BLOCK blkptr)
inline

Definition at line 97 of file polyblk.h.

97  {
98  block = blkptr;
99  }

Member Function Documentation

◆ get_line()

ICOORDELT_LIST * tesseract::PB_LINE_IT::get_line ( TDimension  y)

Definition at line 337 of file polyblk.cpp.

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

◆ set_to_block()

void tesseract::PB_LINE_IT::set_to_block ( POLY_BLOCK blkptr)
inline

Definition at line 101 of file polyblk.h.

101  {
102  block = blkptr;
103  }

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