From: Anthony Geay Date: Thu, 18 May 2017 06:07:07 +0000 (+0200) Subject: Facto MultiTS 4/5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ed91d846e534d515617a21d6c689600b572ef00e;p=tools%2Fmedcoupling.git Facto MultiTS 4/5 --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 71bc8fcb5..b1e2e2603 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -9095,15 +9095,6 @@ MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const return new MEDFileFieldMultiTS(*this); } -void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const -{ - if(!f1ts) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); - const MEDFileField1TS *f1tsC=dynamic_cast(f1ts); - if(!f1tsC) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !"); -} - /*! * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied * following the given input policy. @@ -9133,32 +9124,6 @@ MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) c return ret.retn(); } -/*! - * Returns a new MEDFileField1TS holding data of a given time step of \a this field. - * \param [in] pos - a time step id. - * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to - * delete this field using decrRef() as it is no more needed. - * \throw If \a pos is not a valid time step id. - */ -MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const -{ - const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos); - if(!item) - { - std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !"; - throw INTERP_KERNEL::Exception(oss.str()); - } - const MEDFileField1TSWithoutSDA *itemC=dynamic_cast(item); - if(itemC) - { - MCAuto ret=MEDFileField1TS::New(*itemC,false); - ret->shallowCpyGlobs(*this); - return ret.retn(); - } - std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !"; - throw INTERP_KERNEL::Exception(oss.str()); -} - MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) try:MEDFileTemplateFieldMultiTS(fid,loadAll,ms) { @@ -9182,21 +9147,6 @@ std::vector< std::vector > MEDFileFieldMultiTS::getFieldSplit return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs); } -DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const -{ - return static_cast(contentNotNull()->getUndergroundDataArray(iteration,order)); -} - -DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const -{ - return static_cast(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries)); -} - -MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const -{ - return MEDFileFieldMultiTS::New(); -} - //= MEDFileAnyTypeFieldMultiTSIterator MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0) @@ -9262,41 +9212,6 @@ MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const return new MEDFileIntFieldMultiTS(*this); } -void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const -{ - if(!f1ts) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); - const MEDFileIntField1TS *f1tsC=dynamic_cast(f1ts); - if(!f1tsC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !"); -} - -/*! - * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field. - * \param [in] pos - a time step id. - * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to - * delete this field using decrRef() as it is no more needed. - * \throw If \a pos is not a valid time step id. - */ -MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const -{ - const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos); - if(!item) - { - std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !"; - throw INTERP_KERNEL::Exception(oss.str()); - } - const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast(item); - if(itemC) - { - MCAuto ret=MEDFileIntField1TS::New(*itemC,false); - ret->shallowCpyGlobs(*this); - return ret.retn(); - } - std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !"; - throw INTERP_KERNEL::Exception(oss.str()); -} - MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS(other,shallowCopyOfContent) { } @@ -9315,16 +9230,6 @@ try:MEDFileTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) catch(INTERP_KERNEL::Exception& e) { throw e; } -DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const -{ - return static_cast(contentNotNull()->getUndergroundDataArray(iteration,order)); -} - -MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const -{ - return MEDFileIntFieldMultiTS::New(); -} - //= MEDFileFields MEDFileFields *MEDFileFields::New() diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 0f75439df..e5ca288d9 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -1207,6 +1207,12 @@ namespace MEDCoupling // MEDLOADER_EXPORT void appendFieldNoProfileSBT(const typename Traits::FieldType *field); MEDLOADER_EXPORT void appendFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile); + // + MEDLOADER_EXPORT typename MLFieldTraits::F1TSType *getTimeStepAtPos(int pos) const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArray(int iteration, int order) const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT typename MLFieldTraits::FMTSType *buildNewEmptyImpl() const; + MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const; protected: const typename MLFieldTraits::FMTSWSDAType *contentNotNull() const; typename MLFieldTraits::FMTSWSDAType *contentNotNull(); @@ -1228,18 +1234,11 @@ namespace MEDCoupling friend class MEDFileTemplateFieldMultiTS; public: MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const; - MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const; MEDLOADER_EXPORT MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const; // - MEDLOADER_EXPORT MEDFileField1TS *getTimeStepAtPos(int pos) const; - MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const; - MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const; - // MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; - MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArray(int iteration, int order) const; - MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT MEDFileFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } public: - MEDLOADER_EXPORT MEDFileFieldMultiTS *buildNewEmpty() const; private: ~MEDFileFieldMultiTS() { } MEDFileFieldMultiTS() { } @@ -1256,13 +1255,8 @@ namespace MEDCoupling friend class MEDFileTemplateFieldMultiTS; public: MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const; - MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const; - MEDLOADER_EXPORT MEDFileIntField1TS *getTimeStepAtPos(int pos) const; MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const; - // - MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArray(int iteration, int order) const; - public: - MEDLOADER_EXPORT MEDFileIntFieldMultiTS *buildNewEmpty() const; + MEDLOADER_EXPORT MEDFileIntFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } private: ~MEDFileIntFieldMultiTS() { } MEDFileIntFieldMultiTS() { } diff --git a/src/MEDLoader/MEDFileField.txx b/src/MEDLoader/MEDFileField.txx index 7f21da526..50a9d6756 100644 --- a/src/MEDLoader/MEDFileField.txx +++ b/src/MEDLoader/MEDFileField.txx @@ -1120,6 +1120,82 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !"); return ret; } + + /*! + * Returns a new MEDFileField1TS holding data of a given time step of \a this field. + * \param [in] pos - a time step id. + * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to + * delete this field using decrRef() as it is no more needed. + * \throw If \a pos is not a valid time step id. + */ + template + typename MLFieldTraits::F1TSType *MEDFileTemplateFieldMultiTS::getTimeStepAtPos(int pos) const + { + const MEDFileAnyTypeField1TSWithoutSDA *item(contentNotNullBase()->getTimeStepAtPos2(pos)); + if(!item) + { + std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + const typename MLFieldTraits::F1TSWSDAType *itemC=dynamic_cast::F1TSWSDAType *>(item); + if(itemC) + { + MCAuto::F1TSType> ret(MLFieldTraits::F1TSType::New(*itemC,false)); + ret->shallowCpyGlobs(*this); + return ret.retn(); + } + std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + + template + typename Traits::ArrayType *MEDFileTemplateFieldMultiTS::getUndergroundDataArray(int iteration, int order) const + { + DataArray *ret(contentNotNull()->getUndergroundDataArray(iteration,order)); + if(!ret) + return NULL; + typename Traits::ArrayType *ret2(dynamic_cast::ArrayType *>(ret)); + if(!ret2) + { + std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS::getUndergroundDataArray : invalid type of data dectected ! Expecting " << MLFieldTraits::F1TSWSDAType::TYPE_STR; + throw INTERP_KERNEL::Exception(oss.str()); + } + return ret2; + } + + template + typename Traits::ArrayType *MEDFileTemplateFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const + { + DataArray *ret(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries)); + if(!ret) + return NULL; + typename Traits::ArrayType *ret2(dynamic_cast::ArrayType *>(ret)); + if(!ret2) + { + std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS::getUndergroundDataArrayExt : invalid type of data dectected ! Expecting " << MLFieldTraits::F1TSWSDAType::TYPE_STR; + throw INTERP_KERNEL::Exception(oss.str()); + } + return ret2; + } + + template + typename MLFieldTraits::FMTSType *MEDFileTemplateFieldMultiTS::buildNewEmptyImpl() const + { + return MLFieldTraits::FMTSType::New(); + } + + template + void MEDFileTemplateFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const + { + if(!f1ts) + throw INTERP_KERNEL::Exception("MEDFileTemplateFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); + const typename MLFieldTraits::F1TSType *f1tsC=dynamic_cast::F1TSType *>(f1ts); + if(!f1tsC) + { + std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS::checkCoherencyOfType : the input field1TS is not a " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " type !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + } } #endif