CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.93k stars 1.38k forks source link

Segmentation fault in Polyhedron_3::split_edge #1188

Closed agodde closed 8 years ago

agodde commented 8 years ago

In the example Polyhedron/polyhedron_prog_cube.cpp: Using the halfedge data structure HalfedgeDS_vector instead of HalfedgeDS_default for the Polyhedron_3 type results in a segmentation fault in a call to the function split_edge(Halfedge_handle h).

The attached gist contains the example with a simple change of line 32 from

typedef CGAL::Polyhedron_3 Polyhedron;

to

typedef CGAL::Polyhedron_3CGAL::Polyhedron_traits_3<Kernel, CGAL::Polyhedron_items_3, CGAL::HalfedgeDS_vector> Polyhedron;

(plus the include for HalfedgeDS_vector.h)

polyhedron_prob_cube.cpp with HaldedgeDS_Vector

sloriot commented 8 years ago

From here : The capacity is restricted to the reserved size. Allocations are not possible beyond the capacity without calling reserve again. All handles and iterators are invalidated upon a reserve call that increases the capacity.

sloriot commented 8 years ago

Calling P.reserve(22,22,22); fixes the segfault. (22 is arbitrary here and need to be set accordingly)

agodde commented 8 years ago

Shouldn't this be mentioned in the documentation of Polyhedron_3 since it changes how one can use the Euler split operations?

sloriot commented 8 years ago

Well, IMO it's more a property of HalfedgeDS_vector that is used as implementation for Polyhedron_3 (which is just a wrapper around it). I tend to think that if one picks up a non default parameter, he should refer to the doc of that parameter. BTW I observe an issue in is_valid() so there must be another issue.

agodde commented 8 years ago

What issue in is_valid() are you talking about? The CGAL_precondition(P.is_valid()) macro succeeds for me.