def __init__(self, atoms): assert isinstance(atoms, Atoms) self.pbc = atoms.get_pbc() cell = atoms.get_cell() """ if not isinstance(cell, np.ndarray): cell = np.array(cell) if cell.shape == (3,): cell = np.diag(cell) assert cell.dtype == float and cell.shape == (3, 3) """ self.vtk_outline = vtkOutlineSource() if (cell - np.diag(cell.diagonal())).any(): corners = np.empty((8, 3), dtype=float) # edges = [map(int,[(i-1)%2==0,i%4>=2,i>=4]) for i in range(8)] for c,a in enumerate([(0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0), \ (0, 0, 1), (1, 0, 1), (0, 1, 1), (1, 1, 1)]): corners[c] = np.dot(a, cell) self.bbox = np.array(zip(np.min(corners, axis=0), \ np.max(corners, axis=0))).ravel() self.vtk_outline.SetCorners(corners.ravel()) self.vtk_outline.SetBoxTypeToOriented() else: self.bbox = np.array(zip(np.zeros(3), cell.diagonal())).ravel() self.vtk_outline.SetBounds(self.bbox) vtkPolyDataModule.__init__(self, self.vtk_outline)
def __init__(self, atoms): assert isinstance(atoms, Atoms) cell = atoms.get_cell() """ if not isinstance(cell, np.ndarray): cell = np.array(cell) if cell.shape == (3,): cell = np.diag(cell) assert cell.dtype == float and cell.shape == (3, 3) """ #TODO bounding box with general unit cell diagcell = np.diag(cell.diagonal()) assert (cell == diagcell).all(), 'Unit cell must be orthogonal' self.bbox = np.array(zip(np.zeros(3),cell.diagonal())).ravel() self.pbc = atoms.get_pbc() self.vtk_outline = vtkOutlineSource() self.vtk_outline.SetBounds(self.bbox) vtkPolyDataModule.__init__(self, self.vtk_outline)
def __init__(self, atoms): assert isinstance(atoms, Atoms) self.pbc = atoms.get_pbc() cell = atoms.get_cell() """ if not isinstance(cell, np.ndarray): cell = np.array(cell) if cell.shape == (3,): cell = np.diag(cell) assert cell.dtype == float and cell.shape == (3, 3) """ self.vtk_outline = vtkOutlineSource() if (cell - np.diag(cell.diagonal())).any(): corners = np.empty((8,3), dtype=float) # edges = [map(int,[(i-1)%2==0,i%4>=2,i>=4]) for i in range(8)] for c,a in enumerate([(0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0), \ (0, 0, 1), (1, 0, 1), (0, 1, 1), (1, 1, 1)]): corners[c] = np.dot(a, cell) self.bbox = np.array(list(zip(np.min(corners, axis=0), \ np.max(corners, axis=0)))).ravel() self.vtk_outline.SetCorners(corners.ravel()) self.vtk_outline.SetBoxTypeToOriented() else: self.bbox = np.array(list(zip(np.zeros(3),cell.diagonal()))).ravel() self.vtk_outline.SetBounds(self.bbox) vtkPolyDataModule.__init__(self, self.vtk_outline)
def __init__(self, data, cell, vtk_renderer, contours=1, depthsort=True): #TODO don't require vtk_renderer... implement vtkScene #TODO contour values from list or autocontours if int # Make sure data argument is a valid array if not isinstance(data, np.ndarray): data = np.array(data) vtkVolumeGrid.__init__(self, data.shape, cell) self.vtk_iso = vtkContourFilter() #vtkMarchingContourFilter? self.vtk_iso.SetInput(self.get_structured_points()) #TODO non-orthogonal self.vtk_iso.SetValue(0, 0.25) self.vtk_iso.SetValue(1, -0.25) self.smoothpipe = vtkSurfaceSmootherPipeline(self, vtk_iso) #TODO use vtkDepthSortPipeline - but vtkPolyDataModule isn't a pipeline self.depthsort = depthsort if self.depthsort: # The depht sort object is set up to generate scalars representing # the sort depth. A camera is assigned for the sorting. The camera # defines the sort vector (position and focal point). self.vtk_ds = vtkDepthSortPolyData() self.vtk_ds.SetCamera(vtk_renderer.GetActiveCamera()) self.vtk_ds.SetInputConnection(self.vtk_iso.GetOutputPort()) self.vtk_ds.SetDirectionToBackToFront() #vtk_ds.SetVector(1, 1, 1) #vtk_ds.SortScalarsOn() #vtk_ds.Update() vtk_renderer.ResetCamera() vtkPolyDataModule.__init__(self, self.vtk_ds) else: vtkPolyDataModule.__init__(self, self.vtk_iso) #TODO add color function """