6 #include "MEDMEM_Exception.hxx"
7 #include "MEDMEM_Mesh.hxx"
8 #include "MEDMEM_Family.hxx"
9 #include "MEDMEM_Group.hxx"
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"
18 #include "LocalTraceCollector.hxx"
19 #endif /* ifdef _DEBUG_*/
22 using namespace MEDMEM;
23 using namespace MED_EN;
25 void affiche_support(const SUPPORT * mySupport)
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] << " ";
44 cout << " Is on all entities !"<< endl;
48 void affiche_famille(MESH *myMesh,medEntityMesh Entity)
50 int NumberOfFamilies = myMesh->getNumberOfFamilies(Entity) ;
51 cout << "NumberOfFamilies : "<<NumberOfFamilies<<endl;
52 for (int i=1; i<NumberOfFamilies+1;i++) {
53 const FAMILY* myFamily = myMesh->getFamily(Entity,i);
54 affiche_support(myFamily);
55 cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
56 int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
57 cout << " - Attributes ("<<NumberOfAttributes<<") :"<<endl;
58 for (int j=1;j<NumberOfAttributes+1;j++)
59 cout << " * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str()<<endl ;
60 int NumberOfGroups = myFamily->getNumberOfGroups() ;
61 cout << " - Groups ("<<NumberOfGroups<<") :"<<endl;
62 for (int j=1;j<NumberOfGroups+1;j++)
63 cout << " * "<<myFamily->getGroupName(j).c_str()<<endl ;
67 void affiche_groupe(MESH *myMesh,medEntityMesh Entity)
69 int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
70 cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
71 for (int i=1; i<NumberOfGroups+1;i++) {
72 const GROUP* myGroup = myMesh->getGroup(Entity,i);
73 affiche_support(myGroup);
74 int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
75 cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
76 for (int j=1;j<NumberOfFamillies+1;j++)
77 cout << " * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
81 int main (int argc, char ** argv) {
83 LocalTraceCollector::instance();
84 #endif /* ifdef _DEBUG_*/
88 if (argc <3) { // after 3, ignored !
89 cerr << "Usage : " << argv[0]
90 << " filename meshname" << endl << endl;
94 string filename = argv[1] ;
95 string meshname = argv[2] ;
97 MESH * myMesh= new MESH() ;
98 myMesh->setName(meshname);
99 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
100 myMeshDriver.setMeshName(meshname);
101 myMeshDriver.open() ;
102 myMeshDriver.read() ;
103 myMeshDriver.close() ;
105 //Construction d'un support total
106 SUPPORT * mySupport = new SUPPORT(myMesh,"Support on CELLs",MED_CELL);
108 cout << "Show Support on all :"<<endl ;
109 affiche_support(mySupport);
110 SUPPORT * mySupport2 = new SUPPORT(* mySupport);
112 affiche_support(mySupport2);
115 //Construction d'un support partiel
116 mySupport = new SUPPORT(myMesh,"Support on CELLs",MED_CELL);
117 mySupport->setAll(false);
119 // int NumberOfGeometricType = 1;
120 int NumberOfGeometricType = 0;
121 // int TotalNumberOfEntity = 2;
122 // medGeometryElement * GeometricTypePartial = new medGeometryElement[NumberOfGeometricType];
123 // GeometricTypePartial[0] = MED_HEXA8;
124 int TotalNumberOfElements = 0;
125 int * NumberOfElements = new int[myMesh->getNumberOfTypes(MED_CELL)];
126 // NumberOfEntity[0] = 2;
127 // int * NumberValue = new int[TotalNumberOfEntity];
128 int * NumberValue = new int[myMesh->getGlobalNumberingIndex(MED_CELL)[myMesh->getNumberOfTypes(MED_CELL)]-1];
129 // NumberValue[0] = 14;
130 // NumberValue[1] = 15;
132 medGeometryElement * GeometricTypePartial = new medGeometryElement[myMesh->getNumberOfTypes(MED_CELL)];
133 const medGeometryElement * GeometricType = myMesh->getTypes(MED_CELL);
134 for (int i=0;i<myMesh->getNumberOfTypes(MED_CELL);i=i+2)
136 NumberOfGeometricType=NumberOfGeometricType+1;
137 TotalNumberOfElements=TotalNumberOfElements+myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
138 NumberOfElements[i/2]=myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);
139 for (int j=0;j<myMesh->getNumberOfElements(MED_CELL,GeometricType[i]);j++)
141 NumberValue[cmp]=myMesh->getGlobalNumberingIndex(MED_CELL)[i]+j;
144 GeometricTypePartial[i/2]=GeometricType[i];
147 mySupport->setpartial("Support partiel",NumberOfGeometricType,TotalNumberOfElements,GeometricTypePartial,NumberOfElements,NumberValue);
149 delete[] NumberOfElements ;
150 delete[] NumberValue ;
151 delete[] GeometricTypePartial ;
153 cout << "Show Partial Support :"<<endl ;
154 affiche_support(mySupport);
155 mySupport2 = new SUPPORT(* mySupport);
157 affiche_support(mySupport2);
161 cout << "Show Family :"<<endl ;
162 affiche_famille(myMesh,MED_NODE);
163 affiche_famille(myMesh,MED_CELL);
164 affiche_famille(myMesh,MED_FACE);
165 affiche_famille(myMesh,MED_EDGE);
167 cout << "Show Group :"<<endl ;
168 affiche_groupe(myMesh,MED_NODE);
169 affiche_groupe(myMesh,MED_CELL);
170 affiche_groupe(myMesh,MED_FACE);
171 affiche_groupe(myMesh,MED_EDGE);