]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/test_copie_family.cxx
Salome HOME
update due to bugs PAL8113 and another I do not remember the number ;) .
[modules/med.git] / src / MEDMEM / test_copie_family.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 using namespace std;
18 using namespace MEDMEM;
19 using namespace MED_EN;
20
21 void affiche_support(const SUPPORT * mySupport) 
22 {
23   cout << "  - Name : "<<mySupport->getName().c_str()<<endl ;
24   cout << "  - Description : "<<mySupport->getDescription().c_str()<<endl ;
25   cout << "  - Entity : "<<mySupport->getEntity()<<endl ;
26   cout << "  - Entities list : "<<endl ;
27   if (!(mySupport->isOnAllElements())) {
28     int NumberOfTypes = mySupport->getNumberOfTypes() ;
29     cout<<"  - NumberOfTypes : "<<NumberOfTypes<<endl;
30     const medGeometryElement * Types = mySupport->getTypes() ;
31     for (int j=0;j<NumberOfTypes;j++) {
32       cout<<"    * Type "<<Types[j]<<" : ";
33       int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
34       const int * Number = mySupport->getNumber(Types[j]) ;
35       for (int k=0; k<NumberOfElements;k++)
36         cout << Number[k] << " ";
37       cout << endl ;
38     }
39   } else
40     cout << "    Is on all entities !"<< endl;
41 }
42
43
44 void affiche_famille(const FAMILY * myFamily)
45 {
46     affiche_support(myFamily);
47     cout << "  - Identifier : "<<myFamily->getIdentifier()<<endl ;
48     int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
49     cout << "  - Attributes ("<<NumberOfAttributes<<") :"<<endl;
50     for (int j=1;j<NumberOfAttributes+1;j++)
51       cout << "    * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str()<<endl ;
52     int NumberOfGroups = myFamily->getNumberOfGroups() ;
53     cout << "  - Groups ("<<NumberOfGroups<<") :"<<endl;
54     for (int j=1;j<NumberOfGroups+1;j++)
55       cout << "    * "<<myFamily->getGroupName(j).c_str()<<endl ;
56 }
57
58 void affiche_groupe(MESH *myMesh,medEntityMesh Entity) 
59 {
60   int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
61   cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
62   for (int i=1; i<NumberOfGroups+1;i++) {
63     const GROUP* myGroup = myMesh->getGroup(Entity,i);
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
72 int main (int argc, char ** argv) {
73
74   int read;
75
76   if (argc <3) { // after 3, ignored !
77     cerr << "Usage : " << argv[0] 
78          << " filename meshname" << endl << endl;
79     exit(-1);
80   }
81
82   string filename = argv[1] ;
83   string meshname = argv[2] ;
84
85   MESH * myMesh= new MESH() ;
86   myMesh->setName(meshname);
87   MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
88   myMeshDriver.setMeshName(meshname);
89   myMeshDriver.open() ;
90   myMeshDriver.read() ;
91   myMeshDriver.close() ;
92
93   const FAMILY * myFamily = myMesh->getFamily(MED_NODE,1);
94   //On renseigne les attributs spécifiques à FAMILY (p/r à SUPPORT) et non renseignés lors de la lecture du maillage
95 //    int  NumberOfAttribute = 3;
96 //    int *AttributeIdentifier = new int[NumberOfAttribute];
97 //    int *AttributeValue = new int[NumberOfAttribute];
98 //    string *AttributeDescription = new string[NumberOfAttribute];
99 //    char *tmp;
100 //    for (int i=0;i<NumberOfAttribute;i++)
101 //      {
102 //        AttributeIdentifier[i]=i+1;
103 //        AttributeValue[i]=(i+1)*10;
104 //        sprintf(tmp,"Attribut N° %d",i+1);
105 //        AttributeDescription[i]=tmp;
106 //      }
107
108 //    myFamily->setNumberOfAttributes(NumberOfAttribute);
109 //    myFamily->setAttributesIdentifiers (AttributeIdentifier);
110 //    myFamily->setAttributesValues (AttributeValue);
111 //    myFamily->setAttributesDescriptions (AttributeDescription);
112
113   cout << "Show Family :"<<endl ;
114   affiche_famille(myFamily);
115   FAMILY * myFamily2 = new FAMILY(* myFamily);
116   //delete myFamily;
117   cout << "Show Family2 :"<<endl ;
118   affiche_famille(myFamily2);
119   FAMILY * myFamily3 = new FAMILY(* myFamily2);
120   delete myFamily2;
121   cout << "Show Family3 :"<<endl ;
122   affiche_famille(myFamily3);
123   delete myFamily3;
124
125   cout << "That's all"<<endl ;
126
127   /*
128   cout << "Show Group :"<<endl ;
129   affiche_groupe(myMesh,MED_NODE);
130   affiche_groupe(myMesh,MED_CELL);
131   affiche_groupe(myMesh,MED_FACE);
132   affiche_groupe(myMesh,MED_EDGE);
133   */
134
135   delete myMesh;
136
137   return 0;
138 }