CGAL Visibility computes wrong visibility polygon (Simple Polygon Visibility algorithm)

只谈情不闲聊 提交于 2019-12-24 00:54:54

问题


I have to compute the visibility polygons of some vertices of a given polygon. I'm using CGALs visibility computation library, but for this example polygon and its 35th vertex (and a few more points), the following (obviously wrong) result is computed, where one edge of the visibility polygon intersects an edge of the original one.

I used the following code for construction:

typedef CGAL::Arrangement_2<CGAL::Arr_segment_traits_2<Epeck>> Arrangement_2;

Arrangement_2 polygon_arr;
CGAL::insert(polygon_arr, polygon.edges_begin(), polygon.edges_end());

Arrangement_2 vp_output;             
CGAL::Simple_polygon_visibility_2<Arrangement_2, CGAL::Tag_false> non_regular_visibility(polygon_arr);


// ci is vertex circulator
Arrangement_2::Halfedge_const_handle preceding_he =
    std::find_if(polygon_arr.halfedges_begin(),polygon_arr.halfedges_end(),
        [&ci](const typename Arrangement_2::Halfedge &e) {
            return !e.face()->is_unbounded() && e.target()->point() == *ci;
         }
);

non_regular_visibility.compute_visibility(*ci, preceding_he, vp_output);
for (auto eit = vp_output.edges_begin(); eit != vp_output.edges_end(); ++eit)
{
    segments.push_back(eit->curve());
}

Is that a bug in CGALs implementation or is it a bug in my code?

Edit: Changing the algorithm to CGAL::Triangular_expansion_visibility_2<Arrangement_2> tev(polygon_arr); (l. 7) solves the problem, so it's probably a bug in CGAL.


回答1:


You are right, it is a bug in CGAL. I created an issue for this : https://github.com/CGAL/cgal/issues/4289



来源:https://stackoverflow.com/questions/58244381/cgal-visibility-computes-wrong-visibility-polygon-simple-polygon-visibility-alg

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!