CGAL中的三种Decorator摘要

CGAL半边数据结构中有三个Decorator类:CGAL::HalfedgeDS_items_decorator<HDS>,CGAL::HalfedgeDS_decorator<HDS>,CGAL::HalfedgeDS_const_decorator<HDS>,这三个Decorator类主要提供对半边数据结构进行检测和修改的功能。其中CGAL::HalfedgeDS_decorator<HDS>,CGAL::HalfedgeDS_const_decorator<HDS>都是CGAL::HalfedgeDS_items_decorator<HDS>的子类。

1 CGAL::HalfedgeDS_const_decorator<HDS>

头文件:#include <CGAL/HalfedgeDS_const_decorator.h>

1.1 创建

CGAL::HalfedgeDS_const_decorator<HDS> D(const HDS & hds);

1.2 有效性检测

半边数据结构本身并未定义有效性,但定义了几个不同级别的有效性测试集。详见手册。

提供了两个检测有效性的函数:

bool D.is_valid(bool verbose = false, int level = 0) const

当半边数据结构hds有效时返回真(根据level进行相应级别的测试)。若verbose为真,统计数据将写到cerr中。

bool D.normalized_border_is_valid(bool verbose = false) const

若半边以规范化的方式表示则返回真。规范化表示是指在枚举半边时,非border边在border边前面,对于border边,第二个半边是border半边(第一个也有可能是)。

2 CGAL::HalfedgeDS_decorator<HDS>

2.1 创建

HalfedgeDS_decorator<HDS> D( HDS& hds);

2.2 新items的创建

Vertex_handle D.vertices_push_back( Vertex v)

向hds中添加顶点v的拷贝。返回新顶点的handle。

Face_handle D.faces_push_back( Face f)

添加面f的拷贝,返回新面的handle。

2.3 复合items的创建

Halfedge_handle D.create_loop()

在hds中创建一个loop,该loop包含一条闭合的边,一个顶点和两个面(圈儿里圈儿外),返回一个半边的handle

Halfedge_handle D.create_segment()

在hds中创建一条线段,包含一条开放的边,两个顶点和一个面

2.4 元素的删除

若未提及,下列操作并不更新受影响的关联关系。

void D.vertices_pop_front()

删除第一个顶点

void D.vertices_pop_back()

删除最后一个顶点

void D.vertices_erase( Vertex_handle v)

删除顶点v

void D.vertices_erase( Vertex_handle first, Vertex_handle last)

删除[first,last)之间的顶点

同样,对于面,有:

void D.faces_pop_front()

void D.faces_pop_back()

void D.faces_erase( Face_handle f)

void D.faces_erase( Face_handle first, Face_handle last)

另外面还多一个操作:

void D.erase_face( Halfedge handle h)

删掉半边h关联的面,并把这个面关联的所有半边都变成border边,若这些半边已经是border边,则删掉。若该操作产生了孤立顶点,也一块儿删掉。

void D.erase_connected_component( Halfedge_handle h)

删掉h所连通的component的所有元素。

unsigned int D.keep_largest_connected_components( unsigned int nb_components_to_keep)

保留nb_components_to_keep个最大的component,其余的删掉。

2.5 修改函数(for border edges)

void D.make_hole( Halfedge_handle h)

删掉h关联的面,创建一个洞

Halfedge handle D.fill_hole( Halfedge_handle h)

使用hds中的一个面填充h关联的洞

Halfedge handle D.fill_hole( Halfedge_handle h, Face f)

使用面f的拷贝填充h关联的洞

Halfedge_handle D.add_face_to_border( Halfedge_handle h, Halfedge_handle g)

用hds中的一个新面填充h和g关联的半边。首先创建一个连接h和g所关联的顶点的边,然后用一个新面填充洞中的独立部分,使得新面与g关联。返回创建的边中与面关联的半边。

Halfedge_handle D.add_face_to_border( Halfedge_handle h, Halfedge_handle g, Face f)

使用面f的拷贝填充与h和g关联的洞。

2.6 其他

D.inside_out()

反转面的方向。

3 CGAL::HalfedgeDS_items_decorator<HDS>

