不精确的直线骨架与CGAL

imprecise straight skeleton with CGAL

本文关键字:CGAL 不精确      更新时间:2023-10-16

当我试图用CGAL绘制直线骨架时,我得到了奇怪的结果(对称多边形上的非对称骨架)。

结果与内核:

  • Exact_predicates_inexact_constructions_kernel
  • Exact_predicates_exact_constructions_kernel

使用内核

    笛卡尔

在这里(这更好,但当我循环地移动多边形定义中的点时,它会断开)。

我正在使用这个代码:

#include <vector>
#include <boost/shared_ptr.hpp>
// #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
// typedef CGAL::Exact_predicates_inexact_constructions_kernel K ;
// #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
// typedef CGAL::Exact_predicates_exact_constructions_kernel K ;
#include <CGAL/Cartesian.h>
typedef CGAL::Cartesian<float> K;
#include <CGAL/Polygon_2.h>
#include <CGAL/create_straight_skeleton_2.h>
typedef K::Point_2 Point_2;
typedef CGAL::Straight_skeleton_2<K> Ss;
typedef boost::shared_ptr<Ss> SsPtr;
int main() {
    Point_2 pts[] = {
        Point_2(0,  -1385),//top
        Point_2(500, 0),//right half:
        Point_2(300, 0),
        Point_2(400, 173),
        Point_2(200, 173),
        Point_2(100, 0),
        Point_2(-100, 0),//left half:
        Point_2(-200, 173),
        Point_2(-400, 173),
        Point_2(-300, 0),
        Point_2(-500, 0),
    } ;
    std::vector<Point_2> poly(pts,pts+11);
    SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.begin(), poly.end(), K());
    //printing for debugging
    for ( Ss::Halfedge_const_iterator i = (*iss).halfedges_begin(); i != (*iss).halfedges_end(); ++i )  {
        if ( i->is_bisector()){
            std::cout<<"i ";
        }
        else {
            std::cout<<"c ";
        }
        CGAL::Point_2<K> pa= i->opposite()->vertex()->point();
        CGAL::Point_2<K> pb= i->vertex()->point();
        std::cout << pa.x() << " " << pa.y() << " " << pb.x() << " " << pb.y() << std::endl;
    }
    return 0;
}

问题似乎是简并性(4行相交于一点)没有被精确计算。

我使用内核不恰当吗?我应该如何使用它来得到这个结果:https://i.stack.imgur.com/ESk9U.png

作为解决方法,我将多边形高档100,然后调用CGAL,然后再次降低结果。


指出:

显示结果的脚本(用于调试):https://gist.github.com/anonymous/5497523

有道理。答案是您正确地使用了内核。这不是你的代码的问题,这是一个bug在CGAL,我需要修复。Jiri (OP),请私下联系我(fernando。cacciola在gmail),以便你可以跟进这件事。