Salome HOME
MEDMEM suppression
[modules/med.git] / src / MedClient / src / FIELDClient.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 template<class T, class INTERLACING_TAG>
24 FIELDClient<T,INTERLACING_TAG>::FIELDClient(typename FIELDI_TRAITS<T,INTERLACING_TAG>::SimpleFieldCorbaPtrType ptrCorba,MEDMEM::SUPPORT * S):_fieldPtr(FIELDI_TRAITS<T,INTERLACING_TAG>::SimpleFieldGlobalType::_duplicate(ptrCorba)),_refCounter(1)
25 {
26   if (!S) 
27     {
28       SCRUTE(_fieldPtr);
29       SCRUTE(_fieldPtr->getSupport());
30       MEDMEM::FIELD<T,INTERLACING_TAG>::_support=new MEDMEM::SUPPORTClient(_fieldPtr->getSupport());
31     }
32   else
33     MEDMEM::FIELD<T,INTERLACING_TAG>::setSupport(S);
34   
35   this->setName(_fieldPtr->getName());
36
37   MEDMEM::FIELD<T,INTERLACING_TAG>::setDescription(_fieldPtr->getDescription());
38   int nc = _fieldPtr->getNumberOfComponents();
39   MEDMEM::FIELD<T,INTERLACING_TAG>::setNumberOfComponents(nc);
40
41   MEDMEM::FIELD<T,INTERLACING_TAG>::setNumberOfValues( MEDMEM::FIELD<T,INTERLACING_TAG>::_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
42
43   string * _s = new string[nc];
44
45   SALOME_TYPES::ListOfString_var s;
46   s = _fieldPtr->getComponentsNames();
47   for (int i=0; i<nc; i++)
48     _s[i] = s[i];
49   MEDMEM::FIELD<T,INTERLACING_TAG>::setComponentsNames(_s);
50
51   s = _fieldPtr->getComponentsDescriptions();
52   for (int i=0; i<nc; i++)
53     _s[i] = s[i];
54   MEDMEM::FIELD<T,INTERLACING_TAG>::setComponentsDescriptions(_s);
55
56   s = _fieldPtr->getComponentsUnits();
57   for (int i=0; i<nc; i++)
58     _s[i] = s[i];
59   MEDMEM::FIELD<T,INTERLACING_TAG>::setMEDComponentsUnits(_s);
60
61   delete [] _s;
62   this->setIterationNumber(_fieldPtr->getIterationNumber());
63   this->setTime(_fieldPtr->getTime());
64   this->setOrderNumber(_fieldPtr->getOrderNumber());
65   fillCopy();
66 }
67
68 template<class T, class INTERLACING_TAG>
69 void FIELDClient<T,INTERLACING_TAG>::fillCopy()
70 {
71   long n;
72   typename FIELDI_TRAITS<T,INTERLACING_TAG>::SenderVarType sender=_fieldPtr->getSenderForValue(MEDMEM::FIELD<T,INTERLACING_TAG>::_interlacingType);
73   T *v = (T *)ReceiverFactory::getValue(sender,n);
74   MEDMEM::MEDMEM_Array_ * array;
75   if(_fieldPtr->getGaussPresence())
76     array=0;
77   //array=new typename MEDMEM::MEDMEM_ArrayInterface<T,INTERLACING_TAG,Gauss>::Array
78   //    (v, MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfComponents(),MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfValues(),true,true);
79   else
80     array=new typename MEDMEM::MEDMEM_ArrayInterface<T,INTERLACING_TAG,NoGauss>::Array
81       (v, MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfComponents(),MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfValues(),true,true);
82   MEDMEM::FIELD<T,INTERLACING_TAG>::setArray(array);
83 }
84
85 template<class T, class INTERLACING_TAG>
86 FIELDClient<T,INTERLACING_TAG>::~FIELDClient()
87 {
88   CORBA::release(_fieldPtr);
89   /* CCAR : better put in FIELD_ destructor if support is a SUPPORTClient
90   if(FIELD<T,INTERLACING_TAG>::_support)
91     FIELD<T,INTERLACING_TAG>::_support->removeReference();
92     */
93 }
94