forked from andregouws/mrMeshPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmp_SendFunctions.py
executable file
·50 lines (32 loc) · 1.39 KB
/
mp_SendFunctions.py
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
#!/usr/bin/python
'''
Send module for mrMeshPy viewer
The mrMeshPyServer uses the routines here to send data back to mrVista over the TCP socket.
Andre' Gouws 2017
'''
from numpy import *
import time
debug = True
def sendROIInfo(theMeshInstance, commandArgs, mainWindowUI, the_TCPserver):
# when a request for ROI info comes in, this sends an initial confirmation that an ROI is available
try:
targetVTKWindow = mainWindowUI.vtkInstances[mainWindowUI.vtkDict[theMeshInstance]]
data_to_send = targetVTKWindow._Iren.filledROIPoints
num2send = len(data_to_send)
if debug: print(num2send)
the_TCPserver.socket.write(str('RoiReady,double,%i,' %num2send))
return 0
except:
the_TCPserver.socket.write(str('NoROIData'))
return 1
def sendROIVertices(theMeshInstance, commandArgs, mainWindowUI, the_TCPserver):
# when a request for ROI info comes we send the data after the confirmation (sendROIInfo above)
targetVTKWindow = mainWindowUI.vtkInstances[mainWindowUI.vtkDict[theMeshInstance]]
data_to_send = targetVTKWindow._Iren.filledROIPoints
the_TCPserver.socket.waitForReadyRead(10)
formatData = array(data_to_send,'d')
formatString = formatData.tostring()
if debug: print(formatData)
if debug: print(formatString)
if debug: print(len(formatString))
the_TCPserver.socket.write(formatString)