def getArrayDescription(array, context): if not array: return None pMd5 = digest(array) context.cacheDataArray(pMd5, { 'array': array, 'mTime': array.GetMTime(), 'ts': time.time() }) root = {} root['hash'] = pMd5 root['vtkClass'] = 'vtkDataArray' root['name'] = array.GetName() root['dataType'] = getJSArrayType(array) root['numberOfComponents'] = array.GetNumberOfComponents() root['size'] = array.GetNumberOfComponents() * array.GetNumberOfTuples() root['ranges'] = [] if root['numberOfComponents'] > 1: for i in range(root['numberOfComponents']): root['ranges'].append(getRangeInfo(array, i)) root['ranges'].append(getRangeInfo(array, -1)) else: root['ranges'].append(getRangeInfo(array, 0)) return root
def writeData(self): self.resamplerFilter.Update() arrays = self.resamplerFilter.GetOutput().GetPointData() for field in self.fieldsToWrite: array = arrays.GetArray(field) if array: b = buffer(array) with open(self.dataHandler.getDataAbsoluteFilePath(field), 'wb') as f: f.write(b) self.DataProber['types'][field] = getJSArrayType(array) if field in self.DataProber['ranges']: dataRange = array.GetRange() if dataRange[0] < self.DataProber['ranges'][field][0]: self.DataProber['ranges'][field][0] = dataRange[0] if dataRange[1] > self.DataProber['ranges'][field][1]: self.DataProber['ranges'][field][1] = dataRange[1] else: self.DataProber['ranges'][field] = [ array.GetRange()[0], array.GetRange()[1] ] else: print('No array for', field) print(self.resamplerFilter.GetOutput())
def getArrayDescription(array, context): if not array: return None pMd5 = digest(array) context.cacheDataArray(pMd5, { 'array': array, 'mTime': array.GetMTime(), 'ts': time.time() }) root = {} root['hash'] = pMd5 root['vtkClass'] = 'vtkDataArray' root['name'] = array.GetName() root['dataType'] = getJSArrayType(array) root['numberOfComponents'] = array.GetNumberOfComponents() root['size'] = array.GetNumberOfComponents() * array.GetNumberOfTuples() root['ranges'] = [] if root['numberOfComponents'] > 1: for i in range(root['numberOfComponents']): root['ranges'].append(getRangeInfo(array, i)) root['ranges'].append(getRangeInfo(array, -1)) else: root['ranges'].append(getRangeInfo(array, 0)) return root
def getArrayDescription(array, context, dataset): if not array: return None if array.GetNumberOfComponents() == 9: adapter = dsa.WrapDataObject(dataset) name = array.GetName() npArray = adapter.GetPointData().GetArray(name) eigenvalues = algorithms.eigenvalue(npArray) merge = np.column_stack((npArray, eigenvalues[:, np.newaxis, :])) n = npArray.shape[0] array.SetNumberOfComponents(12) array.SetNumberOfTuples(n) for i in range(n): array.SetTypedTuple(i, merge[i].ravel()) pMd5 = digest(array) context.cacheDataArray(pMd5, { 'array': array, 'mTime': array.GetMTime(), 'ts': time.time() }) root = {} root['hash'] = pMd5 root['vtkClass'] = 'vtkDataArray' root['name'] = array.GetName() root['dataType'] = getJSArrayType(array) root['numberOfComponents'] = array.GetNumberOfComponents() root['size'] = array.GetNumberOfComponents() * array.GetNumberOfTuples() root['ranges'] = [] if root['numberOfComponents'] > 1: for i in range(root['numberOfComponents']): root['ranges'].append(getRangeInfo(array, i)) root['ranges'].append(getRangeInfo(array, -1)) else: root['ranges'].append(getRangeInfo(array, 0)) return root
def writeData(self): self.resamplerFilter.Update() arrays = self.resamplerFilter.GetOutput().GetPointData() for field in self.fieldsToWrite: array = arrays.GetArray(field) if array: b = buffer(array) with open(self.dataHandler.getDataAbsoluteFilePath(field), 'wb') as f: f.write(b) self.DataProber['types'][field] = getJSArrayType(array) if field in self.DataProber['ranges']: dataRange = array.GetRange() if dataRange[0] < self.DataProber['ranges'][field][0]: self.DataProber['ranges'][field][0] = dataRange[0] if dataRange[1] > self.DataProber['ranges'][field][1]: self.DataProber['ranges'][field][1] = dataRange[1] else: self.DataProber['ranges'][field] = [array.GetRange()[0], array.GetRange()[1]] else: print('No array for', field) print(self.resamplerFilter.GetOutput())