Back to index

salome-med  6.5.0
MEDCouplingFieldDoubleServant.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 "MEDCouplingFieldDoubleServant.hxx"
00021 #include "MEDCouplingFieldDouble.hxx"
00022 
00023 using namespace ParaMEDMEM;
00024 
00025 MEDCouplingFieldDoubleServant::MEDCouplingFieldDoubleServant(const MEDCouplingFieldDouble *cppPointerOfMesh):MEDCouplingFieldServant(cppPointerOfMesh)
00026 {
00027 }
00028 
00029 void MEDCouplingFieldDoubleServant::getTinyInfo(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, SALOME_TYPES::ListOfString_out sa)
00030 {
00031   la=new SALOME_TYPES::ListOfLong;
00032   std::vector<int> tinyInfo;
00033   getPointer()->getTinySerializationIntInformation(tinyInfo);
00034   la->length(tinyInfo.size());
00035   for(int i=0;i<(int)tinyInfo.size();i++)
00036     (*la)[i]=tinyInfo[i];
00037   //
00038   da=new SALOME_TYPES::ListOfDouble;
00039   std::vector<double> tinyInfo2;
00040   getPointer()->getTinySerializationDbleInformation(tinyInfo2);
00041   da->length(tinyInfo2.size());
00042   for(int i=0;i<(int)tinyInfo2.size();i++)
00043     (*da)[i]=tinyInfo2[i];
00044   //
00045   sa=new SALOME_TYPES::ListOfString;
00046   std::vector<std::string> tinyInfo3;
00047   getPointer()->getTinySerializationStrInformation(tinyInfo3);
00048   sa->length(tinyInfo3.size());
00049   for(int i=0;i<(int)tinyInfo3.size();i++)
00050     (*sa)[i]=CORBA::string_dup(tinyInfo3[i].c_str());
00051 }
00052 
00053 void MEDCouplingFieldDoubleServant::getSerialisationData(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble2_out da2)
00054 {
00055   std::vector<DataArrayDouble *> arrays;
00056   DataArrayInt *dataInt;
00057   getPointer()->serialize(dataInt,arrays);
00058   //
00059   la=new SALOME_TYPES::ListOfLong;
00060   if(dataInt)
00061     {
00062       int lgth=dataInt->getNbOfElems();
00063       const int *ptr=dataInt->getConstPointer();
00064       la->length(lgth);
00065       for(int i=0;i<lgth;i++)
00066         (*la)[i]=ptr[i];
00067     }
00068   else
00069     la->length(0);
00070   //
00071   da2=new SALOME_TYPES::ListOfDouble2;
00072   int lgth=arrays.size();
00073   da2->length(lgth);
00074   for(int i=0;i<lgth;i++)
00075     {
00076       SALOME_TYPES::ListOfDouble& locCorbaArr=(*da2)[i];
00077       DataArrayDouble *locArr=arrays[i];
00078       int lgth2=locArr->getNbOfElems();
00079       locCorbaArr.length(lgth2);
00080       const double *pt=locArr->getConstPointer();
00081       for(int j=0;j<lgth2;j++)
00082         locCorbaArr[j]=pt[j];
00083     }
00084 }
00085 
00086 CORBA::Boolean MEDCouplingFieldDoubleServant::ExportDataAs(const char *format, SALOME::GenericObj_out exporter)
00087 {
00088   std::string frmCpp(format);
00089   if(frmCpp=="MEDCorba")
00090     {
00091       SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr cPtr=_this();
00092       Register();
00093       exporter=cPtr;
00094       return true;
00095     }
00096   exporter=SALOME::GenericObj::_nil();
00097   return false;
00098 }