【问题标题】:imprecise straight skeleton with CGALCGAL 不精确的直骨架
【发布时间】:2013-05-01 20:15:04
【问题描述】:

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

内核结果:

  • Exact_predicates_inexact_constructions_kernel
  • Exact_predicates_exact_constructions_kernel

here

使用内核

  • 笛卡尔

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

我正在使用此代码:

#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 条线在一点相遇)没有被精确计算。

我是否不恰当地使用内核?我应该如何使用它来获得这个结果:http://i.imgur.com/3ggYocV.png

作为解决方法,我将多边形放大 100,然后调用 CGAL,然后再次缩小结果。


注意事项:

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

【问题讨论】:

    标签: c++ cgal


    【解决方案1】:

    很公平。 答案是您正在适当地使用内核。这不是您的代码的问题,它是 CGAL 中的一个错误,我需要修复。 Jiri(OP),请私下联系我(Fernando dot cacciola at gmail),以便您跟进此事。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      • 2011-08-04
      • 1970-01-01
      • 1970-01-01
      • 2019-11-13
      相关资源
      最近更新 更多