Skip to content

Commit ba0acbe

Browse files
committed
2 parents 1a8bd1e + e62748c commit ba0acbe

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

geometry.py

+11
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,18 @@ def transform_volume(transform, u, v, l, rotate=None):
8484

8585
return xyz
8686

87+
def get_layer_extents(layer_extents, layer):
88+
min_u, max_u = 0.0, 0.0
89+
min_v, max_v = 0.0, 0.0
90+
min_l, max_l = 0.0, 0.0
91+
for current_layer, extent in viewitems(layer_extents):
92+
if current_layer == layer:
93+
min_u, max_u = extent[0][0], extent[1][0]
94+
min_v, max_v = extent[0][1], extent[1][1]
95+
min_l, max_l = extent[0][2], extent[1][2]
96+
return ((min_u, max_u), (min_v, max_v), (min_l, max_l))
8797

98+
8899
def get_total_extents(layer_extents):
89100

90101
min_u = float('inf')

linear_volume.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def point_position(self, su, sv, sl, resolution=0.01, return_extent=True):
470470
else:
471471
return pos
472472

473-
def mplot_surface(self, ures=8, vres=8, **kwargs):
473+
def mplot_surface(self, ures=8, vres=8, figax=False, **kwargs):
474474
"""Plot the enclosing surfaces of the volume using Mayavi's `mesh()` function
475475
476476
Parameters
@@ -514,13 +514,18 @@ def mplot_surface(self, ures=8, vres=8, **kwargs):
514514
meshpts1 = self.ev(hru, hrv, np.max(self.l))
515515
meshpts2 = self.ev(hru, hrv, np.min(self.l))
516516

517-
m1 = mlab.mesh(*meshpts1, **kwargs)
518-
m2 = mlab.mesh(*meshpts2, **kwargs)
517+
if figax is None:
518+
m1 = mlab.mesh(*meshpts1, **kwargs)
519+
m2 = mlab.mesh(*meshpts2, **kwargs)
519520

520-
# Turn off perspective
521-
fig = mlab.gcf()
522-
fig.scene.camera.trait_set(parallel_projection=1)
523-
return fig
521+
# Turn off perspective
522+
fig = mlab.gcf()
523+
fig.scene.camera.trait_set(parallel_projection=1)
524+
return fig
525+
else:
526+
fig, ax = figax
527+
m1 = ax.plot_surface(*meshpts1, **kwargs)
528+
m2 = ax.plot_surface(*meshpts2, **kwargs)
524529

525530
def mplot_volume(self, ures=8, vres=8, **kwargs):
526531
"""Plot the volume using Mayavi's `scalar_scatter()` function

0 commit comments

Comments
 (0)