tesseract 4.1.1
Loading...
Searching...
No Matches
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 342 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;
376}
int lessthan(const void *first, const void *second)
Definition: polyblk.cpp:379
int16_t y() const
access_function
Definition: points.h:56
void set_y(int16_t yin)
rewrite function
Definition: points.h:65
int16_t x() const
access function
Definition: points.h:52
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: