|
Geometry : |
From: 0xtrzy_at_[hidden]
Date: 2020-06-18 20:32:34
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? for example char 'A' to two separate polygon ibb.co ibb.co 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/poi #include <boost/geometry/geometries/pol #include <boost/geometry/geometries/reg #include <boost/foreach.hpp> typedef boost::geometry::model::d2::po point_t; typedef boost::geometry::model::polygo polygon_t; typedef boost::geometry::model::multi_ mpolygon_t; BOOST_GEOMETRY_REGISTER_MULTI_ int main() { std::deque<polygon_t> green; std::deque<polygon_t> blue; std::deque<polygon_t> wynik; boost::geometry::read_wkt("MUL 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("POL 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 << std::endl; /* how get shapes */ return 0; }
Geometry list run by mateusz at loskot.net