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


Python vtk.vtkPlaneSource函数代码示例

本文整理汇总了Python中vtk.vtkPlaneSource函数的典型用法代码示例。如果您正苦于以下问题:Python vtkPlaneSource函数的具体用法?Python vtkPlaneSource怎么用?Python vtkPlaneSource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了vtkPlaneSource函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PlaneSphereActors

def PlaneSphereActors():
    ps = vtk.vtkPlaneSource()
    ps.SetXResolution(10)
    ps.SetYResolution(10)

    ss = vtk.vtkSphereSource()
    ss.SetRadius (0.3)

    group = vtk.vtkMultiBlockDataGroupFilter()
    group.AddInputConnection(ps.GetOutputPort())
    group.AddInputConnection(ss.GetOutputPort())

    ag = vtk.vtkRandomAttributeGenerator()
    ag.SetInputConnection(group.GetOutputPort())
    ag.GenerateCellScalarsOn()
    ag.AttributesConstantPerBlockOn()

    n = vtk.vtkPolyDataNormals()
    n.SetInputConnection(ag.GetOutputPort())
    n.Update ();

    actors = []
    it = n.GetOutputDataObject(0).NewIterator()
    it.InitTraversal()
    while not it.IsDoneWithTraversal():
        pm = vtk.vtkPolyDataMapper()
        pm.SetInputData(it.GetCurrentDataObject())

        a = vtk.vtkActor()
        a.SetMapper(pm)
        actors.append (a)
        it.GoToNextItem()
    return actors
开发者ID:timkrentz,项目名称:SunTracker,代码行数:33,代码来源:TestRandomAttributeGeneratorScalar.py

示例2: __init__

 def __init__( self ):
   PerkEvaluatorMetric.__init__( self )
   
   self.outputPolyData = vtk.vtkAppendPolyData()
   
   self.planeSource = vtk.vtkPlaneSource()
   self.planePolyData = self.planeSource.GetOutput()
开发者ID:PerkTutor,项目名称:PythonMetrics,代码行数:7,代码来源:ShowUltrasoundSweep.py

示例3: __init__

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

示例4: __init__

    def __init__(self, name, sliceDirections, defaultPlaneOrientation=2):
        self.sliceDirections = sliceDirections
        self._defaultPlaneOrientation = 2

        # orthoPipeline is a list of dictionaries.  each dictionary is:
        # {'planeSource' : vtkPlaneSource, 'planeActor' : vtkActor,
        #  'textureMapToPlane' : vtkTextureMapToPlane,
        #  '
        self._orthoPipeline = []
        # this is the frame that we will use to display our slice pipeline
        self._orthoViewFrame = None
        #
        self._renderer = None

        # list of vtkImagePlaneWidgets (first is "primary", rest are overlays)
        self._ipws = []

        # then some state variables
        self._enabled = True
        self._interactionEnabled = True

        # list of objects that want to be contoured by this slice
        self._contourObjectsDict = {}

        self.overlayMode = 'greenOpacityRange'
        self.fusionAlpha = 0.4

        # we'll use this to store the polydata of our primary slice
        self._primaryCopyPlaneSource = vtk.vtkPlaneSource()
        self._primaryCopyPlaneSource.SetXResolution(64)
        self._primaryCopyPlaneSource.SetYResolution(64)
        self.primaryPolyData = self._primaryCopyPlaneSource.GetOutput()
开发者ID:fvpolpeta,项目名称:devide,代码行数:32,代码来源:sliceDirection.py

示例5: __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()
 
        # Provide some geometry
        resolution = 8
        aPlane = vtk.vtkPlaneSource()
        aPlane.SetXResolution(resolution)
        aPlane.SetYResolution(resolution)

        # Create cell data
        cellData = vtk.vtkFloatArray()
        for i in range(resolution * resolution):
            cellData.InsertNextValue(i+1)

        # Create a lookup table to map cell data to colors
        lut = vtk.vtkLookupTable()
        tableSize = max(resolution*resolution+1, 10)
        lut.SetNumberOfTableValues(tableSize)
        lut.Build()

        # Fill in a few known colors, the rest will be generated if needed
        lut.SetTableValue(0     , 0     , 0     , 0, 1)# Black
        lut.SetTableValue(1, 0.8900, 0.8100, 0.3400, 1)# Banana
        lut.SetTableValue(2, 1.0000, 0.3882, 0.2784, 1)# Tomato
        lut.SetTableValue(3, 0.9608, 0.8706, 0.7020, 1)# Wheat
        lut.SetTableValue(4, 0.9020, 0.9020, 0.9804, 1)# Lavender
        lut.SetTableValue(5, 1.0000, 0.4900, 0.2500, 1)# Flesh
        lut.SetTableValue(6, 0.5300, 0.1500, 0.3400, 1)# Raspberry
        lut.SetTableValue(7, 0.9804, 0.5020, 0.4471, 1)# Salmon
        lut.SetTableValue(8, 0.7400, 0.9900, 0.7900, 1)# Mint
        lut.SetTableValue(9, 0.2000, 0.6300, 0.7900, 1)# Peacock

        aPlane.Update() #Force an update so we can set cell data
        aPlane.GetOutput().GetCellData().SetScalars(cellData)

        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(aPlane.GetOutputPort())
        mapper.SetScalarRange(0, tableSize - 1)
        mapper.SetLookupTable(lut)
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

        self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:59,代码来源:colorcells.py

