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++)
基础教程推荐
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- CString 到 char* 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
