Back to index

salome-med  6.5.0
MEDCouplingFieldTemplate.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDCouplingFieldTemplate.hxx"
00021 #include "MEDCouplingMesh.hxx"
00022 #include "MEDCouplingFieldDouble.hxx"
00023 #include "MEDCouplingFieldDiscretization.hxx"
00024 
00025 #include <sstream>
00026 
00027 using namespace ParaMEDMEM;
00028 
00029 MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception)
00030 {
00031   return new MEDCouplingFieldTemplate(f);
00032 }
00033 
00037 MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(TypeOfField type)
00038 {
00039   return new MEDCouplingFieldTemplate(type);
00040 }
00041 
00042 MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception):MEDCouplingField(*f) 
00043 {
00044   checkCoherency();
00045 }
00046 
00047 MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(TypeOfField type):MEDCouplingField(type)
00048 {
00049 }
00050 
00051 void MEDCouplingFieldTemplate::checkCoherency() const throw(INTERP_KERNEL::Exception)
00052 {
00053   if(_mesh==0)
00054     throw INTERP_KERNEL::Exception("MEDCouplingFieldTemplate::checkCoherency : Empty mesh !");
00055 }
00056 
00057 std::string MEDCouplingFieldTemplate::simpleRepr() const
00058 {
00059   std::ostringstream ret;
00060   ret << "FieldTemplate with name : \"" << getName() << "\"\n";
00061   ret << "Description of field is : \"" << getDescription() << "\"\n";
00062   ret << "FieldTemplate space discretization is : " << _type->getStringRepr() << "\n";
00063   ret << "FieldTemplate nature of field is : " << MEDCouplingNatureOfField::getRepr(_nature) << "\n";
00064   if(_mesh)
00065     ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr();
00066   else
00067     ret << "Mesh support information : No mesh set !\n";
00068   return ret.str();
00069 }
00070 
00071 std::string MEDCouplingFieldTemplate::advancedRepr() const
00072 {
00073   return simpleRepr();
00074 }
00075 
00076 void MEDCouplingFieldTemplate::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
00077 {
00078   tinyInfo.clear();
00079   tinyInfo.push_back((int)_type->getEnum());
00080   tinyInfo.push_back((int)_nature);
00081   std::vector<int> tinyInfo2;
00082   _type->getTinySerializationIntInformation(tinyInfo2);
00083   tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
00084   tinyInfo.push_back((int)tinyInfo2.size());
00085 }
00086 
00087 void MEDCouplingFieldTemplate::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
00088 {
00089   tinyInfo.clear();
00090   _type->getTinySerializationDbleInformation(tinyInfo);
00091 }
00092 
00093 void MEDCouplingFieldTemplate::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
00094 {
00095   tinyInfo.clear();
00096   tinyInfo.push_back(_name);
00097   tinyInfo.push_back(_desc);
00098 }
00099 
00100 void MEDCouplingFieldTemplate::resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt)
00101 {
00102   dataInt=0;
00103   std::vector<int> tinyInfoITmp(tinyInfoI.begin()+2,tinyInfoI.end());
00104   _type->resizeForUnserialization(tinyInfoITmp,dataInt);
00105 }
00106 
00107 void MEDCouplingFieldTemplate::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
00108 {
00109   _nature=(NatureOfField)tinyInfoI[1];
00110   _type->finishUnserialization(tinyInfoD);
00111   _name=tinyInfoS[0];
00112   _desc=tinyInfoS[1];
00113 }
00114 
00115 void MEDCouplingFieldTemplate::serialize(DataArrayInt *&dataInt) const
00116 {
00117   _type->getSerializationIntArray(dataInt);
00118 }
00119