Salome HOME
adding some castem mesh file to test the GIBI driver of Med Memory.
[modules/med.git] / src / MEDMEM / test_copie_group.cxx
1 using namespace std;
2 #include<string>
3
4 #include <math.h>
5 #include <stdlib.h>
6
7 #include "MEDMEM_Exception.hxx"
8 #include "MEDMEM_Mesh.hxx"
9 #include "MEDMEM_Family.hxx"
10 #include "MEDMEM_Group.hxx"
11
12 #include "MEDMEM_MedMeshDriver.hxx"
13 #include "MEDMEM_MedFieldDriver.hxx"
14 #include "MEDMEM_Support.hxx"
15 #include "MEDMEM_Field.hxx"
16 #include "MEDMEM_define.hxx"
17
18
19 void affiche_support(const SUPPORT * mySupport) 
20 {
21   cout << "  - Name : "<<mySupport->getName().c_str()<<endl ;
22   cout << "  - Description : "<<mySupport->getDescription().c_str()<<endl ;
23   cout << "  - Entity : "<<mySupport->getEntity()<<endl ;
24   cout << "  - Entities list : "<<endl ;
25   if (!(mySupport->isOnAllElements())) {
26     int NumberOfTypes = mySupport->getNumberOfTypes() ;
27     cout<<"  - NumberOfTypes : "<<NumberOfTypes<<endl;
28     const medGeometryElement * Types = mySupport->getTypes() ;
29     for (int j=0;j<NumberOfTypes;j++) {
30       cout<<"    * Type "<<Types[j]<<" : ";
31       int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
32       const int * Number = mySupport->getNumber(Types[j]) ;
33       for (int k=0; k<NumberOfElements;k++)
34         cout << Number[k] << " ";
35       cout << endl ;
36     }
37   } else
38     cout << "    Is on all entities !"<< endl;
39 }
40
41
42 void affiche_famille(const FAMILY * myFamily)
43 {
44     affiche_support(myFamily);
45     cout << "  - Identifier : "<<myFamily->getIdentifier()<<endl ;
46     int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
47     cout << "  - Attributes ("<<NumberOfAttributes<<") :"<<endl;
48     for (int j=1;j<NumberOfAttributes+1;j++)
49       cout << "    * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str()<<endl ;
50     int NumberOfGroups = myFamily->getNumberOfGroups() ;
51     cout << "  - Groups ("<<NumberOfGroups<<") :"<<endl;
52     for (int j=1;j<NumberOfGroups+1;j++)
53       cout << "    * "<<myFamily->getGroupName(j).c_str()<<endl ;
54 }
55
56 void affiche_groupe(const GROUP * myGroup) 
57 {
58     affiche_support(myGroup);
59     int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
60     cout << "  - Families ("<<NumberOfFamillies<<") :"<<endl;
61     for (int j=1;j<NumberOfFamillies+1;j++)
62       cout << "    * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
63 }
64
65 int main (int argc, char ** argv) {
66
67   int read;
68
69   if (argc <3) { // after 3, ignored !
70     cerr << "Usage : " << argv[0] 
71          << " filename meshname" << endl << endl;
72     exit(-1);
73   }
74
75   string filename = argv[1] ;
76   string meshname = argv[2] ;
77
78   MESH * myMesh= new MESH() ;
79   myMesh->setName(meshname);
80   MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
81   myMeshDriver.setMeshName(meshname);
82   myMeshDriver.open() ;
83   myMeshDriver.read() ;
84   myMeshDriver.close() ;
85
86   const GROUP * myGroup = myMesh->getGroup(MED_NODE,1);
87   cout << "Show Group :"<<endl ;
88   affiche_groupe(myGroup);
89   GROUP * myGroup2 = new GROUP(* myGroup);
90   //delete myGroup; // no because in mesh !!
91   affiche_groupe(myGroup2);
92   GROUP * myGroup3 = new GROUP(* myGroup2);
93   delete myGroup2;
94   affiche_groupe(myGroup3);
95   delete myGroup3;
96
97   delete myMesh ;
98
99   return 0;
100 }