#!/usr/bin/env python

import vtk

cone = vtk.vtkConeSource()

coneMapper = vtk.vtkPolyDataMapper()
coneMapper.SetInputConnection( cone.GetOutputPort() )

coneActor = vtk.vtkActor()
coneActor.SetMapper( coneMapper )

ren1= vtk.vtkRenderer()
ren1.AddActor( coneActor )
ren1.SetBackground( 0, 0, 0 )

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer( ren1 )

# selection part - green color part
plane = vtk.vtkPlane()
clipper = vtk.vtkClipPolyData()
clipper.SetInputConnection( cone.GetOutputPort() )
clipper.SetClipFunction( plane )
clipper.InsideOutOn()

selectMapper = vtk.vtkPolyDataMapper()
selectMapper.SetInputConnection( clipper.GetOutputPort() )

selectActor = vtk.vtkLODActor()
selectActor.SetMapper(selectMapper)
selectActor.GetProperty().SetColor(0, 1, 0)
selectActor.SetScale(1.01, 1.01, 1.01)

ren1.AddActor( selectActor )
# selection part end

renWinInteractor = vtk.vtkRenderWindowInteractor()
renWinInteractor.SetRenderWindow( renWin )

def myCallback(obj, event):
    global plane, selectActor
    obj.GetPlane(plane)
    selectActor.VisibilityOn()

# ImplicitPlaneWidget - outlines and plane
planeWidget = vtk.vtkImplicitPlaneWidget()
planeWidget.SetInteractor( renWinInteractor )
planeWidget.SetPlaceFactor(1)
planeWidget.SetInputConnection(cone.GetOutputPort())
planeWidget.PlaceWidget()
planeWidget.AddObserver("InteractionEvent", myCallback)
planeWidget.On()
# ImplicitPlaneWidget end

renWinInteractor.Start()

分类: python

6 条评论

Rapid Results Ketones · 2018年10月26日 下午7:17

We would like to thank you again for the gorgeous ideas
you gave Jeremy when preparing her post-graduate research and also,
most importantly, for providing every one of the ideas within a blog post.
In case we had been aware of your website a year ago, we might have been saved the useless measures we were having to take.
Thanks to you. https://www.classifiedposts.co.za/user/profile/20390

Kristen · 2018年10月30日 上午12:40

I really love your website.. Great colors & theme.
Did you create this web site yourself? Please reply back as I’m planning to create my own personal site
and would love to find out where you got this from or
just what the theme is named. Kudos! I have been browsing online
more than 3 hours today, yet I never found any interesting article like yours.
It’s pretty worth enough for me. Personally, if all website owners and bloggers made good content as you did, the
net will be much more useful than ever before. I have
been browsing online more than 3 hours today, but I by no means
found any attention-grabbing article like yours.
It is beautiful price enough for me. In my opinion, if
all web owners and bloggers made excellent content material as you
probably did, the web shall be much more useful than ever before.
http://foxnews.org/

    theArcticOcean · 2018年10月30日 下午6:06

    I just used WordPress to build my web site, that’s a very powerful tool for us.
    And the theme is Hestia. Thanks for your reading.

http://puqawucynavu.mihanblog.com/post/5 · 2018年11月7日 下午6:29

I precisely wished to thank you so much yet again. I am not sure the things that I would have
taken care of without these ideas shared by you concerning that topic.
It seemed to be the horrifying dilemma for me, but taking
note of the professional way you resolved it took
me to weep over happiness. Now i’m happier for
this service and as well , trust you comprehend what an amazing
job you happen to be providing training some other people all
through your web site. I am sure you haven’t come across any of us.

https://www.getjar.com/categories/all-games/action-games/Rules-of-Survival-Cheat-960889 · 2018年11月17日 下午9:16

hello!,I like your writing so much! share we communicate more about your post on AOL? I require an expert on this area to solve my problem. Maybe that’s you! Looking forward to see you.

发表评论

电子邮件地址不会被公开。 必填项已用*标注