Back to index

salome-med  6.5.0
MEDCouplingMultiFieldsServant.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 "MEDCouplingMultiFieldsServant.hxx"
00021 #include "DataArrayDoubleServant.hxx"
00022 #include "MEDCouplingFieldServant.hxx"
00023 #include "MEDCouplingMultiFields.hxx"
00024 #include "MEDCouplingFieldTemplate.hxx"
00025 #include "MEDCouplingMemArray.hxx"
00026 
00027 using namespace ParaMEDMEM;
00028 
00029 MEDCouplingMultiFieldsServant::MEDCouplingMultiFieldsServant(const MEDCouplingMultiFields *cppPointer):MEDCouplingRefCountServant(cppPointer,cppPointer)
00030 {
00031 }
00032 
00033 SALOME_MED::MEDCouplingMeshesCorbaInterface *MEDCouplingMultiFieldsServant::getMeshes()
00034 {
00035   SALOME_MED::MEDCouplingMeshesCorbaInterface *ret=new SALOME_MED::MEDCouplingMeshesCorbaInterface;
00036   std::vector<int> tmp;
00037   std::vector<MEDCouplingMesh *> cppMeshes=getPointer()->getDifferentMeshes(tmp);
00038   int sz=cppMeshes.size();
00039   ret->length(sz);
00040   for(int i=0;i<sz;i++)
00041     (*ret)[i]=MEDCouplingFieldServant::BuildCorbaRefFromCppPointer(cppMeshes[i]);
00042   return ret;
00043 }
00044 
00045 SALOME_MED::MEDCouplingMeshCorbaInterface_ptr MEDCouplingMultiFieldsServant::getMeshWithId(CORBA::Long id)
00046 {
00047   std::vector<int> tmp;
00048   std::vector<MEDCouplingMesh *> cppMeshes=getPointer()->getDifferentMeshes(tmp);
00049   return MEDCouplingFieldServant::BuildCorbaRefFromCppPointer(cppMeshes[id]);
00050 }
00051 
00052 CORBA::Long MEDCouplingMultiFieldsServant::getMainTinyInfo(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, CORBA::Long& nbOfArrays, CORBA::Long& nbOfFields)
00053 {
00054   std::vector<int> tinyInfo;
00055   std::vector<double> tinyInfo2;
00056   int nbOfDiffMeshes, nbOfDiffArr;
00057   nbOfFields=getPointer()->getNumberOfFields();
00058   getPointer()->getTinySerializationInformation(tinyInfo,tinyInfo2,nbOfDiffMeshes,nbOfDiffArr);
00059   nbOfArrays=nbOfDiffArr;
00060   la=new SALOME_TYPES::ListOfLong;
00061   la->length(tinyInfo.size());
00062   for(int i=0;i<(int)tinyInfo.size();i++)
00063     (*la)[i]=tinyInfo[i];
00064   //
00065   da=new SALOME_TYPES::ListOfDouble;
00066   da->length(tinyInfo2.size());
00067   for(int i=0;i<(int)tinyInfo2.size();i++)
00068     (*da)[i]=tinyInfo2[i];
00069   return nbOfDiffMeshes;
00070 }
00071 
00072 void MEDCouplingMultiFieldsServant::getTinyInfo(CORBA::Long id, SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, SALOME_TYPES::ListOfString_out sa)
00073 {
00074   const MEDCouplingFieldDouble *f=getPointer()->getFieldWithId(id);
00075   MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(f);
00076   la=new SALOME_TYPES::ListOfLong;
00077   std::vector<int> tinyInfo;
00078   f2->getTinySerializationIntInformation(tinyInfo);
00079   la->length(tinyInfo.size());
00080   for(int i=0;i<(int)tinyInfo.size();i++)
00081     (*la)[i]=tinyInfo[i];
00082   //
00083   da=new SALOME_TYPES::ListOfDouble;
00084   std::vector<double> tinyInfo2;
00085   f2->getTinySerializationDbleInformation(tinyInfo2);
00086   da->length(tinyInfo2.size());
00087   for(int i=0;i<(int)tinyInfo2.size();i++)
00088     (*da)[i]=tinyInfo2[i];
00089   //
00090   sa=new SALOME_TYPES::ListOfString;
00091   std::vector<std::string> tinyInfo3;
00092   f2->getTinySerializationStrInformation(tinyInfo3);
00093   sa->length(tinyInfo3.size());
00094   for(int i=0;i<(int)tinyInfo3.size();i++)
00095     (*sa)[i]=CORBA::string_dup(tinyInfo3[i].c_str());
00096   f2->decrRef();
00097 }
00098 
00099 void MEDCouplingMultiFieldsServant::getSerialisationData(CORBA::Long id, SALOME_TYPES::ListOfLong_out la)
00100 {
00101   const MEDCouplingFieldDouble *f=getPointer()->getFieldWithId(id);
00102   MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(f);
00103   DataArrayInt *dataInt;
00104   f2->serialize(dataInt);
00105   //
00106   la=new SALOME_TYPES::ListOfLong;
00107   if(dataInt)
00108     {
00109       int lgth=dataInt->getNbOfElems();
00110       const int *ptr=dataInt->getConstPointer();
00111       la->length(lgth);
00112       for(int i=0;i<lgth;i++)
00113         (*la)[i]=ptr[i];
00114     }
00115   else
00116     la->length(0);
00117   f2->decrRef();
00118 }
00119 
00120 SALOME_MED::DataArrayDoubleCorbaInterface_ptr MEDCouplingMultiFieldsServant::getArray(CORBA::Long id)
00121 {
00122   std::vector< std::vector<int> > refs;
00123   std::vector<DataArrayDouble *> das=getPointer()->getDifferentArrays(refs);
00124   DataArrayDoubleServant *retServ=new DataArrayDoubleServant(das[id]);
00125   return retServ->_this();
00126 }
00127 
00128 CORBA::Boolean MEDCouplingMultiFieldsServant::ExportDataAs(const char *format, SALOME::GenericObj_out exporter)
00129 {
00130   std::string frmCpp(format);
00131   if(frmCpp=="MEDCorba")
00132     {
00133       SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr cPtr=_this();
00134       Register();
00135       exporter=cPtr;
00136       return true;
00137     }
00138   exporter=SALOME::GenericObj::_nil();
00139   return false;
00140 }