2013-05-01 134 views
2

當我試圖用CGAL繪製直骨架時,我得到了奇怪的結果(對稱多邊形上的非對稱骨架)。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

回答

4

很公平。 答案是您正在適當地使用內核。這不是你的代碼的問題,這是我需要修復的CGAL中的一個錯誤。 吉日(OP),請私下聯繫我(gmail的fernando dot cacciola),以便你可以跟進。