gpt4 book ai didi

c++ - CGAL Polyhedron_3 flip_edge 函数打破表面

转载 作者:行者123 更新时间:2023-11-28 06:16:52 36 4
gpt4 key购买 nike

我使用 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 的文档相当稀缺。我不知道我是否需要翻转两个半边,如果它破坏了迭代器中的某些东西(这样一旦我翻转了一个,所有其他的都不能翻转)。

最佳答案

我们终于找到了边缘翻转导致表面破裂的原因。在翻转面 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;

关于c++ - CGAL Polyhedron_3 flip_edge 函数打破表面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30105882/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com