Salome HOME
[EDF23738] : multi geometric type in a single mesh having structure elements on each...
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 21 Jun 2021 20:54:32 +0000 (22:54 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 21 Jun 2021 20:54:32 +0000 (22:54 +0200)
src/MEDLoader/MEDFileMeshSupport.cxx
src/MEDLoader/MEDFileMeshSupport.hxx
src/MEDLoader/MEDFileStructureElement.cxx
src/MEDLoader/MEDFileStructureElement.hxx

index 36258715b6f2f5db5e002dd630aba1b91aedda1b..a1b0545939d9eebba076981efcb00769196b2e75 100644 (file)
@@ -120,7 +120,7 @@ const MEDFileUMesh *MEDFileMeshSupports::getSupMeshWithName(const std::string& n
   throw INTERP_KERNEL::Exception(oss.str());
 }
 
-mcIdType MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, const std::string& name) const
+mcIdType MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, INTERP_KERNEL::NormalizedCellType gt, const std::string& name) const
 {
   const MEDFileUMesh *sup(getSupMeshWithName(name));
   switch(entity)
@@ -129,11 +129,11 @@ mcIdType MEDFileMeshSupports::getNumberOfNodesInConnOf(TypeOfField entity, const
       return sup->getNumberOfNodes();
     case ON_CELLS:
       {
-        std::vector<INTERP_KERNEL::NormalizedCellType> gt(sup->getAllGeoTypes());
-        if(gt.size()!=1)
-          throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : on cells only one geometric type allowed !");
-        const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt[0]));
-        return sup->getNumberOfCellsAtLevel(0)*cm.getNumberOfNodes();
+        std::vector<INTERP_KERNEL::NormalizedCellType> gts(sup->getAllGeoTypes());
+        if(std::find(gts.begin(),gts.end(),gt) == gts.end())
+          throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : specified geometric type not found !");
+        const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(gt));
+        return sup->getNumberOfCellsWithType(gt)*cm.getNumberOfNodes();
       }
     default:
       throw INTERP_KERNEL::Exception("MEDFileMeshSupports::getNumberOfNodesInConnOf : not recognized entity type !");
index 8d81c4e78d6790682b3f72fac19f9519139e0b93..584f906c4785e20ccb96a1d2d53da7494da0ad0d 100644 (file)
@@ -42,7 +42,7 @@ namespace MEDCoupling
     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
     MEDLOADER_EXPORT std::vector<std::string> getSupMeshNames() const;
     MEDLOADER_EXPORT const MEDFileUMesh *getSupMeshWithName(const std::string& name) const;
-    MEDLOADER_EXPORT mcIdType getNumberOfNodesInConnOf(TypeOfField entity, const std::string& name) const;
+    MEDLOADER_EXPORT mcIdType getNumberOfNodesInConnOf(TypeOfField entity, INTERP_KERNEL::NormalizedCellType gt, const std::string& name) const;
   private:
     MEDFileMeshSupports(med_idt fid);
     MEDFileMeshSupports();
index 107b5ffbdc42fb653c3cf5078d8e6f78de0a9c7c..3a5b92b835350a4a41cb53598d6e88617e9b9d31 100644 (file)
@@ -383,7 +383,7 @@ mcIdType MEDFileStructureElements::getNumberOfNodesPerSE(const std::string& seNa
     return 1;
   const MEDFileStructureElement *se(getSEWithName(seName));
   std::string meshName(se->getMeshName());
-  return _sup->getNumberOfNodesInConnOf(se->getEntity(),meshName);
+  return _sup->getNumberOfNodesInConnOf(se->getEntity(),se->getGeoType(),meshName);
 }
 
 const MEDFileStructureElement *MEDFileStructureElements::getSEWithName(const std::string& seName) const
index 384f056c16c4b7ffb77cff6a6d7cd5bf873d7222..8cd799e205dad3562b0c135ce6ba1600bbee6473 100644 (file)
@@ -95,6 +95,7 @@ class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlon
     MEDLOADER_EXPORT std::vector<std::string> getVarAtts() const;
     MEDLOADER_EXPORT const MEDFileSEVarAtt *getVarAtt(const std::string& varName) const;
     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileStructureElement"); }
+    MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getGeoType() const { return _geo_type; }
   public:
     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
     std::size_t getHeapMemorySizeWithoutChildren() const;