Back to index

salome-med  6.5.0
MEDMEM_FieldConvert.hxx
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 #ifndef FIELD_CONVERT_HXX
00024 #define FIELD_CONVERT_HXX
00025 
00026 //#include "MEDMEM_FieldForward.hxx"
00027 #include "MEDMEM_Field.hxx" // issue 0021050: compilation with clang
00028 #include "MEDMEM_ArrayInterface.hxx"
00029 #include "MEDMEM_ArrayConvert.hxx"
00030 
00031 namespace MEDMEM {
00032 class FIELD_;
00033 
00034 template <class T> FIELD<T,FullInterlace> *
00035 FieldConvert(const FIELD<T,NoInterlace> & field )
00036 {
00037   typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFullNo;
00038   typedef typename MEDMEM_ArrayInterface<T,FullInterlace,Gauss>::Array ArrayFullGa;
00039 
00040   FIELD<T,FullInterlace> * myField = new FIELD<T,FullInterlace>();
00041   FIELD_ * myField_ = myField;
00042   FIELD_ * field_ = &(const_cast< FIELD<T,NoInterlace> &> (field));
00043   *myField_ = *field_;                        // Opérateur d'affectation de FIELD_ OK
00044   // *((FIELD_ *) myField) = (FIELD_ ) field; //Contructeur par recopie de FIELD_ Pourquoi?
00045 
00046   if  ( field.getGaussPresence() ) {
00047     ArrayFullGa * myArray = ArrayConvert( *(field.getArrayGauss()) );
00048     myField->setArray(myArray);
00049     return myField;
00050   } else {
00051     ArrayFullNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) );
00052     myField->setArray(myArray);
00053     return myField;
00054   }
00055 }
00056 
00057 template <class T> FIELD<T,NoInterlace> *
00058 FieldConvert(const FIELD<T,FullInterlace> & field )
00059 {
00060   typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNoNo;
00061   typedef typename MEDMEM_ArrayInterface<T,NoInterlace,Gauss>::Array ArrayNoGa;
00062 
00063 
00064   FIELD<T,NoInterlace> * myField = new FIELD<T,NoInterlace>();
00065   FIELD_ * myField_ = myField;
00066   FIELD_ * field_ = &(const_cast< FIELD<T,FullInterlace> &> (field));
00067   *myField_ = *field_;                        // Opérateur d'affectation de FIELD_ OK
00068   //   *((FIELD_*) myField) = (FIELD_) field; //Contructeur par recopie de FIELD_ Pourquoi?
00069 
00070   if  ( field.getGaussPresence() ) {
00071     ArrayNoGa * myArray = ArrayConvert( *(field.getArrayGauss()) );
00072     myField->setArray(myArray);
00073     return myField;
00074   } else {
00075     ArrayNoNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) );
00076     myField->setArray(myArray);
00077     return myField;
00078   }
00079 
00080 }
00081 
00082 template <class T> FIELD<T,FullInterlace> *
00083 FieldConvert(const FIELD<T,NoInterlaceByType> & field )
00084 {
00085   typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFullNo;
00086   typedef typename MEDMEM_ArrayInterface<T,FullInterlace,Gauss>::Array ArrayFullGa;
00087 
00088   FIELD<T,FullInterlace> * myField = new FIELD<T,FullInterlace>();
00089   FIELD_ * myField_ = myField;
00090   FIELD_ * field_ = &(const_cast< FIELD<T,NoInterlaceByType> &> (field));
00091   *myField_ = *field_;                        // Opérateur d'affectation de FIELD_ OK
00092   // *((FIELD_ *) myField) = (FIELD_ ) field; //Contructeur par recopie de FIELD_ Pourquoi?
00093 
00094   if  ( field.getGaussPresence() ) {
00095     ArrayFullGa * myArray = ArrayConvert( *(field.getArrayGauss()) );
00096     myField->setArray(myArray);
00097     return myField;
00098   } else {
00099     ArrayFullNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) );
00100     myField->setArray(myArray);
00101     return myField;
00102   }
00103 }
00104 
00105 }
00106 #endif