• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vtk.vtkPlanes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

 def __init__(self,viewer, selection_color):
     self.viewer = viewer
     self.selection_color = selection_color
     outline = vtk.vtkOutlineFilter()
     if vtk.vtkVersion.GetVTKMajorVersion()<6:
         outline.SetInput(self.viewer._polydata)
     else:
         outline.SetInputData(self.viewer._polydata)
                 
     outlineMapper = vtk.vtkPolyDataMapper()
     outlineMapper.SetInputConnection(outline.GetOutputPort())
     self.box=vtk.vtkActor()
     self.box.SetMapper( outlineMapper )
     self.box.GetProperty().SetColor(1,1,1)
     self.box.PickableOff()
     
     self.SetProp3D(self.box)
     self.planes=vtk.vtkPlanes()
     self.SetInteractor(viewer.iren)
     if vtk.vtkVersion.GetVTKMajorVersion()<6:
         self.SetInput(self.viewer._polydata)
     else:
         self.SetInputData(self.viewer._polydata)
         
     self.SetPlaceFactor(1)
     self.PlaceWidget()
     self.InsideOutOn()
     self.SetRotationEnabled(0)
     self.GetPlanes(self.planes)
     self.AddObserver("EndInteractionEvent",self.on_select_atoms)
开发者ID:mark-johnson-1966,项目名称:MDANSE,代码行数:30,代码来源:MolecularViewerPlugin.py


示例2: box_select_points

    def box_select_points(self, start_pos, end_pos):
        aspect = self.model_viewer.viewer.renderer.GetAspect()
        frustum_planes = np.zeros(24)
        self.model_viewer.viewer.renderer.GetActiveCamera().GetFrustumPlanes(aspect[0] / aspect[1], frustum_planes)
        min_pos = np.fmin(start_pos, end_pos)
        max_pos = np.fmax(start_pos, end_pos) + 1

        # Shift frustum planes inwards to match the box selection
        y_world_size = 2.0 * self.model_viewer.viewer.renderer.GetActiveCamera().GetParallelScale()
        window_size = self.model_viewer.viewer.renderer.GetSize()
        pixel_to_world_scale = y_world_size / window_size[1]
        frustum_planes[3] -= pixel_to_world_scale * min_pos[0]
        frustum_planes[7] -= pixel_to_world_scale * (window_size[0] - max_pos[0])
        frustum_planes[11] -= pixel_to_world_scale * min_pos[1]
        frustum_planes[15] -= pixel_to_world_scale * (window_size[1] - max_pos[1])

        # For visualization, it's better to set near and far planes from depth of filtered data
        planes = vtk.vtkPlanes()
        planes.SetFrustumPlanes(frustum_planes)
        self.model_viewer.point_cloud_troupe.set_filtering_frustum(planes)
        filtered_ids = self.model_viewer.point_cloud_troupe.get_filtered_ids()
        if len(filtered_ids) > 0:
            dists = self.model_viewer.cached_points[filtered_ids, :].dot(frustum_planes[16:19])
            min_dist = np.min(dists)
            max_dist = np.max(dists)
            range = max_dist - min_dist
            range = max(range, 0.01)
            frustum_planes[19] = -min_dist + 0.1 * range
            frustum_planes[23] = max_dist + 0.1 * range
            self.set_roibox(frustum_planes)
        else:
            self.reset_roibox()
        # Potential workaround for http://www.vtk.org/Bug/view.php?id=7823
        # self.model_viewer.viewer.renderer.ResetCamera()
        self.model_viewer.change_mode(ViewModes.EDIT_BONES)
开发者ID:awf,项目名称:autodiff,代码行数:35,代码来源:annotate_pose.py


示例3: voiWidgetInteractionCallback

    def voiWidgetInteractionCallback(self, o, e):
        planes = vtk.vtkPlanes()
        o.GetPlanes(planes)
        bounds =  planes.GetPoints().GetBounds()

        # first set bounds
        self.controlFrame.voiBoundsText.SetValue(
            "(%.2f %.2f %.2f %.2f %.2f %.2f) mm" %
            bounds)

        input_data = self.getPrimaryInput()
        if input_data:
            ispacing = input_data.GetSpacing()
            iorigin = input_data.GetOrigin()
            # calculate discrete coords
            bounds = planes.GetPoints().GetBounds()
            voi = 6 * [0]
            # excuse the for loop :)
            for i in range(6):
                voi[i] = int(round((bounds[i] - iorigin[i / 2]) / ispacing[i / 2]))

            # store the VOI (this is a shallow copy)
            self._currentVOI = voi
            # display the discrete extent
            self.controlFrame.voiExtentText.SetValue(
                "(%d %d %d %d %d %d)" % tuple(voi))
