CGAL::2D Arrangements-2

2.3.2 遍历Arrangement Halfedge

Arrangement的一条Halfedge是和一个 X_monotone_curve_2对象绑定,这个curve可以通过e->curve()获取。

e->source()得到源点,e->target()得到目标点,e->twin()得到半边的对边,

第个半边都有一个关联面(incident face),这个关联面在半边的左边,可以通过e->face()获取到。

e->prev()和e->next(),得到关联的上一条和下一条半边。

下面是遍历一个face的halfedge代码段:

cpp 复制代码
template <typename Arrangement>
void print_ccb(typename Arrangement::Ccb_halfedge_const_circulator circ) {
  Ccb_halfedge_const_circulator curr = circ;
  std::cout << "(" << curr->source()->point() << ")";
  do {
    typename Arrangement::Halfedge_const_handle he = curr->handle();
    std::cout << " [" << e->curve() << "] "
              << "(" << e->target()->point() << ")";
  } while (++curr != circ);
  std::cout << std::endl;
}
2.3.3 遍历Arrangement Face

一个Arrangement_2对象arr始终有一个unbounded face,通过arr.unbounded_face()可以拿到,空的Arrangement_2也有一个unbounded face。

通过f->is_unboudned()可以确定一个face是否有边界,有边界的face有一个outer CCB。

下面是遍历face的代码段:

cpp 复制代码
template <typename Arrangement>
void print_face(typename Arrangement::Face_const_handle f) {
  // Print the outer boundary.
  if (f->is_unbounded()) std::cout << "Unbounded face.\n";
  else {
    std::cout << "Outer boundary: ";
    print_ccb(f->outer_ccb());
  }
  // Print the boundary of each of the holes.
  size_t index = 1;
  for (auto hi = f->holes_begin(); hi != f->holes_end(); ++hi) {
    std::cout << " Hole #" << index++ << ": ";
    print_ccb(*hi);
  }
  // Print the isolated vertices.
  index = 1;
  for (auto iv = f->isolated_vertices_begin();
       iv != f->isolated_vertices_end(); ++iv)
  {
    std::cout << " Isolated vertex #" << index++ << ": "
              << "(" << iv->point() << ")\n";
  }
}

遍历整个Arrangement的代码段如下:

cpp 复制代码
void print_arrangement (const Arrangement_2& arr) {
  // Print the arrangement vertices.
  std::cout << arr.number_of_vertices() << " vertices:\n";
  for (auto vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) {
    std::cout << "(" << vit->point() << ")";
    if (vit->is_isolated()) std::cout << " - Isolated.\n";
    else std::cout << " - degree " << vit->degree() << std::endl;
  }
  // Print the arrangement edges.
  std::cout << arr.number_of_edges() << " edges:\n";
  for (auto eit = arr.edges_begin(); eit != arr.edges_end(); ++eit)
    std::cout << "[" << eit->curve() << "]\n";
  // Print the arrangement faces.
  std::cout << arr.number_of_faces() << " faces:\n";
  for (auto fit = arr.faces_begin(); fit != arr.faces_end(); ++fit)
    print_face(fit);
}
2.4修改Arrangement
2.5插入一对不相连的x_Monotone Curves
相关推荐
C++ 老炮儿的技术栈6 分钟前
UDP 与 TCP 的区别是什么?
开发语言·c++·windows·算法·visual studio
wgslucky12 分钟前
Dubbo报错:module java.base does not “opens java.lang“ to unnamed module
java·开发语言·dubbo
whyeekkk34 分钟前
python打卡第48天
开发语言·python
DougLiang2 小时前
关于easyexcel动态下拉选问题处理
java·开发语言
mochensage2 小时前
CSP信奥赛C++常用系统函数汇总
c++·信奥
mochensage2 小时前
C++信息学竞赛中常用函数的一般用法
java·c++·算法
fpcc2 小时前
跟我学c++中级篇——多线程中的文件处理
c++
全职计算机毕业设计2 小时前
基于Java Web的校园失物招领平台设计与实现
java·开发语言·前端
5:003 小时前
云备份项目
linux·开发语言·c++
笨笨马甲3 小时前
Qt Quick模块功能及架构
开发语言·qt