【发布时间】:2018-05-22 12:36:34
【问题描述】:
我正在努力计算多面体在 xy 平面上的投影。目前我使用以下代码:
vector<Polygon_2> ii;
vector<Polygon_with_holes_2> oi;
for (Facet_iterator s = polyhedron.facets_begin();
s != polyhedron.facets_end(); ++s) {
Halfedge_facet_circulator h = s->facet_begin(), he(h);
Polygon_2 polygon;
do {
Point p1 = h->vertex()->point();
polygon.insert(polygon.vertices_end(), Point_2(p1.x(), p1.y()));
} while (++h != he);
if (polygon.orientation() == CGAL::NEGATIVE)
polygon.reverse_orientation();
ii.push_back(polygon);
}
CGAL::join(ii.begin(), ii.end(), std::back_inserter(oi));
这会在多面体表面上进行迭代,并为每个表面手动执行 2d 投影。然后将生成的多边形连接在一起。
但是,从手册中我觉得这不是将库用于此类任务的预期方式。 Project_traits_xy_3 类暗示,有一种常规方法可以使用 CGAL 实现投影。但是,我找不到合适的文档或示例。
任何人都可以在这里指出我正确的方向吗?我觉得,这应该是一个优雅的标准任务。
【问题讨论】:
标签: c++ 3d geometry computational-geometry cgal