return oss.str();
}
+bool MEDFileData::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ bool ret=false;
+ MEDFileFields *fields=_fields;
+ if(fields)
+ ret=fields->changeMeshNames(modifTab) || ret;
+ MEDFileMeshes *meshes=_meshes;
+ if(meshes)
+ ret=meshes->changeNames(modifTab) || ret;
+ return ret;
+}
+
+bool MEDFileData::changeMeshName(const char *oldMeshName, const char *newMeshName) throw(INTERP_KERNEL::Exception)
+{
+ std::string oldName(oldMeshName);
+ std::vector< std::pair<std::string,std::string> > v(1);
+ v[0].first=oldName; v[0].second=newMeshName;
+ return changeMeshNames(v);
+}
+
MEDFileData::MEDFileData()
{
}
int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
//
+ bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
+ bool changeMeshName(const char *oldMeshName, const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ //
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
private:
MEDFileData();
return ret;
}
+bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
+ {
+ if((*it).first==_mesh_name)
+ {
+ _mesh_name=(*it).second;
+ return true;
+ }
+ }
+ return false;
+}
+
void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
{
for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
return _field_per_mesh[0]->getMeshName();
}
+void MEDFileField1TSWithoutDAS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
+{
+ std::string oldName(getMeshName());
+ std::vector< std::pair<std::string,std::string> > v(1);
+ v[0].first=oldName; v[0].second=newMeshName;
+ changeMeshNames(v);
+}
+
+bool MEDFileField1TSWithoutDAS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ bool ret=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ {
+ MEDFileFieldPerMesh *cur(*it);
+ if(cur)
+ ret=cur->changeMeshNames(modifTab) || ret;
+ }
+ return ret;
+}
+
int MEDFileField1TSWithoutDAS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
{
if(_field_per_mesh.empty())
return _time_steps[0]->getMeshName();
}
+void MEDFileFieldMultiTSWithoutDAS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
+{
+ std::string oldName(getMeshName());
+ std::vector< std::pair<std::string,std::string> > v(1);
+ v[0].first=oldName; v[0].second=newMeshName;
+ changeMeshNames(v);
+}
+
+bool MEDFileFieldMultiTSWithoutDAS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ bool ret=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ MEDFileField1TSWithoutDAS *cur(*it);
+ if(cur)
+ ret=cur->changeMeshNames(modifTab) || ret;
+ }
+ return ret;
+}
+
std::string MEDFileFieldMultiTSWithoutDAS::getDtUnit() const throw(INTERP_KERNEL::Exception)
{
if(_time_steps.empty())
return ret;
}
+std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ {
+ const MEDFileFieldMultiTSWithoutDAS *cur(*it);
+ if(cur)
+ ret.push_back(cur->getMeshName());
+ }
+ return ret;
+}
+
std::string MEDFileFields::simpleRepr() const
{
std::ostringstream oss;
_fields.erase(_fields.begin()+i);
}
+bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ bool ret=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ {
+ MEDFileFieldMultiTSWithoutDAS *cur(*it);
+ if(cur)
+ ret=cur->changeMeshNames(modifTab) || ret;
+ }
+ return ret;
+}
+
MEDFileFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
{
if(i<0 || i>=(int)_fields.size())
std::vector<std::string> getLocsReallyUsed() const;
std::vector<std::string> getPflsReallyUsedMulti() const;
std::vector<std::string> getLocsReallyUsedMulti() const;
+ bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception);
void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
const std::string& getDtUnit() const { return _dt_unit; }
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
+ void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
int getMeshIteration() const throw(INTERP_KERNEL::Exception);
int getMeshOrder() const throw(INTERP_KERNEL::Exception);
int getNumberOfComponents() const;
void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
+ void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> _infos;
//! only useable on reading. 0 is for float, 1 for int32, 2 for int64
mutable int _field_type;
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> > _time_steps;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> > _time_steps;
};
class MEDFileFieldMultiTSIterator;
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const;
std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
void simpleRepr(int bkOffset, std::ostream& oss) const;
//
MEDFileFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
MEDFileFieldsIterator *iterator() throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
+ bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
private:
int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPflsReallyUsed() const;
}
+bool MEDFileMesh::changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
+ {
+ if((*it).first==_name)
+ {
+ _name=(*it).second;
+ return true;
+ }
+ }
+ return false;
+}
+
void MEDFileMesh::copyFamGrpMapsFrom(const MEDFileMesh& other)
{
_groups=other._groups;
return _mesh_one_ts[0]->getName();
}
+void MEDFileMeshMultiTS::setName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
+{
+ std::string oldName(getName());
+ std::vector< std::pair<std::string,std::string> > v(1);
+ v[0].first=oldName; v[0].second=newMeshName;
+ changeNames(v);
+}
+
+bool MEDFileMeshMultiTS::changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ bool ret=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> >::iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
+ {
+ MEDFileMesh *cur(*it);
+ if(cur)
+ ret=cur->changeNames(modifTab) || ret;
+ }
+ return ret;
+}
+
MEDFileMesh *MEDFileMeshMultiTS::getOneTimeStep() const throw(INTERP_KERNEL::Exception)
{
if(_mesh_one_ts.empty())
return ret;
}
+bool MEDFileMeshes::changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
+{
+ bool ret=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::iterator it=_meshes.begin();it!=_meshes.end();it++)
+ {
+ MEDFileMeshMultiTS *cur(*it);
+ if(cur)
+ ret=cur->changeNames(modifTab) || ret;
+ }
+ return ret;
+}
+
void MEDFileMeshes::resize(int newSize) throw(INTERP_KERNEL::Exception)
{
_meshes.resize(newSize);
virtual bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
virtual void clearNonDiscrAttributes() const;
void setName(const char *name) { _name=name; }
+ bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
const char *getName() const { return _name.c_str(); }
void setUnivName(const char *name) { _univ_name=name; }
const char *getUnivName() const { return _univ_name.c_str(); }
static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
const char *getName() const throw(INTERP_KERNEL::Exception);
+ void setName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
MEDFileMesh *getOneTimeStep() const throw(INTERP_KERNEL::Exception);
void write(med_idt fid) const throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception);
MEDFileMesh *getMeshWithName(const char *mname) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
+ bool changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
//
void resize(int newSize) throw(INTERP_KERNEL::Exception);
void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
std::string getName();
void setName(const char *name);
std::string getMeshName();
+ void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
int getNumberOfComponents() const;
bool isDealingTS(int iteration, int order) const;
const std::vector<std::string>& getInfo() const;
PyTuple_SetItem(ret,1,elt);
return ret;
}
+
+ bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
+ return self->changeMeshNames(modifTab);
+ }
}
};
std::string getName() const;
void setName(const char *name);
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
+ void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
const std::vector<std::string>& getInfo() const;
%extend
{
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::eraseTimeStepIds : unexpected input array type recognized !");
}
}
+
+ bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
+ return self->changeMeshNames(modifTab);
+ }
}
};
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const;
std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
//
void resize(int newSize) throw(INTERP_KERNEL::Exception);
void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
{
return self->iterator();
}
+
+ bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
+ return self->changeMeshNames(modifTab);
+ }
}
};
int getNumberOfFields() const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
//
+ bool changeMeshName(const char *oldMeshName, const char *newMeshName) throw(INTERP_KERNEL::Exception);
+ //
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
%extend
{
ret->incrRef();
return ret;
}
+
+ bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
+ return self->changeMeshNames(modifTab);
+ }
}
};
return ret;
}
+std::vector< std::pair<std::string, std::string > > convertVecPairStStFromPy(PyObject *pyLi)
+{
+ std::vector< std::pair<std::string, std::string > > ret;
+ const char *msg="convertVecPairStStFromPy : Expecting PyList of Tuples of size 2 ! The first elt in tuple is one string and the 2nd one a string !";
+ if(PyList_Check(pyLi))
+ {
+ int size=PyList_Size(pyLi);
+ ret.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(pyLi,i);
+ if(PyTuple_Check(o))
+ {
+ std::pair<std::string, std::string> p;
+ int size2=PyTuple_Size(o);
+ if(size2!=2)
+ throw INTERP_KERNEL::Exception(msg);
+ PyObject *o0=PyTuple_GetItem(o,0);
+ if(PyString_Check(o0))
+ p.second=std::string(PyString_AsString(o0));
+ else
+ throw INTERP_KERNEL::Exception(msg);
+ PyObject *o1=PyTuple_GetItem(o,1);
+ if(PyString_Check(o1))
+ p.second=std::string(PyString_AsString(o1));
+ else
+ throw INTERP_KERNEL::Exception(msg);
+ ret[i]=p;
+ }
+ else
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ return ret;
+ }
+ throw INTERP_KERNEL::Exception(msg);
+}
+
std::vector< std::pair<std::vector<std::string>, std::string > > convertVecPairVecStFromPy(PyObject *pyLi)
{
std::vector< std::pair<std::vector<std::string>, std::string > > ret;
- const char *msg="convertVecPairVecStFromPy : Expecting PyList of Tuples of size 2 ! The first elt in tupe is a list of strings and the 2nd one a string !";
+ const char *msg="convertVecPairVecStFromPy : Expecting PyList of Tuples of size 2 ! The first elt in tuple is a list of strings and the 2nd one a string !";
if(PyList_Check(pyLi))
{
int size=PyList_Size(pyLi);