迫不及待推荐一个C++计算几何库

转载 2015年07月07日 13:54:53

怎么发现的

有事没事就喜欢找一些感兴趣的问题,然后循着问题中的答案或相关的引用到处漫游,点链接或者偶尔放狗搜一下,然后就找到这个地方了:

github上的位置

谨慎使用: 这个库应该是不错的;但是感觉缺乏Eigen那样严格的代码的peer review机制和大量而有效的测试; 加上对作者编程的风格的不了解, 感觉在使用中碰到问题的可能性会比较大.

一定要跨平台的话,感觉同一作者的同一计算几何库Matlab工具箱版本更实惠。

简单介绍

这个库自己的主页和名称:

libigl - A simple C++ geometry processing library

主页LOGO图片

libigl is a simple C++ geometry processing library. We have a wide functionality including construction of sparse discrete differential geometry operators and finite-elements matrices such as the cotangent Laplacian and diagonalized mass matrix, simple facet and edge-based topology data structures, mesh-viewing utilities for OpenGL and GLSL, and many core functions for matrix manipulation which make Eigen feel a lot more like MATLAB.

It is a header-only library. You do not need to compile anything to use, just include igl headers (e.g. #include "igl/cotmatrix.h") and run. Each header file contains a single function (e.g. igl/cotmatrix.h contains igl::cotmatrix()). Most are tailored to operate on a generic triangle mesh stored in an n×3 matrix of vertex positions V and an m×3 matrix of triangle indices F.

Optionally the library may also be pre-compiled into a statically linked library, for faster compile times with your projects. This only effects compile time (run-time performance and behavior is identical). If in doubt, use the header-only default mode: (i.e. just include the headers you want to use).

We use the Eigen library heavily in our code. Our group prototypes a lot in MATLAB, and we have a useful MATLAB to libigl+Eigen conversion table.

如何使用

Libigl is a header-only library. You do not need to build anything to install. Simply add libigl/include to your include path and include relevant headers. Here is a small “Hello, World” program:

#include <igl/cotmatrix.h>
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <iostream>
int main()
{
  Eigen::MatrixXd V(4,2);
  V<<0,0,
     1,0,
     1,1,
     0,1;
  Eigen::MatrixXi F(2,3);
  F<<0,1,2,
     0,2,3;
  Eigen::SparseMatrix<double> L;
  igl::cotmatrix(V,F,L);
  std::cout<<"Hello, mesh: "<<std::endl<<L*V<<std::endl;
  return 0;
}

If you save this in hello.cpp, then you could compile this with (assuming Eigen is installed in /usr/local/include/eigen3):

Running it would then produce:

Hello, mesh:
 0.5  0.5
-0.5  0.5
-0.5 -0.5
 0.5 -0.5

在visual C++里我只编译成果上面这段, 其它的代码都没搞定, 使用起来感觉比Eigen差; 估计作者大多还是在Linux,MacOS上用g++的

注意事项

  1. Dependencies are on a per-include basis and the majority of the functions in libigl depends only on the Eigen library. For more information see our tutorial.
    .

  2. Some of our functions will take advantage of OpenMP if available. However, it has come to our attention that Visual Studio + Eigen + OpenMP does NOT work properly. Since we use OpenMP only to improve performance, we recommend avoiding OpenMP on Windows or proceeding with caution.

相关文章推荐

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

Liuctic计算几何库

ACM模版Liuctic计算几何库/* * Liuctic 的计算几何库 * p-Lpoint ln,l - Lline ls - Llineseglr - Lrad * 求平面上两点之间...
  • f_zyj
  • f_zyj
  • 2016年07月23日 21:46
  • 817

计算几何几何函数库

 计算几何几何函数库------------------------------------------------------------------------------------------...
  • sunyeyi
  • sunyeyi
  • 2008年03月16日 14:48
  • 4059

开源几何计算数学库

a) Geos Geos的全称就是Geometry Engine Open Source,参考网站就是:http://geos.refractions.net,从名称就可以看出,Geos就是判断...

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

C++常用计算几何算法

从网上转来的几何算法,对点线的基本算法,有兴趣的可以学习下。 #include #include #include #include #define max(a,b) (((a)>(b))?(a):...

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

C++经典类库(C++开发必看)

现实中,C++的库门类繁多,解决的问题也是极其广泛,库从轻量级到重量级的都有。本文为你介绍了十一种类库,有我们常见的,也有不常见的,一起来看。 AD:2013大数据全球技术峰会低价抢票中 ...

C++计算几何算法大全

/* 计算几何 目录  ㈠ 点的基本运算  1. 平面上两点之间距离 1  2. 判断两点是否重合 1  3. 矢量叉乘 1  4. 矢量点乘 2  5. 判断点是否在线段上 2 ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:迫不及待推荐一个C++计算几何库
举报原因:
原因补充:

(最多只允许输入30个字)