#include <boost/polygon/polygon.hpp>
#include <vector>
#include <iostream>
namespace gtl = boost::polygon;
typedef gtl::point_data<double> point;
typedef gtl::polygon_set_data<double> polygon_set;
typedef gtl::polygon_with_holes_data<double> polygon;
#include <boost/range/algorithm.hpp>
// . . 100
//
// . . 75
//
// . . 50
//
// . . 25
//
// . . 0
// 0 25 75 100
void dispp( point p ) {
std::cout << "(" << p.x() << "," << p.y() << ")";
}
void disp( polygon ply ) {
std::cout << std::endl << "====== TRAPEZOIDS ======" << std::endl;
boost::for_each(
*(reinterpret_cast<std::vector<point>*>(&ply)), // うぜぇ(反則技)
dispp
);
}
int main() {
std::vector<point> pts;
pts.push_back( point( 0, 0 ) );
pts.push_back( point( 0, 50 ) );
pts.push_back( point( 25, 50 ) );
pts.push_back( point( 25, 25 ) );
pts.push_back( point( 75, 25 ) );
pts.push_back( point( 75, 75 ) );
pts.push_back( point( 25, 75 ) );
pts.push_back( point( 25, 50 ) );
pts.push_back( point( 0, 50 ) );
pts.push_back( point( 0, 100 ) );
pts.push_back( point( 100, 100 ) );
pts.push_back( point( 100, 0 ) );
polygon ply;
gtl::set_points( ply, pts.begin(), pts.end() );
using namespace gtl::operators;
std::vector<polygon> ots;
polygon_set plys;
plys.insert( ply );
plys.get_trapezoids( ots );
boost::for_each( ots, disp );
return 0;
}
2012年3月28日水曜日
boost::polygon get_trapezoids (台形分割)
お手軽なテッセレーションがほすぃ…。
思ってたよりも、手こずった…。ドキュメントが少ない。
boost::geometry と融合していっても良いのではないか?
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