CGAL POLYHEDRON_3 FLIP_EDDED功能断开表面

CGAL Polyhedron_3 flip_edge function breaks surface

本文关键字:功能 断开 EDDED 表面 FLIP POLYHEDRON CGAL      更新时间:2023-10-16

我使用polyhedron_3作为表面。我扭曲了表面并确保质量我想翻转边缘以避免三角形。到目前为止,我的代码看起来像:

std::vector<std::pair<PlaneMeshAPI::Polyhedron::Halfedge_handle, double> > vEdgeToFlip;
for (PlaneMeshAPI::Polyhedron::Edge_iterator e = P.edges_begin(); e != P.edges_end(); ++e)
{
    // Edge_iterator so that we consider only one of the 2 possible halfedges
    bool bFlippable = true;
    if (e->is_border_edge()) bFlippable = false;
    if (bFlippable && e->facet()->marked() == -1) bFlippable = false;
    if (bFlippable && e->facet()->marked() != e->opposite()->facet()->marked()) bFlippable = false;
    // Marked() returns an int, I want to flip edges between two triangles of the same component
    if (bFlippable)
    {
        PlaneMeshAPI::Polyhedron::Facet_iterator f1, f2;
        PlaneMeshAPI::Polyhedron::Halfedge_handle heh = e;
        double lowestBef = lowestAngle(e->facet(), e->opposite()->facet()); // returns the lowest angle of the two adjacent triangles
        vEdgeToFlip.push_back(std::make_pair(e, lowestBef));
    }
}
for (int i = 0; i < vEdgeToFlip.size(); ++i)
{
    PlaneMeshAPI::Polyhedron::Halfedge_handle e = vEdgeToFlip[i].first;
    e = P.flip_edge(e);
    double lowestNow = lowestAngle(e->facet(), e->opposite()->facet());
    if (lowestNow < vEdgeToFlip[i].second)
        P.flip_edge(e);
}

代码运行正常,但是当我运行P.is_valid(true)时,我有此错误消息:

halfedge 7504 previous pointer integrity corrupted. summe border halfedges (2*nb) = 0 end of CGAL::HalfedgeDS_const_decorator<HDS>::is_valid(): structure is NOT VALID . counting halfedges failed. end of CGAL::Polyhedron_3<...>::is_valid(): structure is NOT VALID.

flip_edge上的文档非常稀缺。我不知道我是否需要翻转两个半身,是否会在迭代器中打破某些东西(因此,一旦我翻转了,所有其他人都无法翻转)。

我们终于找到了为什么边缘翻转导致表面破裂。在翻转Facet e = P.flip_edge(e);之前,您必须确保它不会创建奇异性:

   // Do not flip if this would create two triangle with the same vertices
    if (e->next()->opposite()->next()->opposite() == e->opposite()->next()->next()) continue;
    if (e->opposite()->next()->opposite()->next()->opposite() == e->next()->next()) continue;
    // Do not flip if it would create an edge linking a vertex with itself
    if (e->next()->vertex() == e->opposite()->next()->vertex()) continue;