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