From a7ea9f1dfd01c957246ca358ae43bf05d6452a26 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 30 Jan 2012 11:05:12 +0000 Subject: [PATCH] setTime and getTime in MEDFileField1TS --- src/MEDLoader/MEDFileField.cxx | 7 +++---- src/MEDLoader/MEDFileField.hxx | 3 ++- src/MEDLoader/Swig/MEDLoader.i | 14 +++++++++++++- src/MEDLoader/Swig/MEDLoaderTest3.py | 5 +++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 072d94350..5512563c7 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -998,7 +998,8 @@ std::vector< std::vector > MEDFileFieldPerMesh::getFiel double MEDFileFieldPerMesh::getTime() const { - return _father->getTime(); + int tmp1,tmp2; + return _father->getTime(tmp1,tmp2); } int MEDFileFieldPerMesh::getIteration() const @@ -2495,9 +2496,7 @@ std::vector< std::pair > MEDFileFieldMultiTSWithoutDAS::getTimeSteps(st const MEDFileField1TSWithoutDAS *f1ts=_time_steps[i]; if(f1ts) { - ret[i].first=f1ts->getIteration(); - ret[i].second=f1ts->getOrder(); - ret1[i]=f1ts->getTime(); + ret1[i]=f1ts->getTime(ret[i].first,ret[i].second); } else { diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index c2b7f1c85..29fb1b555 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -308,7 +308,8 @@ namespace ParaMEDMEM int getDimension() const; int getIteration() const { return _iteration; } int getOrder() const { return _order; } - double getTime() const { return _dt; } + double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _dt; } + void setTime(double val, int iteration, int order) { _dt=val; _iteration=iteration; _order=order; } std::string getName() const { return _name; } const std::string& getDtUnit() const { return _dt_unit; } std::string getMeshName() const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index daf58ddcd..82cc924f1 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -618,9 +618,21 @@ namespace ParaMEDMEM int getNumberOfComponents() const; bool isDealingTS(int iteration, int order) const; const std::vector& getInfo() const; + void setTime(double val, int iteration, int order); %extend { - PyObject *getDtIt() const + PyObject *getTime() + { + int tmp1,tmp2; + double tmp0=self->getTime(tmp1,tmp2); + PyObject *res = PyList_New(3); + PyList_SetItem(res,0,SWIG_From_double(tmp0)); + PyList_SetItem(res,1,SWIG_From_int(tmp1)); + PyList_SetItem(res,2,SWIG_From_int(tmp2)); + return res; + } + + PyObject *getDtIt() const { std::pair res=self->getDtIt(); PyObject *elt=PyTuple_New(2); diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index f8d3c4024..a824f2f8e 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -449,7 +449,12 @@ class MEDLoaderTest(unittest.TestCase): ff1.setFieldNoProfileSBT(f1) ff1.write(fname,0) f2=MEDLoader.ReadFieldCell(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2]); + ti,itt,orr=ff1.getTime() + self.assertEqual(0,itt); self.assertEqual(1,orr); self.assertAlmostEqual(2.,ti,14); self.assertTrue(f1.isEqual(f2,1e-12,1e-12)) + ff1.setTime(2.3,3,4) + ti,itt,orr=ff1.getTime() + self.assertEqual(3,itt); self.assertEqual(4,orr); self.assertAlmostEqual(2.3,ti,14); # fname="Pyfile26.med" f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); -- 2.39.2