1 // MED MEDMEM : MED files in memory
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : test_affect_medarray.cxx
28 /* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM
36 #include "MEDMEM_Exception.hxx"
37 #include "MEDMEM_Mesh.hxx"
38 #include "MEDMEM_Family.hxx"
39 #include "MEDMEM_Group.hxx"
41 #include "MEDMEM_MedMeshDriver.hxx"
42 #include "MEDMEM_MedFieldDriver.hxx"
43 #include "MEDMEM_Support.hxx"
44 #include "MEDMEM_Field.hxx"
45 #include "MEDMEM_define.hxx"
48 void affiche_medarray(MEDARRAY<double> & myMedArray)
51 MESSAGE("Show all 1 :");
52 numberof = myMedArray.getLeadingValue() ;
53 for (int i=1; i<=myMedArray.getLengthValue() ; i++) {
54 const double * node = myMedArray.getRow(i) ;
56 for (int j=0;j<numberof;j++)
57 cout << node[j] << " " ;
60 MESSAGE("Show all 2 :");
61 numberof = myMedArray.getLengthValue() ;
62 for (int i=1; i<=myMedArray.getLeadingValue() ; i++) {
63 const double * node = myMedArray.getColumn(i) ;
65 for (int j=0;j<numberof;j++)
66 cout << node[j] << " " ;
69 MESSAGE("Show all 3 :");
70 numberof = myMedArray.getLeadingValue() ;
71 for (int i=1; i<=myMedArray.getLengthValue() ; i++) {
73 for (int j=1;j<numberof+1;j++)
74 cout << myMedArray.getIJ(i,j) << " " ;
78 MESSAGE("Show all 0 :");
79 numberof = myMedArray.getLeadingValue() ;
80 int length = myMedArray.getLengthValue() ;
81 const double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ;
82 for (int i=0; i<length ; i++) {
84 for (int j=0;j<numberof;j++)
85 cout << NoInterlaceArray[j*length+i] << " " ;
91 cout << "Nombre de lignes : " << myMedArray.getLengthValue() << endl;
92 cout << "Nombre de colonnes : " << myMedArray.getLeadingValue() << endl;
93 cout << "Mode d'écriture en mémoire : " << myMedArray.getMode() << endl;
94 cout << "Valeurs (_valuesDefault) :" << endl;
96 for (med_int i=1; i<=myMedArray.getLengthValue(); i++) {
97 for (med_int j=1; j<=myMedArray.getLeadingValue(); j++)
98 cout << i << " " << j << " " << myMedArray.getIJ(i,j) << " " << endl;
104 int main (int argc, char ** argv) {
107 if ((argc !=3) && (argc != 4)) {
108 cerr << "Usage : " << argv[0]
109 << " filename meshname fieldname" << endl << endl;
113 const med_int nb_noeuds = 8;
114 const med_int dimension = 3;
115 const medModeSwitch mode = MED_NO_INTERLACE;
118 MEDARRAY<double> * myMedArray = new MEDARRAY<double>(dimension,nb_noeuds,mode);
119 for (med_int i=1; i<=myMedArray->getLengthValue(); i++) {
120 for (med_int j=1; j<=myMedArray->getLeadingValue(); j++)
121 myMedArray->setIJ(i,j,(double) random());
124 affiche_medarray(* myMedArray);
125 MEDARRAY<double> * myMedArray2 = new MEDARRAY<double>();
126 * myMedArray2 = * myMedArray;
127 // delete myMedArray; // si on recopie les tableaux
128 affiche_medarray(* myMedArray2);
129 delete myMedArray; // si on ne recopie pas les tableaux