1 #include "MEDMEM_Mesh.hxx"
2 #include "MEDMEM_CellModel.hxx"
4 using namespace MEDMEM ;
5 using namespace MED_EN ;
7 int main (int argc, char ** argv) {
9 const string MedFile = "pointe.med" ;
10 const string MeshName = "maa1" ;
11 MESH myMesh(MED_DRIVER,MedFile,MeshName) ;
14 cout << "Mesh name : " << myMesh.getName() << endl << endl ;
16 // we get all type for cell entity :
17 int NumberOfTypes = myMesh.getNumberOfTypes(MED_CELL) ;
18 const CELLMODEL * Types = myMesh.getCellsTypes(MED_CELL) ;
20 cout << "Show Connectivity (Nodal) :" << endl ;
21 // this example use access with a specified medGeometryElement through
23 for (int i=0; i<NumberOfTypes; i++) {
24 cout << "For type " << Types[i].getName() << " : " << endl ;
25 medGeometryElement myType = Types[i].getType() ;
26 int NumberOfElements = myMesh.getNumberOfElements(MED_CELL,myType);
27 int NomberOfNodesPerCell = Types[i].getNumberOfNodes() ;
28 const int * Connectivity =
29 myMesh.getConnectivity(MED_FULL_INTERLACE,
33 for (int j=0; j<NumberOfElements; j++){
34 cout << "Element "<< j+1 <<" : " ;
35 for (int k=0; k<NomberOfNodesPerCell; k++)
36 cout << Connectivity[j*NomberOfNodesPerCell+k]<<" ";
40 cout << "Show Reverse Nodal Connectivity :" << endl ;
41 // this example use global access with index array
42 int NumberOfNodes = myMesh.getNumberOfNodes() ;
43 const int * ReverseNodalConnectivity =
44 myMesh.getReverseConnectivity(MED_NODAL) ;
45 const int * ReverseNodalConnectivityIndex =
46 myMesh.getReverseConnectivityIndex(MED_NODAL) ;
47 for (int i=0; i<NumberOfNodes; i++) {
48 cout << "Node "<<i+1<<" : " ;
49 int IndexBegin = ReverseNodalConnectivityIndex[i] ;
50 int IndexEnd = ReverseNodalConnectivityIndex[i+1] ;
51 for (int j=IndexBegin; j<IndexEnd; j++)
52 // Index value begin at 1 so use j-1
53 cout << ReverseNodalConnectivity[j-1] << " " ;
57 cout << "Show Connectivity (Descending) :" << endl ;
58 // this example use global access with index array
59 int NumberOfElements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
60 const int * DescendingConnectivity =
61 myMesh.getConnectivity(MED_FULL_INTERLACE,
65 const int * DescendingConnectivityIndex =
66 myMesh.getConnectivityIndex(MED_DESCENDING,MED_CELL);
67 for (int i=0; i<NumberOfElements; i++) {
68 cout << "Element "<<i+1<<" : " ;
69 int IndexBegin = DescendingConnectivityIndex[i] ;
70 int IndexEnd = DescendingConnectivityIndex[i+1] ;
71 for (int j=IndexBegin; j<IndexEnd; j++)
72 // Index value begin at 1 so use j-1
73 cout << DescendingConnectivity[j-1] << " " ;
77 cout << "Show Reverse Descending Connectivity :" << endl ;
78 // this example use global access with Index array
79 const int * ReverseDescendingConnectivity =
80 myMesh.getReverseConnectivity(MED_DESCENDING) ;
81 const int * ReverseDescendingConnectivityIndex =
82 myMesh.getReverseConnectivityIndex(MED_DESCENDING) ;
84 int MeshDimension = myMesh.getMeshDimension() ;
85 int NumberOfConstituents = 0;
87 medEntityMesh ConstituentEntity ;
88 // test if we have face (3D) or edge (2D)
89 if (MeshDimension==3) {
90 Constituent = "Face" ;
91 ConstituentEntity = MED_FACE ;
93 if (MeshDimension==2) {
94 Constituent = "Edge" ;
95 ConstituentEntity = MED_EDGE ;
98 NumberOfConstituents =
99 myMesh.getNumberOfElements(ConstituentEntity,MED_ALL_ELEMENTS);
101 if (MeshDimension==1) {
102 MESSAGE("ERROR : MeshDimension = 1 !");
103 MESSAGE("We could not see Reverse Descending Connectivity.") ;
105 for (int i=0; i<NumberOfConstituents; i++) {
106 cout << Constituent << " " << i+1 << " : " ;
107 int IndexBegin = ReverseDescendingConnectivityIndex[i] ;
108 int IndexEnd = ReverseDescendingConnectivityIndex[i+1] ;
109 for (int j=IndexBegin;j<IndexEnd;j++)
110 // Index value begin at 1 so use j-1
111 cout << ReverseDescendingConnectivity[j-1] << " " ;
115 cout << "Show "<< Constituent <<" Connectivity (Nodal) :" << endl ;
116 // this example use global access with index array
117 const int * ConstituentConnectivity =
118 myMesh.getConnectivity(MED_FULL_INTERLACE,
122 const int * ConstituentConnectivityIndex =
123 myMesh.getConnectivityIndex(MED_NODAL,ConstituentEntity);
124 for (int i=0; i<NumberOfConstituents; i++) {
125 cout << Constituent << " " << i+1 << " : " ;
126 int IndexBegin = ConstituentConnectivityIndex[i] ;
127 int IndexEnd = ConstituentConnectivityIndex[i+1] ;
128 for (int j=IndexBegin; j<IndexEnd; j++)
129 // Index value begin at 1 so use j-1
130 cout << ConstituentConnectivity[j-1]<<" ";