Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation
Chronological Thread
- From: Josip Dzolonga <>
- To:
- Subject: Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation
- Date: Sun, 8 Nov 2009 14:48:03 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=ayFmDSwK3UYBDig1sGJ/mdFHBCEYvZN8W3Q7pnxXN0pI6etIj0u+stReMPqeWPa/PJ +H6xL/q88xfnsznKO/xbc3XRIp/wJ8n9oHgkyaa4rp9g0Uud9ipY/JPyRlBdcxpgWcoM H8HdOGGbPXgAdifGCM2/AfTQyP4gDr0W9+Ae4=
Thank you very much. That solved that problem (i.e. no errors, T.is_valid() succeeds), but something weird is going on again. This is the new version of the problematic code
std::set<Vertex_handle> toRemove;
for(std::list<Facet>::iterator iter = grown->facets->begin();
iter != grown->facets->end(); ++iter) {
Cell_handle c = (*iter).first;
int index = (*iter).second;
toRemove.insert(c->vertex((index+1)%4));
toRemove.insert(c->vertex((index+2)%4));
toRemove.insert(c->vertex((index+3)%4));
}
T.remove(toRemove.begin(), toRemove.end());
assert(T.is_valid());
std::cout << "Total of " << toRemove.size() << " vertices removed\n";
Later on when I use the new version of the triangulation, I get the following error
CGAL error: assertion violation!
Expr: v == V[3]
File: /usr/include/CGAL/Triangulation_ds_cell_base_3.h
Line: 98
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
Any ideas why can this happen? If there are some CGAL examples doing similar work, please point me to them.
Thank you in advance,
Josip Djolonga
On Fri, Nov 6, 2009 at 8:01 PM, Nico Kruithof <> wrote:
A vertex is incident to multiple facets. So you add the same vertex several times to the list and then try to remove it several times. Try iterating over the (finite) vertices or use an std::map to get a list containing a single copy of each vertex.-- NicoOn Fri, Nov 6, 2009 at 4:32 PM, Josip Dzolonga <> wrote:
It might be that the answer is obvious, but since I have very limited experience with CGAL I can not see a direct way of doing this. The following does not work by the same reasons I suspectstd::list<Vertex_handle> toRemove;for(std::list<Facet>::iterator iter = grown->facets->begin();iter != grown->facets->end(); ++iter) {Cell_handle c = (*iter).first;int index = (*iter).second;toRemove.push_back(c->vertex((index+1)%4));toRemove.push_back(c->vertex((index+2)%4));toRemove.push_back(c->vertex((index+3)%4));}T.remove(toRemove.begin(), toRemove.end());Thanks,JosipOn Fri, Nov 6, 2009 at 4:21 PM, Sylvain Pion <> wrote:
When you remove() the first vertex, then the Cell c becomes invalid.Josip Dzolonga wrote:
Here is the problematic code:
for(std::list<Facet>::iterator iter = grown->facets->begin();
iter != grown->facets->end(); ++iter) {
Cell_handle c = (*iter).first;
int index = (*iter).second;
T.remove(c->vertex((index+1)%4));
T.remove(c->vertex((index+2)%4));
T.remove(c->vertex((index+3)%4));
}
Basically, I have a set of facets that I have extracted from the triangulation and I want to remove them along with their points. But, the T.remove lines cause segmentation faults, where T is of type CGAL::Triangulation_hierarchy_3<Dt>. I get no precondition errors, just a segfault.
Then, everything can happen. You need to memorize the Vertex_handles
first, and then remove them without refering to Cells or Facets that
may become invalid.
--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
- [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation, Josip Dzolonga, 11/06/2009
- Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation, Sylvain Pion, 11/06/2009
- Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation, Josip Dzolonga, 11/06/2009
- Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation, Nico Kruithof, 11/06/2009
- Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation, Josip Dzolonga, 11/08/2009
- Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation, Nico Kruithof, 11/06/2009
- Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation, Josip Dzolonga, 11/06/2009
- Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation, Sylvain Pion, 11/06/2009
Archive powered by MHonArc 2.6.16.