/
test_vox_display.py
170 lines (141 loc) · 6.93 KB
/
test_vox_display.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import unittest
import os
import geosoft.gxpy.system as gsys
import geosoft.gxpy.vox as gxvox
import geosoft.gxpy.vox_display as gxvoxd
import geosoft.gxpy.map as gxmap
import geosoft.gxpy.view as gxview
import geosoft.gxpy.group as gxgroup
import geosoft.gxpy.surface as gxsurf
import geosoft.gxpy.viewer as gxviewer
from base import GXPYTest
class Test(GXPYTest):
@classmethod
def setUpClass(cls):
cls.setUpGXPYTest()
cls.folder, files = gsys.unzip(os.path.join(os.path.dirname(cls._test_case_py), 'testvoxset.zip'),
folder=cls._gx.temp_folder())
cls.vox_file = os.path.join(cls.folder, 'test.geosoft_voxel')
cls.vectorvox_file = os.path.join(cls.folder, 'mvi.geosoft_vectorvoxel')
def test_voxd(self):
self.start()
with gxvox.Vox.open(self.vox_file) as vox:
vox.unit_of_measure = 'maki'
with gxvoxd.VoxDisplay.solid(vox) as voxd:
self.assertFalse(voxd.is_thematic)
self.assertTrue(voxd.opacity, 1.0)
voxd.opacity = 0.2
self.assertTrue(voxd.opacity, 0.2)
self.assertEqual(voxd.color_map.unit_of_measure, 'maki')
self.assertEqual(voxd.shell_limits, (None, None))
voxd.shell_limits = (None, 0.00002)
self.assertEqual(voxd.shell_limits, (None, 0.00002))
voxd.shell_limits = (0.00002, None)
self.assertEqual(voxd.shell_limits, (0.00002, None))
voxd.shell_limits = (0.00002, 0.00003)
self.assertEqual(voxd.shell_limits, (0.00002, 0.00003))
def test_figure_map(self):
self.start()
with gxvox.Vox.open(self.vox_file) as vox:
vox.unit_of_measure = 'SI Susc'
with gxvoxd.VoxDisplay.solid(vox) as voxd:
voxd.shell_limits = (0.0001, None)
fig_map = voxd.figure_map(title="My Test Vox").file_name
self.crc_map(fig_map)
# gxviewer.view_document(fig_map)
def test_figure_map_smooth(self):
self.start()
with gxvox.Vox.open(self.vox_file) as vox:
vox.unit_of_measure = 'SI Susc'
with gxvoxd.VoxDisplay.solid(vox) as voxd:
voxd.shell_limits = (0.0001, None)
self.assertEqual(voxd.render_mode, gxvoxd.RENDER_FILL)
voxd.render_mode = gxvoxd.RENDER_SMOOTH
self.assertEqual(voxd.render_mode, gxvoxd.RENDER_SMOOTH)
fig_map = voxd.figure_map(title="My Test Vox").file_name
# gxviewer.view_document(fig_map)
self.crc_map(fig_map)
def test_figure_map_zone(self):
self.start()
with gxvox.Vox.open(self.vox_file) as vox:
vox.unit_of_measure = 'SI Susc'
with gxvoxd.VoxDisplay.solid(vox, color_map='grey.tbl', zone=gxvoxd.ZONE_LINEAR) as voxd:
voxd.shell_limits = (0.0001, None)
fig_map = voxd.figure_map(title="My Test Vox in grey").file_name
self.crc_map(fig_map)
# gxviewer.view_document(fig_map)
def test_figure_map_vectorvoxel(self):
self.start()
with gxvox.Vox.open(self.vectorvox_file) as vox:
vox.unit_of_measure = 'SI Susc'
with gxvoxd.VoxDisplay.solid(vox) as voxd:
voxd.shell_limits = (0.0001, None)
fig_map = voxd.figure_map(title="My Test VectorVox").file_name
# gxviewer.view_document(fig_map)
self.crc_map(fig_map)
def test_figure_map_vectorvoxel_vector(self):
self.start()
with gxvox.Vox.open(self.vectorvox_file) as vox:
vox.unit_of_measure = 'SI Susc'
with gxvoxd.VoxDisplay.vector(vox) as voxd:
voxd.shell_limits = (0.01, None)
voxd.vector_cone_specs = (3, None, None, 100)
fig_map = voxd.figure_map(title="My Test VectorVox").file_name
# gxviewer.view_document(fig_map)
self.crc_map(fig_map)
def test_open(self):
self.start()
with gxvox.Vox.open(self.vox_file) as vox:
vox.unit_of_measure = 'maki'
with gxvoxd.VoxDisplay.solid(vox) as voxd:
with gxview.View_3d.new() as v3d:
v3d_file = v3d.file_name
group_name = gxgroup.VoxDisplayGroup.new(v3d, voxd).name
with gxview.View_3d.open(v3d_file) as v3d:
self.assertEqual(len(v3d.group_list_voxel), 1)
self.assertTrue(group_name in v3d.group_list_voxel)
with gxgroup.VoxDisplayGroup.open(v3d, group_name) as gvd:
self.assertEqual(gvd.name, group_name)
self.assertEqual(gvd.voxd.name, group_name)
self.assertEqual(gvd.voxd.vox.name, group_name)
self.assertEqual(gvd.unit_of_measure, 'maki')
with gxvox.Vox.open(self.vectorvox_file) as vox:
vox.unit_of_measure = 'vecmaki'
with gxvoxd.VoxDisplay.solid(vox) as voxd:
with gxview.View_3d.new() as v3d:
v3d_file = v3d.file_name
group_name = gxgroup.VoxDisplayGroup.new(v3d, voxd).name
with gxview.View_3d.open(v3d_file) as v3d:
self.assertEqual(len(v3d.group_list_voxel), 1)
self.assertTrue(group_name in v3d.group_list_voxel)
with gxgroup.VoxDisplayGroup.open(v3d, group_name) as gvd:
self.assertEqual(gvd.name, group_name)
self.assertEqual(gvd.voxd.name, group_name)
self.assertEqual(gvd.voxd.vox.name, group_name)
self.assertEqual(gvd.unit_of_measure, 'vecmaki')
with gxvox.Vox.open(self.vectorvox_file) as vox:
vox.unit_of_measure = 'vecmaki'
with gxvoxd.VoxDisplay.vector(vox) as voxd:
with gxview.View_3d.new() as v3d:
v3d_file = v3d.file_name
group_name = gxgroup.VoxDisplayGroup.new(v3d, voxd).name
with gxview.View_3d.open(v3d_file) as v3d:
self.assertEqual(len(v3d.group_list_vectorvoxel), 1)
self.assertTrue(group_name in v3d.group_list_vectorvoxel)
with gxgroup.VoxDisplayGroup.open(v3d, group_name) as gvd:
self.assertEqual(gvd.name, group_name)
self.assertEqual(gvd.voxd.name, group_name)
self.assertEqual(gvd.unit_of_measure, 'vecmaki')
# @unittest.skip('Fails in 9.5')
def test_isosurface(self):
self.start()
with gxvox.Vox.open(self.vectorvox_file) as vox:
fn = gxsurf.SurfaceDataset.vox_surface(vox,
(0.005, 0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64, 1.28),
temp=True).file_name
with gxview.View_3d.new() as v3d:
v3d_file = v3d.file_name
gxgroup.surface_group_from_file(v3d, fn)
self.crc_map(v3d_file)
if __name__ == '__main__':
unittest.main()