From: Anthony Geay Date: Wed, 17 May 2017 08:39:05 +0000 (+0200) Subject: Ready for the big factorization on MEDFile*Field1TS and MEDFile*MultiTS X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bf1a01d90a0cc5ce62eddec24454954171a07a09;p=tools%2Fmedcoupling.git Ready for the big factorization on MEDFile*Field1TS and MEDFile*MultiTS --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index ad1abe180..5134fc720 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -6833,16 +6833,25 @@ MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const return ret.retn(); } -void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto& arr) +MCAuto MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto& arr) { if(!f) throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !"); if(arr.isNull()) throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !"); - DataArrayDouble *arrOutC(dynamic_cast((DataArray*)arr)); - if(!arrOutC) - throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !"); + int t1,t2; + double t0(f->getTime(t1,t2)); + std::string tu(f->getTimeUnit()); + MCAuto arr2(DynamicCastSafe(arr)); + MCAuto ft(MEDCouplingFieldTemplate::New(*f)); + MCAuto ret(MEDCouplingFieldDouble::New(*ft)); + ret->setTime(t0,t1,t2); ret->setArray(arr2); ret->setTimeUnit(tu); + return ret.retn(); + /*DataArrayDouble *arrOutC(dynamic_cast((DataArray*)arr)); f->setArray(arrOutC); + MCAuto ret; + ret.takeRef(f); + return ret;*/ } /*! @@ -6944,8 +6953,8 @@ MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const { MCAuto arrOut; MCAuto ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -6977,8 +6986,8 @@ MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int m throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); MCAuto arrOut; MCAuto ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -7009,8 +7018,8 @@ MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, in throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !"); MCAuto arrOut; MCAuto ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -7037,8 +7046,8 @@ MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, { MCAuto arrOut; MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -7066,8 +7075,8 @@ MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, { MCAuto arrOut; MCAuto ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -7102,8 +7111,8 @@ MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, co throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); MCAuto arrOut; MCAuto ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -7457,7 +7466,7 @@ MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, co if(getFileName().empty()) throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !"); MCAuto arrOut; - MCAuto ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()); + MCAuto ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull())); MCAuto ret2(SetDataArrayDoubleInIntField(ret,arrOut)); return ret2.retn(); } @@ -9789,9 +9798,9 @@ MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, i if(!myF1TSC) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !"); MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase())); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -9821,9 +9830,9 @@ MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type if(!myF1TSC) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !"); MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase())); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -9842,8 +9851,8 @@ MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, con const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order)); MCAuto arrOut; MCAuto ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase())); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -9875,9 +9884,9 @@ MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField t if(!myF1TSC) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !"); MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase())); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -9907,9 +9916,9 @@ MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField t if(!myF1TSC) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !"); MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase())); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! @@ -9924,9 +9933,9 @@ MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type if(!myF1TSC) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !"); MCAuto arrOut; - MCAuto ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase()); - MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut); - return ret.retn(); + MCAuto ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase())); + MCAuto ret2(MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut)); + return ret2.retn(); } /*! diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 2c4473f3f..3c0a76491 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -920,7 +920,7 @@ namespace MEDCoupling MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; public: - MEDLOADER_EXPORT static void SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto& arr); + MEDLOADER_EXPORT static MCAuto SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto& arr); public: MEDLOADER_EXPORT MEDFileField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const; private: