1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2011 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Guillaume Boulant (EDF)
23 __mapTypeOfField2ParavisLabel={
24 MEDCoupling.ON_CELLS:"OnCell",
25 MEDCoupling.ON_NODES:"OnPoint",
26 MEDCoupling.ON_GAUSS_PT:"ON_GAUSS_PT",
27 MEDCoupling.ON_GAUSS_NE:"ON_GAUSS_NE"}
29 def pvis_typeOfFieldLabel(typeOfField):
30 # A field name could identify several MEDCoupling fields, that
31 # differ by their spatial discretization on the mesh (values on
32 # cells, values on nodes, ...). This spatial discretization is
33 # specified (at least) by the TypeOfField that is an integer value
35 # 0 = ON_CELLS = OnCell
36 # 1 = ON_NODES = OnPoint
40 return __mapTypeOfField2ParavisLabel[typeOfField]
44 def pvis_scalarmap(filename,meshname,fieldname,typeOfField,iteration=-1):
46 This is the minimalist function to render a scalar map on a field
47 load from a med file using the PARAVIS module.
51 reader = pvsimple.MEDReader( FileName=filename )
52 # For fiels defined on cells, it seems to be required to specify
54 if typeOfField == MEDCoupling.ON_CELLS:
55 reader.Groups = ["GROUP/%s/%s/No_Group"%(meshname,pvis_typeOfFieldLabel(typeOfField))]
57 representation = pvsimple.GetDisplayProperties(reader)
58 representation.ColorArrayName = fieldname
60 lookupTable = pvsimple.GetLookupTableForArray(
61 fieldname, 1, NanColor=[0.25, 0.0, 0.0],
62 RGBPoints=[25.0, 0.23, 0.30, 0.754, 245.0, 0.71, 0.016, 0.15],
63 VectorMode='Magnitude', ColorSpace='Diverging', ScalarRangeInitialized=1.0 )
64 representation.LookupTable = lookupTable
73 from xmed import properties
74 properties.setup(properties.testdata_02) # test with nodes
75 #properties.setup(properties.testdata_03) # test with cells
76 pvis_scalarmap(properties.testFilePath,
77 properties.testMeshName,
78 properties.testFieldName,
79 properties.testTypeOfField,
80 properties.testFieldIt)
82 if __name__ == "__main__":