CGAL:查找点所在的面/三角形?

5

阅读了相关信息后,我的结论是:

#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 >& points)
{
  points.push_back(Point(1., 1.));
  points.push_back(Point(2., 1.));
  points.push_back(Point(2., 2.));
  points.push_back(Point(1., 2.));      
}

int main()
{
  std::vector< Point > points;
  load_points(points);
  Delaunay dt;
  dt.insert(points.begin(), points.end());
  std::cout << dt.number_of_vertices() << std::endl;

  typedef std::vector<Delaunay::Face_handle> Faces;
  Faces faces;
  std::back_insert_iterator<Faces> result( faces );
  result = dt.get_conflicts ( Delaunay::Point(1.5, 1.5),
                                std::back_inserter(faces) );

  return 0;
}

这将找到其外接圆包含该点的面。之后,我需要使用一种方法来测试该点是否在这些三角形内(我认为CGAL可以做到这一点?不过实现起来很容易)。

无论如何,我如何从面中获取三角形呢?

答案是:

CGAL::Triangle_2<K> f = dt.triangle(faces[0]);
std::cout << dt.triangle(faces[0]) << std::endl;
std::cout << dt.triangle(faces[1]) << std::endl;

等等,我不太明白您的意思。您需要我将以下内容翻译成中文吗?

我不知道如何很好地使用Triangle类,但至少这是一个开始。

我本来想做一个实际的答案,但stackoverflow没有允许我这样做。

1个回答

4

您应该使用locate成员函数,其文档可以在这里找到。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接