Centos7.2 eclipse使用CGAL求主骨架
来源:互联网 发布:华资软件招聘 编辑:程序博客网 时间:2024/05/22 04:55
环境说明
centos7.2 1511版本,直接使用eclipse IDE可执行文件。eclipse版本:eclipse-cpp-neon-1a-linux-gtk-x86_64.tar.gz Eclipse IDE for C/C++ Developers Version: Neon.1a Release (4.6.1) Build id: 20161007-1200
Centos7.2安装CGAL请查看之前文章
打开eclipse创建C++可执行文件工程
新建main.cpp文件,使用官网example:
#include "print.h"typedef CGAL::Exact_predicates_inexact_constructions_kernel K ;typedef K::Point_2 Point ;typedef CGAL::Polygon_2<K> Polygon_2 ;typedef CGAL::Straight_skeleton_2<K> Ss ;typedef boost::shared_ptr<Ss> SsPtr ;int main(){ Polygon_2 poly ; poly.push_back( Point(-1,-1) ) ; poly.push_back( Point(0,-12) ) ; poly.push_back( Point(1,-1) ) ; poly.push_back( Point(12,0) ) ; poly.push_back( Point(1,1) ) ; poly.push_back( Point(0,12) ) ; poly.push_back( Point(-1,1) ) ; poly.push_back( Point(-12,0) ) ; // You can pass the polygon via an iterator pair SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.vertices_begin(), poly.vertices_end()); // Or you can pass the polygon directly, as below. // To create an exterior straight skeleton you need to specify a maximum offset. double lMaxOffset = 5 ; SsPtr oss = CGAL::create_exterior_straight_skeleton_2(lMaxOffset, poly); print_straight_skeleton(*iss); print_straight_skeleton(*oss); return 0;}
1.编译提示无法找到print.h文件: 从./cgal-releases-CGAL-4.7/Straight_skeleton_2/examples/Straight_skeleton_2目录下复制该文件到工程源文件夹下,与main.cpp文件在一起。 2.编译提示缺少库:
3.编译成功后运行结果:Straight skeleton with 10 vertices, 34 halfedges and 8 faces(-12,0)->(-1,-1) contour(-1,-1)->(-12,0) contour(-1,-1)->(0,-12) contour(0,-12)->(-1,-1) contour(0,-12)->(1,-1) contour(1,-1)->(0,-12) contour(1,-1)->(12,0) contour(12,0)->(1,-1) contour(12,0)->(1,1) contour(1,1)->(12,0) contour(1,1)->(0,12) contour(0,12)->(1,1) contour(0,12)->(-1,1) contour(-1,1)->(0,12) contour(-1,1)->(-12,0) contour(-12,0)->(-1,1) contour(-1,-1)->(5.3871e-17,-1.23134e-16) bisector(5.3871e-17,-1.23134e-16)->(-1,-1) bisector(0,-12)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(0,-12) bisector(1,-1)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(1,-1) bisector(12,0)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(12,0) bisector(1,1)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(1,1) bisector(0,12)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(0,12) bisector(-1,1)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(-1,1) bisector(-12,0)->(5.3871e-17,-1.23134e-16) bisector(5.3871e-17,-1.23134e-16)->(-12,0) bisector(5.3871e-17,-1.23134e-16)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(5.3871e-17,-1.23134e-16) bisector
修改输出骨架点skeleton vertex
在print.h文件中添加输出函数:
template<class K>void print_straight_skeleton_vertex( CGAL::Straight_skeleton_2<K> const& ss ){ typedef CGAL::Straight_skeleton_2<K> Ss ; typedef typename Ss::Vertex_const_handle Vertex_const_handle ; typedef typename Ss::Vertex_const_iterator Vertex_const_iterator; typedef typename Ss::Halfedge_const_handle Halfedge_const_handle ; typedef typename Ss::Halfedge_const_iterator Halfedge_const_iterator ; Halfedge_const_handle null_halfedge ; Vertex_const_handle null_vertex ; std::cout << "Straight skeleton with " << ss.size_of_vertices() << " vertices, " << ss.size_of_halfedges() << " halfedges and " << ss.size_of_faces() << " faces" << std::endl ; for ( Halfedge_const_iterator i = ss.halfedges_begin(); i != ss.halfedges_end(); ++i ) { print_point(i->opposite()->vertex()->point()) ; std::cout << "->" ; print_point(i->vertex()->point()); std::cout << " " << ( i->is_bisector() ? "bisector" : "contour" ) << std::endl; } for ( Vertex_const_iterator j = ss.vertices_begin(); j != ss.vertices_end(); ++j ) { print_point(j->point()); std::cout << ( j->is_skeleton() ? "skeleton vertex" : "contour vertex" )<< std::endl; }}
输出为:Straight skeleton with 10 vertices, 34 halfedges and 8 faces(-12,0)->(-1,-1) contour(-1,-1)->(-12,0) contour(-1,-1)->(0,-12) contour(0,-12)->(-1,-1) contour(0,-12)->(1,-1) contour(1,-1)->(0,-12) contour(1,-1)->(12,0) contour(12,0)->(1,-1) contour(12,0)->(1,1) contour(1,1)->(12,0) contour(1,1)->(0,12) contour(0,12)->(1,1) contour(0,12)->(-1,1) contour(-1,1)->(0,12) contour(-1,1)->(-12,0) contour(-12,0)->(-1,1) contour(-1,-1)->(5.3871e-17,-1.23134e-16) bisector(5.3871e-17,-1.23134e-16)->(-1,-1) bisector(0,-12)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(0,-12) bisector(1,-1)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(1,-1) bisector(12,0)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(12,0) bisector(1,1)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(1,1) bisector(0,12)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(0,12) bisector(-1,1)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(-1,1) bisector(-12,0)->(5.3871e-17,-1.23134e-16) bisector(5.3871e-17,-1.23134e-16)->(-12,0) bisector(5.3871e-17,-1.23134e-16)->(-1.23134e-16,-1.07742e-16) bisector(-1.23134e-16,-1.07742e-16)->(5.3871e-17,-1.23134e-16) bisector(-1,-1)contour vertex(0,-12)contour vertex(1,-1)contour vertex(12,0)contour vertex(1,1)contour vertex(0,12)contour vertex(-1,1)contour vertex(-12,0)contour vertex(5.3871e-17,-1.23134e-16)skeleton vertex(-1.23134e-16,-1.07742e-16)skeleton vertex
说明:
实验代码中只运行了 create_interior_straight_skeleton_2
阅读全文
0 0
- Centos7.2 eclipse使用CGAL求主骨架
- CGAL安装与使用
- CGAL使用心得
- CGAL使用心得
- CGAL安装使用
- Maven骨架的使用
- CGAL
- CGAL
- CGAL使用心得(附加说明)
- CGAL使用心得(附加说明)
- CGAL使用心得(附加说明)
- 使用Archetype生成项目骨架
- Eclipse、IDEA创建Maven自定义骨架
- CGAL——学习2
- 使用CGAL中出现的错误
- ubuntu下使用CGAL的pro文件
- 使用vs2013、CodeBlocks分别编译cgal
- java 骨架类理解2
- 什么样的开题报告会被毙掉?
- 06-图2 Saving James Bond
- 如何用VOSviewer分析CNKI数据?
- 四线直流风扇PWM调速探研
- 如何高效学Python?
- Centos7.2 eclipse使用CGAL求主骨架
- 了解C++类和对象
- 期末考试 编程题#1:输出200(Coursera 程序设计与算法 专项课程3 C++程序设计 郭炜、刘家瑛;OpenJudge)
- springmvc第一讲:学习大纲
- Leetcode 212. Word Search II
- 数字图像处理知识体系
- java中交换两个Integer类型的数据
- 杨辉三角
- 横竖屏切换探讨