0
我在Boost中有多邊形,我試圖提取多邊形的片段,然後保存用於創建片段的點。我在C++中使用Boost庫。如何在Boost庫中提取參考片段的點
我該怎麼做?
typedef boost::tuple<double, double> point;
typedef boost::geometry::model::polygon<point> polygon;
typedef boost::geometry::model::referring_segment<point> segment;
template<typename Segment>
void get_segments(Segment const& s) {
std::cout << "Segment is "<<dsv(s) << std::endl;
std::cout << "Points of this segments are :";
//Extract the points of this segment somehow
}
int main() {
polygon poly;
boost::geometry::read_wkt(
"polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6, 3.4 2.0, 4.1 3.0, 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7, 2.0 1.3))",
poly);
polygon hull;
boost::geometry::convex_hull(poly, hull);
// Now I know I can `dsv()` and print to the screen like this:
std::cout << "hull: " << dsv(hull) << std::endl;
boost::geometry::for_each_segment(boost::geometry::exterior_ring(hull),
get_segments<segment>);
return 0;
}