1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDCouplingFieldDoubleServant.hxx"
22 #include "MEDCouplingFieldDouble.hxx"
24 using namespace ParaMEDMEM;
26 MEDCouplingFieldDoubleServant::MEDCouplingFieldDoubleServant(const MEDCouplingFieldDouble *cppPointerOfMesh):MEDCouplingFieldServant(cppPointerOfMesh)
30 char *MEDCouplingFieldDoubleServant::getName()
32 return CORBA::string_dup(getPointer()->getName().c_str());
35 SALOME_TYPES::ListOfString *MEDCouplingFieldDoubleServant::getInfoOnComponents()
37 const DataArrayDouble *arr=getPointer()->getArray();
38 SALOME_TYPES::ListOfString *ret=new SALOME_TYPES::ListOfString;
41 const std::vector<std::string> &comps=arr->getInfoOnComponents();
42 ret->length(comps.size());
43 for(std::size_t i=0;i<comps.size();i++)
44 (*ret)[i]=CORBA::string_dup(comps[i].c_str());
48 throw INTERP_KERNEL::Exception("MEDCouplingFieldDoubleServant::getInfoOnComponents : no array specified !");
51 void MEDCouplingFieldDoubleServant::getTinyInfo(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, SALOME_TYPES::ListOfString_out sa)
53 la=new SALOME_TYPES::ListOfLong;
54 std::vector<int> tinyInfo;
55 getPointer()->getTinySerializationIntInformation(tinyInfo);
56 la->length(tinyInfo.size());
57 for(int i=0;i<(int)tinyInfo.size();i++)
60 da=new SALOME_TYPES::ListOfDouble;
61 std::vector<double> tinyInfo2;
62 getPointer()->getTinySerializationDbleInformation(tinyInfo2);
63 da->length(tinyInfo2.size());
64 for(int i=0;i<(int)tinyInfo2.size();i++)
65 (*da)[i]=tinyInfo2[i];
67 sa=new SALOME_TYPES::ListOfString;
68 std::vector<std::string> tinyInfo3;
69 getPointer()->getTinySerializationStrInformation(tinyInfo3);
70 sa->length(tinyInfo3.size());
71 for(int i=0;i<(int)tinyInfo3.size();i++)
72 (*sa)[i]=CORBA::string_dup(tinyInfo3[i].c_str());
75 void MEDCouplingFieldDoubleServant::getSerialisationData(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble2_out da2)
77 std::vector<DataArrayDouble *> arrays;
78 DataArrayInt *dataInt;
79 getPointer()->serialize(dataInt,arrays);
81 la=new SALOME_TYPES::ListOfLong;
84 int lgth=dataInt->getNbOfElems();
85 const int *ptr=dataInt->getConstPointer();
87 for(int i=0;i<lgth;i++)
93 da2=new SALOME_TYPES::ListOfDouble2;
94 int lgth=arrays.size();
96 for(int i=0;i<lgth;i++)
98 SALOME_TYPES::ListOfDouble& locCorbaArr=(*da2)[i];
99 DataArrayDouble *locArr=arrays[i];
100 int lgth2=locArr->getNbOfElems();
101 locCorbaArr.length(lgth2);
102 const double *pt=locArr->getConstPointer();
103 for(int j=0;j<lgth2;j++)
104 locCorbaArr[j]=pt[j];
108 CORBA::Boolean MEDCouplingFieldDoubleServant::ExportDataAs(const char *format, SALOME::GenericObj_out exporter)
110 std::string frmCpp(format);
111 if(frmCpp=="MEDCorba")
113 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr cPtr=_this();
118 exporter=SALOME::GenericObj::_nil();