示例6: initSeedPoint

 def initSeedPoint(self):
     print "initializing SeedPoint"
     self.vtkSeeds = vtk.vtkPlaneSource()
     self.vtkSeeds.SetXResolution(4)
     self.vtkSeeds.SetYResolution(4)
     self.vtkSeeds.SetOrigin(0.0, 0.0, 0.0)
     self.vtkSeeds.SetPoint1(-10.0, -10.0, -10.0)
     self.vtkSeeds.SetPoint2(10.0, 10.0, 10.0)
开发者ID:CreativeCodingLab,项目名称:DarkSkyVis,代码行数:8,代码来源:vtkDarkSkyFlow.py

示例7: coplanar

        def coplanar(self):
            numSelected = EventHandler().get_num_selected()
            if numSelected !=3:
                error_msg("You must first select exactly 3 markers",
                          )
                return

            # SetNormal is missing from the 4.2 python API so this is
            # a long winded way of setting the pw to intersect 3
            # selected markers
            m1, m2, m3 = EventHandler().get_selected()

            p1 = m1.get_center()
            p2 = m2.get_center()
            p3 = m3.get_center()
            
            pw = pwo.get_pw()
            planeO = vtk.vtkPlaneSource()
            planeO.SetOrigin(pw.GetOrigin())
            planeO.SetPoint1(pw.GetPoint1())
            planeO.SetPoint2(pw.GetPoint2())
            planeO.Update()

            planeN = vtk.vtkPlaneSource()
            planeN.SetOrigin(p1)
            planeN.SetPoint1(p2)
            planeN.SetPoint2(p3)
            planeN.Update()

            normal = planeN.GetNormal()
            planeO.SetNormal(normal)
            planeO.SetCenter(
                (p1[0] + p2[0] + p3[0])/3,
                (p1[1] + p2[1] + p3[1])/3,
                (p1[2] + p2[2] + p3[2])/3,
                )
            planeO.Update()

            pwxyz = pwo.get_pwxyz()
            pw.SetOrigin(planeO.GetOrigin())
            pw.SetPoint1(planeO.GetPoint1())
            pw.SetPoint2(planeO.GetPoint2())
            pw.UpdatePlacement()
            pwo.update_plane()
            pwo.Render()
            pwxyz.Render()
开发者ID:neurodebian,项目名称:PyLocator,代码行数:46,代码来源:plane_widgets_observer_toolbar.py

示例8: __init__

    def __init__(self, center=(0,0,0), color=(0,0,1) ):
        self.src = vtk.vtkPlaneSource()
        #self.src.SetCenter(center)
        self.mapper = vtk.vtkPolyDataMapper()
        self.mapper.SetInput(self.src.GetOutput())
        self.SetMapper(self.mapper)

        self.SetColor(color)
        self.SetOrigin(center)
开发者ID:aewallin,项目名称:randompolygon,代码行数:9,代码来源:ovdvtk.py

