From: Anthony Geay Date: Thu, 18 May 2017 09:39:27 +0000 (+0200) Subject: Finished X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fagy%2FNoFieldDoublePriority;p=tools%2Fmedcoupling.git Finished --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 25a87324b..cb09988db 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -45,10 +45,20 @@ using namespace MEDCoupling; template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA; template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA; template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA; +template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA; +template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTSWithoutSDA; template class MEDCoupling::MEDFileTemplateField1TS; +template class MEDCoupling::MEDFileTemplateField1TS; template class MEDCoupling::MEDFileTemplateField1TS; +template class MEDCoupling::MEDFileNDTemplateField1TS; +template class MEDCoupling::MEDFileNDTemplateField1TS; template class MEDCoupling::MEDFileTemplateFieldMultiTS; +template class MEDCoupling::MEDFileTemplateFieldMultiTS; template class MEDCoupling::MEDFileTemplateFieldMultiTS; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; +template class MEDCoupling::MEDFileNDTemplateFieldMultiTS; const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64"; const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32"; @@ -5779,7 +5789,7 @@ MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA() } MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, - const std::vector& infos):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) + const std::vector& infos):MEDFileField1TSNDTemplateWithoutSDA(fieldName,meshName,csit,iteration,order,infos) { DataArrayInt *arr(getOrCreateAndGetArrayTemplate()); arr->setInfoAndChangeNbOfCompo(infos); @@ -5790,19 +5800,6 @@ const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const return TYPE_STR; } -MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const -{ - MCAuto ret(new MEDFileField1TSWithoutSDA); - ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this); - ret->deepCpyLeavesFrom(*this); - if(_arr.isNotNull()) - { - MCAuto arr2(_arr->convertToDblArr()); - ret->setArray(arr2); - } - return ret.retn(); -} - /*! * Returns a pointer to the underground DataArrayInt instance and a * sequence describing parameters of a support of each part of \a this field. The @@ -5877,7 +5874,7 @@ MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA() } MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, - const std::vector& infos):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) + const std::vector& infos):MEDFileField1TSNDTemplateWithoutSDA(fieldName,meshName,csit,iteration,order,infos) { DataArrayFloat *arr(getOrCreateAndGetArrayTemplate()); arr->setInfoAndChangeNbOfCompo(infos); @@ -5888,19 +5885,6 @@ const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const return TYPE_STR; } -MEDFileField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::convertToDouble() const -{ - MCAuto ret(new MEDFileField1TSWithoutSDA); - ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this); - ret->deepCpyLeavesFrom(*this); - if(_arr.isNotNull()) - { - MCAuto arr2(_arr->convertToDblArr()); - ret->setArray(arr2); - } - return ret.retn(); -} - /*! * Returns a pointer to the underground DataArrayFloat instance and a * sequence describing parameters of a support of each part of \a this field. The @@ -6056,7 +6040,7 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -6195,9 +6179,14 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector()); break; } + case MED_NODE://6432 + { + ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector()); + break; + } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -6880,111 +6869,21 @@ std::vector< std::vector > MEDFileField1TS::getFieldSplitedBy //= MEDFileIntField1TS -MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,fieldName,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -/*! - * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied. - * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. - * - * \warning this is a shallow copy constructor - */ -MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileTemplateField1TS(other,shallowCopyOfContent) -{ -} - -MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const -{ - return new MEDFileIntField1TS(*this); -} - -/*! - * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied - * following the given input policy. - * - * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) - * By default (true) the globals are deeply copied. - * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field. - */ -MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const -{ - MCAuto ret; - const MEDFileAnyTypeField1TSWithoutSDA *content(_content); - if(content) - { - const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast(content); - if(!contc) - throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !"); - MCAuto newc(contc->convertToDouble()); - ret=static_cast(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc)); - } - else - ret=MEDFileField1TS::New(); - if(isDeepCpyGlobs) - ret->deepCpyGlobs(*this); - else - ret->shallowCpyGlobs(*this); - return ret.retn(); -} - MCAuto MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f) { if(!f) throw INTERP_KERNEL::Exception("MEDFileIntField1TS::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->setTime(t0,t1,t2); ret->setTimeUnit(tu); return ret; } //= MEDFileFloatField1TS -MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,fieldName,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileFloatField1TS::MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) -{ -} -catch(INTERP_KERNEL::Exception& e) -{ throw e; } - -MEDFileFloatField1TS *MEDFileFloatField1TS::shallowCpy() const -{ - return new MEDFileFloatField1TS(*this); -} - //= MEDFileFloatField1TS //= MEDFileAnyTypeFieldMultiTSWithoutSDA @@ -7447,8 +7346,13 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos); break; } + case MED_NODE://6432 + { + _time_steps[i]=MEDFileFloatField1TSWithoutSDA::New(getName(),getMeshName(),i+1,numdt,numo,_infos); + break; + } default: - throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !"); + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !"); } if(loadAll) _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities); @@ -8092,9 +7996,14 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); break; } + case MED_NODE://6432 + { + ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities); + break; + } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -8123,9 +8032,14 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); break; } + case MED_NODE://6432 + { + ret=new MEDFileFloatFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0); + break; + } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -8172,28 +8086,6 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -//= MEDFileIntFieldMultiTSWithoutSDA - -MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const -{ - MCAuto ret(new MEDFileFieldMultiTSWithoutSDA); - ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this); - int i=0; - for(std::vector< MCAuto >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++) - { - const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it); - if(eltToConv) - { - const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast(eltToConv); - if(!eltToConvC) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !"); - MCAuto elt=eltToConvC->convertToDouble(); - ret->setIteration(i,elt); - } - } - return ret.retn(); -} - //= MEDFileAnyTypeFieldMultiTS /*! @@ -9060,35 +8952,6 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() //= MEDFileIntFieldMultiTS -/*! - * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied - * following the given input policy. - * - * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) - * By default (true) the globals are deeply copied. - * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field. - */ -MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const -{ - MCAuto ret; - const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content); - if(content) - { - const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast(content); - if(!contc) - throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !"); - MCAuto newc(contc->convertToDouble()); - ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc)); - } - else - ret=MEDFileFieldMultiTS::New(); - if(isDeepCpyGlobs) - ret->deepCpyGlobs(*this); - else - ret->shallowCpyGlobs(*this); - return ret.retn(); -} - //= MEDFileFields MEDFileFields *MEDFileFields::New() @@ -9324,9 +9187,14 @@ try:MEDFileFieldGlobsReal(fid) _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities); break; } + case MED_NODE://6432 + { + _fields[i]=MEDFileFloatFieldMultiTSWithoutSDA::New(fid,fieldName,meshName,typcha,infos,nbOfStep,dtunit,loadAll,ms,entities); + break; + } default: { - std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index d670fee4f..c39bfdafd 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -688,7 +688,7 @@ namespace MEDCoupling { protected: MEDFileField1TSTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order):MEDFileAnyTypeField1TSWithoutSDA(fieldName,meshName,csit,iteration,order) { } - MEDFileField1TSTemplateWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA() { } + MEDFileField1TSTemplateWithoutSDA() { } public: MEDLOADER_EXPORT void setArray(DataArray *arr); MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const; @@ -726,10 +726,20 @@ namespace MEDCoupling static const char TYPE_STR[]; }; + template + class MEDFileField1TSNDTemplateWithoutSDA : public MEDFileField1TSTemplateWithoutSDA + { + public: + MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const; + protected: + MEDFileField1TSNDTemplateWithoutSDA() { } + MEDFileField1TSNDTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) { } + }; + /*! * SDA is for Shared Data Arrays such as profiles. */ - class MEDFileIntField1TSWithoutSDA : public MEDFileField1TSTemplateWithoutSDA + class MEDFileIntField1TSWithoutSDA : public MEDFileField1TSNDTemplateWithoutSDA { public: MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA(); @@ -739,7 +749,6 @@ namespace MEDCoupling 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 MEDFileField1TSWithoutSDA *convertToDouble() const; protected: MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); public: @@ -749,7 +758,7 @@ namespace MEDCoupling /*! * SDA is for Shared Data Arrays such as profiles. */ - class MEDFileFloatField1TSWithoutSDA : public MEDFileField1TSTemplateWithoutSDA + class MEDFileFloatField1TSWithoutSDA : public MEDFileField1TSNDTemplateWithoutSDA { public: MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA(); @@ -759,7 +768,6 @@ namespace MEDCoupling MEDLOADER_EXPORT const char *getTypeStr() const; MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; MEDLOADER_EXPORT DataArrayFloat *getUndergroundDataArrayFloatExt(std::vector< std::pair,std::pair > >& entries) const; - MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const; protected: MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); public: @@ -931,12 +939,25 @@ namespace MEDCoupling MEDFileField1TS() { } }; - class MEDFileIntField1TS : public MEDFileTemplateField1TS + template + class MEDFileNDTemplateField1TS : public MEDFileTemplateField1TS { - friend class MEDFileTemplateField1TS; public: MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const; - MEDLOADER_EXPORT MEDFileIntField1TS *shallowCpy() const; + protected: + ~MEDFileNDTemplateField1TS() { } + MEDFileNDTemplateField1TS() { } + MEDFileNDTemplateField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,loadAll,ms) { } + MEDFileNDTemplateField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,fieldName,loadAll,ms) { } + MEDFileNDTemplateField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + MEDFileNDTemplateField1TS(const typename MLFieldTraits::F1TSWSDAType& other, bool shallowCopyOfContent):MEDFileTemplateField1TS(other,shallowCopyOfContent) { } + }; + + class MEDFileIntField1TS : public MEDFileNDTemplateField1TS + { + friend class MEDFileTemplateField1TS; + public: + MEDLOADER_EXPORT MEDFileIntField1TS *shallowCpy() const { return new MEDFileIntField1TS(*this); } public: MEDLOADER_EXPORT static MCAuto ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f); private: @@ -944,25 +965,37 @@ namespace MEDCoupling private: ~MEDFileIntField1TS() { } MEDFileIntField1TS() { } - MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); - MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); - MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); - MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,loadAll,ms) { } + MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,loadAll,ms) { } + MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + /*! + * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied. + * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. + * + * \warning this is a shallow copy constructor + */ + MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateField1TS(other,shallowCopyOfContent) { } }; - class MEDFileFloatField1TS : public MEDFileTemplateField1TS + class MEDFileFloatField1TS : public MEDFileNDTemplateField1TS { friend class MEDFileTemplateField1TS; private: med_field_type getMEDFileFieldType() const { return MED_INT32; }//6432 - MEDLOADER_EXPORT MEDFileFloatField1TS *shallowCpy() const; + MEDLOADER_EXPORT MEDFileFloatField1TS *shallowCpy() const { return new MEDFileFloatField1TS(*this); } private: ~MEDFileFloatField1TS() { } MEDFileFloatField1TS() { } - MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); - MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); - MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); - MEDFileFloatField1TS(const MEDFileFloatField1TSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,loadAll,ms) { } + MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,loadAll,ms) { } + MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + /*! + * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied. + * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. + * + * \warning this is a shallow copy constructor + */ + MEDFileFloatField1TS(const MEDFileFloatField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateField1TS(other,shallowCopyOfContent) { } }; class MEDFileAnyTypeFieldMultiTSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope @@ -1082,31 +1115,41 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA() { } }; - class MEDFileIntFieldMultiTSWithoutSDA : public MEDFileTemplateFieldMultiTSWithoutSDA + template + class MEDFileNDTemplateFieldMultiTSWithoutSDA : public MEDFileTemplateFieldMultiTSWithoutSDA { - friend class MEDFileTemplateFieldMultiTSWithoutSDA; public: - MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA *convertToDouble() const; + protected: + MEDFileNDTemplateFieldMultiTSWithoutSDA() { } + MEDFileNDTemplateFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDFileNDTemplateFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileNDTemplateFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + }; + + class MEDFileIntFieldMultiTSWithoutSDA : public MEDFileNDTemplateFieldMultiTSWithoutSDA + { + friend class MEDFileTemplateFieldMultiTSWithoutSDA; + public: + MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileIntFieldMultiTSWithoutSDA(*this); } protected: - MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } - MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } med_field_type getMEDFileFieldType() const { return MED_INT32; } public: MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA() { } }; - class MEDFileFloatFieldMultiTSWithoutSDA : public MEDFileTemplateFieldMultiTSWithoutSDA + class MEDFileFloatFieldMultiTSWithoutSDA : public MEDFileNDTemplateFieldMultiTSWithoutSDA { - friend class MEDFileTemplateFieldMultiTSWithoutSDA; + friend class MEDFileTemplateFieldMultiTSWithoutSDA; public: - MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } - MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA *convertToDouble() const; + MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileFloatFieldMultiTSWithoutSDA(*this); } protected: - MEDFileFloatFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } - MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + MEDFileFloatFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } med_field_type getMEDFileFieldType() const { return MED_INT32; }//6432 public: MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA() { } @@ -1274,6 +1317,8 @@ namespace MEDCoupling template class MEDFileNDTemplateFieldMultiTS : public MEDFileTemplateFieldMultiTS { + public: + MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const; protected: ~MEDFileNDTemplateFieldMultiTS() { } MEDFileNDTemplateFieldMultiTS() { } @@ -1290,7 +1335,6 @@ namespace MEDCoupling friend class MEDFileTemplateFieldMultiTS; public: MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const { return new MEDFileIntFieldMultiTS(*this); } - MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const; MEDLOADER_EXPORT MEDFileIntFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } private: ~MEDFileIntFieldMultiTS() { } diff --git a/src/MEDLoader/MEDFileField.txx b/src/MEDLoader/MEDFileField.txx index 6bcb4271d..e3ba8eeb8 100644 --- a/src/MEDLoader/MEDFileField.txx +++ b/src/MEDLoader/MEDFileField.txx @@ -199,6 +199,24 @@ namespace MEDCoupling } } + /////////////////////////////////////////////////////// + + template + MEDFileField1TSWithoutSDA *MEDFileField1TSNDTemplateWithoutSDA::convertToDouble() const + { + MCAuto ret(new MEDFileField1TSWithoutSDA); + ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this); + ret->deepCpyLeavesFrom(*this); + if(this->_arr.isNotNull()) + { + MCAuto arr2(this->_arr->convertToDblArr()); + ret->setArray(arr2); + } + return ret.retn(); + } + + /////////////////////////////////////////////////////// + template MEDFileTemplateField1TS::MEDFileTemplateField1TS() { @@ -704,6 +722,103 @@ namespace MEDCoupling } return ret.retn(); } + + ////////////////////////// + + /*! + * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied + * following the given input policy. + * + * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) + * By default (true) the globals are deeply copied. + * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field. + */ + template + MEDFileField1TS *MEDFileNDTemplateField1TS::convertToDouble(bool isDeepCpyGlobs) const + { + MCAuto ret; + const MEDFileAnyTypeField1TSWithoutSDA *content(this->_content); + if(content) + { + const typename MLFieldTraits::F1TSWSDAType *contc(dynamic_cast::F1TSWSDAType *>(content)); + if(!contc) + { + std::ostringstream oss; oss << "MEDFileNDTemplateField1TS::convertToDouble : the content inside this is not " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " ! This is incoherent !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + MCAuto newc(contc->convertToDouble()); + ret=static_cast(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc)); + } + else + ret=MEDFileField1TS::New(); + if(isDeepCpyGlobs) + ret->deepCpyGlobs(*this); + else + ret->shallowCpyGlobs(*this); + return ret.retn(); + } + + ////////////////////////// + + template + typename MLFieldTraits::FMTSWSDAType *MEDFileTemplateFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) + { + return new typename MLFieldTraits::FMTSWSDAType(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities); + } + + template + void MEDFileTemplateFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const + { + if(!f1ts) + throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); + const typename MLFieldTraits::F1TSWSDAType *f1tsC(dynamic_cast::F1TSWSDAType *>(f1ts)); + if(!f1tsC) + { + std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " type !"; + throw INTERP_KERNEL::Exception(oss.str()); + } + } + + template + const char *MEDFileTemplateFieldMultiTSWithoutSDA::getTypeStr() const + { + return MLFieldTraits::F1TSWSDAType::TYPE_STR; + } + + template + MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileTemplateFieldMultiTSWithoutSDA::createNew() const + { + return new typename MLFieldTraits::FMTSWSDAType; + } + + template + MEDFileAnyTypeField1TSWithoutSDA *MEDFileTemplateFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const + { + return new typename MLFieldTraits::F1TSWSDAType; + } + + ////////////////////////// + + template + MEDFileFieldMultiTSWithoutSDA *MEDFileNDTemplateFieldMultiTSWithoutSDA::convertToDouble() const + { + MCAuto ret(new MEDFileFieldMultiTSWithoutSDA); + ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this); + int i=0; + for(std::vector< MCAuto >::const_iterator it=this->_time_steps.begin();it!=this->_time_steps.end();it++,i++) + { + const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it); + if(eltToConv) + { + const typename MLFieldTraits::F1TSWSDAType *eltToConvC(dynamic_cast::F1TSWSDAType *>(eltToConv)); + if(!eltToConvC) + throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !"); + MCAuto elt(eltToConvC->convertToDouble()); + ret->setIteration(i,elt); + } + } + return ret.retn(); + } ////////////////////////// @@ -1196,42 +1311,37 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception(oss.str()); } } - - template - typename MLFieldTraits::FMTSWSDAType *MEDFileTemplateFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) - { - return new typename MLFieldTraits::FMTSWSDAType(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities); - } - + + ////////////////////////// + + /*! + * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied + * following the given input policy. + * + * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations) + * By default (true) the globals are deeply copied. + * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field. + */ template - void MEDFileTemplateFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const + MEDFileFieldMultiTS *MEDFileNDTemplateFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const { - if(!f1ts) - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !"); - const typename MLFieldTraits::F1TSWSDAType *f1tsC(dynamic_cast::F1TSWSDAType *>(f1ts)); - if(!f1tsC) + MCAuto ret; + const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(this->_content); + if(content) { - std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a " << MLFieldTraits::F1TSWSDAType::TYPE_STR << " type !"; - throw INTERP_KERNEL::Exception(oss.str()); + const typename MLFieldTraits::FMTSWSDAType *contc=dynamic_cast::FMTSWSDAType *>(content); + if(!contc) + throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !"); + MCAuto newc(contc->convertToDouble()); + ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc)); } - } - - template - const char *MEDFileTemplateFieldMultiTSWithoutSDA::getTypeStr() const - { - return MLFieldTraits::F1TSWSDAType::TYPE_STR; - } - - template - MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileTemplateFieldMultiTSWithoutSDA::createNew() const - { - return new typename MLFieldTraits::FMTSWSDAType; - } - - template - MEDFileAnyTypeField1TSWithoutSDA *MEDFileTemplateFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const - { - return new typename MLFieldTraits::F1TSWSDAType; + else + ret=MEDFileFieldMultiTS::New(); + if(isDeepCpyGlobs) + ret->deepCpyGlobs(*this); + else + ret->shallowCpyGlobs(*this); + return ret.retn(); } } diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 65365882a..d2498bbe3 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -189,6 +189,12 @@ def MEDCouplingMEDFileIntField1TSnew(cls,*args): def MEDCouplingMEDFileIntFieldMultiTSnew(cls,*args): import _MEDLoader return _MEDLoader.MEDFileIntFieldMultiTS____new___(cls,args) +def MEDCouplingMEDFileFloatField1TSnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDFileFloatField1TS____new___(cls,args) +def MEDCouplingMEDFileFloatFieldMultiTSnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDFileFloatFieldMultiTS____new___(cls,args) def MEDCouplingMEDFileParametersnew(cls,*args): import _MEDLoader return _MEDLoader.MEDFileParameters____new___(cls,args) @@ -217,6 +223,10 @@ MEDFileIntField1TS.__new__=classmethod(MEDCouplingMEDFileIntField1TSnew) del MEDCouplingMEDFileIntField1TSnew MEDFileIntFieldMultiTS.__new__=classmethod(MEDCouplingMEDFileIntFieldMultiTSnew) del MEDCouplingMEDFileIntFieldMultiTSnew +MEDFileFloatField1TS.__new__=classmethod(MEDCouplingMEDFileFloatField1TSnew) +del MEDCouplingMEDFileFloatField1TSnew +MEDFileFloatFieldMultiTS.__new__=classmethod(MEDCouplingMEDFileFloatFieldMultiTSnew) +del MEDCouplingMEDFileFloatFieldMultiTSnew MEDFileParameters.__new__=classmethod(MEDCouplingMEDFileParametersnew) del MEDCouplingMEDFileParametersnew %} diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index f44959c41..219e502e3 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -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) %module MEDLoader @@ -182,6 +182,7 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileFieldMultiTS::getFieldAtLevelOld; %newobject MEDCoupling::MEDFileFieldMultiTS::getUndergroundDataArray; %newobject MEDCoupling::MEDFileFieldMultiTS::convertToInt; + %newobject MEDCoupling::MEDFileIntFieldMultiTS::New; %newobject MEDCoupling::MEDFileIntFieldMultiTS::field; %newobject MEDCoupling::MEDFileIntFieldMultiTS::LoadSpecificEntities; @@ -192,6 +193,16 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel; %newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldAtLevelOld; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::New; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::field; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::LoadSpecificEntities; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getUndergroundDataArray; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::convertToDouble; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldAtLevel; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldAtTopLevel; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldOnMeshAtLevel; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldAtLevelOld; + %newobject MEDCoupling::MEDFileAnyTypeField1TS::New; %newobject MEDCoupling::MEDFileAnyTypeField1TS::NewAdv; %newobject MEDCoupling::MEDFileAnyTypeField1TS::shallowCpy; @@ -215,6 +226,15 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileIntField1TS::getUndergroundDataArray; %newobject MEDCoupling::MEDFileIntField1TS::convertToDouble; +%newobject MEDCoupling::MEDFileFloatField1TS::New; +%newobject MEDCoupling::MEDFileFloatField1TS::field; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldAtLevel; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldAtTopLevel; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldOnMeshAtLevel; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldAtLevelOld; +%newobject MEDCoupling::MEDFileFloatField1TS::getUndergroundDataArray; +%newobject MEDCoupling::MEDFileFloatField1TS::convertToDouble; + %newobject MEDCoupling::MEDFileData::New; %newobject MEDCoupling::MEDFileData::deepCopy; %newobject MEDCoupling::MEDFileData::getMeshes; @@ -285,9 +305,11 @@ using namespace MEDCoupling; %feature("unref") MEDFileAnyTypeField1TS "$this->decrRef();" %feature("unref") MEDFileField1TS "$this->decrRef();" %feature("unref") MEDFileIntField1TS "$this->decrRef();" +%feature("unref") MEDFileFloatField1TS "$this->decrRef();" %feature("unref") MEDFileAnyTypeFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileIntFieldMultiTS "$this->decrRef();" +%feature("unref") MEDFileFloatFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileMeshSupports "$this->decrRef();" %feature("unref") MEDFileStructureElements "$this->decrRef();" %feature("unref") MEDFileFields "$this->decrRef();" @@ -2473,6 +2495,82 @@ namespace MEDCoupling } }; + class MEDFileFloatField1TS : public MEDFileAnyTypeField1TS + { + public: + static MEDFileFloatField1TS *New(); + static MEDFileFloatField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatField1TS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); + static MEDFileFloatField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); + MEDCoupling::MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + // + void setFieldNoProfileSBT(const MEDCouplingFieldFloat *field) throw(INTERP_KERNEL::Exception); + void setFieldProfile(const MEDCouplingFieldFloat *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileFloatField1TS() throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(); + } + + MEDFileFloatField1TS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(fileName,loadAll); + } + + MEDFileFloatField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(fileName,fieldName,loadAll); + } + + MEDFileFloatField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(fileName,fieldName,iteration,order,loadAll); + } + + MEDFileFloatField1TS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(db); + } + + // serialization + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFloatField1TS"); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + + PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret1=0; + DataArrayFloat *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayFloat, SWIG_POINTER_OWN | 0 )); + return ret; + } + + DataArrayFloat *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) + { + DataArrayFloat *ret=self->getUndergroundDataArray(); + if(ret) + ret->incrRef(); + return ret; + } + } + }; + class MEDFileAnyTypeFieldMultiTSIterator { public: @@ -2863,6 +2961,8 @@ namespace MEDCoupling } }; + class MEDFileIntFieldMultiTS; + class MEDFileFieldMultiTS : public MEDFileAnyTypeFieldMultiTS { public: @@ -2880,7 +2980,7 @@ namespace MEDCoupling // void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); - MEDCoupling::MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); %extend { MEDFileFieldMultiTS() @@ -3074,13 +3174,7 @@ namespace MEDCoupling static MEDFileIntFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { std::vector > tmp(convertTimePairIdsFromPy(entities)); - std::size_t sz(tmp.size()); - std::vector< std::pair > entitiesCpp(sz); - for(std::size_t i=0;i > entitiesCpp(convertVecPairIntToVecPairTOFCT(tmp)); return MEDFileIntFieldMultiTS::LoadSpecificEntities(fileName,fieldName,entitiesCpp,loadAll); } @@ -3108,6 +3202,83 @@ namespace MEDCoupling } } }; + + class MEDFileFloatFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + { + public: + static MEDFileFloatFieldMultiTS *New(); + static MEDFileFloatFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatFieldMultiTS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); + // + void appendFieldNoProfileSBT(const MEDCouplingFieldFloat *field) throw(INTERP_KERNEL::Exception); + void appendFieldProfile(const MEDCouplingFieldFloat *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + MEDCoupling::MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *field(int iteration, int order, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileFloatFieldMultiTS() + { + return MEDFileFloatFieldMultiTS::New(); + } + + MEDFileFloatFieldMultiTS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatFieldMultiTS::New(fileName,loadAll); + } + + MEDFileFloatFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatFieldMultiTS::New(fileName,fieldName,loadAll); + } + + MEDFileFloatFieldMultiTS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatFieldMultiTS::New(db); + } + + // serialization + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFloatFieldMultiTS"); + } + + static MEDFileFloatFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) + { + std::vector > tmp(convertTimePairIdsFromPy(entities)); + std::vector< std::pair > entitiesCpp(convertVecPairIntToVecPairTOFCT(tmp)); + return MEDFileFloatFieldMultiTS::LoadSpecificEntities(fileName,fieldName,entitiesCpp,loadAll); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + + PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret1=0; + DataArrayFloat *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayFloat, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + DataArrayFloat *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception) + { + DataArrayFloat *ret=self->getUndergroundDataArray(iteration,order); + if(ret) + ret->incrRef(); + return ret; + } + } + }; class MEDFileMeshSupports : public RefCountObject, public MEDFileWritableStandAlone { diff --git a/src/MEDLoader/Swig/MEDLoaderTypemaps.i b/src/MEDLoader/Swig/MEDLoaderTypemaps.i index 0cf84bc09..27eae0a2d 100644 --- a/src/MEDLoader/Swig/MEDLoaderTypemaps.i +++ b/src/MEDLoader/Swig/MEDLoaderTypemaps.i @@ -68,6 +68,8 @@ static PyObject *convertMEDFileField1TS(MEDCoupling::MEDFileAnyTypeField1TS *p, ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileField1TS,owner); if(dynamic_cast(p)) ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileIntField1TS,owner); + if(dynamic_cast(p)) + ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileFloatField1TS,owner); if(!ret) throw INTERP_KERNEL::Exception("Not recognized type of MEDFileAnyTypeField1TS on downcast !"); return ret; @@ -85,6 +87,8 @@ static PyObject *convertMEDFileFieldMultiTS(MEDCoupling::MEDFileAnyTypeFieldMult ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileFieldMultiTS,owner); if(dynamic_cast(p)) ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileIntFieldMultiTS,owner); + if(dynamic_cast(p)) + ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_MEDCoupling__MEDFileFloatFieldMultiTS,owner); if(!ret) throw INTERP_KERNEL::Exception("Not recognized type of MEDFileAnyTypeFieldMultiTS on downcast !"); return ret; @@ -146,6 +150,18 @@ static std::vector > convertTimePairIdsFromPy(PyObject *pyLi) return ret; } +static std::vector< std::pair > convertVecPairIntToVecPairTOFCT(const std::vector >& tmp) +{ + std::size_t sz(tmp.size()); + std::vector< std::pair > entitiesCpp(sz); + for(std::size_t i=0;i& v) { if(PyList_Check(pyLi))