]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/test_copie_family.cxx
Salome HOME
update from the MedMemory V1.0.1
[modules/med.git] / src / MEDMEM / test_copie_family.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(MESH *myMesh,medEntityMesh Entity) 
57 {
58   int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
59   cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
60   for (int i=1; i<NumberOfGroups+1;i++) {
61     const GROUP* myGroup = myMesh->getGroup(Entity,i);
62     affiche_support(myGroup);
63     int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
64     cout << "  - Families ("<<NumberOfFamillies<<") :"<<endl;
65     for (int j=1;j<NumberOfFamillies+1;j++)
66       cout << "    * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
67   }
68 }
69
70 int main (int argc, char ** argv) {
71
72   int read;
73
74   if (argc <3) { // after 3, ignored !
75     cerr << "Usage : " << argv[0] 
76          << " filename meshname" << endl << endl;
77     exit(-1);
78   }
79
80   string filename = argv[1] ;
81   string meshname = argv[2] ;
82
83   MESH * myMesh= new MESH() ;
84   myMesh->setName(meshname);
85   MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
86   myMeshDriver.setMeshName(meshname);
87   myMeshDriver.open() ;
88   myMeshDriver.read() ;
89   myMeshDriver.close() ;
90
91   const FAMILY * myFamily = myMesh->getFamily(MED_NODE,1);
92   //On renseigne les attributs spécifiques à FAMILY (p/r à SUPPORT) et non renseignés lors de la lecture du maillage
93 //    int  NumberOfAttribute = 3;
94 //    int *AttributeIdentifier = new int[NumberOfAttribute];
95 //    int *AttributeValue = new int[NumberOfAttribute];
96 //    string *AttributeDescription = new string[NumberOfAttribute];
97 //    char *tmp;
98 //    for (int i=0;i<NumberOfAttribute;i++)
99 //      {
100 //        AttributeIdentifier[i]=i+1;
101 //        AttributeValue[i]=(i+1)*10;
102 //        sprintf(tmp,"Attribut N° %d",i+1);
103 //        AttributeDescription[i]=tmp;
104 //      }
105
106 //    myFamily->setNumberOfAttributes(NumberOfAttribute);
107 //    myFamily->setAttributesIdentifiers (AttributeIdentifier);
108 //    myFamily->setAttributesValues (AttributeValue);
109 //    myFamily->setAttributesDescriptions (AttributeDescription);
110
111   cout << "Show Family :"<<endl ;
112   affiche_famille(myFamily);
113   FAMILY * myFamily2 = new FAMILY(* myFamily);
114   //delete myFamily;
115   cout << "Show Family2 :"<<endl ;
116   affiche_famille(myFamily2);
117   FAMILY * myFamily3 = new FAMILY(* myFamily2);
118   delete myFamily2;
119   cout << "Show Family3 :"<<endl ;
120   affiche_famille(myFamily3);
121   delete myFamily3;
122
123   cout << "That's all"<<endl ;
124
125   /*
126   cout << "Show Group :"<<endl ;
127   affiche_groupe(myMesh,MED_NODE);
128   affiche_groupe(myMesh,MED_CELL);
129   affiche_groupe(myMesh,MED_FACE);
130   affiche_groupe(myMesh,MED_EDGE);
131   */
132
133   delete myMesh;
134
135   return 0;
136 }