1 // Copyright (C) 2007-2012 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 COORDINATE 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_tableau(const double * myArray, int nb_lignes, int nb_colonnes)
47 cout << "Nombre de lignes : " << nb_lignes << endl;
48 cout << "Nombre de colonnes : " << nb_colonnes << endl;
49 cout << "Valeurs :" << endl;
51 for (int i=0; i<nb_lignes; i++) {
52 for (int j=0; j<nb_colonnes; j++)
53 cout << myArray[j*nb_lignes+i] << " ";
57 static void affiche_coordinate(COORDINATE & myCoordinate, int _numberofNodes, int _spaceDimension)
59 cout << "- Système de coordonnées : " << myCoordinate.getCoordinatesSystem() << endl;
60 cout << "- Tableau des coordonnées : " << endl;
61 // affiche_medarray(* myCoordinate.getCoordinatePtr());
62 affiche_tableau(myCoordinate.getCoordinates(MED_NO_INTERLACE),_numberofNodes,_spaceDimension);
63 //on récupère les dimensions
64 // int _spaceDimension = (int) myCoordinate.getCoordinatePtr()->getLeadingValue();
65 //int _numberofNodes = (int) myCoordinate.getCoordinatePtr()->getLengthValue();
66 cout << "- Nom des coordonnées : " << endl;
67 for (int i=1; i<=_spaceDimension; i++)
68 cout << i << " " << myCoordinate.getCoordinateName(i) << endl;
69 // cout<<myCoordinate.getCoordinatesNames()<<endl;
70 cout << "- Unité des coordonnées : " << endl;
71 for (int i=1; i<=_spaceDimension; i++)
72 cout << i << " " << myCoordinate.getCoordinateUnit(i) << endl;
73 cout << "- Indices des noeuds : " << endl;
74 // cout<<myCoordinate.getNodesNumbers()<<endl;
75 for (int i=0; i<_numberofNodes; i++)
76 cout << i << " " << myCoordinate.getNodesNumbers()[i] << endl;
80 int main (int argc, char ** argv) {
82 if ((argc !=3) && (argc != 4)) {
83 cerr << "Usage : " << argv[0]
84 << " filename meshname fieldname" << endl << endl;
88 const med_int numberofNodes = 5;
89 const med_int spaceDimension = 3;
90 const medModeSwitch mode = MED_FULL_INTERLACE;
92 //construction tableau MEDARRAY des coordonnées
93 MEDARRAY<double> * myMedArray = new MEDARRAY<double>(spaceDimension,numberofNodes,mode);
94 for (med_int i=1; i<=myMedArray->getLengthValue(); i++) {
95 for (med_int j=1; j<=myMedArray->getLeadingValue(); j++)
96 myMedArray->setIJ(i,j,(double) rand());
99 //construction noms des coordonnées
100 string * myCoordinatesNames = new string[spaceDimension];
101 if (spaceDimension >= 1) myCoordinatesNames[0] = "x";
102 if (spaceDimension >= 2) myCoordinatesNames[1] = "y";
103 if (spaceDimension >= 3) myCoordinatesNames[2] = "z";
105 //construction unités des coordonnées
106 string * myCoordinatesUnits = new string[spaceDimension];
107 if (spaceDimension >= 1) myCoordinatesUnits[0] = "m";
108 if (spaceDimension >= 2) myCoordinatesUnits[1] = "m";
109 if (spaceDimension >= 3) myCoordinatesUnits[2] = "m";
111 //construction des indices des noeuds
112 int * myNodeNumber = new int[numberofNodes];
113 for (int i=0; i<numberofNodes; i++)
114 myNodeNumber[i]=numberofNodes-i-1;
116 //construction de l'objet COORDINATE
117 COORDINATE * myCoordinate = new COORDINATE();
118 myCoordinate->setCoordinates(myMedArray);
119 myCoordinate->setCoordinatesNames(myCoordinatesNames);
120 myCoordinate->setCoordinatesUnits(myCoordinatesUnits);
121 myCoordinate->setNodesNumbers(myNodeNumber);
123 // myCoordinate->setCoordinatesNames((string *)NULL);
124 // myCoordinate->setNodesNumbers((int *) NULL);
127 delete[] myCoordinatesNames ;
128 delete[] myCoordinatesUnits ;
129 delete[] myNodeNumber ;
131 affiche_coordinate(* myCoordinate,numberofNodes,spaceDimension);
132 COORDINATE * myCoordinate2 = new COORDINATE(* myCoordinate);
133 delete myCoordinate ;
135 affiche_coordinate(* myCoordinate2,numberofNodes,spaceDimension);
136 delete myCoordinate2 ;