1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 /* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM
28 #include "MEDMEM_Exception.hxx"
29 #include "MEDMEM_Mesh.hxx"
30 #include "MEDMEM_Family.hxx"
31 #include "MEDMEM_Group.hxx"
33 #include "MEDMEM_MedMeshDriver.hxx"
34 #include "MEDMEM_MedFieldDriver.hxx"
35 #include "MEDMEM_Support.hxx"
36 #include "MEDMEM_Field.hxx"
37 #include "MEDMEM_define.hxx"
40 using namespace MEDMEM;
41 using namespace MED_EN;
43 void affiche_medarray(MEDARRAY<double> & myMedArray)
46 MESSAGE("Show all 1 :");
47 numberof = myMedArray.getLeadingValue() ;
48 for (int i=1; i<=myMedArray.getLengthValue() ; i++) {
49 const double * node = myMedArray.getRow(i) ;
51 for (int j=0;j<numberof;j++)
52 cout << node[j] << " " ;
55 MESSAGE("Show all 2 :");
56 numberof = myMedArray.getLengthValue() ;
57 for (int i=1; i<=myMedArray.getLeadingValue() ; i++) {
58 const double * node = myMedArray.getColumn(i) ;
60 for (int j=0;j<numberof;j++)
61 cout << node[j] << " " ;
64 MESSAGE("Show all 3 :");
65 numberof = myMedArray.getLeadingValue() ;
66 for (int i=1; i<=myMedArray.getLengthValue() ; i++) {
68 for (int j=1;j<numberof+1;j++)
69 cout << myMedArray.getIJ(i,j) << " " ;
73 MESSAGE("Show all 0 :");
74 numberof = myMedArray.getLeadingValue() ;
75 int length = myMedArray.getLengthValue() ;
76 const double * NoInterlaceArray = myMedArray.get(MED_NO_INTERLACE) ;
77 for (int i=0; i<length ; i++) {
79 for (int j=0;j<numberof;j++)
80 cout << NoInterlaceArray[j*length+i] << " " ;
86 cout << "Nombre de lignes : " << myMedArray.getLengthValue() << endl;
87 cout << "Nombre de colonnes : " << myMedArray.getLeadingValue() << endl;
88 cout << "Mode d'écriture en mémoire : " << myMedArray.getMode() << endl;
89 cout << "Valeurs (_valuesDefault) :" << endl;
91 for (med_int i=1; i<=myMedArray.getLengthValue(); i++) {
92 for (med_int j=1; j<=myMedArray.getLeadingValue(); j++)
93 cout << i << " " << j << " " << myMedArray.getIJ(i,j) << " " << endl;
99 int main (int argc, char ** argv) {
101 if ((argc !=3) && (argc != 4)) {
102 cerr << "Usage : " << argv[0]
103 << " filename meshname fieldname" << endl << endl;
107 const med_int nb_noeuds = 8;
108 const med_int dimension = 3;
109 const medModeSwitch mode = MED_NO_INTERLACE;
112 MEDARRAY<double> * myMedArray = new MEDARRAY<double>(dimension,nb_noeuds,mode);
113 for (med_int i=1; i<=myMedArray->getLengthValue(); i++) {
114 for (med_int j=1; j<=myMedArray->getLeadingValue(); j++)
115 myMedArray->setIJ(i,j,(double) random());
118 affiche_medarray(* myMedArray);
119 MEDARRAY<double> * myMedArray2 = new MEDARRAY<double>(* myMedArray,false);
121 affiche_medarray(* myMedArray2);
122 MEDARRAY<double> * myMedArray3 = new MEDARRAY<double>(10,20);
123 (* myMedArray3) = (* myMedArray2) ;
125 affiche_medarray(* myMedArray3);