Maria GDK 5.0.0.738
Documentation of native code in develop branch
Loading...
Searching...
No Matches
STK::Polygon< VectorType > Class Template Reference

#include <StkPolygon.h>

Classes

class  Ring
 

Public Types

typedef std::vector< VectorType >::const_iterator NodeIter
 

Public Member Functions

 Polygon ()
 
 ~Polygon ()
 
bool operator== (const Polygon &p) const
 
bool operator!= (const Polygon &p) const
 
void append (const VectorType &p)
 
void append (int i, const VectorType &p)
 
void appendRing (const Ring &ring)
 
void appendRing (const std::vector< VectorType > &pts)
 
template<typename Iter >
void appendRing (const Iter &begin, const Iter &end)
 
void deleteRing (int i)
 
bool empty () const
 
int numRings () const
 
int numNodes (int ring) const
 
void calcBBox ()
 
double minX () const
 
double minY () const
 
double maxX () const
 
double maxY () const
 
int totalSize () const
 
void reverse ()
 
double totalArea () const
 
const Ringring (int i) const
 
Ringring (int i)
 
VectorType & getNode (int i, int j)
 
const VectorType & getNode (int i, int j) const
 
void setNode (int i, int j, const VectorType &n)
 
void clear ()
 
bool pointInside (const VectorType &p) const
 
Ring calcConvHull () const
 
void sortRings ()
 
void scale (double sx, double sy, double sz=1.0)
 
bool calcIntersect (const Polygon &p, std::vector< Polygon > &result, int precision=6)
 Boolean Operators.
 
bool calcUnion (const Polygon &p, std::vector< Polygon > &result, int precision=6)
 
bool calcDiff (const Polygon &p, std::vector< Polygon > &result, int precision=6)
 
bool calcXor (const Polygon &p, std::vector< Polygon > &result, int precision=6)
 
bool triangulate (std::vector< VectorType > &vtxarr, std::vector< unsigned int > &idxarr) const
 
bool writeGnuplot2d (const char *filename)
 Write textfile for plotting in gnuplot. Useful for debugging.
 
void cleanupPoly (std::vector< Polygon > &outputPolygons, int precision)
 
bool write (std::ostream &os) const
 
bool read (std::istream &is)
 

Protected Attributes

std::vector< Ringrings_
 
double minx_
 
double maxx_
 
double miny_
 
double maxy_
 

Detailed Description

template<class VectorType>
class STK::Polygon< VectorType >

Polygon - Short description. Detailed description.

Constructor & Destructor Documentation

◆ Polygon()

template<class VectorType >
STK::Polygon< VectorType >::Polygon ( )
inline

Constructor.

◆ ~Polygon()

template<class VectorType >
STK::Polygon< VectorType >::~Polygon ( )
inline

Destructor.

Member Function Documentation

◆ calcBBox()

template<class VectorType >
void STK::Polygon< VectorType >::calcBBox ( )
inline

Calculate Bounding Box. Calculates the bounding box of the polygon.

◆ pointInside()

template<class VectorType >
bool STK::Polygon< VectorType >::pointInside ( const VectorType &  p) const
inline

Check for point inside polygon

Warning
The polygon must be sorted with the largest ring first.

◆ reverse()

template<class VectorType >
void STK::Polygon< VectorType >::reverse ( )
inline

Reverse polygon. Reverse winding of all rings in the polygon.

◆ scale()

template<class VectorType >
void STK::Polygon< VectorType >::scale ( double  sx,
double  sy,
double  sz = 1.0 
)
inline

Scale polygon. This method will scale each polygon ring about its center

◆ sortRings()

template<class VectorType >
void STK::Polygon< VectorType >::sortRings ( )
inline

Sort polygon rings. This method will sort the rings such that the largest ring with a positive area will come first, next the largest ring with a negative area (largest hole), next the largest remaining positive ring, etc in alternating hole/not hole fashion.

◆ totalArea()

template<class VectorType >
double STK::Polygon< VectorType >::totalArea ( ) const
inline

Return total (signed) area. This method returns the total area of the polygon, with all holes subtracted.

◆ triangulate()

template<class VectorType >
bool STK::Polygon< VectorType >::triangulate ( std::vector< VectorType > &  vtxarr,
std::vector< unsigned int > &  idxarr 
) const
inline

Triangulate polygon This method will triangulate the polygon using the mapbox "earcut" triangulation library.

https://github.com/mapbox/earcut.hpp

The method will return an array of points and an array of indices pointing to these points, representing the triangles.


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