1 // Copyright (C) 2007-2016 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 "MEDCouplingFieldDoubleClient.hxx"
22 #include "MEDCouplingMeshClient.hxx"
23 #include "MEDCouplingMesh.hxx"
27 using namespace MEDCoupling;
29 MEDCouplingFieldDouble *MEDCouplingFieldDoubleClient::New(SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr)
33 SALOME_TYPES::ListOfLong *tinyL;
34 SALOME_TYPES::ListOfDouble *tinyD;
35 SALOME_TYPES::ListOfString *tinyS;
36 //1st CORBA call : getting all tiny info of all types (int, double string).
37 fieldPtr->getTinyInfo(tinyL,tinyD,tinyS);
38 int tinyLgth=tinyL->length();
39 std::vector<int> tinyLV(tinyLgth);
40 for(int i=0;i<tinyLgth;i++)
41 tinyLV[i]=(*tinyL)[i];
44 tinyLgth=tinyD->length();
45 std::vector<double> tinyLD(tinyLgth);
46 for(int i=0;i<tinyLgth;i++)
47 tinyLD[i]=(*tinyD)[i];
50 tinyLgth=tinyS->length();
51 std::vector<std::string> tinyLS(tinyLgth);
52 for(int i=0;i<tinyLgth;i++)
53 tinyLS[i]=(*tinyS)[i];
56 TypeOfField type=(TypeOfField) tinyLV[0];
57 TypeOfTimeDiscretization td=(TypeOfTimeDiscretization) tinyLV[1];
58 MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(type,td);
59 //2nd CORBA call to retrieves the mesh.
60 SALOME_MED::MEDCouplingMeshCorbaInterface_ptr meshPtr=fieldPtr->getMesh();
61 MEDCouplingMesh *mesh=MEDCouplingMeshClient::New(meshPtr);
62 meshPtr->UnRegister();
63 CORBA::release(meshPtr);
67 std::vector<DataArrayDouble *> arrays;
68 ret->resizeForUnserialization(tinyLV,array0,arrays);
69 SALOME_TYPES::ListOfLong *bigArr0;
70 SALOME_TYPES::ListOfDouble2 *bigArr;
71 //3rd CORBA invocation to get big content
72 fieldPtr->getSerialisationData(bigArr0,bigArr);
73 if(bigArr0->length()!=0)
75 int *pt=array0->getPointer();
76 int lgth=array0->getNbOfElems();
77 for(int i=0;i<lgth;i++)
81 tinyLgth=arrays.size();
82 for(int i=0;i<tinyLgth;i++)
84 SALOME_TYPES::ListOfDouble& oneArr=(*bigArr)[i];
85 DataArrayDouble *curArrToFill=arrays[i];
86 double *pt=curArrToFill->getPointer();
87 int lgth=curArrToFill->getNbOfElems();
88 for(int j=0;j<lgth;j++)
93 //notify server that the servant is no more used.
94 fieldPtr->UnRegister();
96 ret->finishUnserialization(tinyLV,tinyLD,tinyLS);