]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
setTime and getTime in MEDFileField1TS
authorageay <ageay>
Mon, 30 Jan 2012 11:05:12 +0000 (11:05 +0000)
committerageay <ageay>
Mon, 30 Jan 2012 11:05:12 +0000 (11:05 +0000)
src/MEDLoader/MEDFileField.cxx
src/MEDLoader/MEDFileField.hxx
src/MEDLoader/Swig/MEDLoader.i
src/MEDLoader/Swig/MEDLoaderTest3.py

index 072d94350e4fc34933051e189e1842250a518b4d..5512563c758331106ad5ecd9500cc99d0c8b7184 100644 (file)
@@ -998,7 +998,8 @@ std::vector< std::vector<const DataArrayDouble *> > 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<int,int> > 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
         {
index c2b7f1c855deb6181d5f3692ec060a6dd43bc157..29fb1b5552503be8e2ca4196ddd7aaaaf69feb60 100644 (file)
@@ -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);
index daf58ddcd23d11c636207814d48b48454634d4da..82cc924f117ea72c1cfb5553fe9083a3a306e1ef 100644 (file)
@@ -618,9 +618,21 @@ namespace ParaMEDMEM
     int getNumberOfComponents() const;
     bool isDealingTS(int iteration, int order) const;
     const std::vector<std::string>& 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<int,int> res=self->getDtIt();
            PyObject *elt=PyTuple_New(2);
index f8d3c40249df11696136f80809ecd10129006277..a824f2f8ef43239c905c63b77580cb90eb562311 100644 (file)
@@ -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();