Salome HOME
SWIG exception: removing C++11 warnings, minimal work.
[tools/medcoupling.git] / src / MEDLoader / MEDFileStructureElement.cxx
index b268b885710657dcafeb73f20a353370792d8d3b..b53ff049a64655dd7087ad90b1e90d605a38dd28 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -34,6 +34,11 @@ std::string MEDFileSEHolder::getModelName() const
   return _father->getName();
 }
 
+std::string MEDFileSEHolder::getName() const
+{
+  return _name;
+}
+
 void MEDFileSEHolder::setName(const std::string& name)
 {
   _name=name;
@@ -261,8 +266,38 @@ TypeOfField MEDFileStructureElement::getEntity() const
   return _tof;
 }
 
+std::string MEDFileStructureElement::getMeshName() const
+{
+  return _sup_mesh_name;
+}
+
+std::vector<std::string> MEDFileStructureElement::getVarAtts() const
+{
+  std::vector<std::string> ret;
+  for(std::vector< MCAuto<MEDFileSEVarAtt> >::const_iterator it=_var_att.begin();it!=_var_att.end();it++)
+    if((*it).isNotNull())
+      ret.push_back((*it)->getName());
+  return ret;
+}
+
+const MEDFileSEVarAtt *MEDFileStructureElement::getVarAtt(const std::string& varName) const
+{
+  for(std::vector< MCAuto<MEDFileSEVarAtt> >::const_iterator it=_var_att.begin();it!=_var_att.end();it++)
+    if((*it).isNotNull())
+      if((*it)->getName()==varName)
+        return *it;
+  std::ostringstream oss; oss << "MEDFileStructureElement::getVarAtt : no var att with name \"" << varName << "\" !";
+  throw INTERP_KERNEL::Exception(oss.str());
+}
+
 ////////////////////
 
+MEDFileStructureElements *MEDFileStructureElements::New(const std::string& fileName, const MEDFileMeshSupports *ms)
+{
+  MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+  return New(fid,ms);
+}
+
 MEDFileStructureElements *MEDFileStructureElements::New(med_idt fid, const MEDFileMeshSupports *ms)
 {
   return new MEDFileStructureElements(fid,ms);
@@ -296,6 +331,7 @@ MEDFileStructureElements::MEDFileStructureElements(med_idt fid, const MEDFileMes
   _elems.resize(nbSE);
   for(int i=0;i<nbSE;i++)
     _elems[i]=MEDFileStructureElement::New(fid,i,ms);
+  _sup.takeRef(ms);
 }
 
 MEDFileStructureElements::MEDFileStructureElements()
@@ -334,3 +370,41 @@ const MEDFileStructureElement *MEDFileStructureElements::getWithGT(int idGT) con
   std::ostringstream oss; oss << "MEDFileStructureElements::getWithGT : no such geo type " << idGT << " !";
   throw INTERP_KERNEL::Exception(oss.str());
 }
+
+int MEDFileStructureElements::getNumberOfNodesPerSE(const std::string& seName) const
+{
+  if(seName=="MED_PARTICLE")
+    return 1;
+  const MEDFileStructureElement *se(getSEWithName(seName));
+  std::string meshName(se->getMeshName());
+  return _sup->getNumberOfNodesInConnOf(se->getEntity(),meshName);
+}
+
+const MEDFileStructureElement *MEDFileStructureElements::getSEWithName(const std::string& seName) const
+{
+  for(std::vector< MCAuto<MEDFileStructureElement> >::const_iterator it=_elems.begin();it!=_elems.end();it++)
+    {
+      if((*it).isNotNull())
+        if((*it)->getName()==seName)
+          return *it;
+    }
+  std::ostringstream oss; oss << "MEDFileStructureElements::getSEWithName : no such structure element with name " << seName << " !";
+  throw INTERP_KERNEL::Exception(oss.str());
+}
+
+std::vector<std::string> MEDFileStructureElements::getVarAttsOf(const std::string& seName) const
+{
+  const MEDFileStructureElement *se(getSEWithName(seName));
+  return se->getVarAtts();
+}
+
+const MEDFileSEVarAtt *MEDFileStructureElements::getVarAttOf(const std::string &seName, const std::string& varName) const
+{
+  const MEDFileStructureElement *se(getSEWithName(seName));
+  return se->getVarAtt(varName);
+}
+
+const MEDFileUMesh *MEDFileStructureElements::getSupMeshWithName(const std::string& name) const
+{
+  return _sup->getSupMeshWithName(name);
+}