本文整理汇总了Python中vtk.vtkStructuredGridOutlineFilter函数的典型用法代码示例。如果您正苦于以下问题:Python vtkStructuredGridOutlineFilter函数的具体用法?Python vtkStructuredGridOutlineFilter怎么用?Python vtkStructuredGridOutlineFilter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkStructuredGridOutlineFilter函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__ (self, mod_m):
debug ("In StructuredGridOutline::__init__ ()")
Common.state.busy ()
Base.Objects.Module.__init__ (self, mod_m)
self.act = None
data_src = self.mod_m.get_data_source ()
self.type = data_src.get_grid_type ()
if self.type != "STRUCTURED_GRID":
msg = "This module does not support the %s dataset."%(self.type)
msg = msg + "\nOnly STRUCTURED_GRID data is supported by "\
"this module."
raise Base.Objects.ModuleException, msg
self.outline = vtk.vtkStructuredGridOutlineFilter ()
self.outline.SetInput (mod_m.GetOutput ())
self.mapper = self.map = vtk.vtkPolyDataMapper ()
self.map.SetInput (self.outline.GetOutput ())
self.map.SetScalarVisibility (0)
self.actor = self.act = vtk.vtkActor ()
self.act.SetMapper (self.map)
self.act.GetProperty ().SetColor (*Common.config.fg_color)
self.renwin.add_actors (self.act)
# used for the pipeline browser
self.pipe_objs = self.act
self.renwin.Render ()
Common.state.idle ()
示例2: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self,
module_manager,
vtk.vtkStructuredGridOutlineFilter(),
"Processing.",
("vtkStructuredGrid",),
("vtkPolyData",),
replaceDoc=True,
inputFunctions=None,
outputFunctions=None,
)
示例3: make_models
def make_models(self):
"""
make models
"""
# Read some structured data.
pl3d = vtk.vtkMultiBlockPLOT3DReader()
pl3d.SetXYZFileName(VTK_DATA_ROOT + "/Data/combxyz.bin")
pl3d.SetQFileName(VTK_DATA_ROOT + "/Data/combq.bin")
pl3d.SetScalarFunctionNumber(100)
pl3d.SetVectorFunctionNumber(202)
pl3d.Update()
pl3d_output = pl3d.GetOutput().GetBlock(0)
# Here we subsample the grid. The SetVOI method requires six values
# specifying (imin,imax, jmin,jmax, kmin,kmax) extents. In this
# example we extracting a plane. Note that the VOI is clamped to zero
# (min) and the maximum i-j-k value; that way we can use the
# -1000,1000 specification and be sure the values are clamped. The
# SampleRate specifies that we take every point in the i-direction;
# every other point in the j-direction; and every third point in the
# k-direction. IncludeBoundaryOn makes sure that we get the boundary
# points even if the SampleRate does not coincident with the boundary.
extract = vtk.vtkExtractGrid()
extract.SetInputData(pl3d_output)
extract.SetVOI(self.slice_factor, self.slice_factor, -1000, 1000, -1000, 1000)
extract.SetSampleRate(1, 2, 3)
extract.IncludeBoundaryOn()
mapper = vtk.vtkDataSetMapper()
mapper.SetInputConnection(extract.GetOutputPort())
mapper.SetScalarRange(.18, .7)
self.surface_actor = vtk.vtkActor()
self.surface_actor.SetMapper(mapper)
outline = vtk.vtkStructuredGridOutlineFilter()
outline.SetInputData(pl3d_output)
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
self.outline_actor = vtk.vtkActor()
self.outline_actor.SetMapper(outlineMapper)
self.outline_actor.GetProperty().SetColor(0, 0, 0)
self.extract_model = extract
示例4:
# SampleRate specifies that we take every point in the i-direction;
# every other point in the j-direction; and every third point in the
# k-direction. IncludeBoundaryOn makes sure that we get the boundary
# points even if the SampleRate does not coincident with the boundary.
extract = vtk.vtkExtractGrid()
extract.SetInputData(pl3d_output)
extract.SetVOI(30, 30, -1000, 1000, -1000, 1000)
extract.SetSampleRate(1, 2, 3)
extract.IncludeBoundaryOn()
mapper = vtk.vtkDataSetMapper()
mapper.SetInputConnection(extract.GetOutputPort())
mapper.SetScalarRange(.18, .7)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
outline = vtk.vtkStructuredGridOutlineFilter()
outline.SetInputData(pl3d_output)
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
outlineActor.GetProperty().SetColor(0, 0, 0)
# Add the usual rendering stuff.
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
示例5: __init__
def __init__(self, parent, data_dir):
super(QGlyphViewer,self).__init__(parent)
# Make tha actual QtWidget a child so that it can be re parented
interactor = QVTKRenderWindowInteractor(self)
self.layout = QtGui.QHBoxLayout()
self.layout.addWidget(interactor)
self.layout.setContentsMargins(0,0,0,0)
self.setLayout(self.layout)
# Read the data
xyx_file = os.path.join(data_dir, "combxyz.bin")
q_file = os.path.join(data_dir, "combq.bin")
pl3d = vtk.vtkMultiBlockPLOT3DReader()
pl3d.SetXYZFileName(xyx_file)
pl3d.SetQFileName(q_file)
pl3d.SetScalarFunctionNumber(100)
pl3d.SetVectorFunctionNumber(202)
pl3d.Update()
blocks = pl3d.GetOutput()
b0 = blocks.GetBlock(0)
# Setup VTK environment
renderer = vtk.vtkRenderer()
render_window = interactor.GetRenderWindow()
render_window.AddRenderer(renderer)
interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
render_window.SetInteractor(interactor)
renderer.SetBackground(0.2,0.2,0.2)
# Draw Outline
outline = vtk.vtkStructuredGridOutlineFilter()
outline.SetInputData(b0)
outline_mapper = vtk.vtkPolyDataMapper()
outline_mapper.SetInputConnection(outline.GetOutputPort())
outline_actor = vtk.vtkActor()
outline_actor.SetMapper(outline_mapper)
outline_actor.GetProperty().SetColor(1,1,1)
renderer.AddActor(outline_actor)
renderer.ResetCamera()
# Draw Outline
outline = vtk.vtkStructuredGridOutlineFilter()
outline.SetInputData(b0)
outline_mapper = vtk.vtkPolyDataMapper()
outline_mapper.SetInputConnection(outline.GetOutputPort())
outline_actor = vtk.vtkActor()
outline_actor.SetMapper(outline_mapper)
outline_actor.GetProperty().SetColor(1,1,1)
renderer.AddActor(outline_actor)
renderer.ResetCamera()
# Threshold points
threshold = vtk.vtkThresholdPoints()
threshold.SetInputData(b0)
threshold.ThresholdByUpper(0.5)
# Draw arrows
arrow = vtk.vtkArrowSource()
glyphs = vtk.vtkGlyph3D()
glyphs.SetInputData(b0)
glyphs.SetSourceConnection(arrow.GetOutputPort())
glyphs.SetInputConnection(threshold.GetOutputPort())
glyphs.SetVectorModeToUseVector()
glyphs.SetScaleModeToScaleByVector()
glyphs.SetScaleFactor(0.005)
glyphs.SetColorModeToColorByVector()
# Mapper
glyph_mapper = vtk.vtkPolyDataMapper()
glyph_mapper.SetInputConnection(glyphs.GetOutputPort())
glyph_actor = vtk.vtkActor()
glyph_actor.SetMapper(glyph_mapper)
glyph_mapper.UseLookupTableScalarRangeOn()
renderer.AddActor(glyph_actor)
# Set color lookuptable
glyphs.Update()
s0,sf = glyphs.GetOutput().GetScalarRange()
lut = vtk.vtkColorTransferFunction()
lut.AddRGBPoint(s0, 1,0,0)
lut.AddRGBPoint(sf, 0,1,0)
glyph_mapper.SetLookupTable(lut)
self.b0 = b0
self.renderer = renderer
self.interactor = interactor
self.threshold = threshold
示例6:
Plot3D0 = vtk.vtkMultiBlockPLOT3DReader()
Plot3D0.SetFileName(VTK_DATA_ROOT + "/Data/combxyz.bin")
Plot3D0.SetQFileName(VTK_DATA_ROOT + "/Data/combq.bin")
Plot3D0.SetBinaryFile(1)
Plot3D0.SetMultiGrid(0)
Plot3D0.SetHasByteCount(0)
Plot3D0.SetIBlanking(0)
Plot3D0.SetTwoDimensionalGeometry(0)
Plot3D0.SetForceRead(0)
Plot3D0.SetByteOrder(0)
Plot3D0.Update()
output = Plot3D0.GetOutput().GetBlock(0)
Geometry5 = vtk.vtkStructuredGridOutlineFilter()
Geometry5.SetInputData(output)
Mapper5 = vtk.vtkPolyDataMapper()
Mapper5.SetInputConnection(Geometry5.GetOutputPort())
Mapper5.SetImmediateModeRendering(1)
Mapper5.UseLookupTableScalarRangeOn()
Mapper5.SetScalarVisibility(0)
Mapper5.SetScalarModeToDefault()
Actor5 = vtk.vtkActor()
Actor5.SetMapper(Mapper5)
Actor5.GetProperty().SetRepresentationToSurface()
Actor5.GetProperty().SetInterpolationToGouraud()
Actor5.GetProperty().SetAmbient(0.15)
Actor5.GetProperty().SetDiffuse(0.85)
示例7: testAll
def testAll(self):
# cut data
pl3d = vtk.vtkMultiBlockPLOT3DReader()
pl3d.SetXYZFileName(VTK_DATA_ROOT + "/Data/combxyz.bin")
pl3d.SetQFileName(VTK_DATA_ROOT + "/Data/combq.bin")
pl3d.SetScalarFunctionNumber(100)
pl3d.SetVectorFunctionNumber(202)
pl3d.Update()
pl3d_output = pl3d.GetOutput().GetBlock(0)
range = pl3d_output.GetPointData().GetScalars().GetRange()
min = range[0]
max = range[1]
value = (min + max) / 2.0
# cf = vtk.vtkGridSynchronizedTemplates3D()
cf = vtk.vtkContourFilter()
cf.SetInputData(pl3d_output)
cf.SetValue(0, value)
cf.GenerateTrianglesOff()
cf.Update()
self.failUnlessEqual(
cf.GetOutputDataObject(0).GetNumberOfPoints(), 4674)
self.failUnlessEqual(
cf.GetOutputDataObject(0).GetNumberOfCells(), 4012)
cf.GenerateTrianglesOn()
cf.Update()
self.failUnlessEqual(
cf.GetOutputDataObject(0).GetNumberOfPoints(), 4674)
self.failUnlessEqual(
cf.GetOutputDataObject(0).GetNumberOfCells(), 8076)
# cf ComputeNormalsOff
cfMapper = vtk.vtkPolyDataMapper()
cfMapper.SetInputConnection(cf.GetOutputPort())
cfMapper.SetScalarRange(
pl3d_output.GetPointData().GetScalars().GetRange())
cfActor = vtk.vtkActor()
cfActor.SetMapper(cfMapper)
# outline
outline = vtk.vtkStructuredGridOutlineFilter()
outline.SetInputData(pl3d_output)
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
outlineActor.GetProperty().SetColor(0, 0, 0)
# # Graphics stuff
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(outlineActor)
ren1.AddActor(cfActor)
ren1.SetBackground(1, 1, 1)
renWin.SetSize(400, 400)
cam1 = ren1.GetActiveCamera()
cam1.SetClippingRange(3.95297, 50)
cam1.SetFocalPoint(9.71821, 0.458166, 29.3999)
cam1.SetPosition(2.7439, -37.3196, 38.7167)
cam1.SetViewUp(-0.16123, 0.264271, 0.950876)
iren.Initialize()
# render the image
#
# loop over surfaces
i = 0
while i < 17:
cf.SetValue(0, min + (i / 16.0) * (max - min))
renWin.Render()
cf.SetValue(0, min + (0.2) * (max - min))
renWin.Render()
i += 1
示例8: InitVTKMethods
def InitVTKMethods(self):
"""Initializes the VTK methods to be used"""
self._outline=vtkStructuredGridOutlineFilter()
self._tube=vtkTubeFilter()
self._mapper_=vtkPolyDataMapper()
self.actor=vtkLODActor()
示例9: print
# Time execution
timer = vtk.vtkTimerLog()
timer.StartTimer()
interpolator.Update()
timer.StopTimer()
time = timer.GetElapsedTime()
print("Interpolate Points (Voronoi): {0}".format(time))
intMapper = vtk.vtkPolyDataMapper()
intMapper.SetInputConnection(interpolator.GetOutputPort())
intActor = vtk.vtkActor()
intActor.SetMapper(intMapper)
# Create an outline
outline = vtk.vtkStructuredGridOutlineFilter()
outline.SetInputData(output)
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
# Gaussian kernel-------------------------------------------------------
gaussianKernel = vtk.vtkGaussianKernel()
#gaussianKernel = vtk.vtkEllipsoidalGaussianKernel()
#gaussianKernel.UseScalarsOn()
#gaussianKernel.UseNormalsOn()
gaussianKernel.SetSharpness(4)
gaussianKernel.SetRadius(0.5)