【问题标题】:Lightweight Delaunay trianguation library (for c++) [closed]轻量级 Delaunay 三角函数库(用于 C++)[关闭]
【发布时间】:2010-11-29 15:20:42
【问题描述】:

我想玩一些(2D)Delaunay 三角剖分,并且正在寻找一个相当小的库来使用。我知道 CGAL,但我想知道那里是否有一些相当简单明了的东西。

我想做的事:

  • 创建任意一组点的三角剖分
  • 找到任意点所在的三角形,并获取顶点
  • 创建三角测量图像(可选)

建议?

【问题讨论】:

  • 你需要它作为一个库,还是一个独立的程序可以?
  • 独立程序可能不行。我希望将其集成到更大的软件工具中。

标签: c++ geometry triangulation cgal


【解决方案1】:

您可能应该详细说明您的目标,以便提供更相关的答案,但首先让我提一下Triangle,这是一个用 C 编写的 2D Delaunay 生成工具,可以单独使用程序,或从您自己的代码中调用。

那么,关于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;
}

【讨论】:

  • 感谢您将我指向三角。它非常简单易用。
  • 可以在原生 iPad 应用中使用这些方法吗?
  • @AndrewProck 你把它用作库了吗?因为我没有找到任何使用这个三角形库的代码示例
  • main 在 triangle.c 中
  • 我真的不知道你是否可以将 CGAL 用作库,我真的不知道该链接什么
【解决方案2】:

另见 poly2tri,它看起来不错:https://github.com/greenm01/poly2tri

【讨论】:

  • 这是针对受约束的 delaunay,如果您使用随机的一组点,我不确定这是否可行。
【解决方案3】:

我已将 Gnu Triangulated Surface library 用于 2D Delaunay 三角测量,并且效果很好。调用起来有点奇怪,因为它使用 OOP-in-C GLib 样式,但它很容易成为 wrapped up

【讨论】:

    猜你喜欢
    • 2012-08-02
    • 2013-12-24
    • 1970-01-01
    • 2010-10-17
    • 1970-01-01
    • 2013-05-12
    • 1970-01-01
    • 2011-07-21
    • 2011-10-25
    相关资源
    最近更新 更多