本文介绍了轻量级Delaunay trianguation库(用于c ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想玩一些(2D)Delaunay三角测量,并寻找一个合理的小图书馆工作。我知道CGAL,但我想知道是否有相当简单和直接的东西在那里。



我想做的事情:




  • 创建任意点集合的三角形

  • 找到任意点所在的三角形, li>
  • 创建三角形图片(可选)



建议?

$ b $你应该详细说明你的目标,以便提供更相关的答案,但让我先提一下,一个2D Delaunay生成工具,用C语言编写,可以作为独立程序使用,也可以从您自己的代码中调用。



然后,关于CGAL,这里是一个典型的小例子,如果你仍然考虑它:

  #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>德劳内
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,,));
points.push_back(Point(1,,));
}

int main()
{
std :: vector<点>点数;
load_points(points);
Delaunay dt;
dt.insert(points.begin(),points.end());
std :: cout<< dt.number_of_vertices()< std :: endl;
return 0;
}


I'd like to play around with some (2D) Delaunay triangulations, and am looking for a reasonably small library to work with. I'm aware of CGAL, but I was wondering if there was something fairly simple and straightforward out there.

Things I would like to do:

  • create a triangulation of an arbitrary set of points
  • find triangle an arbitrary point is in, and fetch the vertices
  • create an image of the triangulation (optional)

Suggestions?

解决方案

You should probably detail your goals a bit, so that more relevant answers can be provided, but let me first mention Triangle, a 2D Delaunay generation tool, which is written in C, and can be used both as a standalone program, or called from your own code.

Then, about CGAL, here is a typical small example, in case you still consider it:

#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;
  return 0;
}

这篇关于轻量级Delaunay trianguation库(用于c ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 06:28