Back to index

salome-med  6.5.0
FIELDClient.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 template<class T, class INTERLACING_TAG>
00024 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)
00025 {
00026   if (!S) 
00027     {
00028       SCRUTE(_fieldPtr);
00029       SCRUTE(_fieldPtr->getSupport());
00030       MEDMEM::FIELD<T,INTERLACING_TAG>::_support=new MEDMEM::SUPPORTClient(_fieldPtr->getSupport());
00031     }
00032   else
00033     MEDMEM::FIELD<T,INTERLACING_TAG>::setSupport(S);
00034   
00035   setName(_fieldPtr->getName());
00036 
00037   MEDMEM::FIELD<T,INTERLACING_TAG>::setDescription(_fieldPtr->getDescription());
00038   int nc = _fieldPtr->getNumberOfComponents();
00039   MEDMEM::FIELD<T,INTERLACING_TAG>::setNumberOfComponents(nc);
00040 
00041   MEDMEM::FIELD<T,INTERLACING_TAG>::setNumberOfValues( MEDMEM::FIELD<T,INTERLACING_TAG>::_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00042 
00043   string * _s = new string[nc];
00044 
00045   SALOME_TYPES::ListOfString_var s;
00046   s = _fieldPtr->getComponentsNames();
00047   for (int i=0; i<nc; i++)
00048     _s[i] = s[i];
00049   MEDMEM::FIELD<T,INTERLACING_TAG>::setComponentsNames(_s);
00050 
00051   s = _fieldPtr->getComponentsDescriptions();
00052   for (int i=0; i<nc; i++)
00053     _s[i] = s[i];
00054   MEDMEM::FIELD<T,INTERLACING_TAG>::setComponentsDescriptions(_s);
00055 
00056   s = _fieldPtr->getComponentsUnits();
00057   for (int i=0; i<nc; i++)
00058     _s[i] = s[i];
00059   MEDMEM::FIELD<T,INTERLACING_TAG>::setMEDComponentsUnits(_s);
00060 
00061   delete [] _s;
00062   setIterationNumber(_fieldPtr->getIterationNumber());
00063   setTime(_fieldPtr->getTime());
00064   setOrderNumber(_fieldPtr->getOrderNumber());
00065   fillCopy();
00066 }
00067 
00068 template<class T, class INTERLACING_TAG>
00069 void FIELDClient<T,INTERLACING_TAG>::fillCopy()
00070 {
00071   long n;
00072   typename FIELDI_TRAITS<T,INTERLACING_TAG>::SenderVarType sender=_fieldPtr->getSenderForValue(MEDMEM::FIELD<T,INTERLACING_TAG>::_interlacingType);
00073   T *v = (T *)ReceiverFactory::getValue(sender,n);
00074   MEDMEM::MEDMEM_Array_ * array;
00075   if(_fieldPtr->getGaussPresence())
00076     array=0;
00077   //array=new typename MEDMEM::MEDMEM_ArrayInterface<T,INTERLACING_TAG,Gauss>::Array
00078   //    (v, MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfComponents(),MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfValues(),true,true);
00079   else
00080     array=new typename MEDMEM::MEDMEM_ArrayInterface<T,INTERLACING_TAG,NoGauss>::Array
00081       (v, MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfComponents(),MEDMEM::FIELD<T,INTERLACING_TAG>::getNumberOfValues(),true,true);
00082   MEDMEM::FIELD<T,INTERLACING_TAG>::setArray(array);
00083 }
00084 
00085 template<class T, class INTERLACING_TAG>
00086 FIELDClient<T,INTERLACING_TAG>::~FIELDClient()
00087 {
00088   CORBA::release(_fieldPtr);
00089   /* CCAR : better put in FIELD_ destructor if support is a SUPPORTClient
00090   if(FIELD<T,INTERLACING_TAG>::_support)
00091     FIELD<T,INTERLACING_TAG>::_support->removeReference();
00092     */
00093 }
00094