当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkMultiBlockPLOT3DReader函数代码示例

本文整理汇总了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)
开发者ID:XiaoxiaoLiu,项目名称:VTK,代码行数:29,代码来源:Plot3D.py

示例2: __init__

 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkMultiBlockPLOT3DReader(), 'Reading vtkMultiBlockPLOT3D.',
         (), ('vtkMultiBlockPLOT3D',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkMultiBlockPLOT3DReader.py

示例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
开发者ID:reshama,项目名称:PyDataNYC2015,代码行数:44,代码来源:sample_grid_model.py

示例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()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:31,代码来源:SubsampleGrid.py

示例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
开发者ID:diego0020,项目名称:tutorial-vtk-pyqt,代码行数:92,代码来源:02_embed_in_qt.py

示例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)
开发者ID:inviCRO,项目名称:VTK,代码行数:31,代码来源:TestMultiBlockStreamer.py

示例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
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:92,代码来源:TestGridSynchronizedTemplates3D.py

示例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")
开发者ID:ALouis38,项目名称:VTK,代码行数:31,代码来源:fieldToSGrid.py

示例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
开发者ID:timkrentz,项目名称:SunTracker,代码行数:31,代码来源:MultidimensionalSolution.py

示例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()
开发者ID:151706061,项目名称:VTK,代码行数:31,代码来源:Plot3DVectors.py


注:本文中的vtk.vtkMultiBlockPLOT3DReader函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。