Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
vgl_polygon_scan_iterator< T > Class Template Reference

Fill a polygonal face with interior scan lines. More...

#include <vgl_fwd.h>

Inheritance diagram for vgl_polygon_scan_iterator< T >:
Inheritance graph
[legend]

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...
 

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. More...
 
 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). More...
 
 ~vgl_polygon_scan_iterator () override
 Destructor. More...
 
void reset () override
 Resets iterator to first segment of first scan line. More...
 
bool next () override
 Moves iterator to next segment. More...
 
int scany () const override
 Returns current scan line. More...
 
int startx () const override
 Returns start of current span. More...
 
int endx () const override
 Returns end of current span. More...
 
fstartx () const
 Returns start of current span (floating point value). More...
 
fendx () const
 Returns end of current span (floating point value). More...
 
fscany () const
 Returns current scan line (floating point value). More...
 
void get_crossedge_vertices (int *&chainnum, int *&vertnum, int &numcrossedges)
 
int count ()
 Number of image points (= integer grid points) inside the region. More...
 

Private Member Functions

 vgl_polygon_scan_iterator (const vgl_polygon_scan_iterator &)=delete
 
vgl_polygon_scan_iteratoroperator= (const vgl_polygon_scan_iterator &)=delete
 
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. More...
 
void get_prev_vert (vertind v, vertind &prev)
 Returns the vertex preceding v in v's chain. More...
 
void display_chains ()
 
void display_crossedges ()
 

Private Attributes

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

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:

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 33 of file vgl_fwd.h.

Member Typedef Documentation

◆ Point2

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

◆ vgl_polygon_scan_iterator() [1/3]

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 96 of file vgl_polygon_scan_iterator.hxx.

◆ vgl_polygon_scan_iterator() [2/3]

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 109 of file vgl_polygon_scan_iterator.hxx.

◆ ~vgl_polygon_scan_iterator()

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

Destructor.

Definition at line 86 of file vgl_polygon_scan_iterator.hxx.

◆ vgl_polygon_scan_iterator() [3/3]

template<class T>
vgl_polygon_scan_iterator< T >::vgl_polygon_scan_iterator ( const vgl_polygon_scan_iterator< T > &  )
privatedelete

Member Function Documentation

◆ count()

int vgl_region_scan_iterator::count ( )
inlineinherited

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

Definition at line 48 of file vgl_region_scan_iterator.h.

◆ delete_edge()

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

Definition at line 196 of file vgl_polygon_scan_iterator.hxx.

◆ display_chains()

template<class T >
void vgl_polygon_scan_iterator< T >::display_chains ( )
private

Definition at line 423 of file vgl_polygon_scan_iterator.hxx.

◆ display_crossedges()

template<class T >
void vgl_polygon_scan_iterator< T >::display_crossedges ( )
private

Definition at line 444 of file vgl_polygon_scan_iterator.hxx.

◆ endx()

template<class T>
int vgl_polygon_scan_iterator< T >::endx ( ) const
inlineoverridevirtual

Returns end of current span.

Implements vgl_region_scan_iterator.

Definition at line 106 of file vgl_polygon_scan_iterator.h.

◆ fendx()

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.

◆ fscany()

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.

◆ fstartx()

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.

◆ get_crossedge_vertices()

template<class T >
void vgl_polygon_scan_iterator< T >::get_crossedge_vertices ( int *&  chainnum,
int *&  vertnum,
int &  numcrossedges 
)

Definition at line 268 of file vgl_polygon_scan_iterator.hxx.

◆ get_next_vert()

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 398 of file vgl_polygon_scan_iterator.hxx.

◆ get_prev_vert()

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 411 of file vgl_polygon_scan_iterator.hxx.

◆ get_pt()

template<class T>
Point2 vgl_polygon_scan_iterator< T >::get_pt ( vertind  v) const
inlineprivate

Definition at line 151 of file vgl_polygon_scan_iterator.h.

◆ get_x()

template<class T>
T vgl_polygon_scan_iterator< T >::get_x ( vertind  v) const
inlineprivate

Definition at line 145 of file vgl_polygon_scan_iterator.h.

◆ get_y()

template<class T>
T vgl_polygon_scan_iterator< T >::get_y ( vertind  v) const
inlineprivate

Definition at line 148 of file vgl_polygon_scan_iterator.h.

◆ init()

template<class T >
void vgl_polygon_scan_iterator< T >::init ( )
private

Definition at line 124 of file vgl_polygon_scan_iterator.hxx.

◆ insert_edge()

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

Definition at line 216 of file vgl_polygon_scan_iterator.hxx.

◆ next()

template<class T >
bool vgl_polygon_scan_iterator< T >::next ( )
overridevirtual

Moves iterator to next segment.

Implements vgl_region_scan_iterator.

Definition at line 289 of file vgl_polygon_scan_iterator.hxx.

◆ operator=()

template<class T>
vgl_polygon_scan_iterator& vgl_polygon_scan_iterator< T >::operator= ( const vgl_polygon_scan_iterator< T > &  )
privatedelete

◆ reset()

template<class T >
void vgl_polygon_scan_iterator< T >::reset ( )
overridevirtual

Resets iterator to first segment of first scan line.

Implements vgl_region_scan_iterator.

Definition at line 246 of file vgl_polygon_scan_iterator.hxx.

◆ scany()

template<class T>
int vgl_polygon_scan_iterator< T >::scany ( ) const
inlineoverridevirtual

Returns current scan line.

Implements vgl_region_scan_iterator.

Definition at line 100 of file vgl_polygon_scan_iterator.h.

◆ startx()

template<class T>
int vgl_polygon_scan_iterator< T >::startx ( ) const
inlineoverridevirtual

Returns start of current span.

Implements vgl_region_scan_iterator.

Definition at line 103 of file vgl_polygon_scan_iterator.h.

Member Data Documentation

◆ boundp

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.

◆ crossedges

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

array of edges crossing current scan line

Definition at line 140 of file vgl_polygon_scan_iterator.h.

◆ curcrossedge

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.

◆ fxl

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.

◆ fxr

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.

◆ fy

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.

◆ have_window

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

Definition at line 71 of file vgl_polygon_scan_iterator.h.

◆ k

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.

◆ numcrossedges

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

number of edges currently crossing scan line

Definition at line 141 of file vgl_polygon_scan_iterator.h.

◆ numverts

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

total number of vertices comprising face

Definition at line 142 of file vgl_polygon_scan_iterator.h.

◆ poly_

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.

◆ win

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.

◆ xl

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.

◆ xr

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.

◆ y

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.

◆ y0

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.

◆ y1

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.

◆ yverts

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

array of all vertices ordered by y coordinate

Definition at line 139 of file vgl_polygon_scan_iterator.h.


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