7 #include "MEDMEM_Exception.hxx"
8 #include "MEDMEM_Mesh.hxx"
9 #include "MEDMEM_Family.hxx"
10 #include "MEDMEM_Group.hxx"
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"
18 using namespace MEDMEM;
20 void affiche_support(const SUPPORT * mySupport)
22 cout << " - Name : "<<mySupport->getName().c_str()<<endl ;
23 cout << " - Description : "<<mySupport->getDescription().c_str()<<endl ;
24 cout << " - Entity : "<<mySupport->getEntity()<<endl ;
25 cout << " - Entities list : "<<endl ;
26 if (!(mySupport->isOnAllElements())) {
27 int NumberOfTypes = mySupport->getNumberOfTypes() ;
28 cout<<" - NumberOfTypes : "<<NumberOfTypes<<endl;
29 const medGeometryElement * Types = mySupport->getTypes() ;
30 for (int j=0;j<NumberOfTypes;j++) {
31 cout<<" * Type "<<Types[j]<<" : ";
32 int NumberOfElements = mySupport->getNumberOfElements(Types[j]) ;
33 const int * Number = mySupport->getNumber(Types[j]) ;
34 for (int k=0; k<NumberOfElements;k++)
35 cout << Number[k] << " ";
39 cout << " Is on all entities !"<< endl;
43 void affiche_famille(const FAMILY * myFamily)
45 affiche_support(myFamily);
46 cout << " - Identifier : "<<myFamily->getIdentifier()<<endl ;
47 int NumberOfAttributes = myFamily->getNumberOfAttributes() ;
48 cout << " - Attributes ("<<NumberOfAttributes<<") :"<<endl;
49 for (int j=1;j<NumberOfAttributes+1;j++)
50 cout << " * "<<myFamily->getAttributeIdentifier(j)<<" : "<<myFamily->getAttributeValue(j)<<", "<<myFamily->getAttributeDescription(j).c_str()<<endl ;
51 int NumberOfGroups = myFamily->getNumberOfGroups() ;
52 cout << " - Groups ("<<NumberOfGroups<<") :"<<endl;
53 for (int j=1;j<NumberOfGroups+1;j++)
54 cout << " * "<<myFamily->getGroupName(j).c_str()<<endl ;
57 void affiche_groupe(MESH *myMesh,medEntityMesh Entity)
59 int NumberOfGroups = myMesh->getNumberOfGroups(Entity) ;
60 cout << "NumberOfGroups : "<<NumberOfGroups<<endl;
61 for (int i=1; i<NumberOfGroups+1;i++) {
62 const GROUP* myGroup = myMesh->getGroup(Entity,i);
63 affiche_support(myGroup);
64 int NumberOfFamillies = myGroup->getNumberOfFamilies() ;
65 cout << " - Families ("<<NumberOfFamillies<<") :"<<endl;
66 for (int j=1;j<NumberOfFamillies+1;j++)
67 cout << " * "<<myGroup->getFamily(j)->getName().c_str()<<endl ;
71 int main (int argc, char ** argv) {
75 if (argc <3) { // after 3, ignored !
76 cerr << "Usage : " << argv[0]
77 << " filename meshname" << endl << endl;
81 string filename = argv[1] ;
82 string meshname = argv[2] ;
84 MESH * myMesh= new MESH() ;
85 myMesh->setName(meshname);
86 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
87 myMeshDriver.setMeshName(meshname);
90 myMeshDriver.close() ;
92 const FAMILY * myFamily = myMesh->getFamily(MED_NODE,1);
93 //On renseigne les attributs spécifiques à FAMILY (p/r à SUPPORT) et non renseignés lors de la lecture du maillage
94 // int NumberOfAttribute = 3;
95 // int *AttributeIdentifier = new int[NumberOfAttribute];
96 // int *AttributeValue = new int[NumberOfAttribute];
97 // string *AttributeDescription = new string[NumberOfAttribute];
99 // for (int i=0;i<NumberOfAttribute;i++)
101 // AttributeIdentifier[i]=i+1;
102 // AttributeValue[i]=(i+1)*10;
103 // sprintf(tmp,"Attribut N° %d",i+1);
104 // AttributeDescription[i]=tmp;
107 // myFamily->setNumberOfAttributes(NumberOfAttribute);
108 // myFamily->setAttributesIdentifiers (AttributeIdentifier);
109 // myFamily->setAttributesValues (AttributeValue);
110 // myFamily->setAttributesDescriptions (AttributeDescription);
112 cout << "Show Family :"<<endl ;
113 affiche_famille(myFamily);
114 FAMILY * myFamily2 = new FAMILY(* myFamily);
116 cout << "Show Family2 :"<<endl ;
117 affiche_famille(myFamily2);
118 FAMILY * myFamily3 = new FAMILY(* myFamily2);
120 cout << "Show Family3 :"<<endl ;
121 affiche_famille(myFamily3);
124 cout << "That's all"<<endl ;
127 cout << "Show Group :"<<endl ;
128 affiche_groupe(myMesh,MED_NODE);
129 affiche_groupe(myMesh,MED_CELL);
130 affiche_groupe(myMesh,MED_FACE);
131 affiche_groupe(myMesh,MED_EDGE);