From: Anthony Geay Date: Fri, 25 Sep 2020 06:12:54 +0000 (+0200) Subject: Ready to test X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=562bb55b3ac51e4f97bf17fc2c15974c6f9e50c4;p=tools%2Fmedcoupling.git Ready to test --- diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx index 4c513a8bb..671ad54f3 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx @@ -65,6 +65,11 @@ MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::NewWithoutCheck(const MEDCou return new MEDCouplingFieldTemplate(f,false); } +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::NewWithoutCheck(const MEDCouplingFieldInt64& f) +{ + return new MEDCouplingFieldTemplate(f,false); +} + bool MEDCouplingFieldTemplate::isEqualIfNotWhy(const MEDCouplingFieldTemplate *other, double meshPrec, std::string& reason) const { return isEqualIfNotWhyProtected(other,meshPrec,reason); diff --git a/src/MEDLoader/MEDFileField1TS.cxx b/src/MEDLoader/MEDFileField1TS.cxx index fd0969226..bc6e48e11 100644 --- a/src/MEDLoader/MEDFileField1TS.cxx +++ b/src/MEDLoader/MEDFileField1TS.cxx @@ -44,6 +44,7 @@ template class MEDCoupling::MEDFileNDTemplateField1TS; const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64"; const char MEDFileInt32Field1TSWithoutSDA::TYPE_STR[]="INT32"; +const char MEDFileInt64Field1TSWithoutSDA::TYPE_STR[]="INT64"; const char MEDFileFloatField1TSWithoutSDA::TYPE_STR[]="FLOAT32"; //= MEDFileAnyTypeField1TSWithoutSDA @@ -1550,7 +1551,7 @@ DataArray *MEDFileInt32Field1TSWithoutSDA::getUndergroundDataArrayExt(std::vecto * \throw If no field values are available. * \sa getUndergroundDataArray() */ -DataArrayInt *MEDFileInt32Field1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const +DataArrayInt32 *MEDFileInt32Field1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const { if(_field_per_mesh.size()!=1) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !"); @@ -1575,6 +1576,91 @@ MEDFileInt32Field1TSWithoutSDA *MEDFileInt32Field1TSWithoutSDA::deepCopy() const return ret.retn(); } +//= MEDFileInt64Field1TSWithoutSDA + +MEDFileInt64Field1TSWithoutSDA *MEDFileInt64Field1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos) +{ + return new MEDFileInt64Field1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos); +} + +MEDFileInt64Field1TSWithoutSDA::MEDFileInt64Field1TSWithoutSDA() +{ +} + +MEDFileInt64Field1TSWithoutSDA::MEDFileInt64Field1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, + const std::vector& infos):MEDFileField1TSNDTemplateWithoutSDA(fieldName,meshName,csit,iteration,order,infos) +{ + DataArrayInt64 *arr(getOrCreateAndGetArrayTemplate()); + arr->setInfoAndChangeNbOfCompo(infos); +} + +const char *MEDFileInt64Field1TSWithoutSDA::getTypeStr() const +{ + return TYPE_STR; +} + +/*! + * Returns a pointer to the underground DataArrayIdType instance and a + * sequence describing parameters of a support of each part of \a this field. The + * caller should not decrRef() the returned DataArrayIdType. This method allows for a + * direct access to the field values. This method is intended for the field lying on one + * mesh only. + * \param [in,out] entries - the sequence describing parameters of a support of each + * part of \a this field. Each item of this sequence consists of two parts. The + * first part describes a type of mesh entity and an id of discretization of a + * current field part. The second part describes a range of values [begin,end) + * within the returned array relating to the current field part. + * \return DataArrayIdType * - the pointer to the field values array. + * \throw If the number of underlying meshes is not equal to 1. + * \throw If no field values are available. + * \sa getUndergroundDataArray() + */ +DataArray *MEDFileInt64Field1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const +{ + return getUndergroundDataArrayIntExt(entries); +} + +/*! + * Returns a pointer to the underground DataArrayInt instance and a + * sequence describing parameters of a support of each part of \a this field. The + * caller should not decrRef() the returned DataArrayIdType. This method allows for a + * direct access to the field values. This method is intended for the field lying on one + * mesh only. + * \param [in,out] entries - the sequence describing parameters of a support of each + * part of \a this field. Each item of this sequence consists of two parts. The + * first part describes a type of mesh entity and an id of discretization of a + * current field part. The second part describes a range of values [begin,end) + * within the returned array relating to the current field part. + * \return DataArrayInt * - the pointer to the field values array. + * \throw If the number of underlying meshes is not equal to 1. + * \throw If no field values are available. + * \sa getUndergroundDataArray() + */ +DataArrayInt64 *MEDFileInt64Field1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const +{ + if(_field_per_mesh.size()!=1) + throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !"); + if(_field_per_mesh[0]==0) + throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !"); + _field_per_mesh[0]->getUndergroundDataArrayExt(entries); + return getUndergroundDataArrayTemplate(); +} + +MEDFileInt64Field1TSWithoutSDA *MEDFileInt64Field1TSWithoutSDA::shallowCpy() const +{ + MCAuto ret(new MEDFileInt64Field1TSWithoutSDA(*this)); + ret->deepCpyLeavesFrom(*this); + return ret.retn(); +} + +MEDFileInt64Field1TSWithoutSDA *MEDFileInt64Field1TSWithoutSDA::deepCopy() const +{ + MCAuto ret(shallowCpy()); + if(_arr.isNotNull()) + ret->_arr=_arr->deepCopy(); + return ret.retn(); +} + //= MEDFileFloatField1TSWithoutSDA MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos) @@ -1832,6 +1918,12 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDF ret->_content=c; c->incrRef(); return ret.retn(); } + if(dynamic_cast(c)) + { + MCAuto ret(MEDFileInt64Field1TS::New()); + ret->_content=c; c->incrRef(); + return ret.retn(); + } if(dynamic_cast(c)) { MCAuto ret(MEDFileFloatField1TS::New()); @@ -2639,3 +2731,19 @@ MCAuto MEDFileInt32Field1TS::ConvertFieldIntToFieldDoubl ret->setTime(t0,t1,t2); ret->setTimeUnit(tu); return ret; } + +//= MEDFileInt64Field1TS + +MCAuto MEDFileInt64Field1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt64 *f) +{ + if(!f) + throw INTERP_KERNEL::Exception("MEDFileInt64Field1TS::ConvertFieldIntToFieldDouble : null input field !"); + int t1,t2; + double t0(f->getTime(t1,t2)); + std::string tu(f->getTimeUnit()); + MCAuto ft(MEDCouplingFieldTemplate::New(*f)); + MCAuto ret(MEDCouplingFieldDouble::New(*ft)); + ret->setTime(t0,t1,t2); ret->setTimeUnit(tu); + return ret; +} + diff --git a/src/MEDLoader/MEDFileField1TS.hxx b/src/MEDLoader/MEDFileField1TS.hxx index ad610783c..91efa14a6 100644 --- a/src/MEDLoader/MEDFileField1TS.hxx +++ b/src/MEDLoader/MEDFileField1TS.hxx @@ -212,7 +212,7 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileInt32Field1TSWithoutSDA *shallowCpy() const; MEDLOADER_EXPORT const char *getTypeStr() const; MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; - MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT DataArrayInt32 *getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const; protected: MEDFileInt32Field1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); public: @@ -232,7 +232,7 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileInt64Field1TSWithoutSDA *shallowCpy() const; MEDLOADER_EXPORT const char *getTypeStr() const; MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; - MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT DataArrayInt64 *getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const; protected: MEDFileInt64Field1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); public: @@ -476,7 +476,7 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileInt64Field1TS *shallowCpy() const { return new MEDFileInt64Field1TS(*this); } MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileInt64Field1TS"); } public: - MEDLOADER_EXPORT static MCAuto ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt32 *f); + MEDLOADER_EXPORT static MCAuto ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt64 *f); private: med_field_type getMEDFileFieldType() const { return MED_INT64; } private: diff --git a/src/MEDLoader/MEDFileFieldMultiTS.cxx b/src/MEDLoader/MEDFileFieldMultiTS.cxx index 6ad718de6..672f1a5c3 100644 --- a/src/MEDLoader/MEDFileFieldMultiTS.cxx +++ b/src/MEDLoader/MEDFileFieldMultiTS.cxx @@ -31,15 +31,19 @@ using namespace MEDCoupling; -template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; template class MEDCoupling::MEDFileTemplateFieldMultiTSWithoutSDA; -template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; -template class MEDCoupling::MEDFileTemplateFieldMultiTS; +template class MEDCoupling::MEDFileTemplateFieldMultiTS; +template class MEDCoupling::MEDFileTemplateFieldMultiTS; template class MEDCoupling::MEDFileTemplateFieldMultiTS; template class MEDCoupling::MEDFileTemplateFieldMultiTS; -template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; extern INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type geotype); @@ -1285,6 +1289,12 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromCont ret->_content=c; c->incrRef(); return ret.retn(); } + if(dynamic_cast(c)) + { + MCAuto ret(MEDFileInt64FieldMultiTS::New()); + ret->_content=c; c->incrRef(); + return ret.retn(); + } if(dynamic_cast(c)) { MCAuto ret(MEDFileFloatFieldMultiTS::New()); @@ -2057,6 +2067,7 @@ MCAuto MEDFileAnyTypeFieldMultiTS::Aggregate(const s std::size_t sz(fmtss.size()); std::vector fmtss1; std::vector fmtss2; + std::vector fmtss3; for(std::vector::const_iterator it=fmtss.begin();it!=fmtss.end();it++) { if(!(*it)) @@ -2073,14 +2084,22 @@ MCAuto MEDFileAnyTypeFieldMultiTS::Aggregate(const s fmtss2.push_back(elt2); continue; } + const MEDFileInt64FieldMultiTS *elt3(dynamic_cast(*it)); + if(elt3) + { + fmtss3.push_back(elt3); + continue; + } throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !"); } - if(fmtss1.size()!=sz && fmtss2.size()!=sz) + if(fmtss1.size()!=sz && fmtss2.size()!=sz && fmtss3.size()!=sz) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !"); if(fmtss1.size()==sz) return AggregateHelperFMTS(fmtss1,dts); if(fmtss2.size()!=sz) - return AggregateHelperFMTS(fmtss2,dts); + return AggregateHelperFMTS(fmtss2,dts); + if(fmtss3.size()!=sz) + return AggregateHelperFMTS(fmtss3,dts); throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !"); }