def _get_iso_mesh(self, data, iso=None, color=(1, 0.2, 0.2, 1), z_shift=True): if iso is None: iso_val = self.options.get_iso_val() * data.max() else: iso_val = iso vertices, faces = isosurface(data, iso_val) nx, ny, nz = data.shape # Center Isosurface around Origin vertices[:, 0] = vertices[:, 0] - nx / 2 vertices[:, 1] = vertices[:, 1] - ny / 2 if z_shift: vertices[:, 2] = vertices[:, 2] - nz / 2 mesh_data = MeshData(vertexes=vertices, faces=faces) colors = np.zeros((mesh_data.faceCount(), 4), dtype=float) for idx in range(4): colors[:, idx] = color[idx] mesh_data.setFaceColors(colors) mesh = GLMeshItem(meshdata=mesh_data, smooth=True, shader='edgeHilight') mesh.setGLOptions('translucent') return mesh
def _get_iso_mesh(self, data, color, sign): iso_val = sign * self.options.get_iso_val() vertices, faces = isosurface(data, iso_val * data.max()) nx, ny, nz = data.shape # Center Isosurface around Origin vertices[:, 0] = vertices[:, 0] - nx / 2 vertices[:, 1] = vertices[:, 1] - ny / 2 vertices[:, 2] = vertices[:, 2] - nz / 2 mesh_data = MeshData(vertexes=vertices, faces=faces) colors = np.zeros((mesh_data.faceCount(), 4), dtype=float) # Sets color to Red (RGB, 0 = red, 1 = green, 2 = blue) if color == 'red': colors[:, 0] = 1.0 colors[:, 1] = 0.2 colors[:, 2] = 0.2 elif color == 'blue': colors[:, 0] = 0.2 colors[:, 1] = 0.2 colors[:, 2] = 1.0 # Transparency (I guess) colors[:, 3] = 1 mesh_data.setFaceColors(colors) mesh = GLMeshItem(meshdata=mesh_data, smooth=True, shader='edgeHilight') mesh.setGLOptions('translucent') return mesh