CGAL的资料尤其是中文资料少之又少,现根据自己要完成的工作进行一个记录和总结,也希望能填补资料的空缺。
在CGAL中,使用半边结构Halfedge Data Structure来存储网格信息,另外一个类似于CGAL的库OpenMesh同样使用的是这种半边结构。
关于半边结构,请点这里:http://www.flipcode.com/archives/The_Half-Edge_Data_Structure.shtml
CGAL内部通过三层结构(Polyhedron Layer、Halfedge data structure Layer、Items Layer)实现半边结构,如图所示:
Polyehdron Layer 提供了易用的借口,我们可以通过Halfedge_Handle 、 Facet_Handle、 Vertex_Handle及对应的迭代器Iterator来进行访问、遍历及更新数据。同时也可以通过一些简单的成员函数进行欧拉操作(Euler Operations)等。
Items Layer 负责存储底层的数据,包括顶点Vertex、Halfedge、Face的信息。
中间层Halfedge_data_structure Layer负责组织和管理Items Layer的信息,内部使用双向链表(bidirectional list)或者容器(vector)来实现。
在CGAL的Include目录里有一个undocumented头文件:triangulate_polyhedron.h,顾名思义这个头文件的作用是对多面体进行三角化的。
通过这个库文件引用的头文件可以看得出CGAL是通过Triangulation_2_filtered_projection_traits_3.h将三维坐标点映射到二维平面上,再通过Constrained_Delaunay_triangulation_2.h对其进行三角化,随后通过HalfedgeDS_decorator.h对原多面体进行三角化。
我将此库文件进行重新注释解读如下:
// Copyright (c) 2010-2011 GeometryFactory Sarl (France). // All rights reserved. // // This file is part of CGAL (www.cgal.org). // You can redistribute it and/or modify it under the terms of the GNU // General Public License as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // // // Author(s) : Laurent Rineau #ifndef CGAL_TRIANGULATE_POLYHEDRON_H #include <CGAL/Modifier_base.h> #include <CGAL/HalfedgeDS_decorator.h> #include <CGAL/Triangulation_vertex_base_with_info_2.h> #include <CGAL/Triangulation_face_base_with_info_2.h> #include <CGAL/Co