File: pygi_isolate.py

package info (click to toggle)
v-sim 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,188 kB
  • sloc: ansic: 115,451; f90: 19,861; python: 2,120; makefile: 1,002; xml: 719; cpp: 688; sh: 23
file content (80 lines) | stat: -rw-r--r-- 2,238 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
from gi.repository import v_sim

# Load the file to test.
data=v_sim.Data.new()
data.addFile("diff.ascii",0,None)
v_sim.visuBasicLoad_dataFromFile(data,None,0)

# Parse the configuration files.
v_sim.visuBasicParse_configFiles()

def prox(data, c1, c2, rad):
  r1 = data.convertXYZToReduced(c1)
  r2 = data.convertXYZToReduced(c2)
  for dx in range(-1, 2):
    for dy in range(-1, 2):
      for dz in range(-1, 2):
        r2_trans = v_sim.Coord.__new__(v_sim.Coord)
	r2_trans.x = r2.x + dx
	r2_trans.y = r2.y + dy
	r2_trans.z = r2.z + dz
	c2_trans = data.convertReducedToXYZ(r2_trans)
	dist2 = (c1.x-c2_trans.x)**2 + (c1.y-c2_trans.y)**2 + (c1.z-c2_trans.z)**2
	if dist2 <= (rad) ** 2:
	  return True
  return False

##RAD = input('Choose a radius: ')
##NODE = input('Choose a node id: ')
RAD = 5.
NODE = 216
print "All nodes further than ",RAD," from node ",NODE," will be hidden."

coord0 = data.getNodeCoordinates(data.getNodeFromNumber(NODE))

dataIter = data.iterNew()
data.iterStart(dataIter)
while (dataIter.node is not None):
	if prox(data, coord0, data.getNodeCoordinates(dataIter.node), RAD):
		print "Node ",dataIter.node.number," is visible"
		dataIter.node.setVisibility(True)
	else:
		print "Node ",dataIter.node.number," is hidden"
		dataIter.node.setVisibility(False)
	data.iterNext(dataIter)

#----------------------DUMP----------------------#
print '\n\t---DUMP dans du resultat dans diffOut.ascii---\n'

outFilename = "diffOut.png"
##outFilename = "diffOut.ascii"

dumps = v_sim.visuDumpGet_allModules()
for dump in dumps:
	if dump.fileType.match(outFilename):
		if dump.bitmap:
			ctx = v_sim.PixmapContext.new(450, 450)
			v_sim.openGLInit_context();

			view = data.getOpenGLView()
			view.camera.length0 = data.getBoxLengths()[0];

			v_sim.openGLModelize(view.camera);
			data.setSizeOfView(450, 450)
			v_sim.openGLProject(view.window, view.camera,
					    data.getBoxLengths()[1])

			v_sim.visuExtensions_rebuildAllLists(data)
			v_sim.openGL_reDraw(None, data)

			image = v_sim.visuOpenGLGet_pixmapData(450, 450, True)
		else:
			image = None

		# The exportation routine.
		dump.callWriteFunc(outFilename, 450, 450, data, image, None, None)
		
		if dump.bitmap:
			ctx.free()
		break