Salome HOME
Typo and whitespace fixes by Kunda
[tools/medcoupling.git] / src / MEDLoader / MEDFileStructureElement.cxx
index d2de14def61ade58a031d87ae2df9ddd7e3582c0..0eb37f489f64d47061cf6ae2bec34fcfa2494c1c 100644 (file)
@@ -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;
@@ -266,8 +271,33 @@ 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);
@@ -341,11 +371,13 @@ const MEDFileStructureElement *MEDFileStructureElements::getWithGT(int idGT) con
   throw INTERP_KERNEL::Exception(oss.str());
 }
 
-int MEDFileStructureElements::getNumberOfNodesPerCellOf(const std::string& seName) const
+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->getNumberOfNodesPerCellOf(meshName);
+  return _sup->getNumberOfNodesInConnOf(se->getEntity(),meshName);
 }
 
 const MEDFileStructureElement *MEDFileStructureElements::getSEWithName(const std::string& seName) const
@@ -360,3 +392,19 @@ const MEDFileStructureElement *MEDFileStructureElements::getSEWithName(const std
   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);
+}