开发者ID:sanguinariojoe,项目名称:devide,代码行数:26,代码来源:slice3dVWR.py


示例4: Execute

    def Execute(self):

        if self.Surface == None:
            self.PrintError('Error: no Surface.')

        if self.WidgetType == "box":
            self.ClipFunction = vtk.vtkPlanes()
        elif self.WidgetType == "sphere":
            self.ClipFunction = vtk.vtkSphere()

        self.Clipper = vtk.vtkClipPolyData()
        self.Clipper.SetInput(self.Surface)
        self.Clipper.SetClipFunction(self.ClipFunction)
        self.Clipper.GenerateClippedOutputOn()
        self.Clipper.InsideOutOn()
        
        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(self.Surface)
        mapper.ScalarVisibilityOff()
        self.Actor = vtk.vtkActor()
        self.Actor.SetMapper(mapper)
        self.vmtkRenderer.Renderer.AddActor(self.Actor)

        if self.WidgetType == "box":
            self.ClipWidget = vtk.vtkBoxWidget()
            self.ClipWidget.GetFaceProperty().SetColor(0.6,0.6,0.2)
            self.ClipWidget.GetFaceProperty().SetOpacity(0.25)
        elif self.WidgetType == "sphere":
            self.ClipWidget = vtk.vtkSphereWidget()
            self.ClipWidget.GetSphereProperty().SetColor(0.6,0.6,0.2)
            self.ClipWidget.GetSphereProperty().SetOpacity(0.25)
            self.ClipWidget.GetSelectedSphereProperty().SetColor(0.6,0.0,0.0)
            self.ClipWidget.GetSelectedSphereProperty().SetOpacity(0.75)
            self.ClipWidget.SetRepresentationToSurface()
            self.ClipWidget.SetPhiResolution(20)
            self.ClipWidget.SetThetaResolution(20)

        self.ClipWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        self.Display()

        self.Transform = vtk.vtkTransform()
        self.ClipWidget.GetTransform(self.Transform)

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()

        if self.CleanOutput == 1:
            cleaner = vtk.vtkCleanPolyData()
            cleaner.SetInput(self.Surface)
            cleaner.Update()
            self.Surface = cleaner.GetOutput()

        if self.Surface.GetSource():
            self.Surface.GetSource().UnRegisterAllOutputs()
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:59,代码来源:vmtksurfaceclipper.py


示例5: SelectPolygons

 def SelectPolygons(self, widget, event_string):
     # As can be seen the callback takes two arguments.  The first being the object that generates the event 
     # and the second argument the event name (which is a string).        
     self.planes = vtk.vtkPlanes()
     self.boxWidget.GetPlanes(self.planes)
     self.boundsPlane_presel = self.planes.GetPoints().GetBounds()
     
     return
开发者ID:cgallego,项目名称:segmentLesion,代码行数:8,代码来源:segment.py


示例6: executeClip

 def executeClip( self, caller=None, event=None ):
     planes = vtk.vtkPlanes(); np = 6
     self.clipper.GetPlanes(planes)
     if not self.cropRegion: self.cropRegion = [0.0]*np
     for ip in range( np ):
         plane = planes.GetPlane( ip )
         o = plane.GetOrigin()
         self.cropRegion[ip] = o[ ip/2 ]
     self.cropVolume() 
开发者ID:arulalant,项目名称:uvcdat,代码行数:9,代码来源:VolumeViewer.py


示例7: createContent

 def createContent( self ):
     input =  self.module.inputModule.getOutput()  
     self.boxWidget = vtk.vtkBoxWidget()
     self.boxWidget.SetRotationEnabled(0)
     self.boxWidget.SetPlaceFactor(1.0)
     self.boxWidget.SetInput( input )
     self.planes = vtk.vtkPlanes()
     self.boxWidget.AddObserver("StartInteractionEvent", self.startConfiguration )
     self.boxWidget.AddObserver("InteractionEvent",      self.updateConfiguration )
     self.boxWidget.AddObserver("EndInteractionEvent",   self.endConfiguration ) 
