Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vgl_polygon_scan_iterator< T > Class Template Reference

#include <vgl_polygon_scan_iterator.h>

Inheritance diagram for vgl_polygon_scan_iterator< T >:

Inheritance graph
[legend]
List of all members.

Detailed Description

template<class T>
class vgl_polygon_scan_iterator< T >

Fill a polygonal face with interior scan lines.

This class provides an iterator-style interface to polygon scan conversion. There are convenient constructors from vgl_polygon, and_ lists of floats. An auxiliary clipping window can be specified by the constructor argument, vgl_box_2d<T> win.

Concave Polygon Scan Conversion by Paul Heckbert from "Graphics Gems", Academic Press, 1990

Scan convert nvert-sided concave non-simple polygon with vertices at (point[i].x, point[i].y) for i in [0..nvert-1] within the window win by calling spanproc for each visible span of pixels. Polygon can be clockwise or counterclockwise. Algorithm does uniform point sampling at pixel centers. Inside-outside test done by Jordan's rule: a point is considered inside if an emanating ray intersects the polygon an odd number of times.

Note: The span limits, startx and endx, are closed intervals. That is, you can use the endpoints of the span as valid interior points. Also, the initial and final y scan lines returned by the iterator are interior to the polygon. The constructor argument, win, is a clipping window that is intersected with the polygonal region to determine the actual scanned area.

Example usage:

  vgl_polygon_scan_iterator<float> psi(mypoints);
  psi.set_include_boundary(true); // optional flag, default is true
  for (psi.reset(); psi.next(); ) {
    int y = psi.scany();
    for (int x = psi.startx(); x <= psi.endx(); ++x)
         ....
  }

Definition at line 57 of file vgl_polygon_scan_iterator.h.

Public Types

typedef vgl_polygon< T
>::point_t 
Point2

Public Member Functions

 vgl_polygon_scan_iterator (vgl_polygon< T > const &face, bool boundaryp=true)
 Construct with a polygon and bool indicating whether boundary included.
 vgl_polygon_scan_iterator (vgl_polygon< T > const &face, bool boundaryp, vgl_box_2d< T > const &window)
 Construct with a polygon, bool indicating whether boundary included and window (area visible).
 ~vgl_polygon_scan_iterator ()
 Destructor.
void reset ()
 Resets iterator to first segment of first scan line.
bool next ()
 Moves iterator to next segment.
int scany () const
 Returns current scan line.
int startx () const
 Returns start of current span.
int endx () const
 Returns end of current span.
fstartx () const
 Returns start of current span (floating point value).
fendx () const
 Returns end of current span (floating point value).
fscany () const
 Returns current scan line (floating point value).
int count ()
 Number of image points (= integer grid points) inside the region.

Private Member Functions

get_x (vertind v) const
get_y (vertind v) const
Point2 get_pt (vertind v) const
void init ()
void delete_edge (vertind v)
void insert_edge (vertind v)
void get_next_vert (vertind v, vertind &next)
 Returns the vertex following v in v's chain.
void get_prev_vert (vertind v, vertind &prev)
 Returns the vertex preceding v in v's chain.
void display_chains ()
void display_crossedges ()

Private Attributes

int boundp
 boolean indicating if boundary should be included or not
int xl
 left bound of current span
fxl
 left bound of current span (floating point value)
int xr
 right bound of current span
fxr
 right bound of current span (floating point value)
int k
 current index of vertices ordered by increasing y
int y0
 bottommost scan line
int y1
 topmost scan line
int y
 current scan line
fy
 floating point value of current scan line (i.e. T(y))
int curcrossedge
 crossedge marking start of next scan segment
vgl_box_2d< T > win
 clipping window
bool have_window
vgl_polygon< T > poly_
 the polygon
vertindyverts
 array of all vertices ordered by y coordinate
crossedgecrossedges
 array of edges crossing current scan line
int numcrossedges
 number of edges currently crossing scan line
int numverts
 total number of vertices comprising face

Classes

struct  crossedge
 Describes an edge crossing the current scan line. More...
