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 "MEDCouplingMultiFieldsServant.hxx"
22 #include "DataArrayDoubleServant.hxx"
23 #include "MEDCouplingFieldServant.hxx"
24 #include "MEDCouplingMultiFields.hxx"
25 #include "MEDCouplingFieldDouble.hxx"
26 #include "MEDCouplingFieldTemplate.hxx"
27 #include "MEDCouplingMemArray.hxx"
29 using namespace ParaMEDMEM;
31 MEDCouplingMultiFieldsServant::MEDCouplingMultiFieldsServant(const MEDCouplingMultiFields *cppPointer):MEDCouplingRefCountServant(cppPointer,cppPointer)
35 SALOME_MED::MEDCouplingMeshesCorbaInterface *MEDCouplingMultiFieldsServant::getMeshes()
37 SALOME_MED::MEDCouplingMeshesCorbaInterface *ret=new SALOME_MED::MEDCouplingMeshesCorbaInterface;
39 std::vector<MEDCouplingMesh *> cppMeshes=getPointer()->getDifferentMeshes(tmp);
40 int sz=cppMeshes.size();
43 (*ret)[i]=MEDCouplingFieldServant::BuildCorbaRefFromCppPointer(cppMeshes[i]);
47 SALOME_MED::MEDCouplingMeshCorbaInterface_ptr MEDCouplingMultiFieldsServant::getMeshWithId(CORBA::Long id)
50 std::vector<MEDCouplingMesh *> cppMeshes=getPointer()->getDifferentMeshes(tmp);
51 return MEDCouplingFieldServant::BuildCorbaRefFromCppPointer(cppMeshes[id]);
54 char *MEDCouplingMultiFieldsServant::getName()
56 return CORBA::string_dup(getPointer()->getName().c_str());
59 SALOME_TYPES::ListOfString *MEDCouplingMultiFieldsServant::getInfoOnComponents()
61 std::vector<const MEDCouplingFieldDouble *> fs=getPointer()->getFields();
62 for(std::vector<const MEDCouplingFieldDouble *>::const_iterator it=fs.begin();it!=fs.end();it++)
66 const DataArrayDouble *arr=(*it)->getArray();
69 SALOME_TYPES::ListOfString *ret=new SALOME_TYPES::ListOfString;
70 const std::vector<std::string> &comps=arr->getInfoOnComponents();
71 ret->length(comps.size());
72 for(std::size_t i=0;i<comps.size();i++)
73 (*ret)[i]=CORBA::string_dup(comps[i].c_str());
78 throw INTERP_KERNEL::Exception("MEDCouplingMultiFieldsServant::getInfoOnComponents : impossible to find a not null DataArrayDouble !");
81 CORBA::Long MEDCouplingMultiFieldsServant::getMainTinyInfo(SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, CORBA::Long& nbOfArrays, CORBA::Long& nbOfFields)
83 std::vector<int> tinyInfo;
84 std::vector<double> tinyInfo2;
85 int nbOfDiffMeshes, nbOfDiffArr;
86 nbOfFields=getPointer()->getNumberOfFields();
87 getPointer()->getTinySerializationInformation(tinyInfo,tinyInfo2,nbOfDiffMeshes,nbOfDiffArr);
88 nbOfArrays=nbOfDiffArr;
89 la=new SALOME_TYPES::ListOfLong;
90 la->length(tinyInfo.size());
91 for(int i=0;i<(int)tinyInfo.size();i++)
94 da=new SALOME_TYPES::ListOfDouble;
95 da->length(tinyInfo2.size());
96 for(int i=0;i<(int)tinyInfo2.size();i++)
97 (*da)[i]=tinyInfo2[i];
98 return nbOfDiffMeshes;
101 void MEDCouplingMultiFieldsServant::getTinyInfo(CORBA::Long id, SALOME_TYPES::ListOfLong_out la, SALOME_TYPES::ListOfDouble_out da, SALOME_TYPES::ListOfString_out sa)
103 const MEDCouplingFieldDouble *f=getPointer()->getFieldWithId(id);
104 MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(*f);
105 la=new SALOME_TYPES::ListOfLong;
106 std::vector<int> tinyInfo;
107 f2->getTinySerializationIntInformation(tinyInfo);
108 la->length(tinyInfo.size());
109 for(int i=0;i<(int)tinyInfo.size();i++)
110 (*la)[i]=tinyInfo[i];
112 da=new SALOME_TYPES::ListOfDouble;
113 std::vector<double> tinyInfo2;
114 f2->getTinySerializationDbleInformation(tinyInfo2);
115 da->length(tinyInfo2.size());
116 for(int i=0;i<(int)tinyInfo2.size();i++)
117 (*da)[i]=tinyInfo2[i];
119 sa=new SALOME_TYPES::ListOfString;
120 std::vector<std::string> tinyInfo3;
121 f2->getTinySerializationStrInformation(tinyInfo3);
122 sa->length(tinyInfo3.size());
123 for(int i=0;i<(int)tinyInfo3.size();i++)
124 (*sa)[i]=CORBA::string_dup(tinyInfo3[i].c_str());
128 void MEDCouplingMultiFieldsServant::getSerialisationData(CORBA::Long id, SALOME_TYPES::ListOfLong_out la)
130 const MEDCouplingFieldDouble *f=getPointer()->getFieldWithId(id);
131 MEDCouplingFieldTemplate *f2=MEDCouplingFieldTemplate::New(*f);
132 DataArrayInt *dataInt;
133 f2->serialize(dataInt);
135 la=new SALOME_TYPES::ListOfLong;
138 int lgth=dataInt->getNbOfElems();
139 const int *ptr=dataInt->getConstPointer();
141 for(int i=0;i<lgth;i++)
149 SALOME_MED::DataArrayDoubleCorbaInterface_ptr MEDCouplingMultiFieldsServant::getArray(CORBA::Long id)
151 std::vector< std::vector<int> > refs;
152 std::vector<DataArrayDouble *> das=getPointer()->getDifferentArrays(refs);
153 DataArrayDoubleServant *retServ=new DataArrayDoubleServant(das[id]);
154 return retServ->_this();
157 CORBA::Boolean MEDCouplingMultiFieldsServant::ExportDataAs(const char *format, SALOME::GenericObj_out exporter)
159 std::string frmCpp(format);
160 if(frmCpp=="MEDCorba")
162 SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr cPtr=_this();
167 exporter=SALOME::GenericObj::_nil();