零、安装过程墙裂推荐关闭杀毒软件。
一、首先是CGAL下载。
1、链接:https://pan.baidu.com/s/15uNzMOPuE1qKDNoUjGtFeQ
提取码:dx5l
2、安装注意:选择x64
3、安装完成后,可能需要手动添加环境变量path:C:\dev\CGAL-4.14\auxiliary\gmp\lib
二、下载boost1.70
链接:https://pan.baidu.com/s/1Kh-wu9A1lhEQfHJkHUbI9w
提取码:q7cx
三、安装boost1.70
1、一切默认
2、设置环境变量
BOOST_LIBRARYDIR=C:\local\boost_1_70_0\lib64-msvc-12.0
BOOST_INCLUDEDIR=C:\local\boost_1_70_0
3、修改环境变量Path
C:\local\boost_1_70_0\lib64-msvc-12.0
四、安装ZLIB。
1、下载ZLIB,
链接:https://pan.baidu.com/s/1tv3ICy3G2iKQ7JJmxqyEJw
提取码:naqh
2、编译ZLIB
到C:\BaiduNetdiskDownload\zlib-1.2.11\contrib\vstudio\vc12下面,找到那个.sln文件,用vs2013打开,按下图编译:
五、eigen.下载可以去官网,也不用编译。我胆小,做了下面的事:
添加环境变量EIGEN3_INC_DIR为C:\Eigen\signature_of_eigen3_matrix_library
在path中增加C:\Eigen;C:\Eigen\eigen
在pro文件中增加:
INCLUDEPATH += C:/eigen
其实最关键的是,在所有的include最前面加上
#define CGAL_EIGEN3_ENABLED
注意:是最前面!
六、运行CMake,指定好源文件目录和目标目录,选择好编译器。之后执行configure,哈哈,祖国山河一片红。
别管他,再点一次configure你会看到configure done,点一次generate。你会看到generate done.
注意:
7.1 Debug vs. Release
The CMake variable CMAKE_BUILD_TYPE
indicates how to build the libraries. It accepts the values Release
or Debug
. The default is Release
and should be kept, unless you want to debug your program.
This is not an issue for solution/project files, as there the user selects the build type from within the IDE.
7.2 Static vs. Shared Libraries
Shared libraries, also called dynamic-link libraries, are built by default (.dll
on Windows, .so
on Linux, .dylib
on MacOS). You can choose to produce static libraries instead by setting the CMake variable BUILD_SHARED_LIBS
to FALSE
. If you use cmake-gui
, a tick box for that variable is available to set it.
八、在cmake指定的输出目录中,找到CGAL.sln。用vs2013打开,编译之。注意用release和x64
九、使用的时候,以QT为例:
1、想着在所有包含头文件的最前面,加上:
#define CGAL_EIGEN3_ENABLED //为了使用eigen #define CGAL_USE_BASIC_VIEWER //为了三维显示
例如,我的包含文件:
#define CGAL_EIGEN3_ENABLED
#define CGAL_USE_BASIC_VIEWER
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Surface_mesh_parameterization/IO/File_off.h>
#include <CGAL/Surface_mesh_parameterization/parameterize.h>
#include <CGAL/Polygon_mesh_processing/measure.h>
#include <iostream>
#include <fstream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Surface_mesh<Kernel::Point_3> SurfaceMesh;
typedef boost::graph_traits<SurfaceMesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<SurfaceMesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
namespace SMP = CGAL::Surface_mesh_parameterization;
2、pro文件中:
QT+= opengl
INCLUDEPATH += C:/dev/CGAL-4.14/include \ #boost的路径
C:/dev/CGAL-4.14/build/include \
C:/dev/CGAL-4.14/include \
C:/dev/CGAL-4.14/build/include \
C:/local/boost_1_70_0/boost \
C:/local/boost_1_70_0 \
C:/eigen \
C:/dev/CGAL-4.14/auxiliary/gmp/include \
C:/dev/CGAL-4.14/demo/Polyhedron \
C:/dev/CGAL-4.14/demo/Polyhedron/include
#为了读取stl文件
INCLUDEPATH += C:/Qt/Qt5.8.0/5.8/msvc2013_64/include/QtXml \
C:/Qt/Qt5.8.0/5.8/msvc2013_64/include/QtOpenGL
LIBS += -LC:/dev/CGAL-4.14/build/lib/ -lCGAL-vc120-mt-4.14
LIBS += -LC:/dev/CGAL-4.14/build/lib/ -lCGAL_Qt5-vc120-mt-4.14
LIBS += -LC:/dev/CGAL-4.14/auxiliary/gmp/lib/ -llibgmp-10
LIBS += -LC:/local/boost_1_70_0/lib64-msvc-12.0/ -llibboost_system-vc120-mt-x64-1_70 #boost
LIBS += -LC:/local/boost_1_70_0/lib64-msvc-12.0/ -llibboost_thread-vc120-mt-x64-1_70 #boost