示例9: __init__

 def __init__(self):
     # ODE initialization
     self.world = ode.World()
     self.world.setGravity(GRAVITY)
     self.world.setERP(ERP)
     self.world.setCFM(CFM)
     self.space = ode.Space()
     self.floor = ode.GeomPlane(self.space, (0.0,1.0,0.0), 0.0)
     self.jointGroup = ode.JointGroup()
     self.time = 0.0
     # VTK initialization
     self.renderer = vtk.vtkRenderer()
     self.renderer.SetBackground(102.0/255.0,204/255.0,1.0)
     self.window = vtk.vtkRenderWindow()
     self.window.SetSize(WINDOW_WIDTH,WINDOW_HEIGHT)
     self.window.AddRenderer(self.renderer)
     self.interactor = vtk.vtkRenderWindowInteractor()
     self.interactor.SetRenderWindow(self.window)
     self.axes = vtk.vtkAxesActor()
     self.axes.SetAxisLabels(0)
     transform = vtk.vtkTransform()
     transform.Scale(0.1,0.1,0.1)
     self.axes.SetUserTransform(transform)
     self.renderer.AddActor(self.axes)
     # Create ground plane visualization
     self.floorVisual = vtk.vtkPlaneSource()
     self.floorVisual.SetNormal((0.0,1.0,0.0))
     self.floorVisual.SetResolution(10,10)
     self.floorReader = vtk.vtkJPEGReader()
     self.floorReader.SetFileName(FLOOR_IMAGE)
     self.floorTexture = vtk.vtkTexture()
     transform = vtk.vtkTransform()
     transform.Scale(50.0,50.0,50.0)
     self.floorTexture.SetTransform(transform)
     self.floorTexture.SetInput(self.floorReader.GetOutput())
     self.floorMap = vtk.vtkTextureMapToPlane()
     self.floorMap.SetInput(self.floorVisual.GetOutput())
     self.floorMapper = vtk.vtkPolyDataMapper()
     self.floorMapper.SetInput(self.floorMap.GetOutput())
     self.floorActor = vtk.vtkActor()
     transform = vtk.vtkTransform()
     transform.Scale(100.0,100.0,100.0)
     self.floorActor.SetUserTransform(transform)
     self.floorActor.SetMapper(self.floorMapper)
     self.floorActor.SetTexture(self.floorTexture)
     self.renderer.AddActor(self.floorActor)
     # VTK camera setup
     self.camera = vtk.vtkCamera()
     self.renderer.SetActiveCamera(self.camera)
     self.cameraFocus = [0.0, 0.0, 0.0]
     self.cameraPos = [4.0, 2.5, 1.5]
     self.cameraOffset = [0.0,1.0,3.0]
     self.cameraRoll = 0.0
     # Keep track of the simulated bodies and robots
     self.bodies = []
     self.robots = []
     self.controllers = []
开发者ID:tioguerra,项目名称:pyrobosim,代码行数:57,代码来源:sim.py

示例10: _MakeXYActors

    def _MakeXYActors(self, reduce=1):
        # get a texture-mapped actor
        extent = self._ImageReslice.GetOutputExtent()
        origin = self._ImageReslice.GetOutputOrigin()
        spacing = self._ImageReslice.GetOutputSpacing()

        bounds = [origin[0] + spacing[0] * (extent[0] - 0.5),
                  origin[0] + spacing[0] * (extent[1] + 0.5),
                  origin[1] + spacing[1] * (extent[2] - 0.5),
                  origin[1] + spacing[1] * (extent[3] + 0.5),
                  origin[2] + spacing[2] * (extent[4] - 0.5),
                  origin[2] + spacing[2] * (extent[5] + 0.5)]

        for sliceNumber in range(extent[4], old_div((extent[5] + 1), reduce)):
            # the z position of the slice
            z = origin[2] + reduce * sliceNumber * spacing[2]

            plane = vtk.vtkPlaneSource()
            plane.SetXResolution(1)
            plane.SetYResolution(1)
            plane.SetOrigin(bounds[0], bounds[2], z)
            plane.SetPoint1(bounds[1], bounds[2], z)
            plane.SetPoint2(bounds[0], bounds[3], z)

            imageClip = vtk.vtkExtractVOI()
            imageClip.SetInput(self._ImageToStructuredPoints.GetOutput())
            imageClip.SetVOI(extent[0], extent[1],
                             extent[2], extent[3],
                             reduce * sliceNumber, reduce * sliceNumber)
            imageClip.ReleaseDataFlagOn()

            texture = vtk.vtkTexture()
            texture.SetQualityTo32Bit()
            texture.SetInput(imageClip.GetOutput())
            texture.RepeatOff()
            texture.InterpolateOn()
            texture.MapColorScalarsThroughLookupTableOff()

            for i in range(3):
                mapper = vtk.vtkPolyDataMapper()
                mapper.SetInput(plane.GetOutput())
                mapper.SetClippingPlanes(self._ClippingPlanes[i])

                actor = vtk.vtkActor()
                actor.SetMapper(mapper)
                actor.SetTexture(texture)
                actor.PickableOff()
                actor.SetProperty(self._PropertyXY)

                self._PlanesXY.append(plane)
                self._ImageClipsXY.append(imageClip)
                self._ActorsXY.append(actor)

        numberOfPlanes = (extent[5] - extent[4] + 1) / reduce * 3
        return self._ActorsXY[-numberOfPlanes:]
开发者ID:parallaxinnovations,项目名称:vtkAtamai,代码行数:55,代码来源:VolumePlanesFactory.py