开发者ID:imclab,项目名称:vistrails,代码行数:10,代码来源:ResampleModule.py


示例8: __init__

    def __init__( self, parent, imode_callback, rmode_callback, ppos_callback, ao, **kwargs ):
        # initialize Panel
        if 'id' not in kwargs:
            kwargs['id'] = wx.ID_ANY
        wx.Panel.__init__( self, parent, **kwargs )

        self.setInteractionMode = imode_callback
        self.setInteractionMode(True)
        
        self.recordingMode = False
        self.setRecordingMode = rmode_callback
        self.setRecordingMode(False)
        
        self.setPickerPos = ppos_callback
        
        self.ao = ao
        self.aa = False
        self.firstRender = True

        self.vtkWidget = wxVTKRenderWindowInteractor(self, wx.ID_ANY)
        self.iren = self.vtkWidget._Iren
        self.iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
        
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetBackground(0,0,0)
        self.imageLayer = {}
        self.CISID = -1  # Current Image Set ID
        self.imageLayer[self.CISID] = IBCRenderer(self.renderer, self.iren.Render)
        self.bacteriaLayer = BacteriaLayer(self.renderer, self.iren.Render)
        
        self.viewCamActive = True
        
        # for interactive clipping
        self.planes = vtk.vtkPlanes()
        
        self.ellipsoid = None
        self.ellipsoidTextActor = None
        
        # The SetInteractor method is how 3D widgets are associated with the
        # render window interactor. Internally, SetInteractor sets up a bunch
        # of callbacks using the Command/Observer mechanism (AddObserver()).
        self.boxWidget = vtk.vtkBoxWidget()
        self.boxWidget.SetInteractor(self.iren)
        self.boxWidget.SetPlaceFactor(1.0)

        # init vtk window
        self.vtkWidget.Enable(1)
        self.vtkWidget.AddObserver("ExitEvent", lambda o,e,f=parent: f.Close())
        self.vtkWidget.GetRenderWindow().AddRenderer(self.renderer)
        
        # Bind VTK events
        self.iren.AddObserver("KeyPressEvent", self.OnKeyDown)
        
        self.Sizer = wx.BoxSizer()
        self.Sizer.Add(self.vtkWidget, 1, wx.EXPAND)
开发者ID:smdabdoub,项目名称:ProkaryMetrics,代码行数:55,代码来源:vtkRender.py


示例9: set_region_of_interest

 def set_region_of_interest(self, planes_vector):
     if planes_vector is None:
         self.planes_troupe.set_visible(False)
         if self.point_cloud_troupe is not None:
             self.point_cloud_troupe.set_filtering_frustum(None)
     else:
         planes = vtk.vtkPlanes()
         planes.SetFrustumPlanes(planes_vector)
         if self.point_cloud_troupe is not None:
             self.point_cloud_troupe.set_filtering_frustum(planes)
         self.planes_troupe.set_planes(planes)
         self.planes_troupe.set_visible(True)
开发者ID:awf,项目名称:autodiff,代码行数:12,代码来源:annotate_pose.py


示例10: resetClippingBox

	def resetClippingBox(self):
		"""
		Resets position and shape of the clipping box.
		"""
		# Reset the planes by setting identity transform
		transform = vtkTransform()
		self.clippingBox.SetTransform(transform)

		# Make sure the mapper is informed of the changes
		planes = vtkPlanes()
		self.clippingBox.GetPlanes(planes)
		self._updateMapperWithClippingPlanes(planes)
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:12,代码来源:ClippingBox.py


示例11: clipVolumeRender

	def clipVolumeRender(self, obj, evt, *args):
		"""
		clip the module based on the given clipping planes
		"""
		modules = self.getModulesToClip()
		planes = vtk.vtkPlanes()
		obj.GetPlanes(planes)
		
		for mapper in self.clippedMappers:
			mapper.RemoveAllClippingPlanes()
		self.clippedMappers = []
		
		for module in modules:
			if hasattr(module, "mapper") and hasattr(module.mapper, "SetClippingPlanes"):  
				module.mapper.SetClippingPlanes(planes)   
				self.clippedMappers.append(module.mapper)
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:16,代码来源:CutWidget.py


