X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingFieldTemplate.cxx;h=2e1c24a3ff2ca113047cd413674d8067bb1009ae;hb=0c9d48870957c4a9f6f82fc8e2c569780a5f886b;hp=a94b6700a8157c53d17d61ea379395f81bec5c75;hpb=feaed8311a3ebdb6a2e54b827a5338fcae61e267;p=modules%2Fmed.git diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx index a94b6700a..2e1c24a3f 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D +// Copyright (C) 2007-2013 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 @@ -27,7 +27,7 @@ using namespace ParaMEDMEM; -MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception) +MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble& f) { return new MEDCouplingFieldTemplate(f); } @@ -40,7 +40,7 @@ MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(TypeOfField type) return new MEDCouplingFieldTemplate(type); } -MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception):MEDCouplingField(f,false) +MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f):MEDCouplingField(f,false) { forceTimeOfThis(f); checkCoherency(); @@ -50,7 +50,7 @@ MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(TypeOfField type):MEDCoupling { } -void MEDCouplingFieldTemplate::checkCoherency() const throw(INTERP_KERNEL::Exception) +void MEDCouplingFieldTemplate::checkCoherency() const { if(_mesh==0) throw INTERP_KERNEL::Exception("MEDCouplingFieldTemplate::checkCoherency : Empty mesh !"); @@ -61,8 +61,11 @@ std::string MEDCouplingFieldTemplate::simpleRepr() const std::ostringstream ret; ret << "FieldTemplate with name : \"" << getName() << "\"\n"; ret << "Description of field is : \"" << getDescription() << "\"\n"; - ret << "FieldTemplate space discretization is : " << _type->getStringRepr() << "\n"; - ret << "FieldTemplate nature of field is : " << MEDCouplingNatureOfField::getRepr(_nature) << "\n"; + if(_type) + { ret << "FieldTemplate space discretization is : " << _type->getStringRepr() << "\n"; } + else + { ret << "FieldTemplate has no spatial discretization !\n"; } + ret << "FieldTemplate nature of field is : \"" << MEDCouplingNatureOfField::GetReprNoThrow(_nature) << "\"\n"; if(_mesh) ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr(); else @@ -77,6 +80,8 @@ std::string MEDCouplingFieldTemplate::advancedRepr() 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); @@ -88,6 +93,8 @@ void MEDCouplingFieldTemplate::getTinySerializationIntInformation(std::vector& tinyInfo) const { + if(!((const MEDCouplingFieldDiscretization *)_type)) + throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationDbleInformation !"); tinyInfo.clear(); _type->getTinySerializationDbleInformation(tinyInfo); } @@ -101,6 +108,8 @@ void MEDCouplingFieldTemplate::getTinySerializationStrInformation(std::vector& tinyInfoI, DataArrayInt *&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()); _type->resizeForUnserialization(tinyInfoITmp,dataInt); @@ -108,6 +117,8 @@ void MEDCouplingFieldTemplate::resizeForUnserialization(const std::vector& 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 !"); _nature=(NatureOfField)tinyInfoI[1]; _type->finishUnserialization(tinyInfoD); _name=tinyInfoS[0]; @@ -119,3 +130,30 @@ void MEDCouplingFieldTemplate::serialize(DataArrayInt *&dataInt) const _type->getSerializationIntArray(dataInt); } +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 !"; + else + fd->reprQuickOverview(stream); + stream << std::endl; + if(!_mesh) + stream << "\nNo mesh support defined !"; + else + { + std::ostringstream oss; + _mesh->reprQuickOverview(oss); + std::string tmp(oss.str()); + stream << "\nMesh info : " << tmp.substr(0,tmp.find('\n')); + } +}