CGAL中Polyhedron_3中与半边结构有关的具体使用

来源:互联网 发布:mac如何安装f6驱动 编辑:程序博客网 时间:2024/05/17 08:21

CGALPolyhedron_3中与半边结构有关的具体使用

 

半边结构可以根据点,半边,面中的任一个来得到另外两个。在我的使用过程中,我觉得半边是联系的纽带。CGAL中有些不方便的是不能用面来直接得到绕面的所有顶点,或者不能根据点来得到一绕该点的一邻域的所有点,这个经常性的操作有时会带来一些不方便。

在使用的过程中,你可以通过使用Source insight 等查看源代码的软件来看其具体包含的函数及使用方法。

<!--[if !supportLists]-->1.<!--[endif]-->据半边来得到顶点。

Halfedge_handle he;

Vertex_handle vh = he->vertex();

2.根据顶点得到其三维坐标 

Point p = v->point();

可查看Point.h看其成员及成员函数,若需转换其成其它形式如CVector3d,可用

Cvector3d point = Cvector3d(v->point().x(),v->point().y(),v->point().z());

<!--[if !supportLists]-->3.     <!--[endif]-->据半边得到面。

Facet_handle f = he->facet();

<!--[if !supportLists]-->4.     <!--[endif]-->据顶点得到半边

Vertex_handle v;

Halfedge_handle he = v->halfedge();

<!--[if !supportLists]-->5.     <!--[endif]-->据顶点得到面

因为没有直接通过顶点得到面的函数,所以先用半边来查找

Halfedge_around_vertex_circulator he = v->vertex_begin();

Facet_handle f = he->facet();

根据上图也可以得到,此面即为与此顶点相关联的面.

<!--[if !supportLists]-->6.     <!--[endif]-->据面得到顶点。

同样地,没有通过面直接得到顶点的函数,则利用半边来实现。

Halfedge_around_facet_circulator he = f->facet_begin();

Vertex_handle v = he->vertex();

需要注意的是,这里并没有说明其遍历的顺序。这里有个不清楚的是,因为一个面相关联的Halfedge有好几个,所以每次遍历的结果有可能不相同。

<!--[if !supportLists]-->7.     <!--[endif]-->据面得到半边

Halfedge_around_facet_circulator he = f->facet_begin();

<!--[if !supportLists]-->8.     <!--[endif]-->据一顶点点得到一邻域的顶点

这也是通过半边来实现的。先得到绕这个点的半边。而这个半边根据上面的图是指向该点的,因此,我们得用该半边的另一半来得到其所指的另一个顶点。

Halfedge_around_vertex_circulator he = v->vertex_begin();

Haledge_handle he_begin = he;

Vertex_handle v;

do{

     v = he->opposite()->vertex();

}while(++he != he_begin);

 

 

 

原创粉丝点击