使用 GTS 的约束 Delaunay 三角剖分中的断言失败
当使用 GNU 三角曲面库进行约束 Delaunay 三角剖分时,我遇到一些间歇性断言失败。我在不同时间看到过以下内容:
Gts:ERROR:cdt.c:974:remove_intersected_vertex: code should not bereached Gts:ERROR:cdt.c:896:remove_intersected_edge:断言失败:(下一个) Gts:ERROR:cdt.c:887:remove_intersected_edge: 断言失败: (o2 == 0.)
我查看了 cdt.c 但我所能弄清楚的是它们来自对 gts_delaunay_add_constraint 的调用。
有人可以解释一下约束可能存在什么问题,这会导致这些断言失败吗?
当我尝试对一组随机顶点进行三角测量时,会发生断言失败。不幸的是,这种情况只发生在大量顶点和约束的情况下,因此很难找出失败输入的模式。即使输入错误,使用 GTS 的代码也不会崩溃,因此最好能够防止这些断言失败,否则我将不得不禁用断言。
编辑:尝试删除所有相交约束(存储在边缘
中):
int numPossEdges = gts_fifo_size(edges);
GtsEdge **possEdges = malloc(numPossEdges * sizeof(GtsEdge *));
for (int i = 0; i < numPossEdges; ++i)
possEdges[i] = gts_fifo_pop(edges);
for (int i = 0; i < numPossEdges; ++i)
for (int j = 0; j < i && possEdges[i] != NULL; ++j)
if (possEdges[j] != NULL && GTS_IN == gts_segments_are_intersecting(&(possEdges[i]->segment), &(possEdges[j]->segment)))
possEdges[i] = NULL;
for (int i = 0; i < numPossEdges; ++i)
if (possEdges[i] != NULL)
gts_fifo_push(edges, possEdges[i]);
仍然遇到相同的断言失败。
I'm getting some intermittent assertion failures when doing constrained Delaunay trianguation with the GNU Triangulated Surface Library. I've seen each of the following at different times:
Gts:ERROR:cdt.c:974:remove_intersected_vertex: code should not be reached
Gts:ERROR:cdt.c:896:remove_intersected_edge: assertion failed: (next)
Gts:ERROR:cdt.c:887:remove_intersected_edge: assertion failed: (o2 == 0.)
I've looked at cdt.c but all I've been able to figure out is that they're coming from calls to gts_delaunay_add_constraint.
Could someone explain what might be the problem with the constraints, that would cause these assertions to fail?
The assertion failures are happening when I try to do triangulation on a set of random vertices. It only happens, unfortunately, for large numbers of vertices and constraints, so it's hard to figure out a pattern for the failing inputs. The code that's using GTS needs to not crash even for bad input, so it would be nice to prevent these assertion failures, otherwise I'll have to disable the assertions.
Edit: Tried removing all intersecting constraints (stored in edges
):
int numPossEdges = gts_fifo_size(edges);
GtsEdge **possEdges = malloc(numPossEdges * sizeof(GtsEdge *));
for (int i = 0; i < numPossEdges; ++i)
possEdges[i] = gts_fifo_pop(edges);
for (int i = 0; i < numPossEdges; ++i)
for (int j = 0; j < i && possEdges[i] != NULL; ++j)
if (possEdges[j] != NULL && GTS_IN == gts_segments_are_intersecting(&(possEdges[i]->segment), &(possEdges[j]->segment)))
possEdges[i] = NULL;
for (int i = 0; i < numPossEdges; ++i)
if (possEdges[i] != NULL)
gts_fifo_push(edges, possEdges[i]);
Still getting the same assertion failures.
如果您完全随机地创建顶点和约束,我想您可能会提供彼此相交的约束边。在这种情况下,我肯定会期望三角测量例程会抱怨。
If you're creating vertices and constraints completely randomly, I imagine you might be supplying constraint edges that intersect each other. In which case I would certainly expect the triangulation routines to complain.