1 # Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG
2 # PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
4 from libMEDMEM_Swig import *
7 #MedFile = "carre_quad4_3.med"
8 #MedFile = "polyedres.med"
9 #MedFile = "polygones.med"
11 #meshName = "CARRE_EN_QUAD4"
12 #meshName = "Erreur orientation"
15 myMesh = MESH(MED_DRIVER,MedFile,meshName)
18 nameMesh = myMesh.getName()
20 print "Mesh name : ",nameMesh
22 numberOfTypes = myMesh.getNumberOfTypes(MED_CELL)
23 print "Show Connectivity (Nodal) : "
25 # This example use access with a specified medGeometryElement through
28 for i in range(numberOfTypes):
29 cellType = myMesh.getCellType(MED_CELL,i)
30 nameType = cellType.getName()
31 type = cellType.getType()
32 numberOfElements = myMesh.getNumberOfElements(MED_CELL,type)
33 numberOfNodesPerCell = cellType.getNumberOfNodes()
34 connectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,
35 MED_NODAL,MED_CELL,type)
36 print "For Type ",nameType," : "
37 for j in range(numberOfElements):
38 print "Element ",(j+1)," : ",connectivity[j*numberOfNodesPerCell:
39 (j+1)*numberOfNodesPerCell]
41 print "Show Reverse Nodal Connectivity :"
43 # This example use global access with index array
45 numberOfNodes = myMesh.getNumberOfNodes()
47 reverseNodalConnectivity = myMesh.getReverseConnectivity(MED_NODAL)
48 reverseNodalConnectivityIndex = myMesh.getReverseConnectivityIndex(MED_NODAL)
50 for i in range(numberOfNodes):
51 indexBegin = reverseNodalConnectivityIndex[i]
52 indexEnd = reverseNodalConnectivityIndex[i+1]
54 # Index value begin at 1 so (index-1) is in fact used here
56 print "Node ",(i+1)," : ",reverseNodalConnectivity[(indexBegin-1):
59 print "Show Connectivity (Descending) :"
61 # This example use global access with index array
63 numberOfElements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
64 descendingConnectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,
65 MED_DESCENDING,MED_CELL,
67 descendingConnectivityIndex = myMesh.getConnectivityIndex(MED_DESCENDING,
70 for i in range(numberOfElements):
71 indexBegin = descendingConnectivityIndex[i]
72 indexEnd = descendingConnectivityIndex[i+1]
74 # Index value begin at 1 so (index-1) is in fact used here
76 print "Element ",(i+1)," : ",descendingConnectivity[(indexBegin-1):
79 print "Show Reverse Descending Connectivity :"
81 # This example use global access with index array
83 meshDimension = myMesh.getMeshDimension()
85 if (meshDimension == 1):
86 print "ERROR : Mesh Dimension = 1"
87 print "Then the Reverse Descending Connectivity could not be seen"
89 if (meshDimension == 2):
91 constituentEntity = MED_EDGE
93 if (meshDimension == 3):
95 constituentEntity = MED_FACE
97 numberOfConstituents = myMesh.getNumberOfElements(constituentEntity,
99 reverseDescendingConnectivity = myMesh.getReverseConnectivity(
101 reverseDescendingConnectivityIndex = myMesh.getReverseConnectivityIndex(
104 for i in range(numberOfConstituents):
105 indexBegin = reverseDescendingConnectivityIndex[i]
106 indexEnd = reverseDescendingConnectivityIndex[i+1]
108 # Index value begin at 1 so (index-1) is in fact used here
110 print constituent," : ",(i+1)," : ",reverseDescendingConnectivity[
111 (indexBegin-1):(indexEnd-1)]
113 print "Show ",constituent," Connectivity (Nodal) :"
115 constituentConnectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,
119 constituentConnectivityIndex = myMesh.getConnectivityIndex(MED_NODAL,
122 for i in range(numberOfConstituents):
123 indexBegin = constituentConnectivityIndex[i]
124 indexEnd = constituentConnectivityIndex[i+1]
126 # Index value begin at 1 so (index-1) is in fact used here
128 print constituent," : ",(i+1)," : ",constituentConnectivity[
129 (indexBegin-1):(indexEnd-1)]
133 nbPolygons = myMesh.getNumberOfPolygons()
136 print " Show Connectivity (Nodal) of POLYGONS:"
138 connectivity = myMesh.getPolygonsConnectivity(MED_NODAL,MED_CELL)
139 index = myMesh.getPolygonsConnectivityIndex(MED_NODAL,MED_CELL)
140 for j in range(nbPolygons):
141 print " Polygon",(j+1)," ",connectivity[ index[j]-1 : index[j+1]-1 ]
145 nbPolyhedrons = myMesh.getNumberOfPolyhedron()
146 if nbPolyhedrons > 0 :
148 print " Show Connectivity (Nodal) of POLYHEDRONS:"
150 connectivity = myMesh.getPolyhedronConnectivity(MED_NODAL)
151 fIndex = myMesh.getPolyhedronFacesIndex()
152 index = myMesh.getPolyhedronIndex(MED_NODAL)
153 for j in range(nbPolyhedrons):
154 print " Polyhedra",(j+1)
155 iF1, iF2 = index[ j ]-1, index[ j+1 ]-1
156 for f in range( iF2 - iF1 ):
157 iN1, iN2 = fIndex[ iF1+f ]-1, fIndex[ iF1+f+1 ]-1
158 print " Face",f+1," ",connectivity[ iN1 : iN2 ]