【问题标题】:CGAL 2D Delaunay Triangulation: How to get edges as vertex id pairsCGAL 2D Delaunay 三角剖分:如何将边作为顶点 id 对
【发布时间】:2012-03-29 20:10:34
【问题描述】:

我有一组 2D 点,每个点都有一个关联的 id。 (例如,如果点存储在数组中,则 id 是每个点的索引 0,....,n-1 )。

现在我创建这些点的 Delaunay 三角剖分,并希望列出所有有限边。对于每条边,我希望得到由对应的 2 个顶点表示的点的 id。示例:如果点 0 和点 2 之间有一条边,则为 (0,2)。这可能吗?

#include <vector>
#include <CGAL\Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL\Delaunay_triangulation_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Delaunay;
typedef K::Point_2 Point;

 void load_points(std::vector<Point>& rPoints)
 {
  rPoints.push_back(Point(10,10));   // first point
  rPoints.push_back(Point(60,10));   // second point
  rPoints.push_back(Point(30,40));   // third point
  rPoints.push_back(Point(40,80));   // fourth point
 }

void main()
{
 std::vector<Point> points;
 load_points(points);

 Delaunay dt;
 dt.insert(points.begin(),points.end());

 for(Delaunay::Finite_edges_iterator it = dt.finite_edges_begin(); it != dt.finite_edges_end(); ++it)
 {
     }
}

【问题讨论】:

    标签: c++ cgal delaunay


    【解决方案1】:

    首先,您需要使用带有these examples 中的信息的顶点类型。那么一条边是一对包含一个面的句柄以及与该边相对的面中顶点的索引。

    如果你有:

    Delaunay::Edge e=*it;
    

    您正在寻找的指数是:

    int i1= e.first->vertex( (e.second+1)%3 )->info();
    int i2= e.first->vertex( (e.second+2)%3 )->info();
    

    【讨论】:

      猜你喜欢
      • 2011-11-12
      • 1970-01-01
      • 2013-11-19
      • 1970-01-01
      • 1970-01-01
      • 2018-12-23
      • 1970-01-01
      • 2020-08-05
      • 2020-05-06
      相关资源
      最近更新 更多