1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 from libMEDMEM_Swig import *
26 MedFile = "pointe.med"
27 #MedFile = "carre_quad4_3.med"
28 #MedFile = "polyedres.med"
29 #MedFile = "polygones.med"
31 #meshName = "CARRE_EN_QUAD4"
32 #meshName = "Erreur orientation"
35 myMesh = MESH(MED_DRIVER,MedFile,meshName)
38 nameMesh = myMesh.getName()
40 print "Mesh name : ",nameMesh
42 numberOfTypes = myMesh.getNumberOfTypes(MED_CELL)
43 print "Show Connectivity (Nodal) : "
45 # This example use access with a specified medGeometryElement through
48 for i in range(numberOfTypes):
49 cellType = myMesh.getCellType(MED_CELL,i)
50 nameType = cellType.getName()
51 type = cellType.getType()
52 numberOfElements = myMesh.getNumberOfElements(MED_CELL,type)
53 numberOfNodesPerCell = cellType.getNumberOfNodes()
54 connectivity = myMesh.getConnectivity(MED_NODAL,MED_CELL,type)
55 print "For Type ",nameType," : "
56 for j in range(numberOfElements):
57 print "Element ",(j+1)," : ",connectivity[j*numberOfNodesPerCell:
58 (j+1)*numberOfNodesPerCell]
60 print "Show Reverse Nodal Connectivity :"
62 # This example use global access with index array
64 numberOfNodes = myMesh.getNumberOfNodes()
66 reverseNodalConnectivity = myMesh.getReverseConnectivity(MED_NODAL)
67 reverseNodalConnectivityIndex = myMesh.getReverseConnectivityIndex(MED_NODAL)
69 for i in range(numberOfNodes):
70 indexBegin = reverseNodalConnectivityIndex[i]
71 indexEnd = reverseNodalConnectivityIndex[i+1]
73 # Index value begin at 1 so (index-1) is in fact used here
75 print "Node ",(i+1)," : ",reverseNodalConnectivity[(indexBegin-1):
78 print "Show Connectivity (Descending) :"
80 # This example use global access with index array
82 numberOfElements = myMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)
83 descendingConnectivity = myMesh.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS)
84 descendingConnectivityIndex = myMesh.getConnectivityIndex(MED_DESCENDING,MED_CELL)
86 for i in range(numberOfElements):
87 indexBegin = descendingConnectivityIndex[i]
88 indexEnd = descendingConnectivityIndex[i+1]
90 # Index value begin at 1 so (index-1) is in fact used here
92 print "Element ",(i+1)," : ",descendingConnectivity[(indexBegin-1):
95 print "Show Reverse Descending Connectivity :"
97 # This example use global access with index array
99 meshDimension = myMesh.getMeshDimension()
101 if (meshDimension == 1):
102 print "ERROR : Mesh Dimension = 1"
103 print "Then the Reverse Descending Connectivity could not be seen"
105 if (meshDimension == 2):
107 constituentEntity = MED_EDGE
109 if (meshDimension == 3):
111 constituentEntity = MED_FACE
113 numberOfConstituents = myMesh.getNumberOfElements(constituentEntity,
115 reverseDescendingConnectivity = myMesh.getReverseConnectivity(
117 reverseDescendingConnectivityIndex = myMesh.getReverseConnectivityIndex(
120 for i in range(numberOfConstituents):
121 indexBegin = reverseDescendingConnectivityIndex[i]
122 indexEnd = reverseDescendingConnectivityIndex[i+1]
124 # Index value begin at 1 so (index-1) is in fact used here
126 print constituent," : ",(i+1)," : ",reverseDescendingConnectivity[
127 (indexBegin-1):(indexEnd-1)]
129 print "Show ",constituent," Connectivity (Nodal) :"
131 constituentConnectivity = myMesh.getConnectivity(MED_NODAL,constituentEntity,MED_ALL_ELEMENTS)
132 constituentConnectivityIndex = myMesh.getConnectivityIndex(MED_NODAL,constituentEntity)
134 for i in range(numberOfConstituents):
135 indexBegin = constituentConnectivityIndex[i]
136 indexEnd = constituentConnectivityIndex[i+1]
138 # Index value begin at 1 so (index-1) is in fact used here
140 print constituent," : ",(i+1)," : ",constituentConnectivity[
141 (indexBegin-1):(indexEnd-1)]