1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 /* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM
30 #include "MEDMEM_Exception.hxx"
31 #include "MEDMEM_Mesh.hxx"
32 #include "MEDMEM_Family.hxx"
33 #include "MEDMEM_Group.hxx"
35 #include "MEDMEM_MedMeshDriver.hxx"
36 #include "MEDMEM_MedFieldDriver.hxx"
37 #include "MEDMEM_Support.hxx"
38 #include "MEDMEM_Field.hxx"
39 #include "MEDMEM_define.hxx"
42 using namespace MEDMEM;
43 using namespace MED_EN;
45 static void affiche_medarray(MEDARRAY<double> & myMedArray)
48 MESSAGE_MED("Show all 1 :");
49 numberof = myMedArray.getLeadingValue() ;
50 for (int i=1; i<=myMedArray.getLengthValue() ; i++) {
51 const double * node = myMedArray.getRow(i) ;
53 for (int j=0;j<numberof;j++)
54 cout << node[j] << " " ;
57 MESSAGE_MED("Show all 2 :");
58 numberof = myMedArray.getLengthValue() ;
59 for (int i=1; i<=myMedArray.getLeadingValue() ; i++) {
60 const double * node = myMedArray.getColumn(i) ;
62 for (int j=0;j<numberof;j++)
63 cout << node[j] << " " ;
66 MESSAGE_MED("Show all 3 :");
67 numberof = myMedArray.getLeadingValue() ;
68 for (int i=1; i<=myMedArray.getLengthValue() ; i++) {
70 for (int j=1;j<numberof+1;j++)
71 cout << myMedArray.getIJ(i,j) << " " ;
75 MESSAGE_MED("Show all 0 :");
76 numberof = myMedArray.getLeadingValue() ;
77 int length = myMedArray.getLengthValue() ;
78 const double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ;
79 for (int i=0; i<length ; i++) {
81 for (int j=0;j<numberof;j++)
82 cout << NoInterlaceArray[j*length+i] << " " ;
88 cout << "Nombre de lignes : " << myMedArray.getLengthValue() << endl;
89 cout << "Nombre de colonnes : " << myMedArray.getLeadingValue() << endl;
90 cout << "Mode d'écriture en mémoire : " << myMedArray.getMode() << endl;
91 cout << "Valeurs (_valuesDefault) :" << endl;
93 for (med_int i=1; i<=myMedArray.getLengthValue(); i++) {
94 for (med_int j=1; j<=myMedArray.getLeadingValue(); j++)
95 cout << i << " " << j << " " << myMedArray.getIJ(i,j) << " " << endl;
101 int main (int argc, char ** argv) {
103 if ((argc !=3) && (argc != 4)) {
104 cerr << "Usage : " << argv[0]
105 << " filename meshname fieldname" << endl << endl;
109 const med_int nb_noeuds = 8;
110 const med_int dimension = 3;
111 const medModeSwitch mode = MED_NO_INTERLACE;
114 MEDARRAY<double> * myMedArray = new MEDARRAY<double>(dimension,nb_noeuds,mode);
115 for (med_int i=1; i<=myMedArray->getLengthValue(); i++) {
116 for (med_int j=1; j<=myMedArray->getLeadingValue(); j++)
117 myMedArray->setIJ(i,j,(double) rand());
120 affiche_medarray(* myMedArray);
121 MEDARRAY<double> * myMedArray2 = new MEDARRAY<double>();
122 * myMedArray2 = * myMedArray;
123 // delete myMedArray; // si on recopie les tableaux
124 affiche_medarray(* myMedArray2);
125 delete myMedArray; // si on ne recopie pas les tableaux