Salome HOME
Merge branch 'agy/edf23738_mix_struc_el_integ'
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 2 Aug 2021 09:34:31 +0000 (11:34 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 2 Aug 2021 09:34:31 +0000 (11:34 +0200)
src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i
src/MEDLoader/MEDFileBlowStrEltUp.cxx
src/MEDLoader/MEDFileField.cxx
src/MEDLoader/MEDFileField.hxx
src/MEDLoader/MEDFileField.txx
src/MEDLoader/MEDFileFieldInternal.cxx
src/MEDLoader/MEDFileFieldInternal.hxx
src/MEDLoader/MEDFileFieldMultiTS.cxx
src/MEDLoader/MEDFileFieldMultiTS.hxx
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Swig/MEDLoaderTypemaps.i

index db3024e33f41888d9ef144ec9fe2e182fe3cb3d6..27c4949e0fbc94bc154c93e601adee5dfb28b753 100644 (file)
@@ -681,6 +681,27 @@ static void convertPyToVectorPairInt(PyObject *pyLi, std::vector< std::pair<mcId
     throw INTERP_KERNEL::Exception(msg);
 }
 
+static void convertPyToVectorVectorPairInt(PyObject *pyLi, std::vector< std::vector< std::pair<mcIdType,mcIdType> > >& arr)
+{
+  const char msg[]="list must contain tuples of 2 integers only or tuple must contain tuples of 2 integers only !";
+  if(PyList_Check(pyLi))
+    {
+      std::size_t size=PyList_Size(pyLi);
+      arr.resize(size);
+      for(std::size_t i = 0 ; i < size ; ++i)
+        convertPyToVectorPairInt(PyList_GetItem(pyLi,i),arr[i]);
+    }
+  else if(PyTuple_Check(pyLi))
+    {
+      std::size_t size=PyTuple_Size(pyLi);
+      arr.resize(size);
+      for(std::size_t i = 0 ; i < size ; ++i)
+        convertPyToVectorPairInt(PyTuple_GetItem(pyLi,i),arr[i]);
+    }
+  else
+    throw INTERP_KERNEL::Exception(msg);
+}
+
 static void convertPyToVectorPairStringInt(PyObject *pyLi, std::vector< std::pair<std::string,int> >& arr)
 {
   const char msg[]="convertPyToVectorPairStringInt : list must contain tuples of 2 integers only or tuple must contain tuples of 1 string and 1 integer only !";
index a94a7d7609d1a3c33fec4de8b333762bcb05da70..d5ac6d1f60fb0d33cb989607863861ecb1c29e9f 100644 (file)
@@ -313,6 +313,7 @@ public:
   FieldWalker2(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd);
   std::string getLoc() const { return _loc; }
   std::string getPfl() const { return _pfl; }
+  INTERP_KERNEL::NormalizedCellType getGeoType() const { return _ct; }
   bool isClassic() const { return _is_classic; }
   bool operator!=(const FieldWalker2& other) const;
   bool operator==(const FieldWalker2& other) const;
@@ -320,6 +321,7 @@ public:
 private:
   std::string _loc;
   std::string _pfl;
+  INTERP_KERNEL::NormalizedCellType _ct;
   bool _is_classic;
   MCAuto<SlicePartDefinition> _pd;
 };
@@ -348,6 +350,7 @@ public:
 private:
   std::vector<std::string> _locs;
   std::vector<std::string> _pfl;
+  std::vector<INTERP_KERNEL::NormalizedCellType> _cts;
   MCAuto<PartDefinition> _pd;
 };
 
