I recently tried to work on boost::geometry library. I found the code below
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <iostream>
namespace bg = boost::geometry;
int main(void)
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point;
typedef bg::model::polygon<point> polygon;
//! create a polygon
polygon p;
p.outer().push_back(point(0., 0.));
p.outer().push_back(point(1., 0.));
p.outer().push_back(point(1., 2.));
p.outer().push_back(point(2., 3.));
p.outer().push_back(point(0., 4.));
//! display it
std::cout << "generated polygon:" << std::endl;
std::cout << bg::wkt<polygon>(p) << std::endl;
return 0;
}
Any idea for checking:
- Is it a simple polygon?
- What is the orientation (clockwise, counterclockwise)
- Is it closed?
By the way, I am using boost version 1.53.0.