mirror of https://github.com/CGAL/cgal
Surface_mesh: Fix collect_garbage in case mesh is not valid
This commit is contained in:
parent
23e624b0e8
commit
4176a2a551
|
|
@ -2680,8 +2680,12 @@ collect_garbage(Visitor &visitor)
|
||||||
for (i=0; i<nH; ++i)
|
for (i=0; i<nH; ++i)
|
||||||
{
|
{
|
||||||
h = Halfedge_index(i);
|
h = Halfedge_index(i);
|
||||||
|
if(target(h) != null_vertex()){
|
||||||
set_target(h, vmap[target(h)]);
|
set_target(h, vmap[target(h)]);
|
||||||
|
}
|
||||||
|
if(next(h) != null_halfedge()){
|
||||||
set_next(h, hmap[next(h)]);
|
set_next(h, hmap[next(h)]);
|
||||||
|
}
|
||||||
if (!is_border(h))
|
if (!is_border(h))
|
||||||
set_face(h, fmap[face(h)]);
|
set_face(h, fmap[face(h)]);
|
||||||
}
|
}
|
||||||
|
|
@ -2691,6 +2695,7 @@ collect_garbage(Visitor &visitor)
|
||||||
for (i=0; i<nF; ++i)
|
for (i=0; i<nF; ++i)
|
||||||
{
|
{
|
||||||
f = Face_index(i);
|
f = Face_index(i);
|
||||||
|
if( halfedge(f) != null_halfedge())
|
||||||
set_halfedge(f, hmap[halfedge(f)]);
|
set_halfedge(f, hmap[halfedge(f)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include <CGAL/Surface_mesh/Surface_mesh.h>
|
||||||
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
CGAL::Surface_mesh<CGAL::Epick::Point_3> mesh;
|
||||||
|
auto f0 = mesh.add_face();
|
||||||
|
auto f1 = mesh.add_face(); // If this line is commented out, it will not crash.
|
||||||
|
mesh.remove_face(f0);
|
||||||
|
|
||||||
|
auto v0 = mesh.add_vertex();
|
||||||
|
auto v1 = mesh.add_vertex(); // If this line is commented out, it will not crash.
|
||||||
|
mesh.remove_vertex(v0);
|
||||||
|
|
||||||
|
auto e0 = mesh.add_edge();
|
||||||
|
auto e1 = mesh.add_edge(); // If this line is commented out, it will not crash.
|
||||||
|
mesh.remove_edge(edge(e0,mesh));
|
||||||
|
|
||||||
|
|
||||||
|
mesh.collect_garbage();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue