Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation


Chronological Thread 
  • From: Nico Kruithof <>
  • To:
  • Subject: Re: [cgal-discuss] Segmentation fault when removing vertices from a Delaunay triangulation
  • Date: Fri, 6 Nov 2009 20:01:54 +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=AR5xq9C7ks8d+GUGItniwfF2KddZTWjnpmr4YKAYe9gCCCRmYQOL8i4wohxqbqbodk OR8RzEZeHPZ/D3rk1beg5AiliqA9DXMx0t9ldUbgOWJrNORl9eXRcU7JJEpUlytYX6uP DLug32ICzykcssoWrM4zlIymJUW6f1GuSkEVg=

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.

-- Nico

On 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 suspect

std::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,
Josip

On Fri, Nov 6, 2009 at 4:21 PM, Sylvain Pion <> wrote:
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.

When you remove() the first vertex, then the Cell c becomes invalid.
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






Archive powered by MHonArc 2.6.16.

Top of Page