示例12: picker_callback

	def picker_callback(self,obj,event):
		
		extract = vtk.vtkExtractSelectedFrustum()
	
		fPlanes=obj.GetFrustum() #collection of planes based on unscaled display
	
		#scale frustum to account for the zaspect
		scaledPlanes=vtk.vtkPlanes()
		scaledNormals=vtk.vtkDoubleArray()
		scaledNormals.SetNumberOfComponents(3)
		scaledNormals.SetNumberOfTuples(6)
		scaledOrigins=vtk.vtkPoints()
		for j in range(6):
			i=fPlanes.GetPlane(j)
			k=i.GetOrigin()
			q=i.GetNormal()
			scaledOrigins.InsertNextPoint(k[0],k[1],k[2]/float(self.Zaspect))
			scaledNormals.SetTuple(j,(q[0],q[1],q[2]*float(self.Zaspect)))
		scaledPlanes.SetNormals(scaledNormals)
		scaledPlanes.SetPoints(scaledOrigins)
			
		
		extract.SetFrustum(scaledPlanes)
		extract.SetInputData(self.vtkPntsPolyData)
		extract.Update()
		extracted = extract.GetOutput()
		
		ids = vtk.vtkIdTypeArray()
		ids = extracted.GetPointData().GetArray("vtkOriginalPointIds")

		
		if ids:
			#store them in an array for an undo operation
			self.lastSelectedIds=ids
			for i in range(ids.GetNumberOfTuples()):
				#turn them red
				self.colors.SetTuple(ids.GetValue(i),(255,0,0))
				self.bool_pnt[ids.GetValue(i)]=False
		
			self.vtkPntsPolyData.GetPointData().SetScalars(self.colors)
			self.vtkPntsPolyData.Modified()
		
		
		self.ui.vtkWidget.update()
		#set flag on ui to show that data has been modified
		self.unsaved_changes=True
开发者ID:majroy,项目名称:pyCM,代码行数:46,代码来源:point_cloud.py


示例13: Execute

    def Execute(self):

        if (self.Mesh == None):
            self.PrintError('Error: no Mesh.')

        self.Planes = vtk.vtkPlanes()
        self.Clipper = vtk.vtkClipDataSet()
        self.Clipper.SetInput(self.Mesh)
        self.Clipper.SetClipFunction(self.Planes)
        self.Clipper.GenerateClippedOutputOn()
        self.Clipper.InsideOutOn()
        
        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        self.vmtkRenderer.RegisterScript(self) 

        mapper = vtk.vtkDataSetMapper()
        mapper.SetInput(self.Mesh)
        mapper.ScalarVisibilityOff()
        self.Actor = vtk.vtkActor()
        self.Actor.SetMapper(mapper)
        self.vmtkRenderer.Renderer.AddActor(self.Actor)

        self.BoxWidget = vtk.vtkBoxWidget()
        self.BoxWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        self.BoxWidget.GetFaceProperty().SetColor(0.6,0.6,0.2)
        self.BoxWidget.GetFaceProperty().SetOpacity(0.25)

        self.vmtkRenderer.AddKeyBinding('i','Interact.', self.InteractCallback)
        self.vmtkRenderer.AddKeyBinding('space','Clip.', self.ClipCallback)

        self.Display()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
        
        if self.Mesh.GetSource():
            self.Mesh.GetSource().UnRegisterAllOutputs()
开发者ID:SaraZanchi,项目名称:vmtk,代码行数:41,代码来源:vmtkmeshclipper.py


示例14: __init__

	def __init__(self,gfx,iso,cropentry,entryval):
		self.gfx = gfx
		self.entry = cropentry
		self.entryval = entryval
		self.crpfn=None
		self.SetProp3D(gfx.map[0].box)
		self.planes=vtk.vtkPlanes()
		self.SetInteractor(gfx.iren)
		self.SetInput(gfx.map[0].iso.GetOutput())
		self.SetPlaceFactor(1)
		self.PlaceWidget()
		self.InsideOutOn()
		self.SetRotationEnabled(0)
		self.GetPlanes(self.planes)
		self.AddObserver("EndInteractionEvent",self.SelectPolygons)
		self.AddObserver("InteractionEvent",self.Update_crop_bounds)
		self.inorout=1
		self.init_entrys()
		(xmin,xmax,ymin,ymax,zmin,zmax)=self.gfx.map[0].box.GetBounds()
		spcing=self.gfx.map[0].reader.GetOutput().GetSpacing()
		self.old=(nint(xmin/spcing[0]),nint(xmax/spcing[0]),nint(ymin/spcing[1]),nint(ymax/spcing[1]),nint(zmin/spcing[2]),nint(zmax/spcing[2]))
