轻德洛奈trianguation库(c++)[封闭]
-
22-07-2019 - |
题
我想要玩弄一些(2D)德劳内三角,而且我在寻找一个合理小型图书馆的工作。我知道CGAL,但我想知道是否有一些相对简单。
事我想做到:
- 创建一个三角测量的任意设定的点
- 找到三角形的任意一点,并获取的顶点
- 创建一个图像的三角测量(可选)
建议?
解决方案
你也许应该详细目标一点,使更多的相关答复能够提供,但首先让我说 三角形, 一2D德洛奈代的工具,这是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> 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;
}
其他提示
另见poly2tri,它看起来漂亮: https://github.com/greenm01/poly2tri
不隶属于 StackOverflow