def getMesh(meshName, structureOnly): sys.stderr.write('===getMesh\n') if (meshName == 'image'): im = svtk.svtkImageData() im.SetDimensions(len(data), 1, 1) return im raise RuntimeError('failed to get mesh')
def testDefaultArray(self): """Test an array arg with default value of 0.""" image = svtk.svtkImageData() image.SetExtent(0, 9, 0, 9, 0, 9) image.AllocateScalars(svtk.SVTK_UNSIGNED_CHAR, 1) ipi = svtk.svtkImagePointIterator() # call this method with the parameter set ipi.Initialize(image, (0, 9, 0, 9, 0, 9)) # call this method without extent parameter ipi.Initialize(image)
def testDefaultObjectPointer(self): """Test a svtkObject pointer arg with default value of 0.""" image = svtk.svtkImageData() image.SetExtent(0, 9, 0, 9, 0, 9) image.AllocateScalars(svtk.SVTK_UNSIGNED_CHAR, 1) ipi = svtk.svtkImagePointIterator() # call this method with the stencil parameter set to None ipi.Initialize(image, (0, 9, 0, 9, 0, 9), None) # call this method without the stencil parameter ipi.Initialize(image, (0, 9, 0, 9, 0, 9))
def testDefaultInt(self): """Simple test of an integer arg with default value.""" image = svtk.svtkImageData() image.SetExtent(0, 9, 0, 9, 0, 9) image.AllocateScalars(svtk.SVTK_UNSIGNED_CHAR, 1) ipi = svtk.svtkImagePointIterator() # call this method with the threadId parameter set to 0 ipi.Initialize(image, (0, 9, 0, 9, 0, 9), None, None, 0) # call this method without the threadId parameter ipi.Initialize(image, (0, 9, 0, 9, 0, 9), None, None)
def get_image(i0,i1,j0,j1,k0,k1): im = svtk.svtkImageData() im.SetExtent(i0,i1,j0,j1,k0,k1) nx = i1 - i0 + 1 ny = j1 - j0 + 1 nz = k1 - k0 + 1 npts = (nx + 1)*(ny + 1)*(nz + 1) ncells = nx*ny*nz get_data_arrays(npts, im.GetPointData()) get_data_arrays(ncells, im.GetCellData()) return im
def MakeBlock(t, x0, y0, dx, dy, nx, ny, nbx, nby, bi, bj): npx = nx + 1 npy = ny + 1 npz = 2 xx = x0 + nx * bi * dx yy = y0 + ny * bj * dy blk = svtk.svtkImageData() blk.SetOrigin(xx, yy, -1.0e-2) blk.SetSpacing(dx, dy, 2.0e-2) blk.SetDimensions(npx, npy, npz) # add an array dat = svtk.svtkFloatArray() dat.SetName('f_xyt') dat.SetNumberOfTuples(npx * npy * npz) k = 0 while k < npz: j = 0 while j < npy: i = 0 while i < npx: px = xx + dx * i py = yy + dy * j q = k * npx * npy + j * npx + i dat.SetValue(q, np.cos(t + px) * np.cos(t + py)) i += 1 j += 1 k += 1 blk.GetPointData().AddArray(dat) # add another array dat = svtk.svtkFloatArray() dat.SetName('sin_x_sin_y') dat.SetNumberOfTuples(npx * npy * npz) k = 0 while k < npz: j = 0 while j < npy: i = 0 while i < npx: px = xx + dx * i py = yy + dy * j q = k * npx * npy + j * npx + i dat.SetValue(q, np.sin(t + px) * np.sin(t + py)) i += 1 j += 1 k += 1 blk.GetPointData().AddArray(dat) return blk
g2 = svtk.svtkMultiBlockDataGroupFilter() g2.AddInputConnection(elev2.GetOutputPort()) g2.AddInputConnection(elev2.GetOutputPort()) g2.Update() elev3 = svtk.svtkElevationFilter() elev3.SetInputConnection(bp.GetOutputPort()) elev3.SetLowPoint(0, 0, -10) elev3.SetHighPoint(0, 0, 10) elev3.SetScalarRange(0, 20) elev3.Update() dobj = svtk.svtkImageData() dobj.DeepCopy(elev3.GetOutput()) ds1 = dsa.WrapDataObject(dobj) elev_copy = numpy.copy(ds1.PointData['Elevation']) elev_copy[1] = numpy.nan ghosts = numpy.zeros(ds1.GetNumberOfPoints(), dtype=numpy.uint8) ghosts[1] = svtk.svtkDataSetAttributes.DUPLICATEPOINT ds1.PointData.append(ghosts, svtk.svtkDataSetAttributes.GhostArrayName()) assert algs.make_point_mask_from_NaNs( ds1, elev_copy )[1] == svtk.svtkDataSetAttributes.DUPLICATEPOINT | svtk.svtkDataSetAttributes.HIDDENPOINT cell_array = numpy.zeros(ds1.GetNumberOfCells()) cell_array[1] = numpy.nan assert algs.make_cell_mask_from_NaNs( ds1, cell_array)[1] == svtk.svtkDataSetAttributes.HIDDENCELL
]) # In the case of Windows, these classes cause a crash. classWindowsExceptions = set([ "svtkWin32VideoSource", # Update() works the first time but a subsequent run calls up the webcam which crashes on close. "svtkCMLMoleculeReader", "svtkCPExodusIIInSituReader", "svtkMINCImageWriter", "svtkQtInitialization" ]) classExceptions = set() emptyPD = svtk.svtkPolyData() emptyID = svtk.svtkImageData() emptySG = svtk.svtkStructuredGrid() emptyUG = svtk.svtkUnstructuredGrid() emptyRG = svtk.svtkRectilinearGrid() # This will hold the classes to be tested. svtkClasses = set() classNames = None classesTested = set() # Keep a record of the classes tested. nonexistentClasses = set() abstractClasses = set() noConcreteImplementation = set() noShutdown = set() noObserver = set()