All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 ( POLY_BLOCK blkptr)
inline

Definition at line 96 of file polyblk.h.

96  {
97  block = blkptr;
98  }

Member Function Documentation

ICOORDELT_LIST * PB_LINE_IT::get_line ( inT16  y)

Definition at line 341 of file polyblk.cpp.

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