PiRSquared17 / poly2tri

Automatically exported from code.google.com/p/poly2tri
Other
0 stars 0 forks source link

Stack overflow on large mesh, SweepContext::MeshClean to blame #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Use broad-first search, smth. like this

void SweepContext::MeshClean(Triangle& triangle)
{
    if (&triangle==NULL) return;
    if (triangle.IsInterior()) return;

    std::deque<Triangle*> deque;
    deque.push_back(&triangle);
    triangle.IsInterior(true);

    while (!deque.empty())
    {
        Triangle &tri = *deque.front();
        deque.pop_front();
        triangles_.push_back(&tri);
        for (int i=0; i<3; ++i)
            if (!tri.constrained_edge[i]) {
                Triangle *tri2 = tri.GetNeighbor(i);
                if (tri2!=NULL && !tri2->IsInterior()) {
                    tri2->IsInterior(true);
                    deque.push_back(tri2);
                }
            }
    }
}

Original issue reported on code.google.com by merc2012...@gmail.com on 31 Jul 2012 at 12:29

GoogleCodeExporter commented 9 years ago

Original comment by mason.gr...@gmail.com on 2 May 2013 at 1:27