CGAL的安裝編譯
eryar@163.com
關鍵字Key Word:CGAL, C++, Delaunay Triangulation, Voronoi diagram,
一、引言 Introduction
CGAL, Computational Geometry Algorithms Library,計算幾何算法庫。設計目標是以C++庫的形式提供方便、高效、可靠的幾何算法。CGAL可用于各種需要幾何計算的領域,如計算機圖形學,科學可視化,計算機輔助設計與建模,地理信息系統,分子生物學,醫學成像,機器人運動規劃,網格生成,數值方法等。
The goal of the CGAL Open Source Project is to provide easy access to efficient and reliable geometric algorithms in the form of a C++ library. CGAL is used in various areas needing geometric computation, such as: computer graphics, scientific visualization, computer aided degisn and modeling, geographic information systems, molecular biology, medical imaging, robotics and motion planning, mesh generation, numerical methods...
計算幾何算法庫(CGAL)提供計算幾何相關的數據結構和算法,如三角剖分(2D 約束三角剖分及二維和三維Delaunay三角剖分),Voronoi圖(二維和三維的點,2D加權Voronoi圖,分割Voronoi圖等),多邊形(布爾操作,偏置),多面體(布爾運算),曲線整理及其應用,網格生成(二維Delaunay網格生成和三維表面和體積網格生成等),幾何處理(表面網格簡化,細分和參數化等),凸殼算法(2D,3D和dD),搜索結構(近鄰搜索,kd樹等),插值,形狀分析,擬合,距離等。
The Computational Geometry Algorithms Library(CAGL), offers data structures and algorithms like triangulations(2D constrained triangulations and Delaunay triangulations in 2D and 3D, periodic triangulations in 3D), Voronoi diagrams(for 2D and 3D points, 2D additively weighted Voronoi diagrams, and segment Voronoi diagrams), polygons(Boolean operations, offsets, straight skeleton), polyhedra(Boolean operations), arrangements of curves and their applications(2D and 3D envelopes, Minkowski sums), mesh generation(2D Delaunay mesh generation and 3D surface and volume mesh generation, skin surfaces), geometry processing(surface mesh simplification, subdivision and parameterization, as well as estimation of local differential properties, and approximation of ridges and umbilics), alpha shapes, convex hull algorithms(in 2D, 3D and interpolation and placement of streamlines), shape analysis, fitting, and distances(smallest enclosing sphere of points or spheres, smallest enclosing ellipsolid of points, principal component analysis), and kinetic data structures.
More information please see: http://www.cgal.org/ .
二、安裝 Installation
1.編譯器Compiler:Visual Studio
2.CMake:下載CMake:www.cmake.org
3.Boost庫:根據機器選擇安裝32/64位的Boost庫,http://boost.teeks99.com.
4.Qt:只有要運行demo程序時才需要,根據需要安裝,最好安裝一下;
5.libQGLViewer:只有要運行3D CGAL的demo程序時才需要,最好安裝一下;
6.CGAL安裝包:Download CGAL installer (http://gforge.inria.fr/frs/?group_id=52) .
運行CGAL安裝包,按提示安裝。因為CGAL需要GMP和MPFR第三方庫,主要是用來處理多精度的整數、有理數(multi precision integers and rational numbers, and for multi precision floating point numbers)。由于Visual C++對GMP和MPFR的工程支持不是很好,CGAL提供編譯好的GMP和MPFR,由安裝包在安裝時從網上下載。所以在安裝過程中如果需要下載GMP和MPFR,一定要下載。
三、編譯 Compiling
先用CMake生成Visual Studio的工程文件。打開CMake,設置sorce code和build the binaries的目錄,如下圖所示:
點擊Configure,選擇所需要的編譯器,如下圖所示:
希望一切都順利,你將會看到“Configuring done”,如下圖所示:
但是,也可能第一次并沒有成功,可能會出現下面的錯誤,如找不到Boost庫:
Can not find BOOST_INCLUDE_DIR。
這時就需要手動在CMake中添加一下,點Add Entry,添加相應的路徑,如下圖所示:
類似地,添加其它報錯的Boost庫,如下圖所示:
再點“Configure”,如果“Generate”可以點擊,就點擊“”生成Visual Studio的解決方案。
生成的解決方案如下圖所示:
打開解決方案,編譯整個解決方案即可。
Congratulations!