gpt4 book ai didi

c++ - CGAL 二维 alpha 形状轮廓

转载 作者:太空狗 更新时间:2023-10-29 20:58:56 28 4
gpt4 key购买 nike

我的问题可能是由于 CGAL c++ 库中的新特性,但我的任务一直在溜走。也就是说,我想找到一组点的 alpha 形状,但我似乎不了解 2D alpha 形状可用的迭代器。

这是我尝试过的:

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

相反,我在分段 vector 中获得了三角测量边。我尝试的另一件事是使用顶点迭代器:

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 演示中一样。

最佳答案

Alpha_shape_edges_iterator 为您提供非外部的边。我猜您对 REGULAR 和 SINGULAR edges 感兴趣。

看看 Classification_typeclassify过滤掉边缘的函数。

关于c++ - CGAL 二维 alpha 形状轮廓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26077895/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com