From ff1d27ed215636f272433f17a4297982f2ae8a37 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 21 May 2014 12:24:23 +0000 Subject: [PATCH] option in destroy to preserve model name --- Geo/GModel.cpp | 8 +++++--- Geo/GModel.h | 4 ++-- Parser/Gmsh.tab.cpp | 2 +- Parser/Gmsh.y | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index df7b22e99a..3a00394b27 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -171,10 +171,12 @@ GModel *GModel::findByName(const std::string &name, const std::string &fileName) return 0; } -void GModel::destroy() +void GModel::destroy(bool keepName) { - _name.clear(); - _fileNames.clear(); + if(!keepName){ + _name.clear(); + _fileNames.clear(); + } _maxVertexNum = _maxElementNum = 0; _checkPointedMaxVertexNum = _checkPointedMaxElementNum = 0; diff --git a/Geo/GModel.h b/Geo/GModel.h index acfc1c8db5..e1a6f3148c 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -178,8 +178,8 @@ class GModel // *not* have a link to the fileName static GModel *findByName(const std::string &name, const std::string &fileName=""); - // delete everything in a GModel - void destroy(); + // delete everything in a GModel (optionally keep name and fileName) + void destroy(bool keepName=false); // get/set global vertex/element num int getMaxVertexNumber(){ return _maxVertexNum; } diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index cdc4c1fa21..fdc453021c 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -7028,7 +7028,7 @@ yyreduce: ClearProject(); } else if(!strcmp((yyvsp[(2) - (3)].c), "Model")){ - GModel::current()->destroy(); + GModel::current()->destroy(true); // destroy, but keep name/filename GModel::current()->getGEOInternals()->destroy(); } else if(!strcmp((yyvsp[(2) - (3)].c), "Physicals")){ diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index c1d43b6980..e557d106d5 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -2477,7 +2477,7 @@ Delete : ClearProject(); } else if(!strcmp($2, "Model")){ - GModel::current()->destroy(); + GModel::current()->destroy(true); // destroy, but keep name/filename GModel::current()->getGEOInternals()->destroy(); } else if(!strcmp($2, "Physicals")){ -- GitLab