struct  vertind
 Vertex index - uniquely identifies a vertex in the array chains. More...


Member Typedef Documentation

template<class T>
typedef vgl_polygon<T>::point_t vgl_polygon_scan_iterator< T >::Point2
 

Definition at line 77 of file vgl_polygon_scan_iterator.h.


Constructor & Destructor Documentation

template<class T>
vgl_polygon_scan_iterator< T >::vgl_polygon_scan_iterator vgl_polygon< T > const &  face,
bool  boundaryp = true
 

Construct with a polygon and bool indicating whether boundary included.

Definition at line 111 of file vgl_polygon_scan_iterator.txx.

template<class T>
vgl_polygon_scan_iterator< T >::vgl_polygon_scan_iterator vgl_polygon< T > const &  face,
bool  boundaryp,
vgl_box_2d< T > const &  window
 

Construct with a polygon, bool indicating whether boundary included and window (area visible).

Definition at line 124 of file vgl_polygon_scan_iterator.txx.

template<class T>
vgl_polygon_scan_iterator< T >::~vgl_polygon_scan_iterator  ) 
 

Destructor.

Definition at line 101 of file vgl_polygon_scan_iterator.txx.


Member Function Documentation

int vgl_region_scan_iterator::count  )  [inline, inherited]
 

Number of image points (= integer grid points) inside the region.

Definition at line 48 of file vgl_region_scan_iterator.h.

template<class T>
void vgl_polygon_scan_iterator< T >::delete_edge vertind  v  )  [private]
 

Definition at line 211 of file vgl_polygon_scan_iterator.txx.

template<class T>
void vgl_polygon_scan_iterator< T >::display_chains  )  [private]
 

Definition at line 420 of file vgl_polygon_scan_iterator.txx.

template<class T>
void vgl_polygon_scan_iterator< T >::display_crossedges  )  [private]
 

Definition at line 441 of file vgl_polygon_scan_iterator.txx.

template<class T>
int vgl_polygon_scan_iterator< T >::endx  )  const [inline, virtual]
 

Returns end of current span.

Implements vgl_region_scan_iterator.

Definition at line 106 of file vgl_polygon_scan_iterator.h.

template<class T>
T vgl_polygon_scan_iterator< T >::fendx  )  const [inline]
 

Returns end of current span (floating point value).

Definition at line 112 of file vgl_polygon_scan_iterator.h.

template<class T>
T vgl_polygon_scan_iterator< T >::fscany  )  const [inline]
 

Returns current scan line (floating point value).

Definition at line 115 of file vgl_polygon_scan_iterator.h.

template<class T>
T vgl_polygon_scan_iterator< T >::fstartx  )  const [inline]
 

Returns start of current span (floating point value).

Definition at line 109 of file vgl_polygon_scan_iterator.h.

template<class T>
void vgl_polygon_scan_iterator< T >::get_next_vert vertind  v,
vertind nextvert
[private]
 

Returns the vertex following v in v's chain.

The vertex is returned through the parameter nextvert. I get a syntax error when I tried to return an object of type vertind. Compiler error says the default return type is int???

Definition at line 395 of file vgl_polygon_scan_iterator.txx.

template<class T>
void vgl_polygon_scan_iterator< T >::get_prev_vert vertind  v,
vertind prevvert
[private]
 

Returns the vertex preceding v in v's chain.

The vertex is returned through the parameter prevvert. I get a syntax error when I tried to return an object of type vertind. Compiler error says the default return type is int???

Definition at line 408 of file vgl_polygon_scan_iterator.txx.

template<class T>
Point2 vgl_polygon_scan_iterator< T >::get_pt vertind  v  )  const [inline, private]
 

Definition at line 146 of file vgl_polygon_scan_iterator.h.

template<class T>
T vgl_polygon_scan_iterator< T >::get_x vertind  v  )  const [inline, private]
 

Definition at line 140 of file vgl_polygon_scan_iterator.h.

