X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileField.txx;h=d08370c773d46b3689e2db6e7bafbc2edfda39fa;hb=de0118467e24e50424bd949ee38e5b7a19f62f45;hp=e3ba8eeb8b73a72b4109c2728da48b0fe06e4cd0;hpb=be04791d7d756c50d1e4296ddf714478dfe78de1;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileField.txx b/src/MEDLoader/MEDFileField.txx index e3ba8eeb8..d08370c77 100644 --- a/src/MEDLoader/MEDFileField.txx +++ b/src/MEDLoader/MEDFileField.txx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -199,6 +199,16 @@ namespace MEDCoupling } } + template + void MEDFileField1TSTemplateWithoutSDA::copyTimeInfoFrom(const typename Traits::FieldType *mcf) + { + if(!mcf) + throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::copyTimeInfoFrom : input field is nullptr !"); + int b(0),c(0); + double a(mcf->getTime(b,c)); + setTime(b,c,a); + } + /////////////////////////////////////////////////////// template @@ -397,6 +407,12 @@ namespace MEDCoupling return ReturnSafelyTypedDataArray(arr); } + template + void MEDFileTemplateField1TS::setArray(DataArray *arr) + { + return contentNotNull()->setArray(arr); + } + template typename Traits::ArrayType *MEDFileTemplateField1TS::getUndergroundDataArray() const { @@ -438,6 +454,12 @@ namespace MEDCoupling return ret.retn(); } + template + void MEDFileTemplateField1TS::copyTimeInfoFrom(const typename Traits::FieldType *mcf) + { + contentNotNull()->copyTimeInfoFrom(mcf); + } + /*! * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance * method should be called (getFieldOnMeshAtLevel for example). @@ -660,16 +682,32 @@ namespace MEDCoupling * \throw If the data array of \a this is already allocated but has different number of * components than \a field. * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. - * \sa setFieldNoProfileSBT() + * \sa setFieldNoProfileSBT, setFieldProfileFlatly */ template void MEDFileTemplateField1TS::setFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) + { + setFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,true); + } + + /*! + * Same as setFieldProfile except that here profile will be created unconditionally + * \sa setFieldProfile + */ + template + void MEDFileTemplateField1TS::setFieldProfileFlatly(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) + { + setFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,false); + } + + template + void MEDFileTemplateField1TS::setFieldProfileGeneral(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, bool smartPflKiller) { setFileName(""); MCAuto ft(MEDCouplingFieldTemplate::NewWithoutCheck(*field)); - contentNotNull()->setFieldProfile(field->timeDiscrSafe(),ft,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull()); + contentNotNull()->setFieldProfile(field->timeDiscrSafe(),ft,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull(),smartPflKiller); } - + /*! * Return an extraction of \a this using \a extractDef map to specify the extraction. * The keys of \a extractDef is level relative to max ext of \a mm mesh. @@ -1200,18 +1238,33 @@ namespace MEDCoupling * \throw If the data array of \a this is already allocated but has different number of * components than \a field. * \throw If elements in \a mesh are not in the order suitable for writing to the MED file. - * \sa setFieldNoProfileSBT() + * \sa setFieldNoProfileSBT, appendFieldProfileFlatly */ template void MEDFileTemplateFieldMultiTS::appendFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) + { + appendFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,true); + } + + /*! + * same as appendFieldProfile except that here profile is created unconditionaly + */ + template + void MEDFileTemplateFieldMultiTS::appendFieldProfileFlatly(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) + { + appendFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,false); + } + + template + void MEDFileTemplateFieldMultiTS::appendFieldProfileGeneral(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, bool smartPflKiller) { const typename Traits::ArrayType *arr(NULL); if(field) arr=field->getArray(); MCAuto field2(MEDFileTemplateField1TS::ToFieldTemplateWithTime(field)); - contentNotNull()->appendFieldProfile(field2,arr,mesh,meshDimRelToMax,profile,*this); + contentNotNull()->appendFieldProfile(field2,arr,mesh,meshDimRelToMax,profile,*this,smartPflKiller); } - + template const typename MLFieldTraits::FMTSWSDAType *MEDFileTemplateFieldMultiTS::contentNotNull() const { @@ -1272,7 +1325,7 @@ namespace MEDCoupling 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; + std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS::getUndergroundDataArray : invalid type of data detected ! Expecting " << MLFieldTraits::F1TSWSDAType::TYPE_STR; throw INTERP_KERNEL::Exception(oss.str()); } return ret2; @@ -1287,7 +1340,7 @@ namespace MEDCoupling 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; + std::ostringstream oss; oss << "MEDFileTemplateFieldMultiTS::getUndergroundDataArrayExt : invalid type of data detected ! Expecting " << MLFieldTraits::F1TSWSDAType::TYPE_STR; throw INTERP_KERNEL::Exception(oss.str()); } return ret2;