Hello,
I have a multi polygon from union two shapes. I would like to draw multipolygon on screen.
Therefore I need a shape to draw. If my polygon no have holes it is simple. But if it have one or more its trouble. How draw a shapes (list of points) from polygon?
P.S. What I can check clockwise of polygons in multipolygon? Simply i can check
std::cout << " simple? " << (boost::geometry::is_simple(p) ? "yes" : "no") << std::endl;
How checking each shape in Polygon?
P.S.S. How set a clockwise one ring?
----
#include <iostream>
#include <deque>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/register/multi_polygon.hpp>
#include <boost/foreach.hpp>
typedef boost::geometry::model::d2::point_xy<double> point_t;
typedef boost::geometry::model::polygon<point_t> polygon_t;
typedef boost::geometry::model::multi_polygon<polygon_t> mpolygon_t;
BOOST_GEOMETRY_REGISTER_MULTI_POLYGON(std::deque<polygon_t>)
int main()
{
std::deque<polygon_t> green;
std::deque<polygon_t> blue;
std::deque<polygon_t> wynik;
boost::geometry::read_wkt("MULTIPOLYGON(((0 4, 3 1, 6 4, 3 0, 0 4)),((0 3, 0.1 3, 0.1 3.5, 0 3.5, 0 3)))", green);
boost::geometry::correct(green);
/* how change polygon[0].outer to clockwise or change to non clockwise */
BOOST_FOREACH(auto const& p, green)
{
std::cout << j++ << ": " << boost::geometry::wkt(p);
std::cout << " simple? " << (boost::geometry::is_simple(p) ? "yes" : "no") << std::endl;
auto zew = p.outer();
k = 0;
for (auto i = std::begin(zew); i != std::end(zew); ++i)
{
std::cout << ":: "<< k++ << " [" << i->x() << " " << i->y() << "] " << std::endl;
}
}
blue.resize(1); /* domyślnie jest puste */
boost::geometry::read_wkt("POLYGON((0 0, 3 4, 6 0, 3 3))", blue[0]);
boost::geometry::correct(blue); /* poprawiamy */
boost::geometry::union_(green, blue, wynik);
std::cout << "\n shape (" << wynik.size() << ") " <<
"green (lub || unia) blue:" << std::endl;
std::cout << "result:" << boost::geometry::wkt(wynik) << std::endl;
BOOST_FOREACH(polygon_t const& v, wynik)
std::cout << boost::geometry::wkt<polygon_t>(v) << std::endl;
/* how get shapes */
return 0;
}