1 // Copyright (C) 2007-2012 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.
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
20 #include "MEDCouplingMultiFieldsServant.hxx"
21 #include "DataArrayDoubleServant.hxx"
22 #include "MEDCouplingFieldServant.hxx"
23 #include "MEDCouplingMultiFields.hxx"
24 #include "MEDCouplingFieldDouble.hxx"
25 #include "MEDCouplingFieldTemplate.hxx"
26 #include "MEDCouplingMemArray.hxx"
28 using namespace ParaMEDMEM;
30 MEDCouplingMultiFieldsServant::MEDCouplingMultiFieldsServant(const MEDCouplingMultiFields *cppPointer):MEDCouplingRefCountServant(cppPointer,cppPointer)
34 SALOME_MED::MEDCouplingMeshesCorbaInterface *MEDCouplingMultiFieldsServant::getMeshes()
36 SALOME_MED::MEDCouplingMeshesCorbaInterface *ret=new SALOME_MED::MEDCouplingMeshesCorbaInterface;
38 std::vector<MEDCouplingMesh *> cppMeshes=getPointer()->getDifferentMeshes(tmp);
39 int sz=cppMeshes.size();
42 (*ret)[i]=MEDCouplingFieldServant::BuildCorbaRefFromCppPointer(cppMeshes[i]);
46 SALOME_MED::MEDCouplingMeshCorbaInterface_ptr MEDCouplingMultiFieldsServant::getMeshWithId(CORBA::Long id)
49 std::vector<MEDCouplingMesh *> cppMeshes=getPointer()->getDifferentMeshes(tmp);
50 return MEDCouplingFieldServant::BuildCorbaRefFromCppPointer(cppMeshes[id]);
53 char *MEDCouplingMultiFieldsServant::getName()
55 return CORBA::string_dup(getPointer()->getName().c_str());
58 SALOME_TYPES::ListOfString *MEDCouplingMultiFieldsServant::getInfoOnComponents()
60 std::vector<const MEDCouplingFieldDouble *> fs=getPointer()->getFields();
61 for(std::vector<const MEDCouplingFieldDouble *>::const_iterator it=fs.begin();it!=fs.end();it++)
65 const DataArrayDouble *arr=(*it)->getArray();
68 SALOME_TYPES::ListOfString *ret=new SALOME_TYPES::ListOfString;
69 const std::vector<std::string> &comps=arr->getInfoOnComponents();
70 ret->length(comps.size());
71 for(std::size_t i=0;i<comps.size();i++)
72 (*ret)[i]=CORBA::string_dup(comps[i].c_str());
77 throw INTERP_KERNEL::Exception("MEDCouplingMultiFieldsServant::getInfoOnComponents : impossible to find a not null DataArrayDouble !");
80 CORBA::Long MEDCouplingMultiFieldsServant::getMainTinyInfo(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, CORBA::Long& nbOfArrays, CORBA::Long& nbOfFields)
82 std::vector<int> tinyInfo;
83 std::vector<double> tinyInfo2;
84 int nbOfDiffMeshes, nbOfDiffArr;
85 nbOfFields=getPointer()->getNumberOfFields();
86 getPointer()->getTinySerializationInformation(tinyInfo,tinyInfo2,nbOfDiffMeshes,nbOfDiffArr);
87 nbOfArrays=nbOfDiffArr;
88 la=new SALOME_TYPES::ListOfLong;
89 la->length(tinyInfo.size());
90 for(int i=0;i<(int)tinyInfo.size();i++)
93 da=new SALOME_TYPES::ListOfDouble;
94 da->length(tinyInfo2.size());
95 for(int i=0;i<(int)tinyInfo2.size();i++)
96 (*da)[i]=tinyInfo2[i];
97 return nbOfDiffMeshes;
100 void MEDCouplingMultiFieldsServant::getTinyInfo(CORBA::Long id, SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, SALOME_TYPES::ListOfString_out sa)
102 const MEDCouplingFieldDouble *f=getPointer()->getFieldWithId(id);
103 MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(f);
104 la=new SALOME_TYPES::ListOfLong;
105 std::vector<int> tinyInfo;
106 f2->getTinySerializationIntInformation(tinyInfo);
107 la->length(tinyInfo.size());
108 for(int i=0;i<(int)tinyInfo.size();i++)
109 (*la)[i]=tinyInfo[i];
111 da=new SALOME_TYPES::ListOfDouble;
112 std::vector<double> tinyInfo2;
113 f2->getTinySerializationDbleInformation(tinyInfo2);
114 da->length(tinyInfo2.size());
115 for(int i=0;i<(int)tinyInfo2.size();i++)
116 (*da)[i]=tinyInfo2[i];
118 sa=new SALOME_TYPES::ListOfString;
119 std::vector<std::string> tinyInfo3;
120 f2->getTinySerializationStrInformation(tinyInfo3);
121 sa->length(tinyInfo3.size());
122 for(int i=0;i<(int)tinyInfo3.size();i++)
123 (*sa)[i]=CORBA::string_dup(tinyInfo3[i].c_str());
127 void MEDCouplingMultiFieldsServant::getSerialisationData(CORBA::Long id, SALOME_TYPES::ListOfLong_out la)
129 const MEDCouplingFieldDouble *f=getPointer()->getFieldWithId(id);
130 MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(f);
131 DataArrayInt *dataInt;
132 f2->serialize(dataInt);
134 la=new SALOME_TYPES::ListOfLong;
137 int lgth=dataInt->getNbOfElems();
138 const int *ptr=dataInt->getConstPointer();
140 for(int i=0;i<lgth;i++)
148 SALOME_MED::DataArrayDoubleCorbaInterface_ptr MEDCouplingMultiFieldsServant::getArray(CORBA::Long id)
150 std::vector< std::vector<int> > refs;
151 std::vector<DataArrayDouble *> das=getPointer()->getDifferentArrays(refs);
152 DataArrayDoubleServant *retServ=new DataArrayDoubleServant(das[id]);
153 return retServ->_this();
156 CORBA::Boolean MEDCouplingMultiFieldsServant::ExportDataAs(const char *format, SALOME::GenericObj_out exporter)
158 std::string frmCpp(format);
159 if(frmCpp=="MEDCorba")
161 SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr cPtr=_this();
166 exporter=SALOME::GenericObj::_nil();