template<class T>
T vgl_polygon_scan_iterator< T >::get_y vertind  v  )  const [inline, private]
 

Definition at line 143 of file vgl_polygon_scan_iterator.h.

template<class T>
void vgl_polygon_scan_iterator< T >::init  )  [private]
 

Definition at line 139 of file vgl_polygon_scan_iterator.txx.

template<class T>
void vgl_polygon_scan_iterator< T >::insert_edge vertind  v  )  [private]
 

Definition at line 230 of file vgl_polygon_scan_iterator.txx.

template<class T>
bool vgl_polygon_scan_iterator< T >::next  )  [virtual]
 

Moves iterator to next segment.

Implements vgl_region_scan_iterator.

Definition at line 289 of file vgl_polygon_scan_iterator.txx.

template<class T>
void vgl_polygon_scan_iterator< T >::reset  )  [virtual]
 

Resets iterator to first segment of first scan line.

Implements vgl_region_scan_iterator.

Definition at line 260 of file vgl_polygon_scan_iterator.txx.

template<class T>
int vgl_polygon_scan_iterator< T >::scany  )  const [inline, virtual]
 

Returns current scan line.

Implements vgl_region_scan_iterator.

Definition at line 100 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::startx  )  const [inline, virtual]
 

Returns start of current span.

Implements vgl_region_scan_iterator.

Definition at line 103 of file vgl_polygon_scan_iterator.h.


Member Data Documentation

template<class T>
int vgl_polygon_scan_iterator< T >::boundp [private]
 

boolean indicating if boundary should be included or not

Definition at line 59 of file vgl_polygon_scan_iterator.h.

template<class T>
crossedge* vgl_polygon_scan_iterator< T >::crossedges [private]
 

array of edges crossing current scan line

Definition at line 135 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::curcrossedge [private]
 

crossedge marking start of next scan segment

Definition at line 69 of file vgl_polygon_scan_iterator.h.

template<class T>
T vgl_polygon_scan_iterator< T >::fxl [private]
 

left bound of current span (floating point value)

Definition at line 61 of file vgl_polygon_scan_iterator.h.

template<class T>
T vgl_polygon_scan_iterator< T >::fxr [private]
 

right bound of current span (floating point value)

Definition at line 63 of file vgl_polygon_scan_iterator.h.

template<class T>
T vgl_polygon_scan_iterator< T >::fy [private]
 

floating point value of current scan line (i.e. T(y))

Definition at line 68 of file vgl_polygon_scan_iterator.h.

template<class T>
bool vgl_polygon_scan_iterator< T >::have_window [private]
 

Definition at line 71 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::k [private]
 

current index of vertices ordered by increasing y

Definition at line 64 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::numcrossedges [private]
 

number of edges currently crossing scan line

Definition at line 136 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::numverts [private]
 

total number of vertices comprising face

Definition at line 137 of file vgl_polygon_scan_iterator.h.

template<class T>
vgl_polygon<T> vgl_polygon_scan_iterator< T >::poly_ [private]
 

the polygon

Definition at line 73 of file vgl_polygon_scan_iterator.h.

template<class T>
vgl_box_2d<T> vgl_polygon_scan_iterator< T >::win [private]
 

clipping window

Definition at line 70 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::xl [private]
 

left bound of current span

Definition at line 60 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::xr [private]
 

right bound of current span

Definition at line 62 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::y [private]
 

current scan line

Definition at line 67 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::y0 [private]
 

bottommost scan line

Definition at line 65 of file vgl_polygon_scan_iterator.h.

template<class T>
int vgl_polygon_scan_iterator< T >::y1 [private]
 

topmost scan line

Definition at line 66 of file vgl_polygon_scan_iterator.h.

template<class T>
vertind* vgl_polygon_scan_iterator< T >::yverts [private]
 

array of all vertices ordered by y coordinate

Definition at line 134 of file vgl_polygon_scan_iterator.h.


The documentation for this class was generated from the following files:
Generated on Thu Jan 10 14:39:28 2008 for core/vgl by  doxygen 1.4.4