示例11: SetInput

    def SetInput(self, imagedata):
        axes = PLANE_DATA[self.orientation][0] # "x", "y" or "z"
        colour = PLANE_DATA[self.orientation][1]
        
        #if self.orientation == SAGITAL:
        #    spacing = min(imagedata.GetSpacing())
        #    permute = vtk.vtkImagePermute()
        #    permute.SetInput(imagedata)
        #    permute.GetOutput().ReleaseDataFlagOn()
        #    permute.SetOutputSpacing(spacing, spacing, spacing)
        #    imagedata = permute.GetOutput()

        # Picker for enabling plane motion.
        # Allows selection of a cell by shooting a ray into graphics window
        picker = vtk.vtkCellPicker()
        picker.SetTolerance(0.005)
        picker.PickFromListOn()

        # 3D widget for reslicing image data.
        # This 3D widget defines a plane that can be interactively placed in an image volume.
        widget = vtk.vtkImagePlaneWidget()
        widget.SetInput(imagedata)
        widget.SetSliceIndex(self.index)
        widget.SetPicker(picker)
        widget.SetKeyPressActivationValue(axes)
        widget.SetInteractor(self.iren)
        widget.TextureVisibilityOff()
        widget.DisplayTextOff()
        widget.RestrictPlaneToVolumeOff()
        exec("widget.SetPlaneOrientationTo"+axes.upper()+"Axes()")
        widget.AddObserver("InteractionEvent",self.Update)
        self.widget = widget
        
        prop = widget.GetPlaneProperty()
        prop.SetColor(colour)

        # Syncronize coloured outline with texture appropriately
        source = vtk.vtkPlaneSource()
        source.SetOrigin(widget.GetOrigin())
        source.SetPoint1(widget.GetPoint1())
        source.SetPoint2(widget.GetPoint2())
        source.SetNormal(widget.GetNormal())
        self.source = source
        
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(source.GetOutput())

        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.SetTexture(widget.GetTexture())
        actor.VisibilityOff()
        self.actor = actor

        self.render.AddActor(actor)
开发者ID:invesalius,项目名称:invesalius3,代码行数:54,代码来源:volume_widgets.py

示例12: _create_geometry

 def _create_geometry(self):
     self._plane_source = vtk.vtkPlaneSource()
     self._plane_source.SetNormal((0.0,0.0,1.0))
     self._plane_source.SetXResolution(1)
     self._plane_source.SetYResolution(1)
     m = vtk.vtkPolyDataMapper()
     m.SetInputConnection(self._plane_source.GetOutputPort())
     a = vtk.vtkActor()
     a.SetMapper(m)
     a.GetProperty().SetOpacity(0.3)
     a.GetProperty().SetColor(0.0, 0.0, 0.7)
     self.props = [a]
开发者ID:sanguinariojoe,项目名称:devide,代码行数:12,代码来源:devide_canvas_object.py

示例13: MakePlane

def MakePlane():
    '''
    Make a plane as the source.
    :return: vtkPolyData with normal and scalar data.
    '''
    source = vtk.vtkPlaneSource()
    source.SetOrigin(-10.0, -10.0, 0.0)
    source.SetPoint2(-10.0, 10.0, 0.0)
    source.SetPoint1(10.0, -10.0, 0.0)
    source.SetXResolution(20)
    source.SetYResolution(20)
    source.Update()
    return MakeElevations(source.GetOutput())
开发者ID:lorensen,项目名称:VTKWikiExamples,代码行数:13,代码来源:ElevationBandsWithGlyphs.py

示例14: createPlaneActor

    def createPlaneActor(plane):
        center = plane.center()
        normal = plane.normal()

        source = vtk.vtkPlaneSource()
        source.SetCenter(center[0], center[1], center[2])
        source.SetNormal(normal[0], normal[1], normal[2])

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(source.GetOutputPort())

        obj = vtk.vtkActor()
        obj.SetMapper(mapper)

        return obj
开发者ID:scruffy-t,项目名称:PydroSquid,代码行数:15,代码来源:viewer.py

示例15: __init__

 def __init__(self, origin, p1, p2, width, height):
     logging.debug("In Slice::__init__()")
     self._p1 = p1
     self._p2 = p2    
     self._width = width
     self._origin = origin
     self._height = height
     self._plane  = vtk.vtkPlaneSource()
     self._plane.SetOrigin(self._origin)
     self._plane.SetPoint1(self._p1)
     self._plane.SetPoint2(self._p2)
     self._plane.Update()
     self.normalizePlaneSize()
     self.createBoundsPlanes()
     self._resliceTransform = None
开发者ID:aevum,项目名称:moonstone,代码行数:15,代码来源:slice.py


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