本文整理汇总了Python中vtk.vtkWarpScalar函数的典型用法代码示例。如果您正苦于以下问题:Python vtkWarpScalar函数的具体用法?Python vtkWarpScalar怎么用?Python vtkWarpScalar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkWarpScalar函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkWarpScalar(), 'Processing.',
('vtkPointSet',), ('vtkPointSet',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkWarpScalar.py
示例2: render_image
def render_image(png_reader):
square = 8
color_map = vtk.vtkLookupTable()
color_map.SetNumberOfColors(16)
color_map.SetHueRange(0, 0.667)
magnitude = vtk.vtkImageMagnitude()
magnitude.SetInput(png_reader.GetOutput())
geometry = vtk.vtkImageDataGeometryFilter()
geometry.SetInput(magnitude.GetOutput())
warp = vtk.vtkWarpScalar()
warp.SetInput(geometry.GetOutput())
warp.SetScaleFactor(0.25)
merge = vtk.vtkMergeFilter()
merge.SetGeometry(warp.GetOutput())
merge.SetScalars(png_reader.GetOutput())
elevation_mtHood = vtk.vtkElevationFilter()
elevation_mtHood.SetInput(merge.GetOutput())
elevation_mtHood.SetLowPoint(0, 0, 0)
elevation_mtHood.SetHighPoint(0, 0, 50)
mapper_3D_mtHood = vtk.vtkDataSetMapper()
mapper_3D_mtHood.SetInput(elevation_mtHood.GetOutput())
mapper_3D_mtHood.SetLookupTable(color_map)
mapper_2D_mtHood = vtk.vtkPolyDataMapper2D()
mapper_2D_mtHood.SetInput(elevation_mtHood.GetOutput())
mapper_2D_mtHood.SetLookupTable(color_map)
actor_2D_mtHood = vtk.vtkActor2D()
actor_2D_mtHood.SetMapper(mapper_2D_mtHood)
actor_2D_mtHood.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay()
actor_2D_mtHood.GetPositionCoordinate().SetValue(0.25,0.25)
actor_3D_mtHood = vtk.vtkActor()
actor_3D_mtHood.SetMapper(mapper_3D_mtHood)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(actor_3D_mtHood)
renderer.SetBackground(.5, .5, .5)
renderWindow.SetSize(600, 600)
renderWindow.Render()
renderWindowInteractor.Start()
开发者ID:arun04ceg,项目名称:2D-spatial-data,代码行数:54,代码来源:height_fields_mount_hood_c1.py
示例3: render_image
def render_image(png_reader):
colorLookup = vtk.vtkLookupTable()
colorLookup.SetNumberOfColors(256)
colorLookup.SetTableRange(0, 255)
for ii in range(0, 256):
colorLookup.SetTableValue(ii, 0, 0, 0, 1)
magnitude = vtk.vtkImageMagnitude()
magnitude.SetInput(png_reader.GetOutput())
geometry = vtk.vtkImageDataGeometryFilter()
geometry.SetInput(magnitude.GetOutput())
warp = vtk.vtkWarpScalar()
warp.SetInput(geometry.GetOutput())
warp.SetScaleFactor(0.25)
merge = vtk.vtkMergeFilter()
merge.SetGeometry(warp.GetOutput())
merge.SetGeometry(warp.GetOutput())
merge.SetScalars(png_reader.GetOutput())
mapper = vtk.vtkDataSetMapper()
mapper.SetInput(merge.GetOutput())
mapper.ScalarVisibilityOn()
mapper.SetLookupTable(colorLookup)
# mapper.SetScalarRange(0,255)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(actor)
renderer.SetBackground(0.5, 0.5, 0.5)
renderWindow.SetSize(600, 600)
renderWindow.Render()
renderWindowInteractor.Start()
开发者ID:arun04ceg,项目名称:2D-spatial-data,代码行数:43,代码来源:height_fields_mount_hood.py
示例4: __init__
def __init__(self, parent, visualizer, **kws):
"""
Initialization
"""
VisualizationModule.__init__(self, parent, visualizer, **kws)
self.descs = {"Normals": "Smooth surface with normals", "FeatureAngle": "Feature angle of normals",
"Slice": "Select slice to be warped", "Scale": "Scale factor for warping"}
self.luminance = vtk.vtkImageLuminance()
#DataGeometry filter, image to polygons
self.geometry = vtk.vtkImageDataGeometryFilter()
self.colorMapper = None
#warp scalars!
self.warp = vtk.vtkWarpScalar()
self.warp.SetScaleFactor(-0.1)
#merge image and new warped data
self.merge = vtk.vtkMergeFilter()
self.normals = vtk.vtkPolyDataNormals()
self.normals.SetFeatureAngle (90)
#first the mapper
self.mapper = vtk.vtkPolyDataMapper()
#make the actor from the mapper
self.actor = vtk.vtkActor()
self.actor.SetMapper(self.mapper)
self.renderer = self.parent.getRenderer()
self.renderer.AddActor(self.actor)
# iactor = self.wxrenwin.GetRenderWindow().GetInteractor()
self.filterDesc = "Visualize 2D slice as 3D map"
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:36,代码来源:WarpScalar.py
示例5:
probeTube.SetNumberOfSides(5)
probeTube.SetRadius(.05)
probeMapper = vtk.vtkPolyDataMapper()
probeMapper.SetInputConnection(probeTube.GetOutputPort())
probeMapper.SetScalarRange(output.GetScalarRange())
probeActor = vtk.vtkActor()
probeActor.SetMapper(probeMapper)
displayLine = vtk.vtkLineSource()
displayLine.SetPoint1(0,0,0)
displayLine.SetPoint2(1,0,0)
displayLine.SetResolution(probeLine.GetResolution())
displayMerge = vtk.vtkMergeFilter()
displayMerge.SetGeometryConnection(displayLine.GetOutputPort())
displayMerge.SetScalarsData(probe.GetPolyDataOutput())
displayMerge.Update()
displayWarp = vtk.vtkWarpScalar()
displayWarp.SetInputData(displayMerge.GetPolyDataOutput())
displayWarp.SetNormal(0,1,0)
displayWarp.SetScaleFactor(.000001)
displayWarp.Update()
displayMapper = vtk.vtkPolyDataMapper()
displayMapper.SetInputData(displayWarp.GetPolyDataOutput())
displayMapper.SetScalarRange(output.GetScalarRange())
displayActor = vtk.vtkActor()
displayActor.SetMapper(displayMapper)
outline = vtk.vtkStructuredGridOutlineFilter()
outline.SetInputData(output)
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
开发者ID:timkrentz,项目名称:SunTracker,代码行数:31,代码来源:mergeFilter.py
示例6: compute_vonMisesStress_for_MV
def compute_vonMisesStress_for_MV(inputfilename, outputfilename):
# ======================================================================
# get system arguments -------------------------------------------------
# Path to input file and name of the output file
#inputfilename = sys.argv[1]
#outputfilename = sys.argv[2]
print " "
print "=================================================================================================="
print "=== Execute Python script to analyze MV geometry in order for the HiFlow3-based MVR-Simulation ==="
print "=================================================================================================="
print " "
# ======================================================================
# Read file
if inputfilename[-4] == 'p':
reader = vtk.vtkXMLPUnstructuredGridReader()
reader.SetFileName(inputfilename)
reader.Update()
else:
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(inputfilename)
reader.Update()
print "Reading input files: DONE."
# ======================================================================
# Compute displacement vector
calc = vtk.vtkArrayCalculator()
calc.SetInput(reader.GetOutput())
calc.SetAttributeModeToUsePointData()
calc.AddScalarVariable('x', 'u0', 0)
calc.AddScalarVariable('y', 'u1', 0)
calc.AddScalarVariable('z', 'u2', 0)
calc.SetFunction('x*iHat+y*jHat+z*kHat')
calc.SetResultArrayName('DisplacementSolutionVector')
calc.Update()
# ======================================================================
# Compute strain tensor
derivative = vtk.vtkCellDerivatives()
derivative.SetInput(calc.GetOutput())
derivative.SetTensorModeToComputeStrain()
derivative.Update()
# ======================================================================
# Compute von Mises stress
calc = vtk.vtkArrayCalculator()
calc.SetInput(derivative.GetOutput())
calc.SetAttributeModeToUseCellData()
calc.AddScalarVariable('Strain_0', 'Strain', 0)
calc.AddScalarVariable('Strain_1', 'Strain', 1)
calc.AddScalarVariable('Strain_2', 'Strain', 2)
calc.AddScalarVariable('Strain_3', 'Strain', 3)
calc.AddScalarVariable('Strain_4', 'Strain', 4)
calc.AddScalarVariable('Strain_5', 'Strain', 5)
calc.AddScalarVariable('Strain_6', 'Strain', 6)
calc.AddScalarVariable('Strain_7', 'Strain', 7)
calc.AddScalarVariable('Strain_8', 'Strain', 8)
calc.SetFunction('sqrt( (2*700*Strain_0 + 28466*(Strain_0+Strain_4+Strain_8))^2 + (2*700*Strain_4 + 28466*(Strain_0+Strain_4+Strain_8))^2 + (2*700*Strain_8 + 28466*(Strain_0+Strain_4+Strain_8))^2 - ( (2*700*Strain_0 + 28466*(Strain_0+Strain_4+Strain_8))*(2*700*Strain_4 + 28466*(Strain_0+Strain_4+Strain_8)) ) - ( (2*700*Strain_0 + 28466*(Strain_0+Strain_4+Strain_8))*(2*700*Strain_8 + 28466*(Strain_0+Strain_4+Strain_8)) ) - ( (2*700*Strain_4 + 28466*(Strain_0+Strain_4+Strain_8))*(2*700*Strain_8 + 28466*(Strain_0+Strain_4+Strain_8)) ) + 3 * ((2*700*Strain_3)^2 + (2*700*Strain_6)^2 + (2*700*Strain_7)^2) )')
calc.SetResultArrayName('vonMisesStress_forMV_mu700_lambda28466')
calc.Update()
print "Computation of displacement vectors, Cauchy strain and vom Mises stress: DONE."
# ======================================================================
# Define dummy variable; get output of calc filter
dummy = calc.GetOutput()
# Get point data arrays u0, u1 and u2
pointData_u0 = dummy.GetPointData().GetArray('u0')
pointData_u1 = dummy.GetPointData().GetArray('u1')
pointData_u2 = dummy.GetPointData().GetArray('u2')
# Set scalars
dummy.GetPointData().SetScalars(pointData_u0)
# ======================================================================
# Warp by scalar u0
warpScalar = vtk.vtkWarpScalar()
warpScalar.SetInput(dummy)
warpScalar.SetNormal(1.0,0.0,0.0)
warpScalar.SetScaleFactor(1.0)
warpScalar.SetUseNormal(1)
warpScalar.Update()
# Get output and set scalars
dummy = warpScalar.GetOutput()
dummy.GetPointData().SetScalars(pointData_u1)
# ======================================================================
# Warp by scalar u1
warpScalar = vtk.vtkWarpScalar()
warpScalar.SetInput(dummy)
warpScalar.SetNormal(0.0,1.0,0.0)
warpScalar.SetScaleFactor(1.0)
warpScalar.SetUseNormal(1)
warpScalar.Update()
# Get output and set scalars
#.........这里部分代码省略.........
开发者ID:CognitionGuidedSurgery,项目名称:msml,代码行数:101,代码来源:vonMisesStressComputation_mvrPostProcessingAnalytics.py
示例7:
lo = Scale * demModel.GetElevationBounds()[0]
hi = Scale * demModel.GetElevationBounds()[1]
demActor = vtk.vtkLODActor()
# create a pipeline for each lod mapper
shrink16 = vtk.vtkImageShrink3D()
shrink16.SetShrinkFactors(16, 16, 1)
shrink16.SetInputConnection(demModel.GetOutputPort())
shrink16.AveragingOn()
geom16 = vtk.vtkImageDataGeometryFilter()
geom16.SetInputConnection(shrink16.GetOutputPort())
geom16.ReleaseDataFlagOn()
warp16 = vtk.vtkWarpScalar()
warp16.SetInputConnection(geom16.GetOutputPort())
warp16.SetNormal(0, 0, 1)
warp16.UseNormalOn()
warp16.SetScaleFactor(Scale)
warp16.ReleaseDataFlagOn()
elevation16 = vtk.vtkElevationFilter()
elevation16.SetInputConnection(warp16.GetOutputPort())
elevation16.SetLowPoint(0, 0, lo)
elevation16.SetHighPoint(0, 0, hi)
elevation16.SetScalarRange(lo, hi)
elevation16.ReleaseDataFlagOn()
normals16 = vtk.vtkPolyDataNormals()
normals16.SetInputConnection(elevation16.GetOutputPort())
开发者ID:0004c,项目名称:VTK,代码行数:31,代码来源:TestInteractorStyleTerrain.py
示例8: render
def render(self, **args):
""" main function to render all required objects """
gridData = args.get('gridData', True)
drawSurface = args.get('drawSurface', True)
drawAxes = args.get('drawAxes', True)
drawColorBar = args.get('drawColorBar', True)
drawLegend = args.get('drawLegend', True)
wireSurface = args.get('wireSurface', False)
drawBox = args.get('drawBox', True)
scaleFactor = args.get('scaleFactor', (1, 1, 1))
autoscale = args.get('autoScale', True)
colorMap = args.get('colorMap', 'rainbow')
reverseMap = args.get('reverseMap', False)
drawGrid = args.get('drawGrid', False)
resolution = args.get('gridResolution', 10)
xtics = args.get('xtics', 0)
ytics = args.get('ytics', 0)
ztics = args.get('ztics', 0)
planeGrid = args.get('planeGrid', True)
xCutterOn = args.get('XCutterOn', True)
yCutterOn = args.get('YCutterOn', True)
zCutterOn = args.get('ZCutterOn', True)
xCutterPos = args.get('XCutterPos', None)
yCutterPos = args.get('YCutterPos', None)
zCutterPos = args.get('ZCutterPos', None)
self.parseRenderArgs(**args)
if gridData:
geometry = vtk.vtkStructuredGridGeometryFilter()
else:
geometry = vtk.vtkRectilinearGridGeometryFilter()
geometry.SetInputData(self.gridfunc)
geometry.SetExtent(self.gridfunc.GetExtent())
if gridData:
wzscale = self.computeScale(self.gridfunc)
self.out = geometry.GetOutput()
else:
geometry.SetExtent(self.gridfunc.GetExtent())
geometry.GetOutput().SetPoints(self.Points)
geometry.GetOutput().GetPointData().SetScalars(self.Colors)
geometry.GetOutput().Update()
self.out = geometry.GetOutput()
self.out.SetPoints(self.Points)
self.out.GetPointData().SetScalars(self.Colors)
self.out.Update()
wzscale = self.computeScale(self.out)
x = self.XScale if autoscale else self.XScale * scaleFactor[0]
y = self.YScale if autoscale else self.YScale * scaleFactor[1]
z = 0.5 * self.ZScale if autoscale else self.ZScale * scaleFactor[2]
transform = vtk.vtkTransform()
transform.Scale(x, y, z)
trans = vtk.vtkTransformPolyDataFilter()
trans.SetInputConnection(geometry.GetOutputPort())
trans.SetTransform(transform)
localScale = wzscale if wzscale < 1 else 1 / wzscale
self.warp = vtk.vtkWarpScalar()
self.warp.XYPlaneOn()
self.warp.SetInputConnection(trans.GetOutputPort())
self.warp.SetNormal(0, 0, 1)
self.warp.UseNormalOn()
self.warp.SetScaleFactor(localScale)
tmp = self.gridfunc.GetScalarRange()
# map gridfunction
self.mapper = vtk.vtkPolyDataMapper()
self.mapper.SetInputConnection(self.warp.GetOutputPort())
# calculate ranges
if self.customZRange:
self.mapper.SetScalarRange(*self.customZRange)
elif self.autoZRange:
mx = max(abs(tmp[0]), abs(tmp[1]))
self.mapper.SetScalarRange(-mx, mx)
else:
self.mapper.SetScalarRange(tmp[0], tmp[1])
wireActor = None
bounds = self.mapper.GetBounds()
# wire mapper
if planeGrid:
if not gridData:
self.plane = vtk.vtkRectilinearGridGeometryFilter()
self.plane.SetInput(self.gridfunc)
self.plane.SetExtent(self.gridfunc.GetExtent())
x_, y_ = x, y
else:
self.plane = vtk.vtkPlaneSource()
self.plane.SetXResolution(resolution)
self.plane.SetYResolution(resolution)
#.........这里部分代码省略.........
开发者ID:viz4biz,项目名称:PyDataNYC2015,代码行数:101,代码来源:vtk_surface.py
示例9: set_initial_display
def set_initial_display(self):
if self.renwininter is None:
self.renwininter = MEQ_QVTKRenderWindowInteractor(self.winsplitter)
self.renwininter.setWhatsThis(rendering_control_instructions)
self.renwin = self.renwininter.GetRenderWindow()
self.inter = self.renwin.GetInteractor()
self.winsplitter.insertWidget(0,self.renwininter)
self.winsplitter.addWidget(self.v_box_controls)
self.winsplitter.setSizes([500,100])
self.renwininter.show()
# Paul Kemper suggested the following:
camstyle = vtk.vtkInteractorStyleTrackballCamera()
self.renwininter.SetInteractorStyle(camstyle)
self.extents = self.image_array.GetDataExtent()
self.spacing = self.image_array.GetDataSpacing()
self.origin = self.image_array.GetDataOrigin()
# An outline is shown for context.
if self.warped_surface:
self.index_selector.initWarpContextmenu()
sx, sy, sz = self.image_array.GetDataSpacing()
xMin, xMax, yMin, yMax, zMin, zMax = self.image_array.GetDataExtent()
xMin = sx * xMin
xMax = sx * xMax
yMin = sy * yMin
yMax = sy * yMax
self.scale_factor = 0.5 * ((xMax-xMin) + (yMax-yMin)) / (self.data_max - self.data_min)
zMin = self.data_min * self.scale_factor
zMax = self.data_max * self.scale_factor
self.outline = vtk.vtkOutlineSource();
self.outline.SetBounds(xMin, xMax, yMin, yMax, zMin, zMax)
else:
self.index_selector.init3DContextmenu()
self.outline = vtk.vtkOutlineFilter()
self.outline.SetInput(self.image_array.GetOutput())
outlineMapper = vtk.vtkPolyDataMapper();
outlineMapper.SetInput(self.outline.GetOutput() );
outlineActor = vtk.vtkActor();
outlineActor.SetMapper(outlineMapper);
# create blue to red color table
self.lut = vtk.vtkLookupTable()
self.lut.SetHueRange(0.6667, 0.0)
self.lut.SetNumberOfColors(256)
self.lut.Build()
# here is where the 2-D image gets warped
if self.warped_surface:
geometry = vtk.vtkImageDataGeometryFilter()
geometry.SetInput(self.image_array.GetOutput())
self.warp = vtk.vtkWarpScalar()
self.warp.SetInput(geometry.GetOutput())
self.warp.SetScaleFactor(self.scale_factor)
self.mapper = vtk.vtkPolyDataMapper();
self.mapper.SetInput(self.warp.GetPolyDataOutput())
self.mapper.SetScalarRange(self.data_min,self.data_max)
self.mapper.SetLookupTable(self.lut)
self.mapper.ImmediateModeRenderingOff()
warp_actor = vtk.vtkActor()
# warp_actor.SetScale(2,1,1)
warp_actor.SetMapper(self.mapper)
min_range = 0.5 * self.scale_factor
max_range = 2.0 * self.scale_factor
self.index_selector.set_emit(False)
self.index_selector.setMaxValue(max_range,False)
self.index_selector.setMinValue(min_range)
self.index_selector.setTickInterval( (max_range - min_range) / 10 )
self.index_selector.setRange(max_range, False)
self.index_selector.setValue(self.scale_factor)
self.index_selector.setLabel('display gain')
self.index_selector.hideNDControllerOption()
self.index_selector.reset_scale_toggle()
self.index_selector.set_emit(True)
else:
# set up ImagePlaneWidgets ...
# The shared picker enables us to use 3 planes at one time
# and gets the picking order right
picker = vtk.vtkCellPicker()
picker.SetTolerance(0.005)
# get locations for initial slices
xMin, xMax, yMin, yMax, zMin, zMax = self.extents
x_index = (xMax-xMin) / 2
y_index = (yMax-yMin) / 2
z_index = (zMax-zMin) / 2
# The 3 image plane widgets are used to probe the dataset.
self.planeWidgetX = vtk.vtkImagePlaneWidget()
self.planeWidgetX.DisplayTextOn()
self.planeWidgetX.SetInput(self.image_array.GetOutput())
self.planeWidgetX.SetPlaneOrientationToXAxes()
self.planeWidgetX.SetSliceIndex(x_index)
self.planeWidgetX.SetPicker(picker)
self.planeWidgetX.SetKeyPressActivationValue("x")
self.planeWidgetX.SetLookupTable(self.lut)
#.........这里部分代码省略.........
开发者ID:gijzelaerr,项目名称:meqtrees-timba,代码行数:101,代码来源:vtk_qt4_3d_display.py
示例10:
#streamer.SetStartPosition(0.18474886E+01, 0.12918899E+00, 0.00000000E+00)
streamer.SetSource(seedFilter.GetOutput())
streamer.SetMaximumPropagation(160000.0)
#streamer.SetMaximumPropagationUnitToTimeUnit()
streamer.SetInitialIntegrationStep(1.0)
#streamer.SetInitialIntegrationStepUnitToCellLengthUnit()
streamer.SetIntegrationDirectionToBoth()
streamer.SetIntegrator(integ)
#
streamTube = vtk.vtkTubeFilter()
streamTube.SetInputConnection(streamer.GetOutputPort())
#streamTube.SetInputArrayToProcess(1,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS, vectors)
streamTube.SetRadius(10000.0)
streamTube.SetNumberOfSides(12)
streamWarp = vtk.vtkWarpScalar()
streamWarp.SetInputConnection(streamTube.GetOutputPort())
streamWarp.SetNormal(0.0,0.0,1.0)
streamWarp.UseNormalOn()
streamWarp.SetScaleFactor(10000.0)
mapStreamTube = vtk.vtkPolyDataMapper()
mapStreamTube.SetInputConnection(streamWarp.GetOutputPort())
#mapStreamTube.SetInputConnection(streamer.GetOutputPort())
#mapStreamTube.SetInputConnection(streamTube.GetOutputPort())
mapStreamTube.SetScalarRange(meshReader.GetOutput().GetPointData().GetScalars().GetRange())
mapStreamTube.SetLookupTable(lut)
streamTubeActor = vtk.vtkActor()
streamTubeActor.SetMapper(mapStreamTube)
streamTubeActor.GetProperty().SetColor(0.0,0.0,0.0)
开发者ID:HyeonJeongKim,项目名称:asgs,代码行数:31,代码来源:tristreamline.py
示例11: elevation
def elevation(self, data):
self.data = data
self.settings = wx.Panel(self)
self.plot_type= self.type = 'elevation'
self.image = self.array_to_2d_imagedata()
geometry = vtk.vtkImageDataGeometryFilter()
if vtk.vtkVersion.GetVTKMajorVersion()<6:
geometry.SetInput(self.image)
else:
geometry.SetInputData(self.image)
self.warp = vtk.vtkWarpScalar()
self.warp.SetInputConnection(geometry.GetOutputPort())
self.warp.SetScaleFactor(1)
self.warp.UseNormalOn()
self.warp.SetNormal(0,0,1)
self.warp.Update()
lut =vtk.vtkLookupTable()
lut.SetTableRange(self.image.GetScalarRange())
lut.SetNumberOfColors(256)
lut.SetHueRange(0.7, 0)
lut.Build()
merge=vtk.vtkMergeFilter()
if vtk.vtkVersion.GetVTKMajorVersion()<6:
merge.SetGeometry(self.warp.GetOutput())
merge.SetScalars(self.image)
else:
merge.SetGeometryInputData(self.warp.GetOutput())
merge.SetScalarsData(self.image)
merge.Update()
self.outline = vtk.vtkOutlineFilter()
self.outline.SetInputConnection(merge.GetOutputPort())
self.outline.Update()
outlineMapper = vtk.vtkPolyDataMapper()
if vtk.vtkVersion.GetVTKMajorVersion()<6:
outlineMapper.SetInputConnection(self.outline.GetOutputPort())
else:
outlineMapper.SetInputData(self.outline.GetOutputDataObject(0))
box=vtk.vtkActor()
box.SetMapper(outlineMapper)
box.GetProperty().SetColor(0,0,0)
self.renderer.AddActor(box)
self.actor_list.append(box)
mapper=vtk.vtkPolyDataMapper()
mapper.SetLookupTable(lut)
mapper.SetScalarRange(self.image.GetScalarRange())
mapper.SetInputConnection(merge.GetOutputPort())
actor=vtk.vtkActor()
actor.SetMapper(mapper)
self.renderer.AddActor(actor)
self.actor_list.append(actor)
scalarBar = vtk.vtkScalarBarActor()
scalarBar.SetTitle("")
scalarBar.SetWidth(0.1)
scalarBar.SetHeight(0.9)
scalarBar.SetLookupTable(lut)
self.renderer.AddActor2D(scalarBar)
self.actor_list.append(scalarBar)
self.build_axes(noZaxis = True)
self.center_on_actor(actor)
self.iren.Render()
self.warp.SetScaleFactor(0)
self.warp.Update()
self.outline.Update()
self.renderer.ResetCameraClippingRange()
self.iren.Render()
sb0 = wx.StaticBox(self.settings, wx.ID_ANY, label = "Scaling Panel")
Sizer0 = wx.StaticBoxSizer(sb0, wx.HORIZONTAL)
content1 = wx.StaticText(self.settings, -1, "X")
self.x_Offset = wx.TextCtrl(self.settings, wx.ID_ANY, size = (45,27),style = wx.TE_PROCESS_ENTER )
self.Bind(wx.EVT_TEXT_ENTER, self.x_spacing_onmove ,self.x_Offset)
self.x_Offset.SetValue('1.0')
self.x_slider = wx.Slider(self.settings,id=wx.ID_ANY,value=100,minValue=0,maxValue=200, style= wx.SL_AUTOTICKS | wx.SL_HORIZONTAL | wx.SL_LABELS)
self.x_slider.Bind(wx.EVT_SCROLL, self.x_spacing_onmove)
content2 = wx.StaticText(self.settings, -1, "Y")
#.........这里部分代码省略.........
开发者ID:mark-johnson-1966,项目名称:MDANSE,代码行数:101,代码来源:Plotter3D.py
示例12: initialize
def initialize (self):
debug ("In WarpScalar::initialize ()")
self.fil = vtk.vtkWarpScalar ()
self._set_input ()
self.fil.Update ()
开发者ID:sldion,项目名称:DNACC,代码行数:5,代码来源:WarpScalar.py
示例13: testSphereWidget
#.........这里部分代码省略.........
MouseMoveEvent 104 206 0 0 0 0 i\n\
LeftButtonReleaseEvent 104 206 0 0 0 0 i\n\
MouseMoveEvent 104 205 0 0 0 0 i\n\
MouseMoveEvent 104 204 0 0 0 0 i\n\
MouseMoveEvent 105 205 0 0 0 0 i\n\
MouseMoveEvent 105 206 0 0 0 0 i\n\
"
# Start by loading some data.
#
dem = vtk.vtkDEMReader()
dem.SetFileName(VTK_DATA_ROOT + "/Data/SainteHelens.dem")
dem.Update()
Scale = 2
lut = vtk.vtkLookupTable()
lut.SetHueRange(0.6, 0)
lut.SetSaturationRange(1.0, 0)
lut.SetValueRange(0.5, 1.0)
lo = Scale * dem.GetElevationBounds()[0]
hi = Scale * dem.GetElevationBounds()[1]
shrink = vtk.vtkImageShrink3D()
shrink.SetShrinkFactors(4, 4, 1)
shrink.SetInputConnection(dem.GetOutputPort())
shrink.AveragingOn()
geom = vtk.vtkImageDataGeometryFilter()
geom.SetInputConnection(shrink.GetOutputPort())
geom.ReleaseDataFlagOn()
warp = vtk.vtkWarpScalar()
warp.SetInputConnection(geom.GetOutputPort())
warp.SetNormal(0, 0, 1)
warp.UseNormalOn()
warp.SetScaleFactor(Scale)
warp.ReleaseDataFlagOn()
elevation = vtk.vtkElevationFilter()
elevation.SetInputConnection(warp.GetOutputPort())
elevation.SetLowPoint(0, 0, lo)
elevation.SetHighPoint(0, 0, hi)
elevation.SetScalarRange(lo, hi)
elevation.ReleaseDataFlagOn()
normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(elevation.GetOutputPort())
normals.SetFeatureAngle(60)
normals.ConsistencyOff()
normals.SplittingOff()
normals.ReleaseDataFlagOn()
normals.Update()
demMapper = vtk.vtkPolyDataMapper()
demMapper.SetInputConnection(normals.GetOutputPort())
demMapper.SetScalarRange(lo, hi)
demMapper.SetLookupTable(lut)
demActor = vtk.vtkActor()
demActor.SetMapper(demMapper)
# Create the RenderWindow, Renderer and both Actors
#
ren = vtk.vtkRenderer()
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:67,代码来源:TestSphereWidget.py
示例14: main
def main(argv):
if len(argv) < 2:
print "usage: ",argv[0]," <data>"
exit(1)
data_fn = argv[1]
mapper = vtk.vtkPolyDataMapper()
if data_fn.find('.vtk') != -1:
reader = vtk.vtkPolyDataReader()
reader.SetFileName(data_fn)
reader.Update()
data = reader.GetOutput()
trianglize = vtk.vtkDelaunay2D()
trianglize.SetInput(data)
trianglize.Update()
mapper.SetInputConnection(trianglize.GetOutputPort())
elif data_fn.find('.pgm') != -1:
reader = vtk.vtkPNMReader()
reader.SetFileName(data_fn)
reader.Update()
data = reader.GetOutput()
trianglize = vtk.vtkImageDataGeometryFilter()
trianglize.SetInput(data)
trianglize.Update()
warp = vtk.vtkWarpScalar()
warp.SetScaleFactor(0.2) # arbitrary choice
warp.SetInputConnection(trianglize.GetOutputPort())
warp.Update()
mapper.SetInputConnection(warp.GetOutputPort())
elif data_fn.find('.dcm') != -1:
reader =vtk.vtkDICOMImageReader()
reader.SetFileName(data_fn)
reader.Update()
data = reader.GetOutput()
trianglize = vtk.vtkImageDataGeometryFilter()
trianglize.SetInput(data)
trianglize.Update()
warp = vtk.vtkWarpScalar()
#warp.SetScaleFactor(0.2) # arbitrary choice
warp.SetInputConnection(trianglize.GetOutputPort())
warp.Update()
mapper.SetInputConnection(warp.GetOutputPort())
else:
print "unrecognized data file:",data_fn
exit(1)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.SetSize(700,700)
renderWindow.AddRenderer(renderer)
renderWindow.SetWindowName("heightfield")
renderer.AddActor(actor)
renderer.SetBackground(0.4,0.3,0.2)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow)
renderWindow.Render()
interactor.Start()
开发者ID:daniel-perry,项目名称:visualization,代码行数:64,代码来源:heightfield.py
示例15: main
def main(argv):
if len(argv) < 2:
print "usage: ",argv[0]," <data> [flat]"
exit(1)
data_fn = argv[1]
flat = False
if len(argv) > 2:
flat = True
mapper = vtk.vtkPolyDataMapper()
if data_fn.find('.vtk') != -1:
reader = vtk.vtkPolyDataReader()
reader.SetFileName(data_fn)
reader.Update()
data = reader.GetOutput()
trianglize = vtk.vtkDelaunay2D()
trianglize.SetInput(data)
trianglize.Update()
mapper.SetInputConnection(trianglize.GetOutputPort())
elif data_fn.find('.pgm') != -1:
reader = vtk.vtkPNMReader()
reader.SetFileName(data_fn)
reader.Update()
data = reader.GetOutput()
geometry = vtk.vtkImageDataGeometryFilter()
geometry.SetInputConnection(reader.GetOutputPort())
geometry.Update()
if flat:
merge = vtk.vtkMergeFilter()
merge.SetGeometry(geometry.GetOutput())
merge.SetScalars(data)
mapper.SetInputConnection(merge.GetOutputPort())
else:
warp = vtk.vtkWarpScalar()
warp.SetInputConnection(geometry.GetOutputPort())
warp.SetScaleFactor(0.3) # looked good
warp.Update()
merge = vtk.vtkMergeFilter()
merge.SetGeometry(warp.GetOutput())
merge.SetScalars(data)
mapper.SetInputConnection(merge.GetOutputPort())
elif data_fn.find('.dcm') != -1:
reader =vtk.vtkDICOMImageReader()
reader.SetFileName(data_fn)
reader.Update()
data = reader.GetOutput()
geometry = vtk.vtkImageDataGeometryFilter()
geometry.SetInput(data)
geometry.Update()
if flat:
mapper.SetInputConnection(geometry.GetOutputPort())
else:
warp = vtk.vtkWarpScalar()
warp.SetInputConnection(geometry.GetOutputPort())
warp.Update()
mapper.SetInputConnection(warp.GetOutputPort())
else:
print "unrecognized data file:",data_fn
exit(1)
lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(10)
lut.SetHueRange(0.5,0.3)
lut.SetSaturationRange(0.6,0.5)
lut.SetValueRange(1.0,0.5)
lut.Build()
mapper.ImmediateModeRenderingOff()
mapper.SetLookupTable(lut)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.SetSize(700,700)
renderWindow.AddRenderer(renderer)
renderer.AddActor(actor)
renderer.SetBackground(0.4,0.3,0.2)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renderWindow)
renderWindow.Render()
interactor.Start()
开发者ID:daniel-perry,项目名称:visualization,代码行数:86,代码来源:colormap.py
示例16: locals
demModel.Update()
catch.catch(globals(),"""#demModel.Print()""")
lo = expr.expr(globals(), locals(),["Scale","*","lindex(demModel.GetElevationBounds(),0)"])
hi = expr.expr(globals(), locals(),["Scale","*","lindex(demModel.GetElevationBounds(),1)"])
demActor = vtk.vtkLODActor()
# create a pipeline for each lod mapper
lods = "4 8 16"
for lod in lods.split():
locals()[get_variable_name("shrink", lod, "")] = vtk.vtkImageShrink3D()
locals()[get_variable_name("shrink", lod, "")].SetShrinkFactors(expr.expr(globals(), locals(),["int","(","lod",")"]),expr.expr(globals(), locals(),["int","(","lod",")"]),1)
locals()[get_variable_name("shrink", lod, "")].SetInputConnection(demModel.GetOutputPort())
locals()[get_variable_name("shrink", lod, "")].AveragingOn()
locals()[get_variable_name("geom", lod, "")] = vtk.vtkImageDataGeometryFilter()
locals()[get_variable_name("geom", lod, "")].SetInputConnection(locals()[get_variable_name("shrink", lod, "")].GetOutputPort())
locals()[get_variable_name("geom", lod, "")].ReleaseDataFlagOn()
locals()[get_variable_name("warp", lod, "")] = vtk.vtkWarpScalar()
locals()[get_variable_name("warp", lod, "")].SetInputConnection(locals()[get_variable_name("geom", lod, "")].GetOutputPort())
locals()[get_variable_name("warp", lod, "")].SetNormal(0,0,1)
locals()[get_variable_name("warp", lod, "")].UseNormalOn()
locals()[get_variable_name("warp", lod, "")].SetScaleFactor(Scale)
locals()[get_variable_name("warp", lod, "")].ReleaseDataFlagOn()
locals()[get_variable_name("elevation", lod, "")] = vtk.vtkElevationFilter()
locals()[get_variable_name("elevation", lod, "")].SetInputConnection(locals()[get_variable_name("warp", lod, "")].GetOutputPort())
locals()[get_variable_name("elevation", lod, "")].SetLowPoint(0,0,lo)
locals()[get_variable_name("elevation", lod, "")].SetHighPoint(0,0,hi)
locals()[get_variable_name("elevation", lod, "")].SetScalarRange(lo,hi)
locals()[get_variable_name("elevation", lod, "")].ReleaseDataFlagOn()
locals()[get_variable_name("toPoly", lod, "")] = vtk.vtkCastToConcrete()
locals()[get_variable_name("toPoly", lod, "")].SetInputConnection(locals()[get_variable_name("elevation", lod, "")].GetOutputPort())
locals()[get_variable_name("normals", lod, "")] = vtk.vtkPolyDataNormals()
locals()[get_variable_name("normals", lod, "")].SetInputConnection(locals()[get_variable_name("toPoly", lod, "")].GetOutputPort())
开发者ID:151706061,项目名称:VTK,代码行数:31,代码来源:dem.py
示例17: bessel_surface
def bessel_surface():
"""
programmable surface
"""
# We create a 100 by 100 point plane to sample
plane = vtk.vtkPlaneSource()
plane.SetXResolution(100)
plane.SetYResolution(100)
# We transform the plane by a factor of 10 on X and Y
transform = vtk.vtkTransform()
transform.Scale(10, 10, 1)
transF = vtk.vtkTransformPolyDataFilter()
transF.SetInputConnection(plane.GetOutputPort())
transF.SetTransform(transform)
# Compute Bessel function and derivatives. We'll use a programmable filter
# for this. Note the unusual GetPolyDataInput() & GetOutputPort() methods.
besselF = vtk.vtkProgrammableFilter()
besselF.SetInputConnection(transF.GetOutputPort())
# The SetExecuteMethod takes a Python function as an argument
# In here is where all the processing is done.
def bessel():
inputs = besselF.GetPolyDataInput()
numPts = inputs.GetNumberOfPoints()
newPts = vtk.vtkPoints()
derivs = vtk.vtkFloatArray()
for i in xrange(0, numPts):
x = inputs.GetPoint(i)
x0, x1 = x[:2]
r = sqrt(x0*x0+x1*x1)
x2 = exp(-r)*cos(10.0*r)
deriv = -exp(-r)*(cos(10.0*r)+10.0*sin(10.0*r))
newPts.InsertPoint(i, x0, x1, x2)
derivs.InsertValue(i, deriv)
besselF.GetPolyDataOutput().CopyStructure(inputs)
besselF.GetPolyDataOutput().SetPoints(newPts)
besselF.GetPolyDataOutput().GetPointData().SetScalars(derivs)
besselF.SetExecuteMethod(bessel)
# We warp the plane based on the scalar values calculated above
warp = vtk.vtkWarpScalar()
warp.SetInputConnection(besselF.GetOutputPort())
warp.XYPlaneOn()
warp.SetScaleFactor(0.5)
# We create a mapper and actor as usual. In the case we adjust the
# scalar range of the mapper to match that of the computed scalars
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(warp.GetOutputPort())
mapper.SetScalarRange(besselF.GetPolyDataOutput().GetScalarRange())
carpet = vtk.vtkActor()
carpet.SetMapper(mapper)
return carpet
开发者ID:alexlib,项目名称:PyDataNYC2015,代码行数:62,代码来源:scenes.py
示例18: vtkGetDataRoot
# from each together.
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Read in an image and compute a luminance value. The image is
# extracted as a set of polygons (vtkImageDataGeometryFilter). We then
# will warp the plane using the scalar (luminance) values.
reader = vtk.vtkBMPReader()
reader.SetFileName(VTK_DATA_ROOT + "/Data/masonry.bmp")
luminance = vtk.vtkImageLuminance()
luminance.SetInputConnection(reader.GetOutputPort())
geometry = vtk.vtkImageDataGeometryFilter()
geometry.SetInputConnection(luminance.GetOutputPort())
warp = vtk.vtkWarpScalar()
warp.SetInputConnection(geometry.GetOutputPort())
warp.SetScaleFactor(-0.1)
# Use vtkMergeFilter to combine the original image with the warped
# geometry.
merge = vtk.vtkMergeFilter()
merge.SetGeometryConnection(warp.GetOutputPort())
merge.SetScalarsConnection(reader.GetOutputPort())
mapper = vtk.vtkDataSetMapper()
mapper.SetInputConnection(merge.GetOutputPort())
mapper.SetScalarRange(0, 255)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# Create renderer stuff
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:31,代码来源:imageWarp.py
示例19: __init__
def __init__(self, renderer, surfaceSize):
'''
Initialize the terrain. This is derived from the expCos.py example on the vtk.org website, link is above.
'''
# Call the parent constructor
super(Terrain,self).__init__(renderer)
# We create a 'surfaceSize' by 'surfaceSize' point plane to sample
plane = vtk.vtkPlaneSource()
plane.SetXResolution(surfaceSize)
plane.SetYResolution(surfaceSize)
# We transform the plane by a factor of 'surfaceSize' on X and Y
transform = vtk.vtkTransform()
transform.Scale(surfaceSize, surfaceSi
|
请发表评论