我的问题可能是由于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库)中获得的边界
相反,我得到了段矢量中的三角形边缘。我试过 的另一件事是使用顶点迭代器:
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演示中一样。
你有没有想出如何让边界顶点,以便? – Flowers 2015-06-05 23:20:45