X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingTimeDiscretization.cxx;h=d0708847221264ec89b0d220495c83f75518149f;hb=e7a9d4f59978fd384ee98db1dfdd5ec2118331ca;hp=6d19818f22b1fecbd91b7ffd0e096eda67d714fc;hpb=e0c843a1fe827a90af91ada8d2033ffb3a7dd1d8;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 6d19818f2..d07088472 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -694,27 +694,27 @@ void MEDCouplingTimeKeeper::checkTimePresence(double time, double eps) const //////////////////////// -MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple(other,deepCopy) +MEDCouplingTimeDiscretizationInt32::MEDCouplingTimeDiscretizationInt32(const MEDCouplingTimeDiscretizationInt32& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple(other,deepCopy) { } -MEDCouplingTimeDiscretizationInt *MEDCouplingTimeDiscretizationInt::performCopyOrIncrRef(bool deepCopy) const +MEDCouplingTimeDiscretizationInt32 *MEDCouplingTimeDiscretizationInt32::performCopyOrIncrRef(bool deepCopy) const { - return new MEDCouplingTimeDiscretizationInt(*this,deepCopy); + return new MEDCouplingTimeDiscretizationInt32(*this,deepCopy); } -MEDCouplingTimeDiscretizationInt *MEDCouplingTimeDiscretizationInt::New(TypeOfTimeDiscretization type) +MEDCouplingTimeDiscretizationInt32 *MEDCouplingTimeDiscretizationInt32::New(TypeOfTimeDiscretization type) { switch(type) { - case MEDCouplingTimeDiscretizationInt::DISCRETIZATION: - return new MEDCouplingTimeDiscretizationInt; + case MEDCouplingTimeDiscretizationInt32::DISCRETIZATION: + return new MEDCouplingTimeDiscretizationInt32; default: throw INTERP_KERNEL::Exception("Time discretization not implemented yet for integers !"); } } -bool MEDCouplingTimeDiscretizationInt::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, int prec, std::string& reason) const +bool MEDCouplingTimeDiscretizationInt32::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, Int32 prec, std::string& reason) const { if(prec!=0) throw INTERP_KERNEL::Exception("isEqualIfNotWhy : only precision equal to 0 supported for int !"); @@ -723,10 +723,10 @@ bool MEDCouplingTimeDiscretizationInt::isEqualIfNotWhy(const MEDCouplingTimeDisc reason="Time discretization is NULL."; return false; } - const MEDCouplingTimeDiscretizationInt *otherC(dynamic_cast(other)); + const MEDCouplingTimeDiscretizationInt32 *otherC(dynamic_cast(other)); if(!otherC) - throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt !"); - if(!MEDCouplingTimeDiscretizationTemplate::areStrictlyCompatible(other,reason)) + throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt32 !"); + if(!MEDCouplingTimeDiscretizationTemplate::areStrictlyCompatible(other,reason)) return false; if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason)) return false; @@ -735,11 +735,72 @@ bool MEDCouplingTimeDiscretizationInt::isEqualIfNotWhy(const MEDCouplingTimeDisc return _array->isEqualIfNotWhy(*other->getArray(),reason); } -bool MEDCouplingTimeDiscretizationInt::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, int prec) const +bool MEDCouplingTimeDiscretizationInt32::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, Int32 prec) const { if(prec!=0) - throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt::isEqualWithoutConsideringStr : only precision 0 is supported !"); - const MEDCouplingTimeDiscretizationInt *otherC(dynamic_cast(other)); + throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt32::isEqualWithoutConsideringStr : only precision 0 is supported !"); + const MEDCouplingTimeDiscretizationInt32 *otherC(dynamic_cast(other)); + if(!otherC) + throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationInt !"); + std::string tmp; + if(!areStrictlyCompatible(other,tmp)) + return false; + std::string reason; + if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason)) + return false; + if(_array==other->getArray()) + return true; + return _array->isEqualWithoutConsideringStr(*(other->getArray())); +} + +//////////////////////// + +MEDCouplingTimeDiscretizationInt64::MEDCouplingTimeDiscretizationInt64(const MEDCouplingTimeDiscretizationInt64& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple(other,deepCopy) +{ +} + +MEDCouplingTimeDiscretizationInt64 *MEDCouplingTimeDiscretizationInt64::performCopyOrIncrRef(bool deepCopy) const +{ + return new MEDCouplingTimeDiscretizationInt64(*this,deepCopy); +} + +MEDCouplingTimeDiscretizationInt64 *MEDCouplingTimeDiscretizationInt64::New(TypeOfTimeDiscretization type) +{ + switch(type) + { + case MEDCouplingTimeDiscretizationInt64::DISCRETIZATION: + return new MEDCouplingTimeDiscretizationInt64; + default: + throw INTERP_KERNEL::Exception("Time discretization not implemented yet for integers !"); + } +} + +bool MEDCouplingTimeDiscretizationInt64::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate *other, Int64 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."; + return false; + } + const MEDCouplingTimeDiscretizationInt64 *otherC(dynamic_cast(other)); + if(!otherC) + throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt64 !"); + if(!MEDCouplingTimeDiscretizationTemplate::areStrictlyCompatible(other,reason)) + return false; + if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason)) + return false; + if(_array==other->getArray()) + return true; + return _array->isEqualIfNotWhy(*other->getArray(),reason); +} + +bool MEDCouplingTimeDiscretizationInt64::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate *other, Int64 prec) const +{ + if(prec!=0) + throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt64::isEqualWithoutConsideringStr : only precision 0 is supported !"); + const MEDCouplingTimeDiscretizationInt64 *otherC(dynamic_cast(other)); if(!otherC) throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationInt !"); std::string tmp; @@ -2481,9 +2542,9 @@ void MEDCouplingLinearTime::getValueForTime(double time, const std::vector(),alpha)); + std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind(std::multiplies(),std::placeholders::_1,alpha)); std::vector tmp(nbComp); - std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind2nd(std::multiplies(),1-alpha)); + std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind(std::multiplies(),std::placeholders::_1,1-alpha)); std::transform(tmp.begin(),tmp.end(),res,res,std::plus()); } @@ -2495,13 +2556,13 @@ void MEDCouplingLinearTime::getValueOnTime(mcIdType eltId, double time, double * else throw INTERP_KERNEL::Exception("No start array existing."); std::size_t nbComp=_array->getNumberOfComponents(); - std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies(),alpha)); + std::transform(value,value+nbComp,value,std::bind(std::multiplies(),std::placeholders::_1,alpha)); std::vector tmp(nbComp); if(_end_array) _end_array->getTuple(eltId,&tmp[0]); else throw INTERP_KERNEL::Exception("No end array existing."); - std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::multiplies(),1-alpha)); + std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind(std::multiplies(),std::placeholders::_1,1-alpha)); std::transform(tmp.begin(),tmp.end(),value,value,std::plus()); }