本文整理汇总了Python中vtk.vtkElevationFilter函数的典型用法代码示例。如果您正苦于以下问题:Python vtkElevationFilter函数的具体用法?Python vtkElevationFilter怎么用?Python vtkElevationFilter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkElevationFilter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkElevationFilter(), 'Processing.',
('vtkDataSet',), ('vtkDataSet',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkElevationFilter.py
示例2: _test
def _test(self, fname):
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(VTK_DATA_ROOT + fname)
elev = vtk.vtkElevationFilter()
elev.SetInputConnection(reader.GetOutputPort())
elev.SetLowPoint(-0.05, 0.05, 0)
elev.SetHighPoint(0.05, 0.05, 0)
grad = vtk.vtkGradientFilter()
grad.SetInputConnection(elev.GetOutputPort())
grad.SetInputArrayToProcess(0, 0, 0, vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS, "Elevation")
grad.Update()
vals = (10, 0, 0)
for i in range(3):
r = grad.GetOutput().GetPointData().GetArray("Gradients").GetRange(i)
self.assertTrue(abs(r[0] - vals[i]) < 1E-4)
self.assertTrue(abs(r[1] - vals[i]) < 1E-4)
elev.SetLowPoint(0.05, -0.05, 0)
elev.SetHighPoint(0.05, 0.05, 0)
grad.Update()
vals = (0, 10, 0)
for i in range(3):
r = grad.GetOutput().GetPointData().GetArray("Gradients").GetRange(i)
self.assertTrue(abs(r[0] - vals[i]) < 1E-4)
self.assertTrue(abs(r[1] - vals[i]) < 1E-4)
开发者ID:0004c,项目名称:VTK,代码行数:34,代码来源:quadraticQuadDeriv.py
示例3: 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
示例4: MakeElevations
def MakeElevations(src):
'''
Generate elevations over the surface.
:param: src - the vtkPolyData source.
:return: - vtkPolyData source with elevations.
'''
bounds = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
src.GetBounds(bounds)
elevFilter = vtk.vtkElevationFilter()
elevFilter.SetInputData(src)
elevFilter.SetLowPoint(0, bounds[2], 0)
elevFilter.SetHighPoint(0, bounds[3], 0)
elevFilter.SetScalarRange(bounds[2], bounds[3])
elevFilter.Update()
return elevFilter.GetPolyDataOutput()
开发者ID:dlrdave,项目名称:VTKWikiExamples,代码行数:15,代码来源:CurvatureBandsWithGlyphs.py
示例5: render_image
def render_image(pointset):
'''
square = 10
color_map = vtk.vtkLookupTable()
color_map.SetNumberOfColors(square * square)
color_map.SetTableRange(0, square * square - 1)
for ii in range(0, square):
for jj in range(0, square):
color_map.SetTableValue(ii, jj / square, jj / square, ii /square)
'''
color_map = vtk.vtkLookupTable()
color_map.SetNumberOfColors(16)
color_map.SetHueRange(0, 0.667)
delaunay = vtk.vtkDelaunay2D()
delaunay.SetTolerance(0.001)
delaunay.SetAlpha(18)
delaunay.SetInput(pointset);
delaunay.Update();
elevation_thorax = vtk.vtkElevationFilter()
elevation_thorax.SetInput(delaunay.GetOutput())
elevation_thorax.SetLowPoint(0, 0, -25)
elevation_thorax.SetHighPoint(0, 0, 25)
meshMapper = vtk.vtkPolyDataMapper2D()
meshMapper.SetInput(elevation_thorax.GetOutput())
meshMapper.SetLookupTable(color_map)
#meshMapper.SetScalarRange(0,255)
meshActor = vtk.vtkActor2D()
meshActor.SetMapper(meshMapper)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(meshActor)
#renderer.AddActor(boundaryActor)
renderer.SetBackground(.5, .5, .5)
renderWindow.SetSize(600, 600)
renderWindow.Render()
renderWindowInteractor.Start()
开发者ID:arun04ceg,项目名称:2D-spatial-data,代码行数:47,代码来源:height_fields_thorax_c1.py
示例6:
ren1 = vtk.vtkRenderer()
ren1.SetViewport(0.5,0,1,1)
renWin = vtk.vtkRenderWindow()
renWin.SetSize(2*sze+100,sze)
renWin.AddRenderer(ren0)
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Create pipeline, render simple object. We'll also color
# the sphere to generate color scalars.
sphere = vtk.vtkSphereSource()
sphere.SetCenter(0,0,0)
sphere.SetRadius(1)
ele = vtk.vtkElevationFilter()
ele.SetInputConnection(sphere.GetOutputPort())
ele.SetLowPoint(0,-1,0)
ele.SetHighPoint(0,1,0)
sphereMapper = vtk.vtkPolyDataMapper()
sphereMapper.SetInputConnection(ele.GetOutputPort())
sphereActor = vtk.vtkActor()
sphereActor.SetMapper(sphereMapper)
ren0.AddActor(sphereActor)
ren0.SetBackground(0,0,0)
iren.Initialize()
ren0.ResetCamera()
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:31,代码来源:TestDepthImageToPointCloud-TwoInputs.py
示例7: source
# Description de la scene
L = 10.
P = 5.
H = 4.
##################
# SPHERE
##################
# On cree une source (en l'occurence une sphere pour le pipeline vtk)
sphere = vtk.vtkSphereSource()
sphere.SetPhiResolution( 20 )
sphere.SetThetaResolution( 20 )
#Filtre de coloration
color_filter = vtk.vtkElevationFilter();
color_filter.SetInputConnection(sphere.GetOutputPort())
color_filter.SetLowPoint(0,0,-0.5);
color_filter.SetHighPoint(0,0,0.5);
# table de valeurs
tv = vtk.vtkLookupTable()
tv.SetHueRange(0.667,0.)
tv.SetSaturationRange(1,1)
tv.SetValueRange(1,1)
# on utiliseur un traceur avec qui colore la sphere selon sa hauteur suivant l'axe
# des z a l'aide d'un filtre de coloration
sphereMapper = vtk.vtkPolyDataMapper()
sphereMapper.SetLookupTable(tv)
sphereMapper.SetInputConnection( color_filter.GetOutputPort() )
开发者ID:aitzkora,项目名称:Zientziako-Jaia,代码行数:31,代码来源:cree_scene.py
示例8: __init__
def __init__(self, parent = None):
super(VTKFrame, self).__init__(parent)
self.vtkWidget = QVTKRenderWindowInteractor(self)
vl = QtGui.QVBoxLayout(self)
vl.addWidget(self.vtkWidget)
vl.setContentsMargins(0, 0, 0, 0)
self.ren = vtk.vtkRenderer()
self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
sphere = vtk.vtkSphereSource()
sphere.SetCenter(1, 1, 1)
sphere.SetRadius(1)
sphere.SetThetaResolution(100)
sphere.SetPhiResolution(100)
sphere.Update()
cube = vtk.vtkCubeSource()
cube.SetBounds(-1,1,-1,1,-1,1)
cube.Update()
# Create 3D cells so vtkImplicitDataSet evaluates inside vs outside correctly
tri = vtk.vtkDelaunay3D()
tri.SetInput(cube.GetOutput())
tri.BoundingTriangulationOff()
# vtkImplicitDataSet needs some scalars to interpolate to find inside/outside
elev = vtk.vtkElevationFilter()
elev.SetInputConnection(tri.GetOutputPort())
implicit = vtk.vtkImplicitDataSet()
implicit.SetDataSet(elev.GetOutput())
clipper = vtk.vtkClipPolyData()
clipper.SetClipFunction(implicit)
clipper.SetInputConnection(sphere.GetOutputPort())
clipper.InsideOutOn()
clipper.Update()
# Vis for clipped sphere
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(clipper.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetRepresentationToWireframe()
# Vis for cube so can see it in relation to clipped sphere
mapper2 = vtk.vtkDataSetMapper()
mapper2.SetInputConnection(elev.GetOutputPort())
actor2 = vtk.vtkActor()
actor2.SetMapper(mapper2)
#actor2.GetProperty().SetRepresentationToWireframe()
#create renderers and add actors of plane and cube
self.ren.AddActor(actor)
self.ren.AddActor(actor2)
self.ren.SetBackground(0.1, 0.2, 0.4)
self.ren.ResetCamera()
self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:62,代码来源:implicitdataset.py
示例9: vtkGetDataRoot
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
res = 6
plane = vtk.vtkPlaneSource()
plane.SetResolution(res,res)
colors = vtk.vtkElevationFilter()
colors.SetInputConnection(plane.GetOutputPort())
colors.SetLowPoint(-0.25,-0.25,-0.25)
colors.SetHighPoint(0.25,0.25,0.25)
planeMapper = vtk.vtkPolyDataMapper()
planeMapper.SetInputConnection(colors.GetOutputPort())
planeActor = vtk.vtkActor()
planeActor.SetMapper(planeMapper)
planeActor.GetProperty().SetRepresentationToWireframe()
# create simple poly data so we can apply glyph
squad = vtk.vtkSuperquadricSource()
squadColors = vtk.vtkElevationFilter()
squadColors.SetInputConnection(squad.GetOutputPort())
squadColors.SetLowPoint(-0.25,-0.25,-0.25)
squadColors.SetHighPoint(0.25,0.25,0.25)
squadCaster = vtk.vtkCastToConcrete()
squadCaster.SetInputConnection(squadColors.GetOutputPort())
squadTransform = vtk.vtkTransform()
transformSquad = vtk.vtkTransformPolyDataFilter()
transformSquad.SetInputConnection(squadColors.GetOutputPort())
transformSquad.SetTransform(squadTransform)
transformSquad.Update()
开发者ID:0004c,项目名称:VTK,代码行数:31,代码来源:progGlyphsBySource.py
示例10: vtkGetDataRoot
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
res = 6
plane = vtk.vtkPlaneSource()
plane.SetResolution(res, res)
colors = vtk.vtkElevationFilter()
colors.SetInputConnection(plane.GetOutputPort())
colors.SetLowPoint(-0.25, -0.25, -0.25)
colors.SetHighPoint(0.25, 0.25, 0.25)
planeMapper = vtk.vtkPolyDataMapper()
planeMapper.SetInputConnection(colors.GetOutputPort())
planeActor = vtk.vtkActor()
planeActor.SetMapper(planeMapper)
planeActor.GetProperty().SetRepresentationToWireframe()
# procedure for generating glyphs
def Glyph(__vtk__temp0=0, __vtk__temp1=0):
global res
ptId = glypher.GetPointId()
pd = glypher.GetPointData()
xyz = glypher.GetPoint()
x = lindex(xyz, 0)
y = lindex(xyz, 1)
length = glypher.GetInput(0).GetLength()
scale = expr.expr(globals(), locals(), ["length", "/", "(", "2.0", "*", "res", ")"])
squad.SetScale(scale, scale, scale)
squad.SetCenter(xyz)
开发者ID:Guokr1991,项目名称:VTK,代码行数:31,代码来源:progGlyphs.py
示例11:
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())
normals16.SetFeatureAngle(60)
normals16.ConsistencyOff()
normals16.SplittingOff()
normals16.ReleaseDataFlagOn()
demMapper16 = vtk.vtkPolyDataMapper()
demMapper16.SetInputConnection(normals16.GetOutputPort())
开发者ID:0004c,项目名称:VTK,代码行数:31,代码来源:TestInteractorStyleTerrain.py
示例12: __init__
def __init__(self, parent = None):
super(VTKFrame, self).__init__(parent)
self.vtkWidget = QVTKRenderWindowInteractor(self)
vl = QtGui.QVBoxLayout(self)
vl.addWidget(self.vtkWidget)
vl.setContentsMargins(0, 0, 0, 0)
self.ren = vtk.vtkRenderer()
self.ren.SetBackground(0.1, 0.2, 0.4)
self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
# Created a grid of points
points = vtk.vtkPoints()
gridSize = 10
for x in range(10):
for y in range(10):
points.InsertNextPoint(x, y, (x+y) / (y+1))
bounds = [1] * 6
points.GetBounds(bounds)
# Add the grid points to a polydata object
inputPolyData = vtk.vtkPolyData()
inputPolyData.SetPoints(points)
# Triangulate the grid points
delaunay = vtk.vtkDelaunay2D()
delaunay.SetInput(inputPolyData)
delaunay.Update()
elevationFilter = vtk.vtkElevationFilter()
elevationFilter.SetInputConnection(delaunay.GetOutputPort())
elevationFilter.SetLowPoint(0, 0, bounds[4])
elevationFilter.SetHighPoint(0, 0, bounds[5])
elevationFilter.Update()
output = vtk.vtkPolyData()
output.ShallowCopy(vtk.vtkPolyData.SafeDownCast(elevationFilter.GetOutput()))
elevation = vtk.vtkFloatArray.SafeDownCast(output.GetPointData().GetArray("Elevation"))
# Create the color map
colorLookupTable = vtk.vtkLookupTable()
colorLookupTable.SetTableRange(bounds[4], bounds[5])
colorLookupTable.Build()
# Generate the colors for each point based on the color map
colors = vtk.vtkUnsignedCharArray()
colors.SetNumberOfComponents(3)
colors.SetName("Colors")
for i in range(output.GetNumberOfPoints()):
val = elevation.GetValue(i)
dcolor = [1.0] * 3
colorLookupTable.GetColor(val, dcolor)
color = [1] * 3
for j in range(3):
color[j] = 255 * dcolor[j]
colors.InsertNextTupleValue(color)
output.GetPointData().AddArray(colors)
# Create a mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(output.GetProducerPort())
# Create an actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
self.ren.AddActor(actor)
self.ren.ResetCamera()
self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:77,代码来源:elevationfilter.py
示例13: test
def test(self):
'''
Create a cone, contour it using the banded contour filter and
color it with the primary additive and subtractive colors.
'''
namedColors = vtk.vtkNamedColors()
# Test printing of the object
# Uncomment if desired
#print namedColors
# How to get a list of colors
colors = namedColors.GetColorNames()
colors = colors.split('\n')
# Uncomment if desired
#print 'Number of colors:', len(colors)
#print colors
# How to get a list of a list of synonyms.
syn = namedColors.GetSynonyms()
syn = syn.split('\n\n')
synonyms = []
for ele in syn:
synonyms.append(ele.split('\n'))
# Uncomment if desired
#print 'Number of synonyms:', len(synonyms)
#print synonyms
# Create a cone
coneSource = vtk.vtkConeSource()
coneSource.SetCenter(0.0, 0.0, 0.0)
coneSource.SetRadius(5.0)
coneSource.SetHeight(10)
coneSource.SetDirection(0,1,0)
coneSource.Update();
bounds = [1.0,-1.0,1.0,-1.0,1.0,-1.0]
coneSource.GetOutput().GetBounds(bounds)
elevation = vtk.vtkElevationFilter()
elevation.SetInputConnection(coneSource.GetOutputPort());
elevation.SetLowPoint(0,bounds[2],0);
elevation.SetHighPoint(0,bounds[3],0);
bcf = vtk.vtkBandedPolyDataContourFilter()
bcf.SetInputConnection(elevation.GetOutputPort());
bcf.SetScalarModeToValue();
bcf.GenerateContourEdgesOn();
bcf.GenerateValues(7,elevation.GetScalarRange());
# Build a simple lookup table of
# primary additive and subtractive colors.
lut = vtk.vtkLookupTable()
lut.SetNumberOfTableValues(7);
rgba = [0.0,0.0,0.0,1.0]
# Test setting and getting a color here.
namedColors.GetColor("Red",rgba);
namedColors.SetColor("My Red",rgba)
namedColors.GetColor("My Red",rgba);
lut.SetTableValue(0,rgba);
namedColors.GetColor("DarkGreen",rgba);
lut.SetTableValue(1,rgba);
namedColors.GetColor("Blue",rgba);
lut.SetTableValue(2,rgba);
namedColors.GetColor("Cyan",rgba);
lut.SetTableValue(3,rgba);
namedColors.GetColor("Magenta",rgba);
lut.SetTableValue(4,rgba);
namedColors.GetColor("Yellow",rgba);
lut.SetTableValue(5,rgba);
namedColors.GetColor("White",rgba);
lut.SetTableValue(6,rgba);
lut.SetTableRange(elevation.GetScalarRange());
lut.Build();
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(bcf.GetOutputPort());
mapper.SetLookupTable(lut);
mapper.SetScalarModeToUseCellData();
contourLineMapper = vtk.vtkPolyDataMapper()
contourLineMapper.SetInputData(bcf.GetContourEdgesOutput());
contourLineMapper.SetScalarRange(elevation.GetScalarRange());
contourLineMapper.SetResolveCoincidentTopologyToPolygonOffset();
actor = vtk.vtkActor()
actor.SetMapper(mapper);
contourLineActor = vtk.vtkActor()
contourLineActor.SetMapper(contourLineMapper);
rgb = [0.0,0.0,0.0]
namedColors.GetColorRGB("black",rgb)
contourLineActor.GetProperty().SetColor(rgb);
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer);
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renderWindow);
renderer.AddActor(actor);
#.........这里部分代码省略.........
开发者ID:0004c,项目名称:VTK,代码行数:101,代码来源:TestNamedColorsIntegration.py
示例14:
import vtk, os, sys
from vtk.test import Testing
ss = vtk.vtkSphereSource() #make mesh to test with
af = vtk.vtkElevationFilter() #add some attributes
af.SetInputConnection(ss.GetOutputPort())
ef = vtk.vtkExtractEdges() #make lines to test
ef.SetInputConnection(af.GetOutputPort())
gf = vtk.vtkGlyph3D() #make verts to test
pts = vtk.vtkPoints()
pts.InsertNextPoint(0,0,0)
verts = vtk.vtkCellArray()
avert = vtk.vtkVertex()
avert.GetPointIds().SetId(0, 0)
verts.InsertNextCell(avert)
onevertglyph = vtk.vtkPolyData()
onevertglyph.SetPoints(pts)
onevertglyph.SetVerts(verts)
gf.SetSourceData(onevertglyph)
gf.SetInputConnection(af.GetOutputPort())
testwrites = ["points","lines","mesh"]
failed = False
for datasetString in testwrites:
if datasetString == "points":
toshow=gf
elif datasetString == "lines":
toshow = ef
开发者ID:timkrentz,项目名称:SunTracker,代码行数:31,代码来源:TestGeoJSONWriter.py
示例15:
except ImportError:
print "Numpy (http://numpy.scipy.org) not found.",
print "This test requires numpy!"
sys.exit(0)
import vtk
import vtk.numpy_interface.dataset_adapter as dsa
import vtk.numpy_interface.algorithms as algs
w = vtk.vtkRTAnalyticSource()
bp = vtk.vtkBrownianPoints()
bp.SetInputConnection(w.GetOutputPort())
bp.Update()
elev = vtk.vtkElevationFilter()
elev.SetInputConnection(bp.GetOutputPort())
elev.SetLowPoint(-10, 0, 0)
elev.SetHighPoint(10, 0, 0)
elev.SetScalarRange(0, 20)
g = vtk.vtkMultiBlockDataGroupFilter()
g.AddInputConnection(elev.GetOutputPort())
g.AddInputConnection(elev.GetOutputPort())
g.Update()
elev2 = vtk.vtkElevationFilter()
elev2.SetInputConnection(bp.GetOutputPort())
elev2.SetLowPoint(0, -10, 0)
elev2.SetHighPoint(0, 10, 0)
开发者ID:0004c,项目名称:VTK,代码行数:31,代码来源:TestNumpyInterface.py
示例16: main
def main():
input = vtk.vtkPolyData()
#double bounds[6]
argc = 1
if(argc == 1):
# Create a sphere to warp
sphere = vtk.vtkSphereSource()
sphere.SetThetaResolution(51)
sphere.SetPhiResolution(17)
sphere.Update()
bounds = sphere.GetOutput().GetBounds()
# Generate some scalars on the polydata
ele = vtk.vtkElevationFilter()
ele.SetInputConnection(sphere.GetOutputPort())
ele.SetLowPoint(0,0,-0.5)
ele.SetHighPoint(0,0,0.5)
ele.SetLowPoint((bounds[1] + bounds[0]) / 2.0,
(bounds[3] + bounds[2]) / 2.0,
-bounds[5])
ele.SetHighPoint((bounds[1] + bounds[0]) / 2.0,
(bounds[3] + bounds[2]) / 2.0,
bounds[5])
ele.Update()
input.ShallowCopy(ele.GetOutput())
else:
inputFilename = argv[1]
reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName(inputFilename)
reader.Update()
input.ShallowCopy(reader.GetOutput())
bounds = input.GetBounds()
# Now create a control mesh, in this case a octagon that encloses
# the point set
pts = vtk.vtkPoints()
pts.SetNumberOfPoints(6)
pts.SetPoint(0,
bounds[0] - .1 * (bounds[1] - bounds[0]),
(bounds[3] + bounds[2]) / 2.0,
(bounds[5] + bounds[4]) / 2.0)
pts.SetPoint(1,
bounds[1] + .1 * (bounds[1] - bounds[0]),
(bounds[3] + bounds[2]) / 2.0,
(bounds[5] + bounds[4]) / 2.0)
pts.SetPoint(2,
(bounds[1] + bounds[0]) / 2.0,
bounds[2] - .1 * (bounds[3] - bounds[2]),
(bounds[5] + bounds[4]) / 2.0)
pts.SetPoint(3,
(bounds[1] + bounds[0]) / 2.0,
bounds[3] + .1 * (bounds[3] - bounds[2]),
(bounds[5] + bounds[4]) / 2.0)
pts.SetPoint(4,
(bounds[1] + bounds[0]) / 2.0,
(bounds[3] + bounds[2]) / 2.0,
bounds[4] - .1 * (bounds[5] - bounds[4]))
pts.SetPoint(5,
(bounds[1] + bounds[0]) / 2.0,
(bounds[3] + bounds[2]) / 2.0,
bounds[5] + .1 * (bounds[5] - bounds[4]))
tris = vtk.vtkCellArray()
tris.InsertNextCell(3)
tris.InsertCellPoint(2)
tris.InsertCellPoint(0)
tris.InsertCellPoint(4)
tris.InsertNextCell(3)
tris.InsertCellPoint(1)
tris.InsertCellPoint(2)
tris.InsertCellPoint(4)
tris.InsertNextCell(3)
tris.InsertCellPoint(3)
tris.InsertCellPoint(1)
tris.InsertCellPoint(4)
tris.InsertNextCell(3)
tris.InsertCellPoint(0)
tris.InsertCellPoint(3)
tris.InsertCellPoint(4)
tris.InsertNextCell(3)
tris.InsertCellPoint(0)
tris.InsertCellPoint(2)
tris.InsertCellPoint(5)
tris.InsertNextCell(3)
tris.InsertCellPoint(2)
tris.InsertCellPoint(1)
tris.InsertCellPoint(5)
#.........这里部分代码省略.........
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:101,代码来源:deform_point_set.py
示例17: vtkGetDataRoot
#!/usr/bin/env python
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
#
# Test butterfly subdivision of point data
#
sphere = vtk.vtkSphereSource()
sphere.SetPhiResolution(11)
sphere.SetThetaResolution(11)
colorIt = vtk.vtkElevationFilter()
colorIt.SetInputConnection(sphere.GetOutputPort())
colorIt.SetLowPoint(0,0,-.5)
colorIt.SetHighPoint(0,0,.5)
butterfly = vtk.vtkButterflySubdivisionFilter()
butterfly.SetInputConnection(colorIt.GetOutputPort())
butterfly.SetNumberOfSubdivisions(3)
lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(256)
lut.Build()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(butterfly.GetOutputPort())
mapper.SetLookupTable(lut)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
linear = vtk.vtkLinearSubdivisionFilter()
linear.SetInputConnection(colorIt.GetOutputPort())
linear.SetNumberOfSubdivisions(3)
mapper2 = vtk.vtkPolyDataMapper()
mapper2.SetInputConnection(linear.GetOutputPort())
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:31,代码来源:subdividePointData.py
示例18: locals
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())
locals()[get_variable_name("normals", lod, "")].SetFeatureAngle(60)
locals()[get_variable_name("normals", lod, "")].ConsistencyOff()
locals()[get_variable_name("normals", lod, "")].SplittingOff()
locals()[get_variable_name("normals", lod, "")].ReleaseDataFlagOn()
locals()[get_variable_name("demMapper", lod, "")] = vtk.vtkPolyDataMapper()
locals()[get_variable_name("demMapper", lod, "")].SetInputConnection(locals()[get_variable_name("normals", lod, "")].GetOutputPort())
开发者ID:151706061,项目名称:VTK,代码行数:31,代码来源:dem.py
示例19: testSphereWidget
#.........这里部分代码省略.........
# 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()
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
renWin.AddRenderer(ren)
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin)
iRen.LightFollowCameraOff()
# iRen.SetInteractorStyle("")
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:67,代码来源:TestSphereWidget.py
示例20: DisplayCone
def DisplayCone(self):
'''
Create a cone, contour it using the banded contour filter and
color it with the primary additive and subtractive colors.
'''
#print namedColors
# Create a cone
coneSource = vtk.vtkConeSource()
coneSource.SetCenter(0.0, 0.0, 0.0)
coneSource.SetRadius(5.0)
coneSource.SetHeight(10)
coneSource.SetDirection(0,1,0)
coneSource.Update()
bounds = [1.0,-1.0,1.0,-1.0,1.0,-1.0]
coneSource.GetOutput().GetBounds(bounds)
elevation = vtk.vtkElevationFilter()
elevation.SetInputConnection(coneSource.GetOutputPort())
elevation.SetLowPoint(0,bounds[2],0)
elevation.SetHighPoint(0,bounds[3],0)
bcf = vtk.vtkBandedPolyDataContourFilter()
bcf.SetInputConnection(elevation.GetOutputPort())
bcf.SetScalarModeToValue()
bcf.GenerateContourEdgesOn()
bcf.GenerateValues(7,elevation.GetScalarRange())
# Build a simple lookup table of
# primary additive and subtractive colors.
lut = vtk.vtkLookupTable()
lut.SetNumberOfTableValues(7)
# Test setting and getting a color here.
# We are also modifying alpha.
rgba = self.GetRGBAColor("Red")
rgba[3] = 0.5
self.namedColors.SetColor("My Red",rgba)
rgba = self.GetRGBAColor("My Red")
lut.SetTableValue(0,rgba)
# Does "My Red" match anything?
match = self.FindSynonyms("My Red")
print "Matching colors to My Red:", match
rgba = self.GetRGBAColor("DarkGreen")
rgba[3] = 0.3
lut.SetTableValue(1,rgba)
# Alternatively we can use our wrapper functions:
lut.SetTableValue(2,self.GetRGBAColor("Blue"))
lut.SetTableValue(3,self.GetRGBAColor("Cyan"))
lut.SetTableValue(4,self.GetRGBAColor("Magenta"))
lut.SetTableValue(5,self.GetRGBAColor("Yellow"))
lut.SetTableValue(6,self.GetRGBAColor("White"))
lut.SetTableRange(elevation.GetScalarRange())
lut.Build()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(bcf.GetOutputPort())
mapper.SetLookupTable(lut)
mapper.SetScalarModeToUseCellData()
contourLineMapper = vtk.vtkPolyDataMapper()
contourLineMapper.SetInputData(bcf.GetContourEdgesOutput())
contourLineMapper.SetScalarRange(elevation.GetScalarRange())
contourLineMapper.SetResolveCoincidentTopologyToPolygonOffset()
actor = vtk.vtkActor()
actor.SetMapper(mapper)
contourLineActor = vtk.vtkActor()
actor.SetMapper(mapper)
contourLineActor.SetMapper(contourLineMapper)
contourLineActor.GetProperty().SetColor(
self.GetRGBColor("black"))
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(actor)
renderer.AddActor(contourLineActor)
renderer.SetBackground(
self.GetRGBColor("SteelBlue"))
renderWindow.Render()
fnsave = "TestNamedColorsIntegration.png"
renLgeIm = vtk.vtkRenderLargeImage()
imgWriter = vtk.vtkPNGWriter()
renLgeIm.SetInput(renderer)
renLgeIm.SetMagnification(1)
imgWriter.SetInputConnection(renLgeIm.GetOutputPort())
imgWriter.SetFileName(fnsave)
imgWriter.Write()
renderWindowInteractor.Start()
开发者ID:zhangzhx,项目名称:VISP,代码行数:98,代码来源:NamedColors.py
注:本文中的vtk.vtkElevationFilter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论