Salome HOME
Fix: getCellsContainingPoints() in case of polyhedron with a face containing colinear...
[tools/medcoupling.git] / doc / user / images / ortho_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 sys
8 if sys.platform == "win32":
9     from MEDCouplingCompat import *
10 else:
11     from MEDCoupling import *
12
13 coordsArr=DataArrayDouble(range(3))
14 mesh1=MEDCouplingCMesh("mesh")
15 mesh1.setCoords(coordsArr,coordsArr,coordsArr[:1])
16 mesh1 = mesh1.buildUnstructured()
17
18 import math
19 r = 3.
20 nb = 10
21 a = 5.
22 coords = []
23 for i in range( nb ):
24   x = r * math.cos( math.radians( i*a )) - r
25   z = r * math.sin( math.radians( i*a ))
26   coords.extend([ x, 0, z ])
27
28 m2=MEDCouplingCurveLinearMesh("myCurveLinearMesh")
29 m2.setNodeGridStructure([1,nb])
30 coo=DataArrayDouble(coords,nb,3)
31 m2.setCoords(coo)
32 m2 = m2.buildUnstructured()
33
34 m3=mesh1.buildExtrudedMesh(m2,1)
35
36 skin=m3.computeSkin()
37 skin.setName("skin")
38 ortho = skin.buildOrthogonalField()
39 ortho.setName("ortho_field")
40
41 from MEDLoader import WriteField, WriteMesh
42 medfile="mesh1.med"
43 WriteMesh(medfile,ortho.getMesh(),True)
44 WriteField(medfile,ortho,False)
45
46
47 import sys
48 import salome
49
50 salome.salome_init()
51 theStudy = salome.myStudy
52
53 import iparameters
54 ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters("Interface Applicative", 1), True)
55
56 #Set up visual properties:
57 ipar.setProperty("AP_ACTIVE_VIEW", "ParaView_0_0")
58 ipar.setProperty("AP_WORKSTACK_INFO", "00000001000000000000000201000000010000038f000000040000000100000001000000080000001800500061007200610056006900650077005f0030005f00300000000102")
59 ipar.setProperty("AP_ACTIVE_MODULE", "ParaViS")
60 ipar.setProperty("AP_SAVEPOINT_NAME", "GUI state: 1")
61 #Set up lists:
62 # fill list AP_VIEWERS_LIST
63 ipar.append("AP_VIEWERS_LIST", "ParaView_1")
64 # fill list ParaView_1
65 ipar.append("ParaView_1", "ParaView scene:7 - viewer:1")
66 ipar.append("ParaView_1", "empty")
67 # fill list AP_MODULES_LIST
68 ipar.append("AP_MODULES_LIST", "ParaViS")
69
70
71 ###
72 ### PARAVIS component
73 ###
74
75 import pvsimple
76 pvsimple.ShowParaviewView()
77 #### import the simple module from the paraview
78 from pvsimple import *
79 #### disable automatic camera reset on 'Show'
80 pvsimple._DisableFirstRenderCameraReset()
81
82 # create a new 'MED Reader'
83 mesh1med = MEDReader(FileName=medfile)
84
85 # get active view
86 renderView1 = GetActiveViewOrCreate('RenderView')
87 # uncomment following to set a specific view size
88 # renderView1.ViewSize = [897, 531]
89
90 # show data in view
91 mesh1medDisplay = Show(mesh1med, renderView1)
92
93 # reset view to fit data
94 renderView1.ResetCamera()
95
96 # update the view to ensure updated data information
97 renderView1.Update()
98
99 # change representation type
100 mesh1medDisplay.SetRepresentationType('Surface With Edges')
101
102 # create a new 'Glyph'
103 glyph1 = Glyph(Input=mesh1med,GlyphType='Arrow')
104
105 # Properties modified on glyph1
106 glyph1.Vectors = ['CELLS', 'ortho_field']
107
108 # show data in view
109 glyph1Display = Show(glyph1, renderView1)
110
111 # trace defaults for the display properties.
112 glyph1Display.Representation = 'Surface'
113
114 # update the view to ensure updated data information
115 renderView1.Update()
116
117 # Properties modified on glyph1
118 glyph1.GlyphMode = 'All Points'
119
120 # update the view to ensure updated data information
121 renderView1.Update()
122
123 # Properties modified on glyph1
124 glyph1.ScaleFactor = 0.7071067811865466
125
126 # update the view to ensure updated data information
127 renderView1.Update()
128
129 # set active source
130 SetActiveSource(mesh1med)
131
132 # Properties modified on renderView1
133 renderView1.Background = [1.0, 1.0, 1.0]
134
135 #### saving camera placements for all active views
136
137 # current camera placement for renderView1
138 renderView1.CameraPosition = [-9.40023601342297, -11.82197473872875, 6.269507101837803]
139 renderView1.CameraFocalPoint = [-3.714211157684638, -4.502747059961789, 3.6997577635620735]
140 renderView1.CameraViewUp = [0.6941544280720486, -0.3114076799016199, 0.6489798817268972]
141 renderView1.CameraParallelScale = 2.4893170029349183
142
143
144 if salome.sg.hasDesktop():
145   salome.sg.updateObjBrowser(True)
146   iparameters.getSession().restoreVisualState(1)