Skip to content
Snippets Groups Projects
Commit 46f1a33f authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

make remove() routines safe
parent d9317e79
Branches
Tags
No related merge requests found
// $Id: GModel.cpp,v 1.43 2007-08-03 14:57:09 geuzaine Exp $
// $Id: GModel.cpp,v 1.44 2007-08-06 19:52:00 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -91,6 +91,30 @@ GVertex * GModel::vertexByTag(int n) const
return 0;
}
void GModel::remove(GRegion *r)
{
riter it = std::find(firstRegion(), lastRegion(), r);
if(it != regions.end()) regions.erase(it);
}
void GModel::remove(GFace *f)
{
fiter it = std::find(firstFace(), lastFace(), f);
if(it != faces.end()) faces.erase(it);
}
void GModel::remove(GEdge *e)
{
eiter it = std::find(firstEdge(), lastEdge(), e);
if(it != edges.end()) edges.erase(it);
}
void GModel::remove(GVertex *v)
{
viter it = std::find(firstVertex(), lastVertex(), v);
if(it != vertices.end()) vertices.erase(it);
}
template <class T>
static void removeInvisible(std::vector<T*> &elements, bool all)
{
......
......@@ -95,10 +95,10 @@ class GModel
void add(GEdge *e) { edges.insert(e); }
void add(GVertex *v) { vertices.insert(v); }
void remove(GRegion *r) { regions.erase(std::find(firstRegion(), lastRegion(), r)); }
void remove(GFace *f) { faces.erase(std::find(firstFace(), lastFace(), f)); }
void remove(GEdge *e) { edges.erase(std::find(firstEdge(), lastEdge(), e)); }
void remove(GVertex *v) { vertices.erase(std::find(firstVertex(), lastVertex(), v)); }
void remove(GRegion *r);
void remove(GFace *f);
void remove(GEdge *e);
void remove(GVertex *v);
// loop over all vertices connected to elements and associate geo entity
void associateEntityWithVertices();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment