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(const FAMILY * myFamily)
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 ;
62 void affiche_groupe(MESH *myMesh,medEntityMesh Entity)
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 ;
76 int main (int argc, char ** argv) {
78 LocalTraceCollector::instance();
79 #endif /* ifdef _DEBUG_*/
83 if (argc <3) { // after 3, ignored !
84 cerr << "Usage : " << argv[0]
85 << " filename meshname" << endl << endl;
89 string filename = argv[1] ;
90 string meshname = argv[2] ;
92 MESH * myMesh= new MESH() ;
93 myMesh->setName(meshname);
94 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
95 myMeshDriver.setMeshName(meshname);
98 myMeshDriver.close() ;
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];
107 // for (int i=0;i<NumberOfAttribute;i++)
109 // AttributeIdentifier[i]=i+1;
110 // AttributeValue[i]=(i+1)*10;
111 // sprintf(tmp,"Attribut N° %d",i+1);
112 // AttributeDescription[i]=tmp;
115 // myFamily->setNumberOfAttributes(NumberOfAttribute);
116 // myFamily->setAttributesIdentifiers (AttributeIdentifier);
117 // myFamily->setAttributesValues (AttributeValue);
118 // myFamily->setAttributesDescriptions (AttributeDescription);
120 cout << "Show Family :"<<endl ;
121 affiche_famille(myFamily);
122 FAMILY * myFamily2 = new FAMILY(* myFamily);
124 cout << "Show Family2 :"<<endl ;
125 affiche_famille(myFamily2);
126 FAMILY * myFamily3 = new FAMILY(* myFamily2);
128 cout << "Show Family3 :"<<endl ;
129 affiche_famille(myFamily3);
132 cout << "That's all"<<endl ;
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);