]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/test_copie_coordinate.cxx
Salome HOME
remove a reference to the $MED_ROOT_DIR in the Makefile.in wich is useless
[modules/med.git] / src / MEDMEM / test_copie_coordinate.cxx
1 /* Programme de test du constructeur de copies de la classe COORDINATE de MEDMEM
2    jroy - 17/12/2002 */
3
4 #include <string>
5
6 #include <math.h>
7 #include <stdlib.h>
8
9 #include "MEDMEM_Exception.hxx"
10 #include "MEDMEM_Mesh.hxx"
11 #include "MEDMEM_Family.hxx"
12 #include "MEDMEM_Group.hxx"
13
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"
19
20 #ifdef _DEBUG_
21 #include "LocalTraceCollector.hxx"
22 #endif /* ifdef _DEBUG_*/
23
24 using namespace std;
25 using namespace MEDMEM;
26 using namespace MED_EN;
27
28 void affiche_tableau(const double * myArray, int nb_lignes, int nb_colonnes)
29 {
30   cout << "Nombre de lignes : " << nb_lignes << endl;
31   cout << "Nombre de colonnes : " << nb_colonnes << endl;
32   cout << "Valeurs :" << endl;
33
34   for (int i=0; i<nb_lignes; i++) {
35     for (int j=0; j<nb_colonnes; j++)
36       cout << myArray[j*nb_lignes+i] << " ";
37     cout << endl;}
38 }
39
40 void affiche_coordinate(COORDINATE & myCoordinate, int _numberofNodes, int _spaceDimension)
41 {
42   cout << "- Système de coordonnées : " << myCoordinate.getCoordinatesSystem() << endl;
43   cout << "- Tableau des coordonnées : " << endl;
44   //  affiche_medarray(* myCoordinate.getCoordinatePtr());
45   affiche_tableau(myCoordinate.getCoordinates(MED_NO_INTERLACE),_numberofNodes,_spaceDimension);
46   //on récupère les dimensions
47   //  int _spaceDimension = (int) myCoordinate.getCoordinatePtr()->getLeadingValue();
48   //int _numberofNodes = (int) myCoordinate.getCoordinatePtr()->getLengthValue();
49   cout << "- Nom des coordonnées : " << endl;
50   for (int i=1; i<=_spaceDimension; i++)
51     cout << i << "   " << myCoordinate.getCoordinateName(i) << endl;
52   //  cout<<myCoordinate.getCoordinatesNames()<<endl;
53   cout << "- Unité des coordonnées : " << endl;
54   for (int i=1; i<=_spaceDimension; i++)
55     cout << i << "   " << myCoordinate.getCoordinateUnit(i) << endl;
56   cout << "- Indices des noeuds : " << endl;
57   //  cout<<myCoordinate.getNodesNumbers()<<endl;
58   for (int i=0; i<_numberofNodes; i++)
59     cout << i << "   " << myCoordinate.getNodesNumbers()[i] << endl;
60 }
61
62
63 int main (int argc, char ** argv) {
64 #ifdef _DEBUG_
65   LocalTraceCollector::instance();
66 #endif /* ifdef _DEBUG_*/
67
68   /*
69   if ((argc !=3) && (argc != 4)) {
70     cerr << "Usage : " << argv[0] 
71          << " filename meshname fieldname" << endl << endl;
72     exit(-1);
73   }
74   */
75   const med_int numberofNodes = 5;
76   const med_int spaceDimension = 3;
77   const medModeSwitch mode = MED_FULL_INTERLACE;
78
79   //construction tableau MEDARRAY des coordonnées
80   MEDARRAY<double> * myMedArray = new MEDARRAY<double>(spaceDimension,numberofNodes,mode);
81   for (med_int i=1; i<=myMedArray->getLengthValue(); i++) {
82     for (med_int j=1; j<=myMedArray->getLeadingValue(); j++)
83       myMedArray->setIJ(i,j,(double) random());
84   };
85
86   //construction noms des coordonnées
87   string * myCoordinatesNames = new string[spaceDimension];
88   if (spaceDimension >= 1) myCoordinatesNames[0] = "x";
89   if (spaceDimension >= 2) myCoordinatesNames[1] = "y";
90   if (spaceDimension >= 3) myCoordinatesNames[2] = "z";
91
92   //construction unités des coordonnées
93   string * myCoordinatesUnits = new string[spaceDimension];
94   if (spaceDimension >= 1) myCoordinatesUnits[0] = "m";
95   if (spaceDimension >= 2) myCoordinatesUnits[1] = "m";
96   if (spaceDimension >= 3) myCoordinatesUnits[2] = "m";
97
98   //construction des indices des noeuds
99   int * myNodeNumber = new int[numberofNodes];
100   for (int i=0; i<numberofNodes; i++)
101     myNodeNumber[i]=numberofNodes-i-1;
102
103   //construction de l'objet COORDINATE
104   COORDINATE * myCoordinate = new COORDINATE();
105   myCoordinate->setCoordinates(myMedArray);
106   myCoordinate->setCoordinatesNames(myCoordinatesNames);
107   myCoordinate->setCoordinatesUnits(myCoordinatesUnits);
108   myCoordinate->setNodesNumbers(myNodeNumber);
109
110   //  myCoordinate->setCoordinatesNames((string *)NULL);
111   //  myCoordinate->setNodesNumbers((int *) NULL);
112
113   delete myMedArray ;
114   delete[] myCoordinatesNames ;
115   delete[] myCoordinatesUnits ;
116   delete[] myNodeNumber ;
117
118   affiche_coordinate(* myCoordinate,numberofNodes,spaceDimension);
119   COORDINATE * myCoordinate2 = new COORDINATE(* myCoordinate);
120   delete myCoordinate ;
121
122   affiche_coordinate(* myCoordinate2,numberofNodes,spaceDimension);
123   delete myCoordinate2 ;
124
125   return 0;
126 }