Peano
Loading...
Searching...
No Matches
Wrapper.py
Go to the documentation of this file.
1import ctypes
2from ctypes import Structure, c_double
3from pathlib import Path
4import sys
5
6
7try:
8 _script_dir = Path(__file__).parent
9except NameError:
10 _script_dir = Path(sys.argv[0]).parent if len(sys.argv) > 0 else Path.cwd()
11
12
13_lib_path = _script_dir / "build" / "libmylib.so"
14_lib = ctypes.CDLL(str(_lib_path))
15
16
17class Pair(Structure):
18 _fields_ = [
19 ("first", c_double),
20 ("second", c_double),
21 ]
22
23
24_lib.ellipsoidTransform.argtypes = (c_double, c_double)
25_lib.ellipsoidTransform.restype = Pair
26_lib.ellipsoidTransformInverse.argtypes = (c_double, c_double)
27_lib.ellipsoidTransformInverse.restype = Pair
28
29_lib.sphereTransform.argtypes = (c_double, c_double)
30_lib.sphereTransform.restype = Pair
31_lib.sphereTransformInverse.argtypes = (c_double, c_double)
32_lib.sphereTransformInverse.restype = Pair
33
34ellipsoidTransform = _lib.ellipsoidTransform
35ellipsoidTransformInverse = _lib.ellipsoidTransformInverse
36
37sphereTransform = _lib.sphereTransform
38sphereTransformInverse = _lib.sphereTransformInverse