Back to index

salome-med  6.5.0
MEDCouplingMeshServant.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 "MEDCouplingMeshServant.hxx"
00021 #include "InterpKernelException.hxx"
00022 #include "MEDCouplingMesh.hxx"
00023 #include "MEDCouplingMemArray.hxx"
00024 
00025 using namespace ParaMEDMEM;
00026 
00027 MEDCouplingMeshServant::MEDCouplingMeshServant(const MEDCouplingMesh *cppPointerOfMesh):MEDCouplingRefCountServant(cppPointerOfMesh,cppPointerOfMesh)
00028 {
00029 }
00030 
00031 void MEDCouplingMeshServant::getTinyInfo(SALOME_TYPES::ListOfDouble_out da, SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfString_out sa)
00032 {
00033   da=new SALOME_TYPES::ListOfDouble;
00034   la=new SALOME_TYPES::ListOfLong;
00035   std::vector<double> tinyInfoD;
00036   std::vector<int> tinyInfoI;
00037   std::vector<std::string> tinyInfoS;
00038   getPointer()->getTinySerializationInformation(tinyInfoD,tinyInfoI,tinyInfoS);
00039   da->length(tinyInfoD.size());
00040   la->length(tinyInfoI.size());
00041   for(int i=0;i<(int)tinyInfoD.size();i++)
00042     (*da)[i]=tinyInfoD[i];
00043   for(int i=0;i<(int)tinyInfoI.size();i++)
00044     (*la)[i]=tinyInfoI[i];
00045   //
00046   sa=new SALOME_TYPES::ListOfString;
00047   int nbOfSts=tinyInfoS.size();
00048   sa->length(nbOfSts);
00049   for(int i=0;i<nbOfSts;i++)
00050     (*sa)[i]=CORBA::string_dup(tinyInfoS[i].c_str());
00051 }
00052 
00053 void MEDCouplingMeshServant::getSerialisationData(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da)
00054 {
00055   DataArrayInt *array1;
00056   DataArrayDouble *array2;
00057   getPointer()->serialize(array1,array2);
00058   la=new SALOME_TYPES::ListOfLong;
00059   if(array1)
00060     {
00061       int lgth=array1->getNbOfElems();
00062       const int *data=array1->getConstPointer();
00063       la->length(lgth);
00064       for(int i=0;i<lgth;i++)
00065         (*la)[i]=data[i];
00066       array1->decrRef();
00067     }
00068   //
00069   da=new SALOME_TYPES::ListOfDouble;
00070   if(array2)
00071     {
00072       int lgth=array2->getNbOfElems();
00073       const double *data2=array2->getConstPointer();
00074       da->length(lgth);
00075       for(int i=0;i<lgth;i++)
00076         (*da)[i]=data2[i];
00077       //
00078       array2->decrRef();
00079     }
00080 }
00081 
00082 CORBA::Boolean MEDCouplingMeshServant::ExportDataAs(const char *format, SALOME::GenericObj_out exporter)
00083 {
00084   std::string frmCpp(format);
00085   if(frmCpp=="MEDCorba")
00086     {
00087       SALOME_MED::MEDCouplingMeshCorbaInterface_ptr cPtr=_this();
00088       Register();
00089       exporter=cPtr;
00090       return true;
00091     }
00092   exporter=SALOME::GenericObj::_nil();
00093   return false;
00094 }