为啥add_face会失败?

我正在使用CGAL实现一个三角网格细分的功能。
我删除了三角网格中的一个单元格,然后对每条边进行中点分割,从而把一个单元格划分成4个小三角形。
我先删除原来的大三角形,再插入4个新创建的小三角形。
我发现只能插入中间的小三角形,其余的都是null_face()。
我尝试过调整新的面片的顶点序,但是发现无济于事,请问该咋解决?

CGAL
Surface_mesh

阅读 1.5k
1 个回答
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>

typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef Mesh::Vertex_index vertex_descriptor;
typedef Mesh::Face_index face_descriptor;

int main()
{
    Mesh m;
    // Add the points as vertices
    vertex_descriptor u = m.add_vertex(K::Point_3(0,1,0));
    vertex_descriptor v = m.add_vertex(K::Point_3(0,0,0));
    vertex_descriptor w = m.add_vertex(K::Point_3(1,1,0));
    vertex_descriptor x = m.add_vertex(K::Point_3(1,0,0));
    m.add_face(u,v,w);
    face_descriptor f = m.add_face(u,v,x);

    if(f == Mesh::null_face())
    {
        std::cerr<<"The face could not be added because of an orientation error."<<std::endl;
        f = m.add_face(u,x,v);
        assert(f != Mesh::null_face());
    }
    return 0;
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题