开发者ID:ggoret,项目名称:VEDA,代码行数:21,代码来源:Map.py


示例15: OnBox

 def OnBox(self, event):
     boxWidget = vtk.vtkBoxWidget()
     # change handle properties
     boxWidget.SetHandleSize(0.005) # default is 0.01
     boxWidget.SetInteractor(self.widget)
     boxWidget.SetPlaceFactor(1.25)
     boxWidget.SetInput(self.normals.GetOutput())
     boxWidget.PlaceWidget()
     boxCallback = self.BoxSelectPolygons()
     boxWidget.AddObserver("EndInteractionEvent", boxCallback)
     boxWidget.KeyPressActivationOff()
     plane = vtk.vtkPlanes()
     self.boxes.append(boxWidget)
     self.planes[boxWidget.GetAddressAsString('')] = plane
     self.region.AddFunction(plane)
     newId = self.GateMenu.AppendCheckItem(-1, "Box #" + str(self.boxCount))
     self.boxCount = self.boxCount + 1
     self.boxIds[newId.GetId()] = boxWidget.GetAddressAsString('')
     newId.Check(True)
     self.Bind(wx.EVT_MENU, self.OnBoxSelect, newId)
     boxWidget.On()
开发者ID:cliburn,项目名称:flow,代码行数:21,代码来源:Main.py


示例16: __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()
 
        # Create source
        camera = vtk.vtkCamera()
        planesArray = [0]*24
        camera.GetFrustumPlanes(2, planesArray)
         
        planes = vtk.vtkPlanes()
        planes.SetFrustumPlanes(planesArray)
         
        frustumSource = vtk.vtkFrustumSource()
        frustumSource.SetPlanes(planes)
        frustumSource.Update()
         
        frustum = frustumSource.GetOutput()
         
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(frustum)
         
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

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


示例17: clip

 def clip(self, plane):
     """Clip the surface against the supplied plane, using a
     vtkClipPolyData filter."""
     
     if self.Clipper is None:
         self.Clipper = vtk.vtkClipPolyData()
         self.Clipper.SetInput(self.Clipped)
         pass
     
     # Get the axis-aligned cuboid bounding the surface
     bounds = self.Surface.GetBounds()
     # (xmin,xmax, ymin,ymax, zmin,zmax)
     planes = vtk.vtkPlanes()
     planes.SetBounds(*bounds)
     # Iterate over BB, find plane with closest normal, replace
     # with our plane.
     maxDot = -1; maxI = -1
     for i in range(planes.GetNumberOfPlanes()):
         bound = planes.GetPlane(i)
         dot = normalDot(plane, bound)
         if dot> maxDot:
             maxDot = dot
             maxI = i
             pass
         continue
     
     planes.GetNormals().SetTuple3(maxI, *plane.GetNormal())
     planes.GetPoints().SetPoint(maxI, *plane.GetOrigin())
     
     self.Clipper.SetClipFunction(planes)
     self.Clipper.GenerateClippedOutputOn()
     self.Clipper.InsideOutOn()
     self.Clipper.Update()
     self.Clipped.DeepCopy(self.Clipper.GetClippedOutput())
     self.Clipped.Update()
     return    
开发者ID:uschille,项目名称:hemelb,代码行数:36,代码来源:SurfacePlaneClipper.py


示例18: buildPipeline

    def buildPipeline(self):
        """ execute() -> None
        Dispatch the vtkRenderer to the actual rendering widget
        """ 
        
        texture_ispec = self.getInputSpec(  1 )                
        xMin, xMax, yMin, yMax, zMin, zMax = self.input().GetWholeExtent()       
        self.sliceCenter = [ (xMax-xMin)/2, (yMax-yMin)/2, (zMax-zMin)/2  ]       
        spacing = self.input().GetSpacing()
        sx, sy, sz = spacing 
