1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from libMEDMEM_Swig import *
24 MedFile = "pointe.med"
25 #MedFile = "carre_quad4_3.med"
26 #MedFile = "polyedres.med"
27 #MedFile = "polygones.med"
29 #meshName = "CARRE_EN_QUAD4"
30 #meshName = "Erreur orientation"
33 myMesh = MESH(MED_DRIVER,MedFile,meshName)
36 nameMesh = myMesh.getName()
38 print "Mesh name : ",nameMesh
40 numberOfTypes = myMesh.getNumberOfTypes(MED_CELL)
41 print "Show Connectivity (Nodal) : "
43 # This example use access with a specified medGeometryElement through
46 for i in range(numberOfTypes):
47 cellType = myMesh.getCellType(MED_CELL,i)
48 nameType = cellType.getName()
49 type = cellType.getType()
50 numberOfElements = myMesh.getNumberOfElements(MED_CELL,type)
51 numberOfNodesPerCell = cellType.getNumberOfNodes()
52 connectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,
53 MED_NODAL,MED_CELL,type)
54 print "For Type ",nameType," : "
55 for j in range(numberOfElements):
56 print "Element ",(j+1)," : ",connectivity[j*numberOfNodesPerCell:
57 (j+1)*numberOfNodesPerCell]
59 print "Show Reverse Nodal Connectivity :"
61 # This example use global access with index array
63 numberOfNodes = myMesh.getNumberOfNodes()
65 reverseNodalConnectivity = myMesh.getReverseConnectivity(MED_NODAL)
66 reverseNodalConnectivityIndex = myMesh.getReverseConnectivityIndex(MED_NODAL)
68 for i in range(numberOfNodes):
69 indexBegin = reverseNodalConnectivityIndex[i]
70 indexEnd = reverseNodalConnectivityIndex[i+1]
72 # Index value begin at 1 so (index-1) is in fact used here
74 print "Node ",(i+1)," : ",reverseNodalConnectivity[(indexBegin-1):
77 print "Show Connectivity (Descending) :"
79 # This example use global access with index array
81 numberOfElements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
82 descendingConnectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,
83 MED_DESCENDING,MED_CELL,
85 descendingConnectivityIndex = myMesh.getConnectivityIndex(MED_DESCENDING,
88 for i in range(numberOfElements):
89 indexBegin = descendingConnectivityIndex[i]
90 indexEnd = descendingConnectivityIndex[i+1]
92 # Index value begin at 1 so (index-1) is in fact used here
94 print "Element ",(i+1)," : ",descendingConnectivity[(indexBegin-1):
97 print "Show Reverse Descending Connectivity :"
99 # This example use global access with index array
101 meshDimension = myMesh.getMeshDimension()
103 if (meshDimension == 1):
104 print "ERROR : Mesh Dimension = 1"
105 print "Then the Reverse Descending Connectivity could not be seen"
107 if (meshDimension == 2):
109 constituentEntity = MED_EDGE
111 if (meshDimension == 3):
113 constituentEntity = MED_FACE
115 numberOfConstituents = myMesh.getNumberOfElements(constituentEntity,
117 reverseDescendingConnectivity = myMesh.getReverseConnectivity(
119 reverseDescendingConnectivityIndex = myMesh.getReverseConnectivityIndex(
122 for i in range(numberOfConstituents):
123 indexBegin = reverseDescendingConnectivityIndex[i]
124 indexEnd = reverseDescendingConnectivityIndex[i+1]
126 # Index value begin at 1 so (index-1) is in fact used here
128 print constituent," : ",(i+1)," : ",reverseDescendingConnectivity[
129 (indexBegin-1):(indexEnd-1)]
131 print "Show ",constituent," Connectivity (Nodal) :"
133 constituentConnectivity = myMesh.getConnectivity(MED_FULL_INTERLACE,
137 constituentConnectivityIndex = myMesh.getConnectivityIndex(MED_NODAL,
140 for i in range(numberOfConstituents):
141 indexBegin = constituentConnectivityIndex[i]
142 indexEnd = constituentConnectivityIndex[i+1]
144 # Index value begin at 1 so (index-1) is in fact used here
146 print constituent," : ",(i+1)," : ",constituentConnectivity[
147 (indexBegin-1):(indexEnd-1)]
151 nbPolygons = myMesh.getNumberOfPolygons()
154 print " Show Connectivity (Nodal) of POLYGONS:"
156 connectivity = myMesh.getPolygonsConnectivity(MED_NODAL,MED_CELL)
157 index = myMesh.getPolygonsConnectivityIndex(MED_NODAL,MED_CELL)
158 for j in range(nbPolygons):
159 print " Polygon",(j+1)," ",connectivity[ index[j]-1 : index[j+1]-1 ]
163 nbPolyhedrons = myMesh.getNumberOfPolyhedron()
164 if nbPolyhedrons > 0 :
166 print " Show Connectivity (Nodal) of POLYHEDRONS:"
168 connectivity = myMesh.getPolyhedronConnectivity(MED_NODAL)
169 fIndex = myMesh.getPolyhedronFacesIndex()
170 index = myMesh.getPolyhedronIndex(MED_NODAL)
171 for j in range(nbPolyhedrons):
172 print " Polyhedra",(j+1)
173 iF1, iF2 = index[ j ]-1, index[ j+1 ]-1
174 for f in range( iF2 - iF1 ):
175 iN1, iN2 = fIndex[ iF1+f ]-1, fIndex[ iF1+f+1 ]-1
176 print " Face",f+1," ",connectivity[ iN1 : iN2 ]