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

fix crash when duplicate entries in tree

parent 8319ea41
No related branches found
No related tags found
No related merge requests found
...@@ -471,6 +471,7 @@ static void _add_vertex(GVertex *gv, Fl_Tree *tree, std::string path) ...@@ -471,6 +471,7 @@ static void _add_vertex(GVertex *gv, Fl_Tree *tree, std::string path)
std::ostringstream vertex; std::ostringstream vertex;
vertex << path << "Point " << gv->tag() << "/"; vertex << path << "Point " << gv->tag() << "/";
Fl_Tree_Item *n = tree->add(vertex.str().c_str()); Fl_Tree_Item *n = tree->add(vertex.str().c_str());
if(!n) return;
if(gv->getVisibility()) n->select(1); if(gv->getVisibility()) n->select(1);
n->user_data((void*)gv); n->user_data((void*)gv);
n->close(); n->close();
...@@ -481,6 +482,7 @@ static void _add_edge(GEdge *ge, Fl_Tree *tree, std::string path) ...@@ -481,6 +482,7 @@ static void _add_edge(GEdge *ge, Fl_Tree *tree, std::string path)
std::ostringstream edge; std::ostringstream edge;
edge << path << "Line " << ge->tag() << "/"; edge << path << "Line " << ge->tag() << "/";
Fl_Tree_Item *n = tree->add(edge.str().c_str()); Fl_Tree_Item *n = tree->add(edge.str().c_str());
if(!n) return;
if(ge->getVisibility()) n->select(1); if(ge->getVisibility()) n->select(1);
n->user_data((void*)ge); n->user_data((void*)ge);
n->close(); n->close();
...@@ -495,6 +497,7 @@ static void _add_face(GFace *gf, Fl_Tree *tree, std::string path) ...@@ -495,6 +497,7 @@ static void _add_face(GFace *gf, Fl_Tree *tree, std::string path)
std::ostringstream face; std::ostringstream face;
face << path << "Surface " << gf->tag() << "/"; face << path << "Surface " << gf->tag() << "/";
Fl_Tree_Item *n = tree->add(face.str().c_str()); Fl_Tree_Item *n = tree->add(face.str().c_str());
if(!n) return;
if(gf->getVisibility()) n->select(1); if(gf->getVisibility()) n->select(1);
n->user_data((void*)gf); n->user_data((void*)gf);
n->close(); n->close();
...@@ -508,6 +511,7 @@ static void _add_region(GRegion *gr, Fl_Tree *tree, std::string path) ...@@ -508,6 +511,7 @@ static void _add_region(GRegion *gr, Fl_Tree *tree, std::string path)
std::ostringstream region; std::ostringstream region;
region << path << "Volume " << gr->tag() << "/"; region << path << "Volume " << gr->tag() << "/";
Fl_Tree_Item *n = tree->add(region.str().c_str()); Fl_Tree_Item *n = tree->add(region.str().c_str());
if(!n) return;
if(gr->getVisibility()) n->select(1); if(gr->getVisibility()) n->select(1);
n->user_data((void*)gr); n->user_data((void*)gr);
n->close(); n->close();
...@@ -532,28 +536,28 @@ static void _add_physical_group(int dim, int num, std::vector<GEntity*> &ge, ...@@ -532,28 +536,28 @@ static void _add_physical_group(int dim, int num, std::vector<GEntity*> &ge,
case 3: case 3:
group << "Physical Volume " << num << name << "/"; group << "Physical Volume " << num << name << "/";
n = tree->add(group.str().c_str()); n = tree->add(group.str().c_str());
n->close(); if(n) n->close();
for(unsigned int i = 0; i < ge.size(); i++) for(unsigned int i = 0; i < ge.size(); i++)
_add_region((GRegion*)ge[i], tree, group.str()); _add_region((GRegion*)ge[i], tree, group.str());
break; break;
case 2: case 2:
group << "Physical Surface " << num << name << "/"; group << "Physical Surface " << num << name << "/";
n = tree->add(group.str().c_str()); n = tree->add(group.str().c_str());
n->close(); if(n) n->close();
for(unsigned int i = 0; i < ge.size(); i++) for(unsigned int i = 0; i < ge.size(); i++)
_add_face((GFace*)ge[i], tree, group.str()); _add_face((GFace*)ge[i], tree, group.str());
break; break;
case 1: case 1:
group << "Physical Line " << num << name << "/"; group << "Physical Line " << num << name << "/";
n = tree->add(group.str().c_str()); n = tree->add(group.str().c_str());
n->close(); if(n) n->close();
for(unsigned int i = 0; i < ge.size(); i++) for(unsigned int i = 0; i < ge.size(); i++)
_add_edge((GEdge*)ge[i], tree, group.str()); _add_edge((GEdge*)ge[i], tree, group.str());
break; break;
case 0: case 0:
group << "Physical Point " << num << name << "/"; group << "Physical Point " << num << name << "/";
n = tree->add(group.str().c_str()); n = tree->add(group.str().c_str());
n->close(); if(n) n->close();
for(unsigned int i = 0; i < ge.size(); i++) for(unsigned int i = 0; i < ge.size(); i++)
_add_vertex((GVertex*)ge[i], tree, group.str()); _add_vertex((GVertex*)ge[i], tree, group.str());
break; break;
...@@ -592,12 +596,14 @@ static void _rebuild_tree_browser(bool force) ...@@ -592,12 +596,14 @@ static void _rebuild_tree_browser(bool force)
Fl_Tree_Item *n; Fl_Tree_Item *n;
n = FlGui::instance()->visibility->tree->add(model.str().c_str()); n = FlGui::instance()->visibility->tree->add(model.str().c_str());
if(n){
if(m->getVisibility()) n->select(1); if(m->getVisibility()) n->select(1);
n->close(); n->close();
}
std::string elementary = model.str() + "Elementary entities/"; std::string elementary = model.str() + "Elementary entities/";
n = FlGui::instance()->visibility->tree->add(elementary.c_str()); n = FlGui::instance()->visibility->tree->add(elementary.c_str());
n->close(); if(n) n->close();
for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++) for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++)
_add_region(*it, FlGui::instance()->visibility->tree, elementary); _add_region(*it, FlGui::instance()->visibility->tree, elementary);
for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++) for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++)
...@@ -609,7 +615,7 @@ static void _rebuild_tree_browser(bool force) ...@@ -609,7 +615,7 @@ static void _rebuild_tree_browser(bool force)
std::string physical = model.str() + "Physical groups/"; std::string physical = model.str() + "Physical groups/";
n = FlGui::instance()->visibility->tree->add(physical.c_str()); n = FlGui::instance()->visibility->tree->add(physical.c_str());
n->close(); if(n) n->close();
std::map<int, std::vector<GEntity*> > groups[4]; std::map<int, std::vector<GEntity*> > groups[4];
m->getPhysicalGroups(groups); m->getPhysicalGroups(groups);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment