Salome HOME
Some factorization before integration of ParaMEDMEM into medcoupling python module
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingTimeDiscretization.cxx
index f9c6b6a784e76825eba1a2fd3bd08596874a80d9..5237b17a462902b32e5a734193358975d037495d 100644 (file)
@@ -118,73 +118,6 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFr
   return ret;
 }
 
-void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
-{
-  if(_array)
-    {
-      tinyInfo.push_back(_array->getNumberOfTuples());
-      tinyInfo.push_back(_array->getNumberOfComponents());
-    }
-  else
-    {
-      tinyInfo.push_back(-1);
-      tinyInfo.push_back(-1);
-    }
-}
-
-void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
-{
-  arrays.resize(1);
-  if(_array!=0)
-    _array->decrRef();
-  DataArrayDouble *arr=0;
-  if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
-    {
-      arr=DataArrayDouble::New();
-      arr->alloc(tinyInfoI[0],tinyInfoI[1]);
-    }
-  _array=arr;
-  arrays[0]=arr;
-}
-
-void MEDCouplingTimeDiscretization::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays)
-{
-  static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size one !";
-  if(arrays.size()!=1)
-    throw INTERP_KERNEL::Exception(MSG);
-  if(_array!=0)
-    _array->decrRef();
-  _array=0;
-  if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
-    {
-      if(!arrays[0])
-        throw INTERP_KERNEL::Exception(MSG);
-      arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
-      _array=arrays[0];
-      _array->incrRef();
-    }
-}
-
-void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
-{
-  _time_tolerance=tinyInfoD[0];
-  int nbOfCompo=_array->getNumberOfComponents();
-  for(int i=0;i<nbOfCompo;i++)
-    _array->setInfoOnComponent(i,tinyInfoS[i]);
-}
-
-void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
-{
-  tinyInfo.push_back(_time_tolerance);
-}
-
-void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
-{
-  int nbOfCompo=_array->getNumberOfComponents();
-  for(int i=0;i<nbOfCompo;i++)
-    tinyInfo.push_back(_array->getInfoOnComponent(i));
-}
-
 bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const
 {
   int iteration,order;
@@ -441,7 +374,7 @@ void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeD
       if(arrays1[i]!=0 && arrays2[i]!=0)
         arrays1[i]->setSelectedComponents(arrays2[i],compoIds);
       else if(arrays1[i]!=0 || arrays2[i]!=0)
-        throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondance are not defined symetrically !");
+        throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondance are not defined symmetrically !");
     }
 }
 
@@ -844,8 +777,6 @@ MEDCouplingTimeDiscretizationFloat *MEDCouplingTimeDiscretizationFloat::New(Type
 
 bool MEDCouplingTimeDiscretizationFloat::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<float> *other, float prec, std::string& reason) const
 {
-  if(prec!=0)
-    throw INTERP_KERNEL::Exception("isEqualIfNotWhy : only precision equal to 0 supported for int !");
   if(!other)
     {
       reason="Time discretization is NULL.";
@@ -895,7 +826,7 @@ std::string MEDCouplingNoTimeLabel::getStringRepr() const
 {
   std::ostringstream stream;
   stream << REPR;
-  stream << "\nTime unit is : \"" << _time_unit << "\"";
+  stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
   return stream.str();
 }
 
@@ -1284,7 +1215,7 @@ std::string MEDCouplingWithTimeStep::getStringRepr() const
 {
   std::ostringstream stream;
   stream << REPR << " Time is defined by iteration=" << _tk.getIteration() << " order=" << _tk.getOrder() << " and time=" << _tk.getTimeValue() << ".";
-  stream << "\nTime unit is : \"" << _time_unit << "\"";
+  stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
   return stream.str();
 }
 
@@ -1295,8 +1226,8 @@ void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh)
   int it=-1,order=-1;
   double val=mesh->getTime(it,order);
   _tk.setAllInfo(val,it,order);
-  std::string tUnit=mesh->getTimeUnit();
-  _time_unit=tUnit;
+  std::string tUnit(mesh->getTimeUnit());
+  setTimeUnit(tUnit);
 }
 
 void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
@@ -1772,7 +1703,7 @@ std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
   std::ostringstream stream;
   stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
   stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
-  stream << "\nTime unit is : \"" << _time_unit << "\"";
+  stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
   return stream.str();
 }
 
@@ -1785,7 +1716,7 @@ void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh *
   _start.setAllInfo(val,it,order);
   _end.setAllInfo(val,it,order);
   std::string tUnit(mesh->getTimeUnit());
-  _time_unit=tUnit;
+  setTimeUnit(tUnit);
 }
 
 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCopyOrIncrRef(bool deepCopy) const
@@ -2157,8 +2088,8 @@ void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh)
   double val=mesh->getTime(it,order);
   _start.setAllInfo(val,it,order);
   _end.setAllInfo(val,it,order);
-  std::string tUnit=mesh->getTimeUnit();
-  _time_unit=tUnit;
+  std::string tUnit(mesh->getTimeUnit());
+  setTimeUnit(tUnit);
 }
 
 std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySizeWithoutChildren() const
@@ -2466,7 +2397,7 @@ std::string MEDCouplingLinearTime::getStringRepr() const
   std::ostringstream stream;
   stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
   stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
-  stream << "Time unit is : \"" << _time_unit << "\"";
+  stream << "Time unit is : \"" << getTimeUnit() << "\"";
   return stream.str();
 }