博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
INSTALL CGAL on ubuntu and use it in qt
阅读量:4042 次
发布时间:2019-05-24

本文共 1859 字,大约阅读时间需要 6 分钟。

Recently, i have read a paper named "as rigid as possible surface modeling", when I turned to its project web page, the author told us it had been implemented in CGAL. So with having a try mind, I decide to study this lib.

let us introduce how to install CGAL on ubuntu:

For instance in debian/Ubuntu, use apt-get in the following way:

sudo apt-get install libcgal-dev

To get the demos use

sudo apt-get install libcgal-demo

After installing, let us try to program the first example in qt.

.pro file looks like below:

#-------------------------------------------------## Project created by QtCreator 2016-01-28T13:29:40##-------------------------------------------------QT       += coreQT       -= guiTARGET = TestCGALCONFIG   += consoleCONFIG   -= app_bundleTEMPLATE = appSOURCES += main.cppLIBS += -L/lib64 -lgmp -lCGALQMAKE_CXXFLAGS += -frounding-math -O3

the content of main.cpp is as follow:

#include 
#include
typedef CGAL::Simple_cartesian
Kernel;typedef Kernel::Point_2 Point_2;typedef Kernel::Segment_2 Segment_2;int main(){ Point_2 p(1,1), q(10,10); std::cout << "p = " << p << std::endl; std::cout << "q = " << q.x() << " " << q.y() << std::endl; std::cout << "sqdist(p,q) = " << CGAL::squared_distance(p,q) << std::endl; Segment_2 s(p,q); Point_2 m(5, 9); std::cout << "m = " << m << std::endl; std::cout << "sqdist(Segment_2(p,q), m) = " << CGAL::squared_distance(s,m) << std::endl; std::cout << "p, q, and m "; switch (CGAL::orientation(p,q,m)){ case CGAL::COLLINEAR: std::cout << "are collinear\n"; break; case CGAL::LEFT_TURN: std::cout << "make a left turn\n"; break; case CGAL::RIGHT_TURN: std::cout << "make a right turn\n"; break; } std::cout << " midpoint(p,q) = " << CGAL::midpoint(p,q) << std::endl; return 0;}

the result is shown in the pic:

你可能感兴趣的文章
retext出现Could not parse file contents, check if you have the necessary module installed解决方案
查看>>
Matlab与CUDA C的混合编程配置出现的问题及解决方案
查看>>
PaperDownloader——文献命名6起来
查看>>
如何将PaperDownloader下载的文献存放到任意位置
查看>>
C/C++中关于动态生成一维数组和二维数组的学习
查看>>
JVM最简生存指南
查看>>
Java的对象驻留
查看>>
logback高级特性使用(二) 自定义Pattern模板
查看>>
JVM并发机制探讨—内存模型、内存可见性和指令重排序
查看>>
可扩展、高可用服务网络设计方案
查看>>
如何构建高扩展性网站
查看>>
微服务架构的设计模式
查看>>
持续可用与CAP理论 – 一个系统开发者的观点
查看>>
nginx+tomcat+memcached (msm)实现 session同步复制
查看>>
c++字符数组和字符指针区别以及str***函数
查看>>
c++类的操作符重载注意事项
查看>>
c++模板与泛型编程
查看>>
WAV文件解析
查看>>
WPF中PATH使用AI导出SVG的方法
查看>>
WPF UI&控件免费开源库
查看>>