CGAL 4.7:排列插入(arr、begin、end)崩溃



我试图对x单调多段线进行聚合插入,但我得到了以下错误:

terminate called after throwing an instance of 'CGAL::Precondition_exception'
  what():  CGAL ERROR: precondition violation!
Expr: i != INVALID_INDEX
File: /home/vladimir/lib-cgal/include/CGAL/Arr_polycurve_basic_traits_2.h
Line: 727

也不知道为什么会发生这种事。我错过什么了吗?我的输入有错吗?还是一个bug?以下是导致此行为的代码片段:

#include <vector>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arr_polyline_traits_2.h>
#include <CGAL/Arrangement_2.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel   Kernel;
typedef Kernel::Point_2                                     Point_2;
typedef CGAL::Arr_segment_traits_2<Kernel>                  Segment_traits_2;
typedef CGAL::Arr_polyline_traits_2<Segment_traits_2>       Geom_traits_2;
typedef CGAL::Arrangement_2<Geom_traits_2>                  Arrangement_2;
int main()
{
    Arrangement_2 arr;
    std::vector<Geom_traits_2::X_monotone_curve_2> segments;
    {
        auto ctor = arr.geometry_traits()->construct_x_monotone_curve_2_object();
        typedef std::vector<Point_2> Line;
        std::vector<Line> lines = {
            {{0,0}, {8,0}},
            {{2,0}, {7,0}},
            {{4,2}, {6,3}},
            {{1,1}, {3,0}, {5,0}},
        };
        for (auto &line: lines) {
            segments.push_back(ctor(line.begin(), line.end()));
        }
    }
    insert(arr, segments.begin(), segments.end());
    return 0;
}

我使用的CGAL版本是4.7,但我用4.5.2和最新的git版本(81d638341)尝试过,结果相同。

这些线是相交的,但据我所知,这应该没问题。我观察到将{{1,1}, {3,0}, {5,0}}更改为{{2,1}, {3,0}, {5,0}}不会导致错误。并且将CCD_ 3分割成两个片段CCD_。

我还注意到另一个有类似问题的线程(链接)已经修复,但我在4.7版本中没有看到这个修复。也许它在代码中的其他地方被修复了,或者这个修复不知怎么丢失了。?不管怎么说,这似乎与我的问题无关,但人们永远不会知道。

我能够重现这个问题,乍一看它像一个bug。我们正在对此进行调查,但目前您有两个解决问题的选项:1.使用增量插入。增量插入基于完全不同的算法。2.将每条多段线分解为线段,并构造线段排列而不是多段线排列。我用一个最小的例子测试了它,这个例子产生了你提供的问题(顺便说一句,就是你),它运行得很好。

BW,你提到的链接是无关的。

最新更新