@@ -362,13 +365,14 @@ const char LocInfo::EPAISSEUR[]="EPAISSEUR";
 LocInfo::LocInfo(const std::vector<FieldWalker2>& fw)
 {
   std::size_t sz(fw.size());
-  _locs.resize(sz); _pfl.resize(sz);
+  _locs.resize(sz); _pfl.resize(sz); _cts.resize(sz);
   if(sz>0)
     _pd=fw[0].getPartDef()->deepCopy();
   for(std::size_t i=0;i<sz;i++)
     {
       _locs[i]=fw[i].getLoc();
       _pfl[i]=fw[i].getPfl();
+      _cts[i]=fw[i].getGeoType();
       if(i>0)
         _pd=(*_pd)+(*(fw[i].getPartDef()));
     }
@@ -636,19 +640,22 @@ MCAuto<MEDFileUMesh> LocInfo::generateNonClassicalData(int zePos, const MEDFileU
         throw INTERP_KERNEL::Exception("LocInfo::generateNonClassicalData : internal error !");
       const MEDFileUMesh *meshLoc(gtk2->getMesh()),*section(gtk2->getSection());
       const MEDFileStructureElement *se(gtk2->getSE());
-      INTERP_KERNEL::NormalizedCellType gt;
+      MCAuto<MEDCouplingUMesh> um(meshLoc->getMeshAtLevel(0));
+      INTERP_KERNEL::NormalizedCellType gt(_cts[i]);
       {
         std::vector<int> nel(meshLoc->getNonEmptyLevels());
         if(nel.size()!=1)
           throw INTERP_KERNEL::Exception(MSG1);
         if(nel[0]!=0)
           throw INTERP_KERNEL::Exception(MSG1);
-        MCAuto<MEDCouplingUMesh> um(meshLoc->getMeshAtLevel(0));
-        if(um->getNumberOfCells()!=1)
+        mcIdType zePos(-1);
+        for(mcIdType icell = 0 ; icell < um->getNumberOfCells() ; ++icell)
+          if( gt == um->getTypeOfCell(icell) )
+            zePos = icell;
+        if(zePos == -1)
           throw INTERP_KERNEL::Exception(MSG1);
-        gt=um->getTypeOfCell(0);
         std::vector<mcIdType> v;
-        um->getNodeIdsOfCell(0,v);
+        um->getNodeIdsOfCell(zePos,v);
         std::size_t sz2(v.size());
         for(std::size_t j=0;j<sz2;j++)
           if(v[j]!=ToIdType(j))
@@ -684,6 +691,7 @@ FieldWalker2::FieldWalker2(const MEDFileFieldPerMeshPerTypePerDisc *pmptpd)
 {
   _loc=pmptpd->getLocalization();
   _pfl=pmptpd->getProfile();
+  _ct=pmptpd->getGeoTypeStatic();
   _is_classic=pmptpd->getType()!=ON_GAUSS_PT;
   _pd=SlicePartDefinition::New(pmptpd->getStart(),pmptpd->getEnd(),1);
 }
index 6dacb50b929f15d41c6c714d379ccb5db2cd6c22..17b42cf447131108946f61fe584076e9caf23266 100644 (file)
@@ -1077,6 +1077,120 @@ void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::strin
 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
 {
   MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
+  this->aggregateFieldsOnSameMeshes(ms);
+}
+
+/*!
+ * This method is dedicated to explosed Structured Elements that can lead to exotic situation.
+ * Especially when there are several structured elements for a same field.
+ * 
+ * This method looks into meshes into \a ms if there is presence of multiple mesh having same name.
+ * If so, these meshes are aggregated in the same order than \a ms.
+ * The fields in \a this lying on the same meshName are also aggregated in the same order than \a this.
+ */
+void MEDFileFields::aggregateFieldsOnSameMeshes(MEDFileMeshes *ms)
+{
+  if(!ms)
+    THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : ms is nullptr !");
+  MCAuto<MEDFileFields> mfs(MEDFileFields::New());
+  std::map<std::string,std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>> > fsByName;
+  for(auto fmts : _fields)
+  {
+    fsByName[fmts->getMeshName()].push_back(fmts);
+  }
+  std::vector<std::string> fieldsNamesToBeAggregated;
+  std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > otherFields;
+  std::set<std::string> expectedMeshNamesToMerge;
+  for(auto fieldsWithSame : fsByName)
+  {
+    if(fieldsWithSame.second.size() > 1)
+    {
+      fieldsNamesToBeAggregated.push_back(fieldsWithSame.first);
+      std::set< std::string > zeMeshNames;
+      for(auto fmtsWithSameName : fieldsWithSame.second)
+        zeMeshNames.insert(fmtsWithSameName->getMeshName());
+      if(zeMeshNames.size()!=1)
+        THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : Presence of multiple MultiTS instances with same name but lying on same meshName. Looks bad !");
+      std::string meshNameToMerge = *zeMeshNames.begin();
+      if(expectedMeshNamesToMerge.find(meshNameToMerge) != expectedMeshNamesToMerge.end())
+        THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : unexpected situation ! Error in implementation !");
+      expectedMeshNamesToMerge.insert(*zeMeshNames.begin());
+    }
+    else
+    {
+      otherFields.push_back(fieldsWithSame.second.front());
+    }
+  }
+  for(auto fieldNameToBeAggregated : fieldsNamesToBeAggregated)
+  {
+    auto base_fs = fsByName[fieldNameToBeAggregated].front();
+    auto fieldsToBeAggregated = fsByName[fieldNameToBeAggregated];
+    std::vector< std::vector< std::pair<int,mcIdType> > > dtsToAggregate;
+    std::vector< MCAuto<MEDFileAnyTypeFieldMultiTS> > eltsToAggregate;
+    for(auto fieldToBeAggregated : fieldsToBeAggregated)
+    {
+      std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > > entries;
+      int iteration,order;
+      {
+        auto dtits = fieldToBeAggregated->getIterations();
+        iteration = dtits.front().first;
+        order = dtits.front().second;
+      }
+      fieldToBeAggregated->getUndergroundDataArrayExt(iteration,order,entries);
+      std::vector< std::pair<int,mcIdType> > dtsToPush;
+      for(auto entry : entries)
+        dtsToPush.push_back({entry.first.first,entry.second.second-entry.second.first});
+      dtsToAggregate.push_back(dtsToPush);
+      MCAuto<MEDFileAnyTypeFieldMultiTS> eltToAggregate = MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(fieldToBeAggregated);
+      eltsToAggregate.push_back(eltToAggregate);
+    }
+    MCAuto<MEDFileAnyTypeFieldMultiTS> gg = MEDFileAnyTypeFieldMultiTS::Aggregate(FromVecAutoToVecOfConst(eltsToAggregate),dtsToAggregate);
+    gg->setMeshName(base_fs->getMeshName());
+    otherFields.push_back(gg->getContent());
+  }
+  // now deal with meshes
+  std::map<std::string,std::vector< MEDFileMesh *> > msByName;
+  for(auto iMesh = 0 ; iMesh < ms->getNumberOfMeshes() ; ++iMesh)
+  {
+    auto curMesh = ms->getMeshAtPos(iMesh);
+    msByName[curMesh->getName()].push_back(curMesh);
+  }
+  std::set<std::string> meshesNamesToBeAggregated;
+  std::vector< MCAuto<MEDFileMesh> > otherMeshes;
+  for(auto msWithSameName : msByName)
+  {
+    if(msWithSameName.second.size()>1)
+      meshesNamesToBeAggregated.insert(msWithSameName.first);
+    else
+    {
+      otherMeshes.push_back( MCAuto<MEDFileMesh>::TakeRef(msWithSameName.second.front()) );
+    }
+  }
+  if(meshesNamesToBeAggregated != expectedMeshNamesToMerge)
+    THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : mismatch between meshes to be aggregated and meshnames into fields to be aggregated");
+  std::vector<const DataArrayDouble *> coos;
+  for(auto meshNameToBeAggregated : meshesNamesToBeAggregated)
+  {
+    for(auto curMesh : msByName[meshNameToBeAggregated])
+    {
+      if(!curMesh->getNonEmptyLevels().empty())
+        THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : only meshes without cells supported.");
+      MEDFileUMesh *curMeshU(dynamic_cast<MEDFileUMesh *>(curMesh));
+      if(!curMeshU)
+        THROW_IK_EXCEPTION("MEDFileFields::aggregateFieldsOnSameMeshes : only unstructured mesh supported.");
+      coos.push_back(curMeshU->getCoords());
+    }
+    MCAuto<DataArrayDouble> coo=DataArrayDouble::Aggregate(coos);
+    MCAuto<MEDFileUMesh> gg = MEDFileUMesh::New();
+    gg->setName(meshNameToBeAggregated);
+    gg->setCoords(coo);
+    otherMeshes.push_back(DynamicCast<MEDFileUMesh,MEDFileMesh>(gg));
+  }
+  //
+  ms->resize(0);
+  for(auto mesh : otherMeshes)
+    ms->pushMesh(mesh);
+  _fields = otherFields;
 }
 
 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
index 3eb3c32bb2992ef97c63c6a606f491b187b26f3f..c06875e108e9d5e4d31cc0894628ed9e7c1aab8f 100644 (file)
@@ -112,6 +112,7 @@ namespace MEDCoupling
     MEDLOADER_EXPORT void keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName);
     MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
     MEDLOADER_EXPORT void blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses);
+    MEDLOADER_EXPORT void aggregateFieldsOnSameMeshes(MEDFileMeshes *ms);
     MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisOnStructureElements() const;
     MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const;
     MEDLOADER_EXPORT void aggregate(const MEDFileFields& other);
index 27af13f7f2f921807e7a8ff2d15866ab7d4afd83..5c34ec86d4aa2bf065f3a3522dc20e9f1b5118de 100644 (file)
@@ -197,6 +197,8 @@ namespace MEDCoupling
         _arr->setContigPartOfSelectedValuesSlice(start,zeArr,(*it).second.first,(*it).second.second,1);
         start+=(*it).second.second-(*it).second.first;
       }