#        self.input().SetSpacing( sx, sy, 5*sz )      
        origin = self.input().GetOrigin()
        ox, oy, oz = origin
        dataType = self.input().GetScalarTypeAsString()
        self.setMaxScalarValue( self.input().GetScalarType() )
        self.colorByMappedScalars = False
        rangeBounds = self.getRangeBounds()

        dr = rangeBounds[1] - rangeBounds[0]
        range_offset = .2*dr
        self.range = [ rangeBounds[0] + range_offset, rangeBounds[1] - range_offset ]
        print "Data Type = %s, range = (%f,%f), range bounds = (%f,%f), max_scalar = %s" % ( dataType, self.range[0], self.range[1], rangeBounds[0], rangeBounds[1], self._max_scalar_value )
        self.probeFilter = None
        textureRange = self.range
        if texture_ispec and texture_ispec.input():
            self.probeFilter = vtk.vtkProbeFilter()
            textureRange = texture_ispec.input().GetScalarRange()
            self.probeFilter.SetSource( texture_ispec.input() )
            self.generateTexture = True

        if (self.surfacePicker == None):           
            self.surfacePicker  = vtk.vtkPointPicker()
                    
        self.levelSetFilter = vtk.vtkContourFilter()
        self.inputModule().inputToAlgorithm( self.levelSetFilter )

        self.clipPlanes = vtk.vtkPlanes() 
        self.polyClipper = vtk.vtkClipPolyData()
        self.polyClipper.SetInputConnection( self.levelSetFilter.GetOutputPort() )
        self.polyClipper.SetClipFunction( self.clipPlanes )
        self.polyClipper.InsideOutOn()
                
        self.levelSetMapper = vtk.vtkPolyDataMapper()
        self.levelSetMapper.SetColorModeToMapScalars()
        if ( self.probeFilter == None ):
            imageRange = self.getImageValues( self.range ) 
            self.levelSetMapper.SetInputConnection( self.polyClipper.GetOutputPort() ) 
            self.levelSetMapper.SetScalarRange( imageRange[0], imageRange[1] )
        else: 
            self.probeFilter.SetInputConnection( self.polyClipper.GetOutputPort() )
            self.levelSetMapper.SetInputConnection( self.probeFilter.GetOutputPort() ) 
            self.levelSetMapper.SetScalarRange( textureRange )
            
        colormapManager = self.getColormapManager( index=1 ) if texture_ispec and texture_ispec.input() else self.getColormapManager()                  
        colormapManager.setAlphaRange ( self.opacityRange ) 
        self.levelSetMapper.SetLookupTable( colormapManager.lut ) 
        self.levelSetMapper.UseLookupTableScalarRangeOn()
       
        self.updateLevels()
          
#        levelSetMapper.SetColorModeToMapScalars()  
#        levelSetActor = vtk.vtkLODActor() 
        self.levelSetActor = vtk.vtkLODActor() 
#            levelSetMapper.ScalarVisibilityOff() 
#            levelSetActor.SetProperty( self.levelSetProperty )              
        self.levelSetActor.SetMapper( self.levelSetMapper )

        self.cursorActor     = vtk.vtkActor()
        self.cursorProperty  = None 
        self.cursor = vtk.vtkSphereSource()
        self.cursor.SetRadius(2.0)
        self.cursor.SetThetaResolution(8)
        self.cursor.SetPhiResolution(8)

        self.clipper = vtk.vtkBoxWidget()
        self.clipper.RotationEnabledOff()
        self.clipper.SetPlaceFactor( 1.0 )    
        self.clipper.AddObserver( 'StartInteractionEvent', self.startClip )
        self.clipper.AddObserver( 'EndInteractionEvent', self.executeClip )
        
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(self.cursor.GetOutput())
        self.cursorActor.SetMapper(mapper)        
        self.createDefaultProperties() 
                                                            
#        pointData = self.levelSetFilter.GetOutput().GetPointData()
#        pointData.SetScalars( colorLevelData )
        
