CGAL 2D alpha形状轮廓 [英] CGAL 2D alpha shape outline

查看:2067
本文介绍了CGAL 2D alpha形状轮廓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



这是我试过的:

  Alpha_shape_2 alpha begin(),pointsVec.end(),FT(1000),Alpha_shape_2 :: GENERAL); 
//很好地编译并提供常规输出,其中pointsVec是Point_2的列表

//然后我在CGAL文档中看到了边缘迭代器

模板< class OutputIterator> //方法 - CGAL alpha形状的迭代器,以便从alpha形状对象获得边缘
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);
}
}

//然后当使用以下代码时:

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

//我得到用于alpha形状的三角剖分中的所有边的列表。

事情是,我需要边界像下面的情节(用R alphahull库获得) / p>



而是在段向量中获得三角形边。
我尝试的另一件事是使用顶点迭代器:

  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
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给出了不是EXTERIOR的边。
我猜你对REGULAR和SINGULAR的边缘感兴趣。



看看 Classification_type classify 函数过滤掉边。


My problem is probably due to the newbiness in the CGAL c++ library, but the task I have keeps slipping away. Namely, I want to find the alpha shape of a set of points, but it seems I don`t understand the iterators available to 2D alpha shapes.

This is what I tried:

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.

The thing is that I need the boundary like in the following plot (obtained with R alphahull library)

Instead I get the triangulation edges in the segments vector. One other thing I tried is to use vertex iterators:

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
      }

but the result is the same. It outputs all the vertices so the drawing only connects them, without the outline (draw lines across the image).

I know that for 3D there is a function for finding the boundary shape vertices:

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

but it does not exist for 2D. Also I`m interested to find out where can you specify the alpha value used for the radius of the shaping circle, like in the windows demo supplied at the CGAL 2D shapes manual.

解决方案

Alpha_shape_edges_iterator gives you edges which are not EXTERIOR. I guess you are interested in REGULAR and SINGULAR edges.

Have a look at the Classification_type and at the classify function to filter out the edges.

这篇关于CGAL 2D alpha形状轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