+    // see definition of _nb_of_tuples_to_be_allocated. array is built from scratch and allocated.
+    _nb_of_tuples_to_be_allocated=-3;
   }
 
   template<class T>
index fc228e675ed9dd6888221de48eecd8ffd4bd8ace..fffb38ef8729f98203585761c1bf63009e697a6e 100644 (file)
@@ -801,6 +801,11 @@ INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType(
   return _father->getGeoType();
 }
 
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoTypeStatic() const
+{
+  return _father->getGeoTypeStatic();
+}
+
 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
 {
   types.insert(_type);
@@ -1778,6 +1783,11 @@ INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
   return _geo_type;
 }
 
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoTypeStatic() const
+{
+  return _geo_type;
+}
+
 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
 {
   ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
@@ -1930,6 +1940,11 @@ INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() co
   throw INTERP_KERNEL::Exception("not implemented yet !");
 }
 
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoTypeStatic() const
+{
+  return _se->getGeoType();
+}
+
 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
 {
   const char startLine[]="  ## ";
index 67db06bdef85a74f8c6d8f40c61076b291731521..91dd391175da19a9f076ce85efdfbb9c69d8ddf0 100644 (file)
@@ -158,6 +158,7 @@ namespace MEDCoupling
     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
     void setType(TypeOfField newType);
     INTERP_KERNEL::NormalizedCellType getGeoType() const;
+    INTERP_KERNEL::NormalizedCellType getGeoTypeStatic() const;
     std::size_t getNumberOfComponents() const;
     mcIdType getNumberOfTuples() const;
     mcIdType getStart() const { return _start; }
@@ -269,6 +270,7 @@ namespace MEDCoupling
     virtual ~MEDFileFieldPerMeshPerTypeCommon();
     virtual void getDimension(int& dim) const = 0;
     virtual INTERP_KERNEL::NormalizedCellType getGeoType() const = 0;
+    virtual INTERP_KERNEL::NormalizedCellType getGeoTypeStatic() const = 0;
     virtual void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const = 0;
     virtual void simpleRepr(int bkOffset, std::ostream& oss, int id) const = 0;
     virtual std::string getGeoTypeRepr() const = 0;
@@ -295,7 +297,8 @@ namespace MEDCoupling
     static MCAuto<MEDFileFieldPerMeshPerType> Aggregate(mcIdType &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<mcIdType,mcIdType> > >& extractInfo);
   public:// overload of abstract methods
     void getDimension(int& dim) const;
-    INTERP_KERNEL::NormalizedCellType getGeoType() const;
+    INTERP_KERNEL::NormalizedCellType getGeoType() const override;
+    INTERP_KERNEL::NormalizedCellType getGeoTypeStatic() const override;
     void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const;
     void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
     std::string getGeoTypeRepr() const;
@@ -317,7 +320,8 @@ namespace MEDCoupling
     std::string getModelName() const;
   public:
     void getDimension(int& dim) const;
-    INTERP_KERNEL::NormalizedCellType getGeoType() const;
+    INTERP_KERNEL::NormalizedCellType getGeoType() const override;
+    INTERP_KERNEL::NormalizedCellType getGeoTypeStatic() const override;
     void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const;
     void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
     std::string getGeoTypeRepr() const;
index 8376767e727948d258aba24f511bcd013691acbb..74bc171d60483120da92f818676099f46000f145 100644 (file)
@@ -1157,6 +1157,36 @@ MEDFileInt32FieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt(
   return ret.retn();
 }
 
+MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileFieldMultiTSWithoutSDA::createNewWithSDA() const
+{
+  MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
+  return DynamicCast<MEDFileFieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
+}
+
+//=
+
+MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileInt32FieldMultiTSWithoutSDA::createNewWithSDA() const
+{
+  MCAuto<MEDFileInt32FieldMultiTS> ret(MEDFileInt32FieldMultiTS::New());
+  return DynamicCast<MEDFileInt32FieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
+}
+
+//=
+
+MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileInt64FieldMultiTSWithoutSDA::createNewWithSDA() const
+{
+  MCAuto<MEDFileInt64FieldMultiTS> ret(MEDFileInt64FieldMultiTS::New());
+  return DynamicCast<MEDFileInt64FieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
+}
+
+//=
+
+MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileFloatFieldMultiTSWithoutSDA::createNewWithSDA() const
+{
+  MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
+  return DynamicCast<MEDFileFloatFieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
+}
+
 //= MEDFileAnyTypeFieldMultiTS
 
 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
@@ -2059,6 +2089,7 @@ MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< type
 
 /*!
  * \a dts and \a ftmss are expected to have same size.
+ * see MEDFileFieldPerMeshPerTypePerDisc::Aggregate for description of \a dts.
  */
 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
 {
index aa4b2330e3816fd5e9e41ca854a1bb939d33aa24..05f7d2b58f9e3802ac45b475278d28449998c061 100644 (file)
@@ -34,7 +34,8 @@ namespace MEDCoupling
   class MEDFileFieldVisitor;
   class MEDFileAnyTypeField1TS;
   class MEDFileAnyTypeField1TSWithoutSDA;
-  
+  class MEDFileAnyTypeFieldMultiTS;
+
   class MEDFileAnyTypeFieldMultiTSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope
   {
   protected:
@@ -53,6 +54,7 @@ namespace MEDCoupling
     MEDLOADER_EXPORT virtual const char *getTypeStr() const = 0;
     MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const = 0;
     MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const = 0;
+    MEDLOADER_EXPORT virtual MCAuto<MEDFileAnyTypeFieldMultiTS> createNewWithSDA() const = 0;
     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const = 0;
     MEDLOADER_EXPORT virtual void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const = 0;
     MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
@@ -147,6 +149,7 @@ namespace MEDCoupling
     MEDLOADER_EXPORT MEDFileInt32FieldMultiTSWithoutSDA *convertToInt() const;
     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileFieldMultiTSWithoutSDA(*this); }
     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFieldMultiTSWithoutSDA"); }
+    MEDLOADER_EXPORT MCAuto<MEDFileAnyTypeFieldMultiTS> createNewWithSDA() const override;
   protected:
     MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileTemplateFieldMultiTSWithoutSDA<double>(fieldName,meshName) { }
     MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA<double>(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { }
@@ -174,6 +177,7 @@ namespace MEDCoupling
     MEDLOADER_EXPORT MEDFileInt32FieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA<Int32>(fid,fieldId,loadAll,ms,entities) { }
     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileInt32FieldMultiTSWithoutSDA(*this); }
     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt32FieldMultiTSWithoutSDA"); }
+    MEDLOADER_EXPORT MCAuto<MEDFileAnyTypeFieldMultiTS> createNewWithSDA() const override;
   protected:
     MEDFileInt32FieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA<Int32>(fieldName,meshName) { }
     MEDFileInt32FieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA<Int32>(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { }
@@ -189,6 +193,7 @@ namespace MEDCoupling
     MEDLOADER_EXPORT MEDFileInt64FieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA<Int64>(fid,fieldId,loadAll,ms,entities) { }
     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileInt64FieldMultiTSWithoutSDA(*this); }
     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt64FieldMultiTSWithoutSDA"); }
+    MEDLOADER_EXPORT MCAuto<MEDFileAnyTypeFieldMultiTS> createNewWithSDA() const override;
   protected:
     MEDFileInt64FieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA<Int64>(fieldName,meshName) { }
     MEDFileInt64FieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA<Int64>(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { }
@@ -204,6 +209,7 @@ namespace MEDCoupling
     MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA<float>(fid,fieldId,loadAll,ms,entities) { }
     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileFloatFieldMultiTSWithoutSDA(*this); }
     MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFloatFieldMultiTSWithoutSDA"); }
+    MEDLOADER_EXPORT MCAuto<MEDFileAnyTypeFieldMultiTS> createNewWithSDA() const override;
   protected:
     MEDFileFloatFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA<float>(fieldName,meshName) { }
     MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA<float>(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { }
index 986ac311b2d83333917ba475f13d846579c942d5..d53d6d623fa5ae57a2da8d282c891bfc26cd0231 100644 (file)
@@ -185,6 +185,7 @@ using namespace MEDCoupling;
 %newobject MEDCoupling::MEDFileFieldMultiTS::getFieldAtLevelOld;
 %newobject MEDCoupling::MEDFileFieldMultiTS::getUndergroundDataArray;
 %newobject MEDCoupling::MEDFileFieldMultiTS::convertToInt;
+%newobject MEDCoupling::MEDFileFieldMultiTS::Aggregate;
 
 %newobject MEDCoupling::MEDFileInt32FieldMultiTS::New;
 %newobject MEDCoupling::MEDFileInt32FieldMultiTS::field;
@@ -3037,6 +3038,17 @@ namespace MEDCoupling
     MEDFileInt32FieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const;
     %extend
        {
+         static MEDFileAnyTypeFieldMultiTS *Aggregate(PyObject *fmtssPy, PyObject *dtsPy)
+         {
+            std::vector<const MEDFileAnyTypeFieldMultiTS *> fmtss;
+            convertFromPyObjVectorOfObj<const MEDFileAnyTypeFieldMultiTS *>(fmtssPy,SWIGTYPE_p_MEDCoupling__MEDFileAnyTypeFieldMultiTS,"MEDFileAnyTypeFieldMultiTS",fmtss);
+            std::vector< std::vector< std::pair<mcIdType,mcIdType> > > dts2;
+            convertPyToVectorVectorPairInt(dtsPy,dts2);
+            std::vector< std::vector< std::pair<int,mcIdType> > > dts(MEDVectorVectorMIIterator(0,dts2),MEDVectorVectorMIIterator(dts2.size(),dts2));
+            MCAuto<MEDFileAnyTypeFieldMultiTS> ret = MEDFileFieldMultiTS::Aggregate(fmtss,dts);
+            return ret.retn();
+         }
+
          MEDFileFieldMultiTS()
          {
            return MEDFileFieldMultiTS::New();
index afdfebdea9dd5ab153b008b9a262adb510727f70..6f9d3c4bcbb5161370d0fe146326d2c4f73edc30 100644 (file)
 // Author : Anthony Geay (EDF R&D)
 
 #include <vector>
+#include <iterator>
+
+class MEDVectorMIIterator : public std::iterator< std::input_iterator_tag, long, long, const std::pair<int,mcIdType> *, std::pair<int,mcIdType> >
+{
+  long _num = 0;
+  std::vector< std::pair<mcIdType,mcIdType> > _data;
+public:
+  explicit MEDVectorMIIterator(long num , std::vector< std::pair<mcIdType,mcIdType> > data) : _num(num),_data(data) {}
+  MEDVectorMIIterator& operator++() { ++_num; return *this;}
+  bool operator==(const MEDVectorMIIterator& other) const {return _num == other._num;}
+  bool operator!=(const MEDVectorMIIterator& other) const {return !(*this == other);}
+  reference operator*() const {return {(int)_data[_num].first,_data[_num].second}; }
+};
+
+class MEDVectorVectorMIIterator : public std::iterator< std::input_iterator_tag, long, long, const std::vector< std::pair<int,mcIdType> >*, std::vector< std::pair<int,mcIdType> > >
+{
+  long _num = 0;
+  std::vector< std::vector< std::pair<mcIdType,mcIdType> > > _data;
+public:
+  explicit MEDVectorVectorMIIterator(long num , std::vector< std::vector< std::pair<mcIdType,mcIdType> > > data) : _num(num),_data(data) {}
+  MEDVectorVectorMIIterator& operator++() { ++_num; return *this;}
+  bool operator==(const MEDVectorVectorMIIterator& other) const {return _num == other._num;}
+  bool operator!=(const MEDVectorVectorMIIterator& other) const {return !(*this == other);}
+  reference operator*() const { auto data = _data[_num]; return reference(MEDVectorMIIterator(0,data),MEDVectorMIIterator(data.size(),data)); }
+};
 
 static PyObject *convertMEDFileMesh(MEDCoupling::MEDFileMesh* mesh, int owner)
 {