Salome HOME
Fix: getCellsContainingPoints() in case of polyhedron with a face containing colinear...
[tools/medcoupling.git] / doc / user / images / measure_field.py
1 # -*- coding: utf-8 -*-
2
3 ###
4 ### This script is intended to be launched in a new SALOME study
5 ###
6
7 import os
8 import salome
9
10 salome.salome_init()
11 theStudy = salome.myStudy
12
13 import sys
14 if sys.platform == "win32":
15     from MEDCouplingCompat import *
16 else:
17     from MEDCoupling import *
18
19 from MEDLoader import WriteMesh, WriteFieldUsingAlreadyWrittenMesh
20
21 medfile="mesh1.med"
22 XCoords=[-0.3,0.,0.1,0.3,0.45,0.47,0.49,1.,1.22] # 9 values along X
23 YCoords=[0.,0.1,0.37,0.45,0.47,0.49,1.007] # 7 values along Y
24 arrX=DataArrayDouble(XCoords)
25 arrX.setInfoOnComponent(0,"X [m]")
26 arrY=DataArrayDouble(YCoords)
27 arrY.setInfoOnComponent(0,"Y [m]")
28 mesh=MEDCouplingCMesh("CMesh")
29 mesh.setCoords(arrX,arrY)
30 WriteMesh(medfile,mesh,True)
31
32 f=mesh.getMeasureField(True)
33 WriteFieldUsingAlreadyWrittenMesh(medfile,f)
34
35 import iparameters
36 ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1), True)
37
38 #Set up visual properties:
39 ipar.setProperty("AP_ACTIVE_VIEW", "ParaView_0_0")
40 ipar.setProperty("AP_WORKSTACK_INFO", "0000000100000000000000020100000001000003b5000000040000000100000001000000080000001800500061007200610056006900650077005f0030005f00300000000102")
41 ipar.setProperty("AP_ACTIVE_MODULE", "ParaViS")
42 ipar.setProperty("AP_SAVEPOINT_NAME", "GUI state: 1")
43 #Set up lists:
44 # fill list AP_VIEWERS_LIST
45 ipar.append("AP_VIEWERS_LIST", "ParaView_1")
46 # fill list ParaView_1
47 ipar.append("ParaView_1", "ParaView scene:33 - viewer:1")
48 ipar.append("ParaView_1", "empty")
49 # fill list AP_MODULES_LIST
50 ipar.append("AP_MODULES_LIST", "ParaViS")
51
52 ###
53 ### PARAVIS component
54 ###
55
56 import pvsimple
57 pvsimple.ShowParaviewView()
58 #### import the simple module from the paraview
59 from pvsimple import *
60 #### disable automatic camera reset on 'Show'
61 pvsimple._DisableFirstRenderCameraReset()
62
63 # create a new 'MED Reader'
64 mesh1med = MEDReader(FileName=medfile)
65
66 # Properties modified on mesh1med
67 mesh1med.AllArrays = ['TS0/CMesh/ComSup0/MeasureOfMesh_CMesh@@][@@P0']
68
69 # get active view
70 renderView1 = GetActiveViewOrCreate('RenderView')
71 # uncomment following to set a specific view size
72 # renderView1.ViewSize = [935, 531]
73
74 # show data in view
75 mesh1medDisplay = Show(mesh1med, renderView1)
76
77 # trace defaults for the display properties.
78 mesh1medDisplay.Representation = 'Surface'
79
80 # update the view to ensure updated data information
81 renderView1.Update()
82
83 # set scalar coloring
84 ColorBy(mesh1medDisplay, ('CELLS', 'MeasureOfMesh_CMesh'))
85
86 # rescale color and/or opacity maps used to include current data range
87 mesh1medDisplay.RescaleTransferFunctionToDataRange(True, False)
88
89 # show color bar/color legend
90 mesh1medDisplay.SetScalarBarVisibility(renderView1, True)
91
92 # get color transfer function/color map for 'MeasureOfMesh_CMesh'
93 measureOfMesh_CMeshLUT = GetColorTransferFunction('MeasureOfMesh_CMesh')
94
95 #### saving camera placements for all active views
96
97 # current camera placement for renderView1
98 renderView1.InteractionMode = '2D'
99 renderView1.CameraPosition = [1.7629894333642653, 1.5037968367059755, -3.5223589503586297]
100 renderView1.CameraFocalPoint = [1.7629894333642653, 1.5037968367059755, 0.0]
101 renderView1.CameraParallelScale = 1.6150499279094872
102
103
104 if salome.sg.hasDesktop():
105   salome.sg.updateObjBrowser(True)
106   iparameters.getSession().restoreVisualState(1)