def loadGridData(path): grid = loadGrid(path) nx, ny, nz, nactive = grid.dims print(nx, ny, nz) bounds = Bounds() grid_data = [] index = 0 for z in range(nz): for y in range(ny): for x in range(nx): # x, y, z = grid.get_corner_xyz(0, global_index=index) x, y, z = grid.get_xyz(global_index=index) active = grid.active(global_index=index) if active: active = 1.0 else: active = 0.0 bounds.addPoint(x, y, z) grid_data.append(x) grid_data.append(y) grid_data.append(z) grid_data.append(active) index += 1 print(bounds) return nx, ny, nz, grid_data, bounds,grid
def __init__(self, textures=None, volume_bounds=None, color_scales=None, data_range=None, polylines=None, faults=None, parent=None): """ @type textures: dict of (str, Texture3D) @type volume_bounds: Bounds """ super(SliceViewer, self).__init__(parent=parent) self.__width = 1.0 self.__height = 1.0 self.__shader = self.createShader() if textures is not None: self.__textures = textures else: self.__textures = {} if color_scales is not None: self.__color_scales = color_scales else: self.__color_scales = {} if volume_bounds is None: self.__volume_bounds = Bounds() self.__volume_bounds.addPoint(0, 0, 0) self.__volume_bounds.addPoint(1, 1, 1) else: self.__volume_bounds = volume_bounds if data_range is None: self.__data_range = 1.0 else: self.__data_range = data_range if polylines is None: self.__polylines = [] else: self.__polylines = polylines if faults is None: self.__faults = [] else: self.__faults = faults self.__current_slice = 0 self.__layer_count = 1 self.__step_size = 1.0 if "grid" in self.__textures: texture = self.__textures["grid"] self.__layer_count = texture.getDepth() self.__step_size = 1.0 / self.__layer_count self.__vbo = VertexBufferObject() self.__vbo.createGrid(texture.getWidth(), texture.getHeight()) self.__camera = Camera() self.__mouse = {} self.__hide_inactive_cells = False self.__lighting = False self.__region_scaling = True self.__flat_polylines = False