return getTimeStepAtPos(pos);
}
+MEDFileFieldMultiTSIterator *MEDFileFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFieldMultiTSIterator(this);
+}
+
std::string MEDFileFieldMultiTS::simpleRepr() const
{
std::ostringstream oss;
changeLocsRefsNamesGen2(mapOfModif);
}
+MEDFileFieldMultiTSIterator::MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
+{
+ if(fmts)
+ {
+ fmts->incrRef();
+ _nb_iter=fmts->getNumberOfTS();
+ }
+}
+
+MEDFileField1TS *MEDFileFieldMultiTSIterator::nextt()
+{
+ if(_iter_id<_nb_iter)
+ {
+ MEDFileFieldMultiTS *fmts(_fmts);
+ if(fmts)
+ return fmts->getTimeStepAtPos(_iter_id++);
+ else
+ return 0;
+ }
+ else
+ return 0;
+}
+
MEDFileFields *MEDFileFields::New()
{
return new MEDFileFields;
return getFieldAtPos(getPosFromFieldName(fieldName));
}
+MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFieldsIterator(this);
+}
+
int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
{
std::string tmp(fieldName);
oss << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
+
+MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
+{
+ if(fs)
+ {
+ fs->incrRef();
+ _nb_iter=fs->getNumberOfFields();
+ }
+}
+
+MEDFileFieldMultiTS *MEDFileFieldsIterator::nextt()
+{
+ if(_iter_id<_nb_iter)
+ {
+ MEDFileFields *fs(_fs);
+ if(fs)
+ return fs->getFieldAtPos(_iter_id++);
+ else
+ return 0;
+ }
+ else
+ return 0;
+}
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> > _time_steps;
};
+ class MEDFileFieldMultiTSIterator;
+
/*!
* User class.
*/
MEDFileField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
MEDFileField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
MEDFileField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTSIterator *iterator() throw(INTERP_KERNEL::Exception);
//
std::string simpleRepr() const;
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
};
+ class MEDCOUPLING_EXPORT MEDFileFieldMultiTSIterator
+ {
+ public:
+ MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts);
+ MEDFileField1TS *nextt();
+ private:
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> _fmts;
+ int _iter_id;
+ int _nb_iter;
+ };
+
+ class MEDFileFieldsIterator;
+
/*!
* Use class.
*/
void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
MEDFileFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldsIterator *iterator() throw(INTERP_KERNEL::Exception);
void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
private:
int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> > _fields;
};
+
+ class MEDCOUPLING_EXPORT MEDFileFieldsIterator
+ {
+ public:
+ MEDFileFieldsIterator(MEDFileFields *fs);
+ MEDFileFieldMultiTS *nextt();
+ private:
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFields> _fs;
+ int _iter_id;
+ int _nb_iter;
+ };
}
#endif
return _meshes.size();
}
+MEDFileMeshesIterator *MEDFileMeshes::iterator() throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileMeshesIterator(this);
+}
+
MEDFileMesh *MEDFileMeshes::getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception)
{
if(i<0 || i>=(int)_meshes.size())
}
}
}
+
+MEDFileMeshesIterator::MEDFileMeshesIterator(MEDFileMeshes *ms):_ms(ms),_iter_id(0),_nb_iter(0)
+{
+ if(ms)
+ {
+ ms->incrRef();
+ _nb_iter=ms->getNumberOfMeshes();
+ }
+}
+
+MEDFileMesh *MEDFileMeshesIterator::nextt()
+{
+ if(_iter_id<_nb_iter)
+ {
+ MEDFileMeshes *ms(_ms);
+ if(ms)
+ return ms->getMeshAtPos(_iter_id++);
+ else
+ return 0;
+ }
+ else
+ return 0;
+}
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> > _mesh_one_ts;
};
+ class MEDFileMeshesIterator;
+
class MEDLOADER_EXPORT MEDFileMeshes : public RefCountObject, public MEDFileWritable
{
public:
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
void write(med_idt fid) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ MEDFileMeshesIterator *iterator() 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);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> > _meshes;
};
+
+ class MEDCOUPLING_EXPORT MEDFileMeshesIterator
+ {
+ public:
+ MEDFileMeshesIterator(MEDFileMeshes *ms);
+ MEDFileMesh *nextt();
+ private:
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMeshes> _ms;
+ int _iter_id;
+ int _nb_iter;
+ };
}
#endif
%newobject ParaMEDMEM::MEDFileMeshes::getMeshAtPos;
%newobject ParaMEDMEM::MEDFileMeshes::getMeshWithName;
%newobject ParaMEDMEM::MEDFileMeshes::__getitem__;
+%newobject ParaMEDMEM::MEDFileMeshes::__iter__;
%newobject ParaMEDMEM::MEDFileFields::New;
%newobject ParaMEDMEM::MEDFileFields::getFieldWithName;
%newobject ParaMEDMEM::MEDFileFields::getFieldAtPos;
%newobject ParaMEDMEM::MEDFileFields::__getitem__;
+%newobject ParaMEDMEM::MEDFileFields::__iter__;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::New;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepAtPos;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStep;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepGivenTime;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::__getitem__;
+%newobject ParaMEDMEM::MEDFileFieldMultiTS::__iter__;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevel;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtTopLevel;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldOnMeshAtLevel;
}
};
+ class MEDFileMeshesIterator
+ {
+ public:
+ %extend
+ {
+ PyObject *next() throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileMesh *ret=self->nextt();
+ if(ret)
+ {
+ ret->incrRef();
+ return convertMEDFileMesh(ret,SWIG_POINTER_OWN | 0 );
+ }
+ else
+ {
+ PyErr_SetString(PyExc_StopIteration,"No more data.");
+ return 0;
+ }
+ }
+ }
+ };
+
class MEDFileMeshes : public RefCountObject, public MEDFileWritable
{
public:
self->setMeshAtPos(obj,mesh);
return self;
}
+
+ MEDFileMeshesIterator *__iter__() throw(INTERP_KERNEL::Exception)
+ {
+ return self->iterator();
+ }
MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception)
{
}
};
+ class MEDFileFieldMultiTSIterator
+ {
+ public:
+ %extend
+ {
+ PyObject *next() throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileField1TS *ret=self->nextt();
+ if(ret)
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDFileField1TS,SWIG_POINTER_OWN | 0);
+ else
+ {
+ PyErr_SetString(PyExc_StopIteration,"No more data.");
+ return 0;
+ }
+ }
+ }
+ };
+
class MEDFileFieldMultiTS : public MEDFileFieldMultiTSWithoutDAS, public MEDFileFieldGlobsReal, public MEDFileWritable
{
public:
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !");
}
+ MEDFileFieldMultiTSIterator *__iter__() throw(INTERP_KERNEL::Exception)
+ {
+ return self->iterator();
+ }
+
PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;
}
};
+ class MEDFileFieldsIterator
+ {
+ public:
+ %extend
+ {
+ PyObject *next() throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileFieldMultiTS *ret=self->nextt();
+ if(ret)
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldMultiTS,SWIG_POINTER_OWN | 0);
+ else
+ {
+ PyErr_SetString(PyExc_StopIteration,"No more data.");
+ return 0;
+ }
+ }
+ }
+ };
+
class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
{
public:
self->setFieldAtPos(obj,field);
return self;
}
+
+ MEDFileFieldsIterator *__iter__() throw(INTERP_KERNEL::Exception)
+ {
+ return self->iterator();
+ }
}
};
mm=MEDFileMesh.New("Pyfile17.med")
mm.write("Pyfile17_bis.med",2)
ff=MEDFileFieldMultiTS("Pyfile17.med")
+ tsExpected=[[1,2],[3,4],[5,6]]
+ for pos,f1ts in enumerate(ff):
+ self.assertEqual(tsExpected[pos],f1ts.getTime()[:2])
+ self.assertEqual(type(f1ts),MEDFileField1TS)
+ pass
self.assertEqual("MeasureOfMesh_Extruded",ff.getName())
self.assertEqual([3,4],ff[1].getTime()[:-1])
self.assertEqual([3,4],ff[3,4].getTime()[:-1])
mmm2=MEDFileMeshMultiTS.New() ; mmm2.setOneTimeStep(mm2)
ms=MEDFileMeshes.New(); ms.setMeshAtPos(0,mm1) ; ms.setMeshAtPos(1,mm2)
d.setMeshes(ms)
+ for name,mmm in zip(["1DMesh_1","2DCurveMesh_1"],ms):
+ self.assertEqual(name,mmm.getName())
+ self.assertEqual(type(mmm),MEDFileUMesh)
+ pass
self.assertEqual(('1DMesh_1', '2DCurveMesh_1'),d.getMeshes().getMeshesNames())
#
ff1=MEDFileFieldMultiTS.New()
ff22.appendFieldNoProfileSBT(f22)
fs=MEDFileFields.New()
fs.pushField(ff1) ; fs.pushField(ff21) ; fs.pushField(ff22)
+ for name,fmts in zip(["f1","f21","f22"],fs):
+ self.assertEqual(name,fmts.getName())
+ pass
d.setFields(fs)
#
fname2="Pyfile29_2.med"