-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.py
92 lines (66 loc) · 1.63 KB
/
testing.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
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
81
82
83
84
85
86
87
88
89
90
91
92
import pyvista as pv
import numpy as np
import ctypes as ct
from cutil import *
verts = np.array([
# target curve
[0, 0, 0],
[0, 0, 1],
[0, 0, 2],
[0, 0, 3],
[0, 0.5, 4],
[0, 1, 5],
[0, 1, 6],
# anomaly
[0.25, 0, 1],
[0.5, 0, 2],
[0.25, 0, 3],
])
ref_verts = np.array([
# reference curve
[1, 0, 0],
[1, 0, 1],
[1, 0, 2],
[1, 0, 3],
[1, 0.5, 4],
[1, 1, 5],
[1, 1, 6],
])
conn = np.array([
# target line
7, 0, 1, 2, 3, 4, 5, 6,
# anomaly line
5, 0, 7, 8, 9, 4,
# null terminator
0
], dtype=np.int32)
ref_conn: np.ndarray = np.array([
7, 0, 1, 2, 3, 4, 5, 6, 0
], dtype=np.int32)
print(ref_conn.dtype)
print(ref_conn.flags)
print(ref_conn.shape)
for i in range(ref_conn.size):
print(ref_conn[i])
segmented = seg_pv2c(ref_verts, ref_conn)
print("found segmented")
new_target = None
if segmented is not None:
print(verts.dtype, conn.dtype)
print(segmented.rsize)
new_target = neighbors_from_segmented(segmented, verts, conn)
target = None
if new_target is not None:
lines = seg_c2pv(new_target)
print(lines)
target = pv.PolyData(verts, lines=lines)
if target is None:
exit("Could not generate PyVista mesh")
# target = pv.PolyData(verts, lines=conn)
reference = pv.PolyData(ref_verts, lines=ref_conn)
plotter = pv.Plotter()
_ = plotter.add_mesh(target, color='blue', render_points_as_spheres=True,
point_size=1, show_vertices=True)
_ = plotter.add_mesh(reference, color='red', render_points_as_spheres=True,
point_size=1, show_vertices=True)
plotter.show(cpos='xy')