def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkSimpleElevationFilter(), 'Processing.',
         ('vtkDataSet',), ('vtkDataSet',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
Esempio n. 2
0
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(self,
                                       module_manager,
                                       vtk.vtkSimpleElevationFilter(),
                                       'Processing.', ('vtkDataSet', ),
                                       ('vtkDataSet', ),
                                       replaceDoc=True,
                                       inputFunctions=None,
                                       outputFunctions=None)
# Control resolution of the test
res = 300
res = 50

# Generate hexes or tets
genHexes = 1

# Use categorical data
catData = 0

# Create a synthetic source with point data
vol = vtk.vtkImageData()
vol.SetDimensions(res, res, res)

ele = vtk.vtkSimpleElevationFilter()
ele.SetInputData(vol)
ele.Update()
print("Processing {0} voxels".format(ele.GetOutput().GetNumberOfCells()))

# Convert point data to cell data
pd2cd = vtk.vtkPointDataToCellData()
pd2cd.SetInputConnection(ele.GetOutputPort())
pd2cd.SetCategoricalData(catData)

# For timing the various tests
timer = vtk.vtkTimerLog()
timer.StartTimer()
pd2cd.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
Esempio n. 4
0
tf.Update()

pd = vtk.vtkPolyData()
pd.CopyStructure(tf.GetOutput())
numPts = pd.GetNumberOfPoints()
oldPts = tf.GetOutput().GetPoints()
newPts = vtk.vtkPoints()
newPts.SetNumberOfPoints(numPts)
for i in range(0, numPts):
    pt = oldPts.GetPoint(i)
    r = math.sqrt(pt[0]*pt[0] + pt[1]*pt[1])
    z = 1.5*math.cos(2*r)
    newPts.SetPoint(i, pt[0], pt[1], z)
pd.SetPoints(newPts)

ele = vtk.vtkSimpleElevationFilter()
ele.SetInputData(pd)

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(ele.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mapper)

ele2 = vtk.vtkElevationFilter()
ele2.SetInputData(pd)
ele2.SetLowPoint(0,0,-1.5)
ele2.SetHighPoint(0,0,1.5)
ele2.SetScalarRange(-1.5,1.5)

mapper2 = vtk.vtkPolyDataMapper()
ren0 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
renWin.AddRenderer(ren0)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

# Create some spheres
sphere1 = vtk.vtkSphereSource()
sphere1.SetCenter(0.0, 0.0, 0.0)
sphere1.SetRadius(0.25)
sphere1.SetThetaResolution(2 * res)
sphere1.SetPhiResolution(res)
sphere1.Update()

ele1 = vtk.vtkSimpleElevationFilter()
ele1.SetInputConnection(sphere1.GetOutputPort())

sphere2 = vtk.vtkSphereSource()
sphere2.SetCenter(0.875, 0.0, 0.0)
sphere2.SetRadius(0.35)
sphere2.SetThetaResolution(2 * res)
sphere2.SetPhiResolution(res)
sphere2.Update()

sphere3 = vtk.vtkSphereSource()
sphere3.SetCenter(2.0, 0.0, 0.0)
sphere3.SetRadius(0.5)
sphere3.SetThetaResolution(2 * res)
sphere3.SetPhiResolution(res)
sphere3.Update()