]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_FieldConvert.hxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MEDMEM / MEDMEM_FieldConvert.hxx
1 //  Copyright (C) 2007-2008  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 #ifndef FIELD_CONVERT_HXX
23 #define FIELD_CONVERT_HXX
24
25 #include "MEDMEM_FieldForward.hxx"
26 #include "MEDMEM_ArrayInterface.hxx"
27 #include "MEDMEM_ArrayConvert.hxx"
28
29 namespace MEDMEM {
30 class FIELD_;
31
32 template <class T> FIELD<T,FullInterlace> *
33 FieldConvert(const FIELD<T,NoInterlace> & field )
34 {
35   typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFullNo;
36   typedef typename MEDMEM_ArrayInterface<T,FullInterlace,Gauss>::Array ArrayFullGa;
37
38   FIELD<T,FullInterlace> * myField = new FIELD<T,FullInterlace>();
39   FIELD_ * myField_ = myField;
40   FIELD_ * field_ = &(const_cast< FIELD<T,NoInterlace> &> (field));
41   *myField_ = *field_;                        // Opérateur d'affectation de FIELD_ OK
42   // *((FIELD_ *) myField) = (FIELD_ ) field; //Contructeur par recopie de FIELD_ Pourquoi?
43
44   if  ( field.getGaussPresence() ) {
45     ArrayFullGa * myArray = ArrayConvert( *(field.getArrayGauss()) );
46     myField->setArray(myArray);
47     return myField;
48   } else {
49     ArrayFullNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) );
50     myField->setArray(myArray);
51     return myField;
52   }
53 }
54
55 template <class T> FIELD<T,NoInterlace> *
56 FieldConvert(const FIELD<T,FullInterlace> & field )
57 {
58   typedef typename MEDMEM_ArrayInterface<T,NoInterlace,NoGauss>::Array ArrayNoNo;
59   typedef typename MEDMEM_ArrayInterface<T,NoInterlace,Gauss>::Array ArrayNoGa;
60
61
62   FIELD<T,NoInterlace> * myField = new FIELD<T,NoInterlace>();
63   FIELD_ * myField_ = myField;
64   FIELD_ * field_ = &(const_cast< FIELD<T,FullInterlace> &> (field));
65   *myField_ = *field_;                        // Opérateur d'affectation de FIELD_ OK
66   //   *((FIELD_*) myField) = (FIELD_) field; //Contructeur par recopie de FIELD_ Pourquoi?
67
68   if  ( field.getGaussPresence() ) {
69     ArrayNoGa * myArray = ArrayConvert( *(field.getArrayGauss()) );
70     myField->setArray(myArray);
71     return myField;
72   } else {
73     ArrayNoNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) );
74     myField->setArray(myArray);
75     return myField;
76   }
77
78 }
79
80 template <class T> FIELD<T,FullInterlace> *
81 FieldConvert(const FIELD<T,NoInterlaceByType> & field )
82 {
83   typedef typename MEDMEM_ArrayInterface<T,FullInterlace,NoGauss>::Array ArrayFullNo;
84   typedef typename MEDMEM_ArrayInterface<T,FullInterlace,Gauss>::Array ArrayFullGa;
85
86   FIELD<T,FullInterlace> * myField = new FIELD<T,FullInterlace>();
87   FIELD_ * myField_ = myField;
88   FIELD_ * field_ = &(const_cast< FIELD<T,NoInterlaceByType> &> (field));
89   *myField_ = *field_;                        // Opérateur d'affectation de FIELD_ OK
90   // *((FIELD_ *) myField) = (FIELD_ ) field; //Contructeur par recopie de FIELD_ Pourquoi?
91
92   if  ( field.getGaussPresence() ) {
93     ArrayFullGa * myArray = ArrayConvert( *(field.getArrayGauss()) );
94     myField->setArray(myArray);
95     return myField;
96   } else {
97     ArrayFullNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) );
98     myField->setArray(myArray);
99     return myField;
100   }
101 }
102
103 }
104 #endif