stereohomology

业余爱好

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

怎么发现的

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

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.

阅读更多
个人分类: 学习学习
想对作者说点什么? 我来说一句

二维计算几何库(C++源码)

2014年01月06日 18KB 下载

三维计算几何库(C++源码)

2014年01月06日 7KB 下载

没有更多推荐了,返回首页

不良信息举报

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

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