本文整理汇总了Python中vtk.vtkMultiBlockPLOT3DReader函数的典型用法代码示例。如果您正苦于以下问题:Python vtkMultiBlockPLOT3DReader函数的具体用法?Python vtkMultiBlockPLOT3DReader怎么用?Python vtkMultiBlockPLOT3DReader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkMultiBlockPLOT3DReader函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testReader3D
def testReader3D(self):
names = [("multi-ascii.xyz", "multi-ascii.q"), ("multi-bin-C.xyz", "multi-bin-C.q"), ("multi-bin.xyz", "multi-bin.q"), ("multi-bin.xyz", "multi-bin-oflow.q")]
for name in names:
r = vtk.vtkMultiBlockPLOT3DReader()
print "Testing ", name[0]
if name[0] == "multi-ascii.xyz":
r.BinaryFileOff()
r.MultiGridOn()
else:
r.AutoDetectFormatOn()
r.SetFileName(str(VTK_DATA_ROOT) + "/Data/" + name[0])
r.SetQFileName(str(VTK_DATA_ROOT) + "/Data/" + name[1])
r.Update()
output = r.GetOutput()
self.assertEqual(output.GetNumberOfBlocks(), 2)
b0 = output.GetBlock(0)
self.assertEqual(int(b0.GetFieldData().GetArray("Properties").GetValue(0)), 2)
pd = b0.GetPointData()
self.assertEqual(int(pd.GetArray("Momentum").GetComponent(10, 2)), 0)
self.assertEqual(int(pd.GetArray("StagnationEnergy").GetValue(3)), 9)
b1 = output.GetBlock(1)
self.assertEqual(int(b1.GetFieldData().GetArray("Properties").GetValue(0)), 2)
pd = b1.GetPointData()
self.assertEqual(int(pd.GetArray("Momentum").GetComponent(10, 2)), 0)
self.assertEqual(int(pd.GetArray("StagnationEnergy").GetValue(3)), 3)
示例2: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkMultiBlockPLOT3DReader(), 'Reading vtkMultiBlockPLOT3D.',
(), ('vtkMultiBlockPLOT3D',),
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: vtkGetDataRoot
#!/usr/bin/env python
# This example demonstrates the subsampling of a structured grid.
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# 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(30, 30, -1000, 1000, -1000, 1000)
extract.SetSampleRate(1, 2, 3)
extract.IncludeBoundaryOn()
示例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: vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# we need to use composite data pipeline with multiblock datasets
alg = vtk.vtkAlgorithm()
pip = vtk.vtkCompositeDataPipeline()
alg.SetDefaultExecutivePrototype(pip)
#del pip
Ren1 = vtk.vtkRenderer()
Ren1.SetBackground(0.33, 0.35, 0.43)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(Ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
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)
示例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: open
vtk.vtkNamedColors().GetColorRGB(colorName, rgb)
return rgb
# Demonstrate the generation of a structured grid from field data. The output
# should be similar to combIso.tcl.
#
# NOTE: This test only works if the current directory is writable
#
try:
channel = open("combsg.vtk", "wb")
channel.close()
channel = open("SGridField.vtk", "wb")
channel.close()
# Create a reader and write out the field
comb = vtk.vtkMultiBlockPLOT3DReader()
comb.SetXYZFileName(VTK_DATA_ROOT + "/Data/combxyz.bin")
comb.SetQFileName(VTK_DATA_ROOT + "/Data/combq.bin")
comb.SetScalarFunctionNumber(100)
comb.Update()
output = comb.GetOutput().GetBlock(0)
wsg = vtk.vtkStructuredGridWriter()
wsg.SetInputData(output)
wsg.SetFileTypeToBinary()
wsg.SetFileName("combsg.vtk")
wsg.Write()
pl3d = vtk.vtkStructuredGridReader()
pl3d.SetFileName("combsg.vtk")
示例9: str
#
# You will most likely use vtkFieldDataToAttributeDataFilter, vtkHedgeHog,
# and vtkProgrammableAttributeDataFilter.
#
# Create the RenderWindow, Renderer and interactor
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# create pipeline
#
# get the pressure gradient vector field
pl3d_gradient = vtk.vtkMultiBlockPLOT3DReader()
pl3d_gradient.SetXYZFileName("" + str(VTK_DATA_ROOT) + "/Data/combxyz.bin")
pl3d_gradient.SetQFileName("" + str(VTK_DATA_ROOT) + "/Data/combq.bin")
pl3d_gradient.SetScalarFunctionNumber(100)
pl3d_gradient.SetVectorFunctionNumber(210)
pl3d_gradient.Update()
pl3d_g_output = pl3d_gradient.GetOutput().GetBlock(0)
# get the velocity vector field
pl3d_velocity = vtk.vtkMultiBlockPLOT3DReader()
pl3d_velocity.SetXYZFileName("" + str(VTK_DATA_ROOT) + "/Data/combxyz.bin")
pl3d_velocity.SetQFileName("" + str(VTK_DATA_ROOT) + "/Data/combq.bin")
pl3d_velocity.SetScalarFunctionNumber(100)
pl3d_velocity.SetVectorFunctionNumber(200)
pl3d_velocity.Update()
pl3d_v_output = pl3d_velocity.GetOutput().GetBlock(0)
# contour the scalar fields
示例10: locals
ren1.SetBackground(.8,.8,.2)
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
vectorLabels = "Velocity Vorticity Momentum Pressure_Gradient"
vectorFunctions = "200 201 202 210"
camera = vtk.vtkCamera()
light = vtk.vtkLight()
# All text actors will share the same text prop
textProp = vtk.vtkTextProperty()
textProp.SetFontSize(10)
textProp.SetFontFamilyToArial()
textProp.SetColor(.3,1,1)
i = 0
for vectorFunction in vectorFunctions.split():
locals()[get_variable_name("pl3d", vectorFunction, "")] = vtk.vtkMultiBlockPLOT3DReader()
locals()[get_variable_name("pl3d", vectorFunction, "")].SetXYZFileName("" + str(VTK_DATA_ROOT) + "/Data/bluntfinxyz.bin")
locals()[get_variable_name("pl3d", vectorFunction, "")].SetQFileName("" + str(VTK_DATA_ROOT) + "/Data/bluntfinq.bin")
locals()[get_variable_name("pl3d", vectorFunction, "")].SetVectorFunctionNumber(expr.expr(globals(), locals(),["int","(","vectorFunction",")"]))
locals()[get_variable_name("pl3d", vectorFunction, "")].Update()
output = locals()[get_variable_name("pl3d", vectorFunction, "")].GetOutput().GetBlock(0)
locals()[get_variable_name("plane", vectorFunction, "")] = vtk.vtkStructuredGridGeometryFilter()
locals()[get_variable_name("plane", vectorFunction, "")].SetInputData(output)
locals()[get_variable_name("plane", vectorFunction, "")].SetExtent(25,25,0,100,0,100)
locals()[get_variable_name("hog", vectorFunction, "")] = vtk.vtkHedgeHog()
locals()[get_variable_name("hog", vectorFunction, "")].SetInputConnection(locals()[get_variable_name("plane", vectorFunction, "")].GetOutputPort())
maxnorm = output.GetPointData().GetVectors().GetMaxNorm()
locals()[get_variable_name("hog", vectorFunction, "")].SetScaleFactor(expr.expr(globals(), locals(),["1.0","/","maxnorm"]))
locals()[get_variable_name("mapper", vectorFunction, "")] = vtk.vtkPolyDataMapper()
locals()[get_variable_name("mapper", vectorFunction, "")].SetInputConnection(locals()[get_variable_name("hog", vectorFunction, "")].GetOutputPort())
locals()[get_variable_name("actor", vectorFunction, "")] = vtk.vtkActor()