Microsoft Visual Studio 2015 编译CGAL库函数的准备工作(图文版)

参照网上的教程安装CGAL后,可以成功用cmake编译生成一个.sln工程文件,但直接在Visual Studio中不能直接运行,需要配置一些库,具体操作如下:
以下操作适合win10 64bits笔记本, Visual Studio中选择“Debug x64”
在这里插入图片描述
鼠标右键项目名称“Project3”,点击最下方“属性”:
在这里插入图片描述

点击C/C++,“常规”,编辑“附加包含目录”,添加:
include: (C:\boost_1_61_0)
include: \include (C:\CGAL-4.11\include)
include: \auxiliary\gmp\include (C:\CGAL-4.11\auxiliary\gmp\include)
include: \include\Qt (C:\Qt\Qt5.6.0\5.6\msvc2015_64\include)

在这里插入图片描述

点击“链接器”, “常规”,编辑“链接库依赖项”:

  • library: \lib (C:\Qt\Qt5.6.0\5.6\msvc2015_64\lib)
  • library: \lib (C:\boost_1_61_0\lib64-msvc-14.0)
  • library: \auxiliary\gmp\lib (C:\CGAL-4.11\auxiliary\gmp\lib)

在这里插入图片描述

点击“链接器”,“输入”,分别编辑“附加依赖项”和“忽略特定默认库”:
添加“libgmp-10.lib;libmpfr-4.lib” 到附加依赖项中。
添加 “gmp-vc100-mt-gd.lib;mpfr-vc100-mt-gd.lib”到忽略特定默认库中。
如果程序中还用到了Qt,还需要添加:
“qtmaind.lib”到附加依赖项中。

在这里插入图片描述

点击VC++目录,分别编辑“包含目录”,“库目录”,“源目录”

  • 包含目录:
    C:\CGAL-4.11\build\include (//C:\CGAL-4.11\build用cmake运行输出文件名,可自定义)
    C:\boost_1_61_0
    C:\CGAL-4.11\auxiliary\gmp\include
    C:\CGAL-4.11\include
  • 库目录:
    C:\boost_1_61_0\stage\lib
    C:\CGAL-4.11\auxiliary\gmp\lib
    C:\CGAL-4.11\build\lib
  • 源目录:
    C:\CGAL-4.11\src

在这里插入图片描述

测试,下面是利用CGAL库中interpolation函数的代码,在Visual Studio中编译运行:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Interpolation_traits_2.h>
#include <CGAL/natural_neighbor_coordinates_2.h>
#include <CGAL/interpolation_functions.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K>             Delaunay_triangulation;
typedef CGAL::Interpolation_traits_2<K>               Traits;
typedef K::FT                                         Coord_type;
typedef K::Point_2                                    Point;
int main()
{
	Delaunay_triangulation T;
	std::map<Point, Coord_type, K::Less_xy_2> function_values;
	typedef CGAL::Data_access< std::map<Point, Coord_type, K::Less_xy_2 > >
		Value_access;
	Coord_type a(0.25), bx(1.3), by(-0.7);
	for (int y = 0; y<3; y++) {
		for (int x = 0; x<3; x++) {
			K::Point_2 p(x, y);
			T.insert(p);
			function_values.insert(std::make_pair(p, a + bx* x + by*y));
		}
	}
	//coordinate computation
	K::Point_2 p(1.3, 0.34);
	std::vector< std::pair< Point, Coord_type > > coords;
	Coord_type norm =
		CGAL::natural_neighbor_coordinates_2
		(T, p, std::back_inserter(coords)).second;
	Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(),
		norm,
		Value_access(function_values));
	std::cout << "Tested interpolation on " << p << " interpolation: "
		<< res << " exact: " << a + bx* p.x() + by* p.y() << std::endl;
	std::cout << "done" << std::endl;
	system("pause");
	return 0;
}

运行结果如下:
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值