Back to index

salome-med  6.5.0
MEDMEM_ArrayConvert.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 MEDMEM_ARRAY_CONVERT_HXX
00024 #define MEDMEM_ARRAY_CONVERT_HXX
00025 
00026 namespace MEDMEM {
00027 
00028 template  <class T, class CHECKING_POLICY >
00029 MEDMEM_Array<T, FullInterlaceGaussPolicy, CHECKING_POLICY> *
00030 ArrayConvert(
00031              const MEDMEM_Array< T, NoInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0
00032              )
00033 {
00034   MEDMEM_Array<T,FullInterlaceGaussPolicy,CHECKING_POLICY> * myArray;
00035   if(values)
00036     myArray = new MEDMEM_Array<T,FullInterlaceGaussPolicy,CHECKING_POLICY> 
00037       (values,
00038        array.getDim(),
00039        array.getNbElem(),
00040        array.getNbGeoType(),
00041        array.getNbElemGeoC(),
00042        array.getNbGaussGeo(),
00043        true,false
00044        );
00045   else
00046      myArray= new MEDMEM_Array<T,FullInterlaceGaussPolicy,CHECKING_POLICY> 
00047       (array.getDim(),
00048        array.getNbElem(),
00049        array.getNbGeoType(),
00050        array.getNbElemGeoC(),
00051        array.getNbGaussGeo()
00052        );
00053   for (int i=1; i <= array.getNbElem() ; i++ )
00054     for (int k=1; k<= array.getNbGauss(i); k++ )
00055       for (int j=1; j<= array.getDim(); j++ )
00056         myArray->setIJK(i,j,k,array.getIJK(i,j,k));
00057 
00058   return myArray;
00059 
00060 }
00061 
00062 template  <class T, class CHECKING_POLICY>
00063 MEDMEM_Array<T, NoInterlaceGaussPolicy, CHECKING_POLICY> *
00064 ArrayConvert(
00065              const MEDMEM_Array< T, FullInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0
00066              )
00067 {
00068   MEDMEM_Array<T,NoInterlaceGaussPolicy,CHECKING_POLICY> * myArray;
00069   if(values)
00070     myArray = new MEDMEM_Array<T, NoInterlaceGaussPolicy,CHECKING_POLICY> (
00071                                                                            values,
00072                                                                            array.getDim(),
00073                                                                            array.getNbElem(),
00074                                                                            array.getNbGeoType(),
00075                                                                            array.getNbElemGeoC(),
00076                                                                            array.getNbGaussGeo(),
00077                                                                            true,false
00078                                                                            );
00079   else
00080     myArray = new MEDMEM_Array<T, NoInterlaceGaussPolicy,CHECKING_POLICY> (
00081                                                                            array.getDim(),
00082                                                                            array.getNbElem(),
00083                                                                            array.getNbGeoType(),
00084                                                                            array.getNbElemGeoC(),
00085                                                                            array.getNbGaussGeo()
00086                                                                            );
00087   for (int i=1; i <= array.getNbElem() ; i++ )
00088     for (int k=1; k<= array.getNbGauss(i); k++ )
00089       for (int j=1; j<= array.getDim(); j++ )
00090         myArray->setIJK(i,j,k,array.getIJK(i,j,k));
00091 
00092   return myArray;
00093 
00094 }
00095 
00096 template  <class T, class CHECKING_POLICY>
00097 MEDMEM_Array<T, FullInterlaceGaussPolicy, CHECKING_POLICY> *
00098 ArrayConvert(
00099              const MEDMEM_Array< T, NoInterlaceByTypeGaussPolicy, CHECKING_POLICY > &array, T* values=0
00100              )
00101 {
00102   MEDMEM_Array<T,FullInterlaceGaussPolicy,CHECKING_POLICY> * myArray;
00103   if(values)
00104     myArray = new MEDMEM_Array<T, FullInterlaceGaussPolicy,CHECKING_POLICY> (
00105                                                                            values,
00106                                                                            array.getDim(),
00107                                                                            array.getNbElem(),
00108                                                                            array.getNbGeoType(),
00109                                                                            array.getNbElemGeoC(),
00110                                                                            array.getNbGaussGeo(),
00111                                                                            true,false
00112                                                                            );
00113   else
00114     myArray = new MEDMEM_Array<T, FullInterlaceGaussPolicy,CHECKING_POLICY> (
00115                                                                            array.getDim(),
00116                                                                            array.getNbElem(),
00117                                                                            array.getNbGeoType(),
00118                                                                            array.getNbElemGeoC(),
00119                                                                            array.getNbGaussGeo()
00120                                                                            );
00121   for (int i=1; i <= array.getNbElem() ; i++ )
00122     for (int k=1; k<= array.getNbGauss(i); k++ )
00123       for (int j=1; j<= array.getDim(); j++ )
00124         myArray->setIJK(i,j,k,array.getIJK(i,j,k));
00125   
00126   return myArray;
00127 
00128 }
00129 
00130 template  <class T, class CHECKING_POLICY>
00131 MEDMEM_Array<T, NoInterlaceGaussPolicy, CHECKING_POLICY> *
00132 ArrayConvert2No(
00133              const MEDMEM_Array< T, NoInterlaceByTypeGaussPolicy, CHECKING_POLICY > &array, T* values=0
00134              )
00135 {
00136   MEDMEM_Array<T,NoInterlaceGaussPolicy,CHECKING_POLICY> * myArray;
00137   if(values)
00138     myArray = new MEDMEM_Array<T, NoInterlaceGaussPolicy,CHECKING_POLICY> (
00139                                                                            values,
00140                                                                            array.getDim(),
00141                                                                            array.getNbElem(),
00142                                                                            array.getNbGeoType(),
00143                                                                            array.getNbElemGeoC(),
00144                                                                            array.getNbGaussGeo(),
00145                                                                            true,false
00146                                                                            );
00147   else
00148     myArray = new MEDMEM_Array<T, NoInterlaceGaussPolicy,CHECKING_POLICY> (
00149                                                                            array.getDim(),
00150                                                                            array.getNbElem(),
00151                                                                            array.getNbGeoType(),
00152                                                                            array.getNbElemGeoC(),
00153                                                                            array.getNbGaussGeo()
00154                                                                            );
00155   for (int i=1; i <= array.getNbElem() ; i++ )
00156     for (int k=1; k<= array.getNbGauss(i); k++ )
00157       for (int j=1; j<= array.getDim(); j++ )
00158         myArray->setIJK(i,j,k,array.getIJK(i,j,k));
00159   
00160   return myArray;
00161 
00162 }
00163 
00164 template  <class T, class CHECKING_POLICY>
00165 MEDMEM_Array<T, NoInterlaceNoGaussPolicy, CHECKING_POLICY> *
00166 ArrayConvert(
00167              const MEDMEM_Array< T, FullInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0
00168              )
00169 {
00170   MEDMEM_Array<T,NoInterlaceNoGaussPolicy,CHECKING_POLICY> * myArray;
00171   if(values)
00172     myArray=new MEDMEM_Array<T, NoInterlaceNoGaussPolicy, CHECKING_POLICY> ( values,
00173                                                                              array.getDim(),
00174                                                                              array.getNbElem(),
00175                                                                              true,false
00176                                                                              );
00177   else
00178     myArray = new MEDMEM_Array<T, NoInterlaceNoGaussPolicy, CHECKING_POLICY> (
00179                                                                               array.getDim(),
00180                                                                               array.getNbElem()
00181                                                                               );
00182   for (int i=1; i <= array.getNbElem() ; i++ )
00183     for (int j=1; j<= array.getDim(); j++ )
00184       myArray->setIJ(i,j,array.getIJ(i,j));
00185 
00186   return myArray;
00187 
00188 }
00189 
00190 template  <class T, class CHECKING_POLICY>
00191 MEDMEM_Array<T, FullInterlaceNoGaussPolicy, CHECKING_POLICY> *
00192 ArrayConvert(
00193              const MEDMEM_Array< T, NoInterlaceByTypeNoGaussPolicy, CHECKING_POLICY > &array, T* values=0
00194              )
00195 {
00196   MEDMEM_Array<T,FullInterlaceNoGaussPolicy,CHECKING_POLICY> * myArray;
00197   if(values)
00198     myArray=new MEDMEM_Array<T, FullInterlaceNoGaussPolicy, CHECKING_POLICY> ( values,
00199                                                                              array.getDim(),
00200                                                                              array.getNbElem(),
00201                                                                              true,false
00202                                                                              );
00203   else
00204     myArray = new MEDMEM_Array<T, FullInterlaceNoGaussPolicy, CHECKING_POLICY> (
00205                                                                               array.getDim(),
00206                                                                               array.getNbElem()
00207                                                                               );
00208   for (int i=1; i <= array.getNbElem() ; i++ )
00209     for (int j=1; j<= array.getDim(); j++ )
00210       myArray->setIJ(i,j,array.getIJ(i,j));
00211   
00212   return myArray;
00213 
00214 }
00215 
00216 template  <class T, class CHECKING_POLICY>
00217 MEDMEM_Array<T, NoInterlaceNoGaussPolicy, CHECKING_POLICY> *
00218 ArrayConvert2No(
00219              const MEDMEM_Array< T, NoInterlaceByTypeNoGaussPolicy, CHECKING_POLICY > &array, T* values=0
00220              )
00221 {
00222   MEDMEM_Array<T,NoInterlaceNoGaussPolicy,CHECKING_POLICY> * myArray;
00223   if(values)
00224     myArray=new MEDMEM_Array<T, NoInterlaceNoGaussPolicy, CHECKING_POLICY> ( values,
00225                                                                              array.getDim(),
00226                                                                              array.getNbElem(),
00227                                                                              true,false
00228                                                                              );
00229   else
00230     myArray = new MEDMEM_Array<T, NoInterlaceNoGaussPolicy, CHECKING_POLICY> (
00231                                                                               array.getDim(),
00232                                                                               array.getNbElem()
00233                                                                               );
00234   for (int i=1; i <= array.getNbElem() ; i++ )
00235     for (int j=1; j<= array.getDim(); j++ )
00236       myArray->setIJ(i,j,array.getIJ(i,j));
00237   
00238   return myArray;
00239 
00240 }
00241 
00242 template  <class T, class CHECKING_POLICY>
00243 MEDMEM_Array<T, FullInterlaceNoGaussPolicy, CHECKING_POLICY> *
00244 ArrayConvert(
00245              const MEDMEM_Array< T, NoInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0
00246              )
00247 {
00248   MEDMEM_Array<T,FullInterlaceNoGaussPolicy,CHECKING_POLICY> * myArray;
00249   if(values)
00250     myArray= new MEDMEM_Array<T, FullInterlaceNoGaussPolicy, CHECKING_POLICY> (values,
00251                                                                                array.getDim(),
00252                                                                                array.getNbElem(),
00253                                                                                true,false
00254                                                                                );
00255   else
00256     myArray= new MEDMEM_Array<T, FullInterlaceNoGaussPolicy, CHECKING_POLICY> (
00257                                                                                array.getDim(),
00258                                                                                array.getNbElem()
00259                                                                                );
00260   for (int i=1; i <= array.getNbElem() ; i++ )
00261     for (int j=1; j<= array.getDim(); j++ )
00262       myArray->setIJ(i,j,array.getIJ(i,j));
00263 
00264   return myArray;
00265 
00266 }
00267 
00268 
00269 
00270 // template  <class T,class INTERLACING_POLICY,class INTERLACING_POLICY_OTHER,
00271 //         class CHECKING_POLICY>
00272 // void ArrayConvert(
00273 //                const MEDMEM_Array< T, INTERLACING_POLICY, CHECKING_POLICY > & arrayin,
00274 //                MEDMEM_Array< T, INTERLACING_POLICY_OTHER, CHECKING_POLICY> * & arrayout
00275 //                )
00276 // {
00277 
00278 //   MEDMEM_Array<T,INTERLACING_POLICY_OTHER,CHECKING_POLICY> *  myArray;
00279 //   myArray= new MEDMEM_Array< T, INTERLACING_POLICY_OTHER, CHECKING_POLICY > (
00280 //                    arrayin.getDim(),
00281 //                    arrayin.getNbElem(),
00282 //                    arrayin.getNbGeoType(),
00283 //                    arrayin.getNbElemGeoC(),
00284 //                    arrayin.getNbGaussGeo()
00285 //                    );
00286 
00287 //   for (int i=1; i <= arrayin.getNbElem() ; i++ )
00288 //     for (int k=1; k<= arrayin.getNbGauss(i); k++ )
00289 //       for (int j=1; j<= arrayin.getDim(); j++ )
00290 //      myArray->setIJK(i,j,k,arrayin.getIJK(i,j,k));
00291 
00292 //   arrayout=myArray;
00293 
00294 // };
00295 
00296 
00297 
00298 
00299 
00300 // template  <class ARRAY_ELEMENT_TYPE,
00301 //         class GAUSS_TAG,class CHECKING_POLICY=IndexCheckPolicy>
00302 //            typename MEDMEM_ArrayInterface<ARRAY_ELEMENT_TYPE,
00303 //                    FullInterlace,
00304 //                    GAUSS_TAG,
00305 //                    CHECKING_POLICY>::Array &
00306 // convertBis(const typename MEDMEM_ArrayInterface<
00307 //         ARRAY_ELEMENT_TYPE,
00308 //         NoInterlace,
00309 //         GAUSS_TAG,
00310 //         CHECKING_POLICY>::Array & array ) {
00311 //   std::cout << "-------- Convert 3" << std::endl;
00312 // };
00313 
00314 } //END NAMESPACE
00315 #endif