Polygon< T > Class Template Reference

Class for a polygon in 2-D. More...

#include <Polygon.h>

List of all members.

Public Types

typedef ads::FixedArray< 2, T > Point
 The representation of a point in 2 dimensions.
typedef std::vector< PointContainer
 Container of points.
typedef Container::terator Iterator
 An iterator over points.
typedef Container::const_iterator ConstIterator
 A const Iterator over points.
typedef int SizeType
 The size type.

Public Member Functions

Constructors etc.

 Polygon ()
 Default constructor. Uninitialized memory.
 Polygon (SizeType size)
 Constructor. Reserve room for size vertices.
 Polygon (const Polygon &other)
 Copy constructor.
Polygonoperator= (const Polygon &other)
 Assignment operator.
 ~Polygon ()
 Trivial destructor.
Accesors.

const ContainergetVertices () const
 Return a const reference to the vector of vertices.
Mathematical functions.

void orderVertices ()
 Order the vertices in a positive orientation.
void removeDuplicates ()
 Remove adjacent duplicate vertices of an ordered polygon.
int computeBottomAndTop (T *bottom, T *top) const
 Find the top and bottom of the polygon. Return bottom vertex index.
template<typename MultiIndexType , typename MultiSizeType >
void scan_convert (std::vector< MultiIndexType > &indices_vector, MultiSizeType extents) const
 Scan convert the Polygon in a 2-D grid.
template<typename MultiIndexType , typename MultiSizeType >
void scan_convert (std::vector< MultiIndexType > &indices_vector, MultiSizeType extents, int z_coord) const
 Scan convert the Polygon in a 3-D grid.
void clip (const Line_2< T > &ln)
 Clip the Polygon against the line.
bool is_valid () const
 Check if polygon is valid.
File I/O.

void get (std::istream &in)
 Read the number of vertices and each vertex.
void put (std::ostream &out) const
 Write each vertex.
void mathematica_print () const
 Write a Line[] object that Mathematica can read.

Related Functions

(Note that these are not member functions.)



template<typename T >
bool operator== (const Polygon< T > &a, const Polygon< T > &b)
 Return true if the polygons have the same points in the same order.
template<typename T >
bool operator!= (const Polygon< T > &a, const Polygon< T > &b)
 Return true if they don't have the same points in the same order.
template<typename T >
std::istream & operator>> (std::istream &in, Polygon< T > &poly)
 Read the number of vertices and each vertex.
template<typename T >
std::ostream & operator<< (std::ostream &out, const Polygon< T > &poly)
 Write each vertex.

Detailed Description

template<typename T = double>
class Polygon< T >

Class for a polygon in 2-D.

Parameters:
T is the number type. By default it is double.

A Polygon is a list of vertices that are ordered in the positive, (counter-clockwise), direction. The edges have outward normals.


Member Function Documentation

template<typename T = double>
bool Polygon< T >::is_valid (  )  const

Check if polygon is valid.

Check that the Polygon has at least three vertices and that adjacent vertices are not equal.

template<typename T = double>
template<typename MultiIndexType , typename MultiSizeType >
void Polygon< T >::scan_convert ( std::vector< MultiIndexType > &  indices_vector,
MultiSizeType  extents,
int  z_coord 
) const [inline]

Scan convert the Polygon in a 3-D grid.

Parameters:
indices_vector is the vector of grid indices.
extents are the extents of the grid.
z_coord is the z-coordinate of the slice being scan-converted.
template<typename T = double>
template<typename MultiIndexType , typename MultiSizeType >
void Polygon< T >::scan_convert ( std::vector< MultiIndexType > &  indices_vector,
MultiSizeType  extents 
) const [inline]

Scan convert the Polygon in a 2-D grid.

Parameters:
indices_vector is the vector of grid indices.
extents are the extents of the grid.

Friends And Related Function Documentation

template<typename T >
bool operator!= ( const Polygon< T > &  a,
const Polygon< T > &  b 
) [related]

Return true if they don't have the same points in the same order.

template<typename T >
std::ostream & operator<< ( std::ostream &  out,
const Polygon< T > &  poly 
) [related]

Write each vertex.

template<typename T >
bool operator== ( const Polygon< T > &  a,
const Polygon< T > &  b 
) [related]

Return true if the polygons have the same points in the same order.

template<typename T >
std::istream & operator>> ( std::istream &  in,
Polygon< T > &  poly 
) [related]

Read the number of vertices and each vertex.

References Polygon< T >::get().


The documentation for this class was generated from the following file:
Generated on Thu Jun 30 02:14:58 2016 for Computational Geometry Package by  doxygen 1.6.3