{
public:
MCConstAuto(const MCConstAuto& other):_ptr(0) { referPtr(other._ptr); }
+ MCConstAuto(const typename MEDCoupling::MCAuto<T> & other):_ptr(0) { referPtr( (const T*) other); }
MCConstAuto(const T *ptr=0):_ptr(ptr) { }
~MCConstAuto() { destroyPtr(); }
bool isNull() const { return _ptr==0; }
MEDFileMeshSupport.cxx
MEDFileStructureElement.cxx
MEDFileEntities.cxx
+ MEDFileBlowStrEltUp.cxx
SauvMedConvertor.cxx
SauvReader.cxx
SauvWriter.cxx
--- /dev/null
+// Copyright (C) 2007-2017 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#include "MEDFileBlowStrEltUp.hxx"
+
+using namespace MEDCoupling;
+
+MEDFileBlowStrEltUp::MEDFileBlowStrEltUp(const MEDFileFields *fsOnlyOnSE, const MEDFileMeshes *ms, const MEDFileStructureElements *ses)
+{
+ if(!fsOnlyOnSE || !ms || !ses)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp constructor : NULL input pointer !");
+ _ms.takeRef(ms); _ses.takeRef(ses);
+ std::vector< std::pair<std::string,std::string> > ps;
+ fsOnlyOnSE->getMeshSENames(ps);
+ std::size_t sz(ps.size());
+ _elts.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const std::pair<std::string,std::string>& p(ps[i]);
+ MCAuto<MEDFileFields> f(fsOnlyOnSE->partOfThisLyingOnSpecifiedMeshSEName(p.first,p.second));
+ _elts[i]=f;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2017 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#ifndef __MEDFILEBLOWSTRELTUP_HXX__
+#define __MEDFILEBLOWSTRELTUP_HXX__
+
+#include "MEDLoaderDefines.hxx"
+#include "MEDFileUtilities.txx"
+#include "MEDFileMesh.hxx"
+#include "MEDFileField.hxx"
+#include "MEDFileStructureElement.hxx"
+
+#include "MEDCouplingRefCountObject.hxx"
+
+namespace MEDCoupling
+{
+ class MEDFileBlowStrEltUp
+ {
+ public:
+ MEDFileBlowStrEltUp(const MEDFileFields *fsOnlyOnSE, const MEDFileMeshes *ms, const MEDFileStructureElements *ses);
+ private:
+ std::vector< MCAuto<MEDFileFields> > _elts;
+ MCConstAuto<MEDFileMeshes> _ms;
+ MCConstAuto<MEDFileStructureElements> _ses;
+ };
+}
+
+#endif
return _se->getDynGT();
}
+std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
+{
+ return _se->getName();
+}
+
void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
{
throw INTERP_KERNEL::Exception("not implemented yet !");
_field_pm_pt=res;
}
+void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
+{
+ std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ {
+ if((*it).isNotNull())
+ {
+ const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
+ if(pt->getModelName()==seName)
+ res.push_back(*it);
+ }
+ }
+ _field_pm_pt=res;
+}
+
+void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ {
+ if((*it).isNotNull())
+ {
+ const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
+ if(pt)
+ {
+ ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
+ }
+ }
+}
+
DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
{
if(!_father)
(*it)->keepOnlyStructureElements();
}
+void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ (*it)->keepOnlyOnSE(seName);
+}
+
+void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ (*it)->getMeshSENames(ps);
+}
+
MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
{
static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to be extracted with \"field\" method ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
_time_steps=ret;
}
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
+{
+ std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ (*it)->keepOnlyOnSE(seName);
+}
+
+void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
+{
+ std::vector< std::pair<std::string,std::string> > ps2;
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ {
+ (*it)->getMeshSENames(ps2);
+ break;
+ }
+ if(ps2.empty())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
+ for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ if((*it).isNotNull())
+ {
+ std::vector< std::pair<std::string,std::string> > ps3;
+ (*it)->getMeshSENames(ps3);
+ if(ps2!=ps3)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
+ }
+ for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
+ {
+ std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
+ if(it2==ps.end())
+ ps.push_back(*it);
+ }
+}
+
bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
{
for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
}
_fields=ret;
}
-
+
+void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
+{
+ std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
+ for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
+ if((*it).isNotNull())
+ {
+ if((*it)->getMeshName()!=meshName)
+ continue;
+ std::vector< std::pair<std::string,std::string> > ps;
+ (*it)->getMeshSENames(ps);
+ std::pair<std::string,std::string> p(meshName,seName);
+ if(std::find(ps.begin(),ps.end(),p)!=ps.end())
+ (*it)->keepOnlyOnSE(seName);
+ ret.push_back(*it);
+ }
+ _fields=ret;
+}
+
+void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
+{
+ for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
+ if((*it).isNotNull())
+ (*it)->getMeshSENames(ps);
+}
+
MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
{
MCAuto<MEDFileFields> ret(deepCopy());
return ret;
}
+MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
+{
+ MCAuto<MEDFileFields> ret(deepCopy());
+ ret->keepOnlyOnMeshSE(meshName,seName);
+ return ret;
+}
+
MEDFileFieldsIterator *MEDFileFields::iterator()
{
return new MEDFileFieldsIterator(this);
public:
static MEDFileFieldPerMeshPerTypeDyn *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc);
int getDynGT() const;
+ std::string getModelName() const;
public:
void getDimension(int& dim) const;
INTERP_KERNEL::NormalizedCellType getGeoType() const;
bool onlyStructureElements() const;
void killStructureElements();
void keepOnlyStructureElements();
+ void keepOnlyOnSE(const std::string& seName);
+ void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
DataArray *getOrCreateAndGetArray();
const DataArray *getOrCreateAndGetArray() const;
const std::vector<std::string>& getInfo() const;
MEDLOADER_EXPORT bool onlyStructureElements() const;
MEDLOADER_EXPORT void killStructureElements();
MEDLOADER_EXPORT void keepOnlyStructureElements();
+ MEDLOADER_EXPORT void keepOnlyOnSE(const std::string& seName);
+ MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& infos);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
MEDLOADER_EXPORT bool onlyStructureElements() const;
MEDLOADER_EXPORT void killStructureElements();
MEDLOADER_EXPORT void keepOnlyStructureElements();
+ MEDLOADER_EXPORT void keepOnlyOnSE(const std::string& seName);
+ MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
MEDLOADER_EXPORT int getPosOfTimeStep(int iteration, int order) const;
MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const;
MEDLOADER_EXPORT std::vector< std::pair<int,int> > getIterations() const;
MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
MEDLOADER_EXPORT bool presenceOfMultiDiscPerGeoType() const;
- MEDLOADER_EXPORT void killStructureElements();
- MEDLOADER_EXPORT void keepOnlyStructureElements();
MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& info);
MEDLOADER_EXPORT int getNumberOfComponents() const;
MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const;
MEDLOADER_EXPORT bool presenceOfStructureElements() const;
MEDLOADER_EXPORT void killStructureElements();
MEDLOADER_EXPORT void keepOnlyStructureElements();
+ 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 MCAuto<MEDFileFields> partOfThisOnStructureElements() const;
+ MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const;
MEDLOADER_EXPORT MEDFileFieldsIterator *iterator();
MEDLOADER_EXPORT void destroyFieldAtPos(int i);
MEDLOADER_EXPORT void destroyFieldsAtPos(const int *startIds, const int *endIds);
bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception);
void killStructureElements() throw(INTERP_KERNEL::Exception);
void keepOnlyStructureElements() throw(INTERP_KERNEL::Exception);
+ void keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName) throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
bool removeFieldsWithoutAnyTimeStep() throw(INTERP_KERNEL::Exception);
%extend
MCAuto<MEDFileFields> ret(self->partOfThisOnStructureElements());
return ret.retn();
}
+
+ MEDFileFields *partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<MEDFileFields> ret(self->partOfThisLyingOnSpecifiedMeshSEName(meshName,seName));
+ return ret.retn();
+ }
static MEDFileFields *LoadSpecificEntities(const std::string& fileName, PyObject *entities, bool loadAll=true) throw(INTERP_KERNEL::Exception)
{
return MEDFileFields::LoadSpecificEntities(fileName,entitiesCpp,loadAll);
}
+ PyObject *getMeshSENames() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<std::string,std::string> > ps;
+ self->getMeshSENames(ps);
+ return convertVectPairStToPy(ps);
+ }
+
PyObject *getCommonIterations() const throw(INTERP_KERNEL::Exception)
{
bool ret1;
return ret;
}
+PyObject *convertVectPairStToPy(const std::vector< std::pair<std::string, std::string > >& vec)
+{
+ int sz=(int)vec.size();
+ PyObject *ret=PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ PyObject *t=PyTuple_New(2);
+ PyTuple_SetItem(t,0,PyString_FromString(vec[i].first.c_str()));
+ PyTuple_SetItem(t,1,PyString_FromString(vec[i].second.c_str()));
+ PyList_SetItem(ret,i,t);
+ }
+ return ret;
+}
+
std::vector< std::pair<std::string, std::string > > convertVecPairStStFromPy(PyObject *pyLi)
{
std::vector< std::pair<std::string, std::string > > ret;