2014-09-27 109 views
3

我的問題可能是由於CGAL C++庫中的新手,但我的任務一直在滑落。也就是說,我想找到一組點的alpha形狀,但似乎我不瞭解可用於2D alpha形狀的迭代器。CGAL 2D alpha shape outline

這是我的嘗試:

Alpha_shape_2 alpha(pointsVec.begin(), pointsVec.end(), FT(1000), Alpha_shape_2::GENERAL); 
//which compiles nicely and provides the regular output where pointsVec is the list of Point_2 

//Then I saw the edge iterator at the CGAL documentation 

template <class OutputIterator> //Method-iterator for CGAL alpha shapes in order to get the edges from alpha shape object 
void alpha_edges(const Alpha_shape_2& A, 
        OutputIterator out) 
{ 
    for(Alpha_shape_edges_iterator it = A.alpha_shape_edges_begin(); 
     it != A.alpha_shape_edges_end(); 
     ++it){ 
     *out++ = A.segment(*it); 
    } 
} 

//Then when using the following code: 

std::vector<Segment> segments; 
alpha_edges(alpha, std::back_inserter(segments)); 

//I get the list of all the edges in the triangulation used for alpha shapes. 

的事情是,我需要像下面的圖(有R alphahull庫)中獲得的邊界

Alphahull

相反,我得到了段矢量中的三角形邊緣。我試過 的另一件事是使用頂點迭代器:

for (Alpha_shape_2::Alpha_shape_vertices_iterator it = alpha.Alpha_shape_vertices_begin(); it != alpha.Alpha_shape_vertices_end(); ++it) 
     { 
      int xalpha = (*it)->point().x(); 
      int yalpha = (*it)->point().y(); 
      alphaCoords.push_back(cv::Point(xalpha, yalpha)); //this for openCV 
     } 

,但結果是一樣的。它輸出所有的頂點,因此繪圖只連接它們,沒有輪廓(在圖像上畫線)。

我知道,3D有尋找邊界形狀頂點的功能:

as.get_alpha_shape_vertices(back_inserter(al_vs), Alpha_shape_3::REGULAR); 

,但它並不適用於2D存在。另外我很想知道在哪裏可以指定用於成形圓半徑的alpha值,就像在CGAL 2D形狀手冊中提供的Windows演示中一樣。

+0

你有沒有想出如何讓邊界頂點,以便? – Flowers 2015-06-05 23:20:45

回答

3

Alpha_shape_edges_iterator讓你邊哪些不是外部。 我想你對常規和奇異邊緣感興趣。

看看Classification_typeclassify函數來濾除邊緣。

+0

對不起,延誤了。答案很好。它返回我需要的REGULAR類型的邊。 – 2014-10-09 09:06:48