【问题标题】:How to work with cgal circulators?如何使用 cgal 循环器?
【发布时间】:2014-05-13 14:35:56
【问题描述】:

我正在尝试对点集进行 delaunay 三角剖分,找到离输入点最近的点,并获取它的事件顶点,但不知何故,以下代码不起作用。

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Point Point;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Vertex_circulator Vertex_circulator;
int main( )
{
  std::ifstream in("data.txt");
  assert(in);
  std::istream_iterator<Point> begin(in);
  std::istream_iterator<Point> end;
  Triangulation T;
  T.insert(begin, end);
  std::cout << T.number_of_vertices() <<std::endl;
  Vertex_handle handle = T.nearest_vertex(Point(1, 1));
  std::cout << handle->point() << std::endl;
  std::cout<<"incidents: \n" << std::endl;
  Vertex_circulator circulator = T.incident_vertices(handle), done(circulator);
  do
    {
      std::cout << circulator->point() << std::endl;
    } while(++circulator != done);
  return 0;
}

例如如果data.txt是

2 3
1 1
1 0

输出是

3
1 1
incidents:

1 0
2 3
2.02461e-307 6.94896e-308

为什么我有最后一行?

【问题讨论】:

    标签: c++ computational-geometry cgal delaunay


    【解决方案1】:

    CGAL 的 2D 三角剖分有一个无限顶点连接到凸包的所有顶点(详见user manual)。

    您可以使用is_infinite 函数来测试单纯形是否无限。

    【讨论】:

      猜你喜欢
      • 2019-08-23
      • 2015-08-19
      • 2014-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多