Lightweight Delaunay trianguation library (for c++)(轻量级 Delaunay 三角函数库(用于 c++))
问题描述
我想玩一些(2D)Delaunay 三角剖分,并且正在寻找一个相当小的库来使用.我知道 CGAL,但我想知道那里是否有一些相当简单明了的东西.
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.
我想做的事:
- 创建任意一组点的三角剖分
- 找到任意点所在的三角形,并获取顶点
- 创建三角测量图像(可选)
建议?
推荐答案
你可能应该详细说明你的目标,以便提供更相关的答案,但我先提一下 Triangle,2D Delaunay 生成工具,用 C 语言编写,既可以作为独立程序使用,也可以调用来自您自己的代码.
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.
那么,关于CGAL,这里是一个典型的小例子,以防你还在考虑:
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 三角函数库(用于 c++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:轻量级 Delaunay 三角函数库(用于 c++)
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- C++ 协变模板 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 静态初始化顺序失败 2022-01-01
- 近似搜索的工作原理 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 从python回调到c++的选项 2022-11-16
- Stroustrup 的 Simple_window.h 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01