diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 02feed5553ea4cf49697932649c3c16aa43a60b3..d6a2b9183b590bb93d7ba0e297a094d7eeb24d0b 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -649,7 +649,7 @@ void Msg::ExchangeOnelabParameter(const std::string &key, std::vector<onelab::number> ps; _onelabClient->get(ps, name); bool noRange = true, noChoices = true, noLoop = true, noGraph = true; - if(ps.size()){ + if(ps.size()){ if(ps[0].getReadOnly()) ps[0].setValue(val[0]); // use value from gmsh else @@ -697,6 +697,34 @@ void Msg::ExchangeOnelabParameter(const std::string &key, #endif } +void Msg::ImportPhysicalsAsOnelabRegions() +{ +#if defined(HAVE_ONELAB) + if(_onelabClient){ + std::map<int, std::vector<GEntity*> > groups[4]; + GModel::current()->getPhysicalGroups(groups); + for(int dim = 0; dim < 3; dim++){ + for(std::map<int, std::vector<GEntity*> >::iterator it = groups[dim].begin(); + it != groups[dim].end(); it++){ + // create "read-only" onelab region + std::string name = GModel::current()->getPhysicalName(dim, it->first); + std::ostringstream num; + num << it->first; + if(name.empty()) + name = std::string("Physical") + + ((dim == 3) ? "Volume" : (dim == 2) ? "Surface" : + (dim == 1) ? "Line" : "Point") + num.str(); + name.insert(0, "Gmsh/Physical groups/"); + onelab::region p(name, num.str()); + p.setDimension(dim); + p.setReadOnly(true); + _onelabClient->set(p); + } + } + } +#endif +} + void Msg::FinalizeOnelab() { #if defined(HAVE_ONELAB) diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h index d6ede43e89f788dd5bc6d9dab15d373274d2a5c4..18dafee6d349403bd555674442b4548845811288 100644 --- a/Common/GmshMessage.h +++ b/Common/GmshMessage.h @@ -90,6 +90,7 @@ class Msg { std::vector<double> &val, std::map<std::string, std::vector<double> > &fopt, std::map<std::string, std::vector<std::string> > &copt); + static void ImportPhysicalsAsOnelabRegions(); }; #endif diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index b5d8afd98fe4d29fbd4986127dd6a17c7d4de412..1044a5bc8938a7ddb35b66f712be1bc574f6cd0f 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -425,6 +425,8 @@ int MergeFile(std::string fileName, bool warnIfMissing) } #endif + Msg::ImportPhysicalsAsOnelabRegions(); + if(!status) Msg::Error("Error loading '%s'", fileName.c_str()); Msg::StatusBar(2, true, "Done reading '%s'", fileName.c_str()); diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp index efb98fe20acca9b617d4ba85d4acbf655e715902..6a0ad4b8b071ed4392e3dc1570671de9a0f124dd 100644 --- a/Fltk/onelabWindow.cpp +++ b/Fltk/onelabWindow.cpp @@ -673,31 +673,6 @@ static void updateOnelabGraphs() drawContext::global()->draw(); } -static void importPhysicalGroups(onelab::client *c, GModel *m) -{ - std::map<int, std::vector<GEntity*> > groups[4]; - m->getPhysicalGroups(groups); - for(int dim = 0; dim < 3; dim++){ - for(std::map<int, std::vector<GEntity*> >::iterator it = groups[dim].begin(); - it != groups[dim].end(); it++){ - // create "read-only" onelab region - std::string name = m->getPhysicalName(dim, it->first); - std::ostringstream num; - num << it->first; - if(name.empty()) - name = std::string("Physical") + - ((dim == 3) ? "Volume" : (dim == 2) ? "Surface" : - (dim == 1) ? "Line" : "Point") + num.str(); - name.insert(0, "Gmsh/Physical groups/"); - onelab::region p(name, num.str()); - p.setDimension(dim); - p.setReadOnly(true); - //p.setVisible(false); - c->set(p); - } - } -} - static void runGmshClient(const std::string &action) { onelab::server::citer it = onelab::server::instance()->findClient("Gmsh"); @@ -712,7 +687,6 @@ static void runGmshClient(const std::string &action) // first pass is special to prevent model reload, as well as // remeshing if a mesh file already exists on disk modelName = GModel::current()->getName(); - importPhysicalGroups(c, GModel::current()); if(!StatFile(mshFileName)) onelab::server::instance()->setChanged(false, "Gmsh"); } @@ -724,7 +698,6 @@ static void runGmshClient(const std::string &action) // the model name has changed modelName = GModel::current()->getName(); geometry_reload_cb(0, 0); - importPhysicalGroups(c, GModel::current()); } } else if(action == "compute"){ @@ -735,7 +708,6 @@ static void runGmshClient(const std::string &action) // changed modelName = GModel::current()->getName(); geometry_reload_cb(0, 0); - importPhysicalGroups(c, GModel::current()); if(FlGui::instance()->onelab->meshAuto()){ mesh_3d_cb(0, 0); CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat);