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