-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (25 loc) · 1 KB
/
main.py
File metadata and controls
33 lines (25 loc) · 1 KB
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
import vtk
# Read the vtk file
reader = vtk.vtkPolyDataReader()
reader.SetFileName('polyex.vtk')
reader.Update()
# pdata is a vtkPolyData instance
pdata = reader.GetOutput()
# Get the address of the underlying c++ object as
# a string and convert the hex into an integer.
# Note: must filter out 'Addr=', hence [5,:]
print pdata.GetAddressAsString('vtkPolyData')
print pdata.GetAddressAsString('vtkPolyData')[5:]
print int(pdata.GetAddressAsString('vtkPolyData')[5:], 16)
addr = int(pdata.GetAddressAsString('vtkPolyData')[5:], 16)
print 'Number of points (python): ', pdata.GetNumberOfPoints()
# Open the shared library. You might need to set
# LD_LIBRARY_PATH (on Linux/Solaris) or DYLD_LIBRARY_PATH
# (on Mac OS X) if you get "dlopen(foo.so, 6): Library not loaded"
# error.
import ctypes
lib = ctypes.cdll.LoadLibrary('foo.so')
# Call the C++ 'foo' procedure, will print out the number of
# points. Note that the address must be converted to c_long
# on Mac OS X platform at least.
lib.foo(ctypes.c_long(addr))