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.编译提示缺少库:

添加CGAL基础库

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
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 b驾照年审过期怎么办 摩托车驾驶证过期一年怎么办 驾驶证过期一年半怎么办 驾照过期了几天怎么办 驾照过期超过一年怎么办 考试驾照过期了怎么办 驾校考试过期了怎么办 驾驶证明过期了怎么办 驾驶证年过期了怎么办 驾照过期六个月怎么办 移动预约号码取消怎么办 身份证换地址驾驶证怎么办 刚来成都怎么办居住证 我在外地怎么办身份证 身份证丢在外地怎么办 换领新身份证时旧证丢了怎么办 二代身份证重号怎么办 北京行驶证到期怎么办 北京驾驶证即将过期怎么办 去澳门没有网络怎么办 三个周期未年检怎么办 深圳驾照丢了怎么办 武汉驾照年审过期怎么办 武汉驾照过期了怎么办 科二过不了怎么办 南京身份证到期换新怎么办 过期身份证丢了怎么办 南京驾照过期了怎么办 换驾照身体证明怎么办 学车办理暂住证怎么办 a牌驾照扣分怎么办 b牌驾照扣分怎么办 b驾照扣分了怎么办 考驾照要暂住证怎么办 换驾驶证有色盲怎么办 外籍人员办理就业证怎么办 驾驶证该审过期怎么办 小车证扣满12分怎么办 b证扣满12分怎么办 车过户后保险怎么办 换新轮胎旧轮胎怎么办