3.1 创建

HalfedgeDS_items_decorator<HDS> D;

3.2 访问函数

Halfedge handle D.get_vertex_halfedge( Vertex_handle v)

若支持顶点与半边的关联,则返回与v关联的半边,否则返回Halfedge_handle()

Vertex_handle D.get_vertex( Halfedge_handle h)

返回h关联的顶点handle

Halfedge_handle D.get_prev( Halfedge_handle h)

若支持反向遍历,则返回h的上一条半边,否则返回Halfedge_handle()

Halfedge_handle D.find_prev( Halfedge_handle h)

返回h的上一条半边。若支持反向遍历,则调用prev方法,否则通过正向遍历实现。

Halfedge_handle D.find_prev_around_vertex( Halfedge_handle h)

Face_handle D.get_face( Halfedge_handle h)

返回h关联的面。

Halfedge_handle D.get_face_halfedge( Face_handle f)

若支持面与半边之间的关联,则返回f关联的半边,否则返回Halfedge_handle()

3.3 修改函数(复合类)

void D.close_tip( Halfedge_handle h) const

使h->opposite()成为h的后继

void D.close_tip( Halfedge_handle h, Vertex_handle v) const

使h->opposite()成为h的后继,并使v成为h关联的顶点

void D.insert_tip( Halfedge_handle h, Halfedge_handle v) const

使h成为v指向的顶点的一环半边。h->opposite()是v的新后继半边,h->next()设置为v->next()。h关联的顶点设置为v关联的顶点。如下图。

insert_tip

void D.remove_tip( Halfedge_handle h) const

从h关联的顶点v的一环半边中移除h->next()->opposite()。h的新后继半边是原来的h->next()->opposite()->next()。如下图。

remove_tip

void D.insert_halfedge( Halfedge_handle h, Halfedge_handle f) const

在半边f和f->next()之间插入半边h,h关联的面设置为f关联的面

void D.remove_halfedge( Halfedge_handle h) const

删掉h->next(),h的新后继为h->next()->next()

void D.set_vertex_in_vertex_loop( Halfedge_handle h, Vertex_handle v) const

貌似。。是让h关联的顶点的所有一环半边关联的顶点都指向顶点v。

void D.set_face_in_face_loop( Halfedge_handle h, Face_handle f) const

使h关联的面的所有绕面半边关联的面都为f。

Halfedge_handle D.flip_edge( Halfedge_handle h) const

执行一次绕面正向边翻转。

3.4 修改函数(基元)

void D.set_vertex_halfedge( Vertex_handle v, Halfedge_handle g) const

把v关联的半边设置为g。

void D.set_vertex_halfedge( Halfedge_handle h) const

把h关联的顶点所关联的半边设置为h。

void D.set_vertex( Halfedge_handle h, Vertex_handle v) const

把h关联的顶点设置为v。

void D.set_prev( Halfedge_handle h, Halfedge_handle g) const

设置h的前一半边为g。

void D.set_face( Halfedge_handle h, Face_handle f) const

设置h关联的面为f。

void D.set_face_halfedge( Face_handle f, Halfedge_handle g) const

设置f关联的半边为g。

void D.set_face_halfedge( Halfedge_handle h) const

设置h关联的面所关联的半边为h。

4 其他半边数据结构修改功能

HalfedgeDS<Traits,Items,Alloc>本身有插入删除元素的成员函数。

此外,HalfedgeDSVertex、HalfedgeDSHalfedge和HalfedgeDSFace三个类也有各自的半边数据结构修改函数。

HalfedgeDSVertex:

void v.set_halfedge( Halfedge_handle h)

HalfedgeDSHalfedge:

void h.set_opposite( Halfedge_handle h)

void h.set_next( Halfedge_handle h)

void h.set_prev( Halfedge_handle h)

void h.set_vertex( Vertex_handle v)

void h.set_face( Face_handle f)

HalfedgeDSFace:

void f .set_halfedge( Halfedge_handle h)

posted on 2012-08-13 19:36  youthlion  阅读(1433)  评论(0编辑  收藏  举报

导航