1 /* Programme de test du constructeur de copies de la classe COORDINATE de MEDMEM
9 #include "MEDMEM_Exception.hxx"
10 #include "MEDMEM_Mesh.hxx"
11 #include "MEDMEM_Family.hxx"
12 #include "MEDMEM_Group.hxx"
14 #include "MEDMEM_MedMeshDriver.hxx"
15 #include "MEDMEM_MedFieldDriver.hxx"
16 #include "MEDMEM_Support.hxx"
17 #include "MEDMEM_Field.hxx"
18 #include "MEDMEM_define.hxx"
21 using namespace MEDMEM;
22 using namespace MED_EN;
24 void affiche_tableau(const double * myArray, int nb_lignes, int nb_colonnes)
26 cout << "Nombre de lignes : " << nb_lignes << endl;
27 cout << "Nombre de colonnes : " << nb_colonnes << endl;
28 cout << "Valeurs :" << endl;
30 for (int i=0; i<nb_lignes; i++) {
31 for (int j=0; j<nb_colonnes; j++)
32 cout << myArray[j*nb_lignes+i] << " ";
36 void affiche_coordinate(COORDINATE & myCoordinate, int _numberofNodes, int _spaceDimension)
38 cout << "- Système de coordonnées : " << myCoordinate.getCoordinatesSystem() << endl;
39 cout << "- Tableau des coordonnées : " << endl;
40 // affiche_medarray(* myCoordinate.getCoordinatePtr());
41 affiche_tableau(myCoordinate.getCoordinates(MED_NO_INTERLACE),_numberofNodes,_spaceDimension);
42 //on récupère les dimensions
43 // int _spaceDimension = (int) myCoordinate.getCoordinatePtr()->getLeadingValue();
44 //int _numberofNodes = (int) myCoordinate.getCoordinatePtr()->getLengthValue();
45 cout << "- Nom des coordonnées : " << endl;
46 for (int i=1; i<=_spaceDimension; i++)
47 cout << i << " " << myCoordinate.getCoordinateName(i) << endl;
48 // cout<<myCoordinate.getCoordinatesNames()<<endl;
49 cout << "- Unité des coordonnées : " << endl;
50 for (int i=1; i<=_spaceDimension; i++)
51 cout << i << " " << myCoordinate.getCoordinateUnit(i) << endl;
52 cout << "- Indices des noeuds : " << endl;
53 // cout<<myCoordinate.getNodesNumbers()<<endl;
54 for (int i=0; i<_numberofNodes; i++)
55 cout << i << " " << myCoordinate.getNodesNumbers()[i] << endl;
59 int main (int argc, char ** argv) {
62 if ((argc !=3) && (argc != 4)) {
63 cerr << "Usage : " << argv[0]
64 << " filename meshname fieldname" << endl << endl;
68 const med_int numberofNodes = 5;
69 const med_int spaceDimension = 3;
70 const medModeSwitch mode = MED_FULL_INTERLACE;
72 //construction tableau MEDARRAY des coordonnées
73 MEDARRAY<double> * myMedArray = new MEDARRAY<double>(spaceDimension,numberofNodes,mode);
74 for (med_int i=1; i<=myMedArray->getLengthValue(); i++) {
75 for (med_int j=1; j<=myMedArray->getLeadingValue(); j++)
76 myMedArray->setIJ(i,j,(double) random());
79 //construction noms des coordonnées
80 string * myCoordinatesNames = new string[spaceDimension];
81 if (spaceDimension >= 1) myCoordinatesNames[0] = "x";
82 if (spaceDimension >= 2) myCoordinatesNames[1] = "y";
83 if (spaceDimension >= 3) myCoordinatesNames[2] = "z";
85 //construction unités des coordonnées
86 string * myCoordinatesUnits = new string[spaceDimension];
87 if (spaceDimension >= 1) myCoordinatesUnits[0] = "m";
88 if (spaceDimension >= 2) myCoordinatesUnits[1] = "m";
89 if (spaceDimension >= 3) myCoordinatesUnits[2] = "m";
91 //construction des indices des noeuds
92 int * myNodeNumber = new int[numberofNodes];
93 for (int i=0; i<numberofNodes; i++)
94 myNodeNumber[i]=numberofNodes-i-1;
96 //construction de l'objet COORDINATE
97 COORDINATE * myCoordinate = new COORDINATE();
98 myCoordinate->setCoordinates(myMedArray);
99 myCoordinate->setCoordinatesNames(myCoordinatesNames);
100 myCoordinate->setCoordinatesUnits(myCoordinatesUnits);
101 myCoordinate->setNodesNumbers(myNodeNumber);
103 // myCoordinate->setCoordinatesNames((string *)NULL);
104 // myCoordinate->setNodesNumbers((int *) NULL);
107 delete[] myCoordinatesNames ;
108 delete[] myCoordinatesUnits ;
109 delete[] myNodeNumber ;
111 affiche_coordinate(* myCoordinate,numberofNodes,spaceDimension);
112 COORDINATE * myCoordinate2 = new COORDINATE(* myCoordinate);
113 delete myCoordinate ;
115 affiche_coordinate(* myCoordinate2,numberofNodes,spaceDimension);
116 delete myCoordinate2 ;