1 #include "MEDMEM_Mesh.hxx"
2 #include "MEDMEM_CellModel.hxx"
4 int main (int argc, char ** argv) {
6 const string MedFile = "pointe.med" ;
7 const string MeshName = "maa1" ;
8 MESH myMesh(MED_DRIVER,MedFile,MeshName) ;
11 cout << "Mesh name : " << myMesh.getName() << endl << endl ;
13 // we get all type for cell entity :
14 int NumberOfTypes = myMesh.getNumberOfTypes(MED_CELL) ;
15 const CELLMODEL * Types = myMesh.getCellsTypes(MED_CELL) ;
17 cout << "Show Connectivity (Nodal) :" << endl ;
18 // this example use access with a specified medGeometryElement through
20 for (int i=0; i<NumberOfTypes; i++) {
21 cout << "For type " << Types[i].getName() << " : " << endl ;
22 medGeometryElement myType = Types[i].getType() ;
23 int NumberOfElements = myMesh.getNumberOfElements(MED_CELL,myType);
24 int NomberOfNodesPerCell = Types[i].getNumberOfNodes() ;
25 const int * Connectivity =
26 myMesh.getConnectivity(MED_FULL_INTERLACE,
30 for (int j=0; j<NumberOfElements; j++){
31 cout << "Element "<< j+1 <<" : " ;
32 for (int k=0; k<NomberOfNodesPerCell; k++)
33 cout << Connectivity[j*NomberOfNodesPerCell+k]<<" ";
37 cout << "Show Reverse Nodal Connectivity :" << endl ;
38 // this example use global access with index array
39 int NumberOfNodes = myMesh.getNumberOfNodes() ;
40 const int * ReverseNodalConnectivity =
41 myMesh.getReverseConnectivity(MED_NODAL) ;
42 const int * ReverseNodalConnectivityIndex =
43 myMesh.getReverseConnectivityIndex(MED_NODAL) ;
44 for (int i=0; i<NumberOfNodes; i++) {
45 cout << "Node "<<i+1<<" : " ;
46 int IndexBegin = ReverseNodalConnectivityIndex[i] ;
47 int IndexEnd = ReverseNodalConnectivityIndex[i+1] ;
48 for (int j=IndexBegin; j<IndexEnd; j++)
49 // Index value begin at 1 so use j-1
50 cout << ReverseNodalConnectivity[j-1] << " " ;
54 cout << "Show Connectivity (Descending) :" << endl ;
55 // this example use global access with index array
56 int NumberOfElements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
57 const int * DescendingConnectivity =
58 myMesh.getConnectivity(MED_FULL_INTERLACE,
62 const int * DescendingConnectivityIndex =
63 myMesh.getConnectivityIndex(MED_DESCENDING,MED_CELL);
64 for (int i=0; i<NumberOfElements; i++) {
65 cout << "Element "<<i+1<<" : " ;
66 int IndexBegin = DescendingConnectivityIndex[i] ;
67 int IndexEnd = DescendingConnectivityIndex[i+1] ;
68 for (int j=IndexBegin; j<IndexEnd; j++)
69 // Index value begin at 1 so use j-1
70 cout << DescendingConnectivity[j-1] << " " ;
74 cout << "Show Reverse Descending Connectivity :" << endl ;
75 // this example use global access with Index array
76 const int * ReverseDescendingConnectivity =
77 myMesh.getReverseConnectivity(MED_DESCENDING) ;
78 const int * ReverseDescendingConnectivityIndex =
79 myMesh.getReverseConnectivityIndex(MED_DESCENDING) ;
81 int MeshDimension = myMesh.getMeshDimension() ;
82 int NumberOfConstituents = 0;
84 medEntityMesh ConstituentEntity ;
85 // test if we have face (3D) or edge (2D)
86 if (MeshDimension==3) {
87 Constituent = "Face" ;
88 ConstituentEntity = MED_FACE ;
90 if (MeshDimension==2) {
91 Constituent = "Edge" ;
92 ConstituentEntity = MED_EDGE ;
95 NumberOfConstituents =
96 myMesh.getNumberOfElements(ConstituentEntity,MED_ALL_ELEMENTS);
98 if (MeshDimension==1) {
99 MESSAGE("ERROR : MeshDimension = 1 !");
100 MESSAGE("We could not see Reverse Descending Connectivity.") ;
102 for (int i=0; i<NumberOfConstituents; i++) {
103 cout << Constituent << " " << i+1 << " : " ;
104 int IndexBegin = ReverseDescendingConnectivityIndex[i] ;
105 int IndexEnd = ReverseDescendingConnectivityIndex[i+1] ;
106 for (int j=IndexBegin;j<IndexEnd;j++)
107 // Index value begin at 1 so use j-1
108 cout << ReverseDescendingConnectivity[j-1] << " " ;
112 cout << "Show "<< Constituent <<" Connectivity (Nodal) :" << endl ;
113 // this example use global access with index array
114 const int * ConstituentConnectivity =
115 myMesh.getConnectivity(MED_FULL_INTERLACE,
119 const int * ConstituentConnectivityIndex =
120 myMesh.getConnectivityIndex(MED_NODAL,ConstituentEntity);
121 for (int i=0; i<NumberOfConstituents; i++) {
122 cout << Constituent << " " << i+1 << " : " ;
123 int IndexBegin = ConstituentConnectivityIndex[i] ;
124 int IndexEnd = ConstituentConnectivityIndex[i+1] ;
125 for (int j=IndexBegin; j<IndexEnd; j++)
126 // Index value begin at 1 so use j-1
127 cout << ConstituentConnectivity[j-1]<<" ";