#        if pd <> None:
#            na = pd.GetNumberOfArrays()
#            print " ** Dataset has %d arrays. ** " % ( pd.GetNumberOfArrays() )
#            for i in range( na ): print "   ---  Array %d: %s " % ( i,  str( pd.GetArrayName(i) ) )
#        else: print " ** No point data. "
           
        self.renderer.AddActor( self.levelSetActor )
        self.surfacePicker.AddPickList( self.levelSetActor )
        self.surfacePicker.PickFromListOn()
        self.renderer.AddViewProp(self.cursorActor)
        self.cursorActor.SetProperty(self.cursorProperty)
        self.renderer.SetBackground( VTK_BACKGROUND_COLOR[0], VTK_BACKGROUND_COLOR[1], VTK_BACKGROUND_COLOR[2] ) 
#.........这里部分代码省略.........
开发者ID:painter1,项目名称:vistrails,代码行数:101,代码来源:LevelSurfaceModule.py


示例19: Execute

    def Execute(self):

        if self.Mesh == None:
            self.PrintError("Error: no Mesh.")

        self.Clipper = vtk.vtkClipDataSet()
        self.Clipper.SetInput(self.Mesh)
        self.Clipper.GenerateClippedOutputOn()
        self.Clipper.SetInsideOut(self.InsideOut)

        if self.Interactive:

            self.Planes = vtk.vtkPlanes()
            self.Clipper.SetClipFunction(self.Planes)

            self.Cutter = vtk.vtkCutter()
            self.Cutter.SetInput(self.Mesh)
            self.Cutter.SetCutFunction(self.Planes)

            self.ClippedMesh = vtk.vtkUnstructuredGrid()
            self.Surface = vtk.vtkPolyData()

            if not self.vmtkRenderer:
                self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
                self.vmtkRenderer.Initialize()
                self.OwnRenderer = 1

            self.vmtkRenderer.RegisterScript(self)

            mapper = vtk.vtkDataSetMapper()
            mapper.SetInput(self.Mesh)
            mapper.ScalarVisibilityOff()
            self.Actor = vtk.vtkActor()
            self.Actor.SetMapper(mapper)
            self.vmtkRenderer.Renderer.AddActor(self.Actor)

            self.BoxWidget = vtk.vtkBoxWidget()
            self.BoxWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
            self.BoxWidget.GetFaceProperty().SetColor(0.6, 0.6, 0.2)
            self.BoxWidget.GetFaceProperty().SetOpacity(0.25)

            self.vmtkRenderer.AddKeyBinding("i", "Interact.", self.InteractCallback)
            self.vmtkRenderer.AddKeyBinding("space", "Clip.", self.ClipCallback)

            self.Display()

            if self.OwnRenderer:
                self.vmtkRenderer.Deallocate()

        else:

            self.Mesh.GetPointData().SetActiveScalars(self.ClipArrayName)

            self.Clipper.GenerateClipScalarsOff()
            self.Clipper.SetValue(self.ClipValue)
            self.Clipper.Update()

            self.Cutter = vtk.vtkContourFilter()
            self.Cutter.SetInput(self.Mesh)
            self.Cutter.SetValue(0, self.ClipValue)
            self.Cutter.Update()

            self.Mesh = self.Clipper.GetOutput()
            self.Surface = self.Cutter.GetOutput()
            self.ClippedMesh = self.Clipper.GetClippedOutput()

        if self.Mesh.GetSource():
            self.Mesh.GetSource().UnRegisterAllOutputs()
开发者ID:abhishek101hi,项目名称:vmtk,代码行数:68,代码来源:vmtkmeshclipper.py


示例20:

        color as doubles.
    '''
    rgb = [0.0, 0.0, 0.0]  # black
    vtk.vtkNamedColors().GetColorRGB(colorName, rgb)
    return rgb

# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

# create cutting planes
planes = vtk.vtkPlanes()
points = vtk.vtkPoints()
norms = vtk.vtkFloatArray()

norms.SetNumberOfComponents(3)
points.InsertPoint(0, 0.0, 0.0, 0.0)
norms.InsertTuple3(0, 0.0, 0.0, 1.0)
points.InsertPoint(1, 0.0, 0.0, 0.0)
norms.InsertTuple3(1, -1.0, 0.0, 0.0)
planes.SetPoints(points)
planes.SetNormals(norms)

# texture
texReader = vtk.vtkStructuredPointsReader()
texReader.SetFileName(VTK_DATA_ROOT + "/Data/texThres2.vtk")
texture = vtk.vtkTexture()
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:31,代码来源:motor.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkPointSource函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkPlaneSource函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap