X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingFieldTemplate.cxx;h=671ad54f30ee23cfaac82a2808c64421efef15bc;hb=f2ab61e92f55ee52cf5196f7904f625d93c8c2d0;hp=2e1c24a3ff2ca113047cd413674d8067bb1009ae;hpb=a23c622fadddf57290253debb129d9008226cdb9;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx index 2e1c24a3f..671ad54f3 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 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 // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,20 +16,74 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingMesh.hxx" +#include "MEDCouplingFieldInt32.hxx" +#include "MEDCouplingFieldInt64.hxx" +#include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldDiscretization.hxx" #include -using namespace ParaMEDMEM; +using namespace MEDCoupling; MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble& f) { - return new MEDCouplingFieldTemplate(f); + return new MEDCouplingFieldTemplate(f,true); +} + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldFloat& f) +{ + return new MEDCouplingFieldTemplate(f,true); +} + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldInt32& f) +{ + return new MEDCouplingFieldTemplate(f,true); +} + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldInt64& f) +{ + return new MEDCouplingFieldTemplate(f,true); +} + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::NewWithoutCheck(const MEDCouplingFieldDouble& f) +{ + return new MEDCouplingFieldTemplate(f,false); +} + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::NewWithoutCheck(const MEDCouplingFieldFloat& f) +{ + return new MEDCouplingFieldTemplate(f,false); +} + +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::NewWithoutCheck(const MEDCouplingFieldInt32& f) +{ + 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); +} + +bool MEDCouplingFieldTemplate::isEqual(const MEDCouplingFieldTemplate *other, double meshPrec) const +{ + std::string tmp; + return isEqualIfNotWhyProtected(other,meshPrec,tmp); +} + +bool MEDCouplingFieldTemplate::isEqualWithoutConsideringStr(const MEDCouplingFieldTemplate *other, double meshPrec) const +{ + return isEqualWithoutConsideringStrProtected(other,meshPrec); } /*! @@ -40,20 +94,46 @@ MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(TypeOfField type) return new MEDCouplingFieldTemplate(type); } -MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f):MEDCouplingField(f,false) +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f, bool isChecked):MEDCouplingField(f,false) +{ + forceTimeOfThis(f); + if(isChecked) + checkConsistencyLight(); +} + +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f, bool isChecked):MEDCouplingField(f,false) +{ + forceTimeOfThis(f); + if(isChecked) + checkConsistencyLight(); +} + +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldInt32& f, bool isChecked):MEDCouplingField(f,false) { forceTimeOfThis(f); - checkCoherency(); + if(isChecked) + checkConsistencyLight(); +} + +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldInt64& f, bool isChecked):MEDCouplingField(f,false) +{ + forceTimeOfThis(f); + if(isChecked) + checkConsistencyLight(); } MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(TypeOfField type):MEDCouplingField(type) { } -void MEDCouplingFieldTemplate::checkCoherency() const +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldTemplate& other, bool deepCopy):MEDCouplingField(other,deepCopy) +{ +} + +void MEDCouplingFieldTemplate::checkConsistencyLight() const { if(_mesh==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldTemplate::checkCoherency : Empty mesh !"); + throw INTERP_KERNEL::Exception("MEDCouplingFieldTemplate::checkConsistencyLight : Empty mesh !"); } std::string MEDCouplingFieldTemplate::simpleRepr() const @@ -78,17 +158,17 @@ std::string MEDCouplingFieldTemplate::advancedRepr() const return simpleRepr(); } -void MEDCouplingFieldTemplate::getTinySerializationIntInformation(std::vector& tinyInfo) const +void MEDCouplingFieldTemplate::getTinySerializationIntInformation(std::vector& tinyInfo) const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationIntInformation !"); tinyInfo.clear(); - tinyInfo.push_back((int)_type->getEnum()); - tinyInfo.push_back((int)_nature); - std::vector tinyInfo2; + tinyInfo.push_back(ToIdType(_type->getEnum())); + tinyInfo.push_back(ToIdType(_nature)); + std::vector tinyInfo2; _type->getTinySerializationIntInformation(tinyInfo2); tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end()); - tinyInfo.push_back((int)tinyInfo2.size()); + tinyInfo.push_back(ToIdType(tinyInfo2.size())); } void MEDCouplingFieldTemplate::getTinySerializationDbleInformation(std::vector& tinyInfo) const @@ -106,16 +186,16 @@ void MEDCouplingFieldTemplate::getTinySerializationStrInformation(std::vector& tinyInfoI, DataArrayInt *&dataInt) +void MEDCouplingFieldTemplate::resizeForUnserialization(const std::vector& tinyInfoI, DataArrayIdType *&dataInt) { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform resizeForUnserialization !"); dataInt=0; - std::vector tinyInfoITmp(tinyInfoI.begin()+2,tinyInfoI.end()); + std::vector tinyInfoITmp(tinyInfoI.begin()+2,tinyInfoI.end()); _type->resizeForUnserialization(tinyInfoITmp,dataInt); } -void MEDCouplingFieldTemplate::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) +void MEDCouplingFieldTemplate::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform finishUnserialization !"); @@ -125,7 +205,7 @@ void MEDCouplingFieldTemplate::finishUnserialization(const std::vector& tin _desc=tinyInfoS[1]; } -void MEDCouplingFieldTemplate::serialize(DataArrayInt *&dataInt) const +void MEDCouplingFieldTemplate::serialize(DataArrayIdType *&dataInt) const { _type->getSerializationIntArray(dataInt); } @@ -135,12 +215,12 @@ void MEDCouplingFieldTemplate::reprQuickOverview(std::ostream& stream) const stream << "MEDCouplingFieldTemplate C++ instance at " << this << ". Name : \"" << _name << "\"." << std::endl; const char *nat=0; try - { + { nat=MEDCouplingNatureOfField::GetRepr(_nature); stream << "Nature of field template : " << nat << ".\n"; - } + } catch(INTERP_KERNEL::Exception& /*e*/) - { } + { } const MEDCouplingFieldDiscretization *fd(_type); if(!fd) stream << "No spatial discretization set !"; @@ -157,3 +237,9 @@ void MEDCouplingFieldTemplate::reprQuickOverview(std::ostream& stream) const stream << "\nMesh info : " << tmp.substr(0,tmp.find('\n')); } } + +MCAuto MEDCouplingFieldTemplate::clone(bool recDeepCpy) const +{ + MCAuto ret(new MEDCouplingFieldTemplate(*this,recDeepCpy)); + return ret; +}