From: Anthony Geay Date: Tue, 16 May 2017 14:13:25 +0000 (+0200) Subject: On the road X-Git-Tag: V8_4_0a1~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=00d3f3fe11658d5daf0b87d36253ddd75dd212c8;p=tools%2Fmedcoupling.git On the road --- diff --git a/src/MEDCoupling/MEDCouplingFieldT.hxx b/src/MEDCoupling/MEDCouplingFieldT.hxx index b9fba16bc..6abd6f8fb 100644 --- a/src/MEDCoupling/MEDCouplingFieldT.hxx +++ b/src/MEDCoupling/MEDCouplingFieldT.hxx @@ -95,8 +95,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector& tinyInfoI, const DataArrayInt *dataInt, const std::vector::ArrayType *>& arrays); MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); MEDCOUPLING_EXPORT void serialize(DataArrayInt *&dataInt, std::vector::ArrayType *>& arrays) const; + MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretizationTemplate *timeDiscrSafe() const; protected: - const MEDCouplingTimeDiscretizationTemplate *timeDiscrSafe() const; MEDCouplingTimeDiscretizationTemplate *timeDiscrSafe(); protected: MEDCouplingTimeDiscretizationTemplate *_time_discr; diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx index 948ef2f64..362b92a7b 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx @@ -74,6 +74,10 @@ MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(TypeOfField type):MEDCoupling { } +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldTemplate& other, bool deepCopy):MEDCouplingField(other,deepCopy) +{ +} + void MEDCouplingFieldTemplate::checkConsistencyLight() const { if(_mesh==0) @@ -181,3 +185,9 @@ void MEDCouplingFieldTemplate::reprQuickOverview(std::ostream& stream) const stream << "\nMesh info : " << tmp.substr(0,tmp.find('\n')); } } + +MCAuto MEDCouplingFieldTemplate::clone(bool recDeepCpy) const +{ + MCAuto ret(new MEDCouplingFieldTemplate(*this,recDeepCpy)); + return ret; +} diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.hxx b/src/MEDCoupling/MEDCouplingFieldTemplate.hxx index 6b27fc218..47ba2bdc6 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.hxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.hxx @@ -16,7 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) #ifndef __PARAMEDMEM_MEDCOUPLINGFIELDTEMPLATE_HXX__ #define __PARAMEDMEM_MEDCOUPLINGFIELDTEMPLATE_HXX__ @@ -48,6 +48,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT std::string simpleRepr() const; MEDCOUPLING_EXPORT std::string advancedRepr() const; MEDCOUPLING_EXPORT void checkConsistencyLight() const; + MEDCOUPLING_EXPORT MCAuto clone(bool recDeepCpy) const; // MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const; @@ -62,6 +63,7 @@ namespace MEDCoupling MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f); MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f); MEDCouplingFieldTemplate(TypeOfField type); + MEDCouplingFieldTemplate(const MEDCouplingFieldTemplate& other, bool deepCopy); }; } diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 40f7921bd..246f9a6bf 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -828,7 +828,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(); } @@ -1217,7 +1217,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(); } @@ -1228,8 +1228,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& tinyInfo) const @@ -1705,7 +1705,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(); } @@ -1718,7 +1718,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 @@ -2090,8 +2090,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 @@ -2399,7 +2399,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(); } diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index 0edcddba3..12829a2ea 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -35,24 +35,35 @@ namespace MEDCoupling class DataArrayDouble; class TimeLabel; + class TimeHolder + { + public: + MEDCOUPLING_EXPORT std::string getTimeUnit() const { return _time_unit; } + MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit) { _time_unit=unit; } + MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const { return getStartTime(iteration,order); } + MEDCOUPLING_EXPORT virtual double getStartTime(int& iteration, int& order) const = 0; + void copyTinyAttrFrom(const TimeHolder& other) { _time_unit=other._time_unit; } + protected: + TimeHolder() { } + TimeHolder(const TimeHolder& other):_time_unit(other._time_unit) { } + private: + std::string _time_unit; + }; + template - class MEDCouplingTimeDiscretizationTemplate : public TimeLabel, public BigMemoryObject + class MEDCouplingTimeDiscretizationTemplate : public TimeLabel, public BigMemoryObject, public TimeHolder { public: MEDCOUPLING_EXPORT void updateTime() const; MEDCOUPLING_EXPORT virtual void setArray(typename Traits::ArrayType *array, TimeLabel *owner); MEDCOUPLING_EXPORT typename Traits::ArrayType *getArray() { return _array; } MEDCOUPLING_EXPORT const typename Traits::ArrayType *getArray() const { return _array; } - MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit) { _time_unit=unit; } - MEDCOUPLING_EXPORT std::string getTimeUnit() const { return _time_unit; } MEDCOUPLING_EXPORT void setTimeTolerance(double val) { _time_tolerance=val; } MEDCOUPLING_EXPORT double getTimeTolerance() const { return _time_tolerance; } - MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const { return getStartTime(iteration,order); } MEDCOUPLING_EXPORT void setTime(double time, int iteration, int order) { setStartTime(time,iteration,order); } MEDCOUPLING_EXPORT void setIteration(int it) { setStartIteration(it); } MEDCOUPLING_EXPORT void setOrder(int order) { setStartOrder(order); } MEDCOUPLING_EXPORT void setTimeValue(double val) { setStartTimeValue(val); } - MEDCOUPLING_EXPORT virtual double getStartTime(int& iteration, int& order) const = 0; MEDCOUPLING_EXPORT virtual void setStartIteration(int it) = 0; MEDCOUPLING_EXPORT virtual void setStartOrder(int order) = 0; MEDCOUPLING_EXPORT virtual void setStartTime(double time, int iteration, int order) = 0; @@ -97,7 +108,6 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate(); MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate& other, bool deepCopy); protected: - std::string _time_unit; double _time_tolerance; typename Traits::ArrayType *_array; protected: diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.txx b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx index a53e36db2..54a0b19f0 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.txx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx @@ -60,14 +60,14 @@ namespace MEDCoupling template void MEDCouplingTimeDiscretizationTemplate::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other) { + TimeHolder::copyTinyAttrFrom(other); _time_tolerance=other._time_tolerance; - _time_unit=other._time_unit; } template void MEDCouplingTimeDiscretizationTemplate::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate& other) { - _time_unit=other._time_unit; + TimeHolder::copyTinyAttrFrom(other); if(_array && other._array) _array->copyStringInfoFrom(*other._array); } @@ -75,7 +75,7 @@ namespace MEDCoupling template std::size_t MEDCouplingTimeDiscretizationTemplate::getHeapMemorySizeWithoutChildren() const { - return _time_unit.capacity(); + return getTimeUnit().capacity(); } template @@ -99,9 +99,9 @@ namespace MEDCoupling bool MEDCouplingTimeDiscretizationTemplate::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *other, std::string& reason) const { std::ostringstream oss; oss.precision(15); - if(_time_unit!=other->_time_unit) + if(getTimeUnit()!=other->getTimeUnit()) { - oss << "Field discretizations differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !"; + oss << "Field discretizations differ : this time unit = \"" << getTimeUnit() << "\" and other time unit = \"" << other->getTimeUnit() << "\" !"; reason=oss.str(); return false; } @@ -176,7 +176,7 @@ namespace MEDCoupling } template - MEDCouplingTimeDiscretizationTemplate::MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate& other, bool deepCopy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance) + MEDCouplingTimeDiscretizationTemplate::MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate& other, bool deepCopy):TimeHolder(other),_time_tolerance(other._time_tolerance) { if(other._array) _array=other._array->performCopyOrIncrRef(deepCopy); @@ -304,7 +304,7 @@ namespace MEDCoupling { std::ostringstream stream; stream << REPR << " Time is defined by iteration=" << _tk.getIteration() << " order=" << _tk.getOrder() << " and time=" << _tk.getTimeValue() << "."; - stream << "\nTime unit is : \"" << this->_time_unit << "\""; + stream << "\nTime unit is : \"" << this->getTimeUnit() << "\""; return stream.str(); }