Örnek
Şöyle yaparız.
Şöyle yaparız.
#include <boost/polygon/point_traits.hpp>
#include <boost/polygon/polygon.hpp>
#include <boost/polygon/polygon_set_data.hpp>
#include <boost/polygon/polygon_set_traits.hpp>
#include <boost/polygon/polygon_traits.hpp>
namespace gtl = boost::polygon;
using namespace boost::polygon::operators;
typedef gtl::polygon_90_data<int> Polygon;
typedef gtl::polygon_traits<Polygon>::point_type Point;
typedef gtl::polygon_90_set_data<int> PolygonSet;
Polygon make_polygon(std::initializer_list<Point> init) {
Polygon p;
p.set(init.begin(), init.end());
return p;
}
template <typename P>
P get_union(P const& a, P const& b) {
std::vector<P> v;
PolygonSet(a+b).get(v);
assert(v.size() == 1);
return std::move(v.front());
}
int main() {
Polygon u = get_union(
make_polygon({ {100, 200}, {120, 200}, {120, 140}, {100, 140} }),
make_polygon({ {115, 180}, {115, 250}, {140, 250}, {140, 180} }));
for (auto& pt : u)
std::cout << "{" << pt.x() << ", " << pt.y() << "} ";
}
Hiç yorum yok:
Yorum Gönder