当前位置: 首页 > news >正文

美创网站建设优势阿里指数查询

美创网站建设优势,阿里指数查询,网站的分页做不好会影响主页,新冠肺炎最新消息前言: 本文主要介绍了如何使用Python VTK高亮显示actor,使用Python语言,高亮显示选中的actor。当窗口中的圆球actor被选中时,会变成红色,并且会显示actor三遍面片边缘信息。 效果: VTK VTK,&…

前言:

    本文主要介绍了如何使用Python VTK高亮显示actor,使用Python语言,高亮显示选中的actor。当窗口中的圆球actor被选中时,会变成红色,并且会显示actor三遍面片边缘信息。

效果:

 VTK

      VTK,(visualizationtoolkit)是一个开放资源的免费软件系统,主要用于三维计算机图形学、图像处理和可视化。Vtk是在面向对象原理的基础上设计和实现的,它的内核是用C++构建。

主要函数介绍:

NewPickedActor.GetProperty(): 

通过该函数,可以设置actor的性质,如颜色、表面样式等。

vtk.vtkSphereSource(): 

创建球体的函数,文中通过一个for循环创建了6个球体。

vtk.vtkMinimalStandardRandomSequence():

 VTK的随机数生成器,用于代码中的球体,随机生成球体的大小和位置。

MouseInteractorHighLightActor: 

定义actor操作方法,这个是一个鼠标操作控件的控制方法。

leftButtonPressEvent(self, obj, event): 

这是一个事件触发函数,当鼠标左键点击对应的actor时,会触发函数,对点的actor高亮显示。

Code:

#!/usr/bin/env python# noinspection PyUnresolvedReferences
import vtkcolors = vtk.vtkNamedColors()
NUMBER_OF_SPHERES = 6class MouseInteractorHighLightActor(vtk.vtkInteractorStyleTrackballCamera):def __init__(self, parent=None):self.AddObserver("LeftButtonPressEvent", self.leftButtonPressEvent)self.LastPickedActor = Noneself.LastPickedProperty = vtk.vtkProperty()def leftButtonPressEvent(self, obj, event):clickPos = self.GetInteractor().GetEventPosition()picker = vtk.vtkPropPicker()picker.Pick(clickPos[0], clickPos[1], 0, self.GetDefaultRenderer())# 创建一个新的actorself.NewPickedActor = picker.GetActor()# If something was selectedif self.NewPickedActor:# If we picked something before, reset its propertyif self.LastPickedActor:self.LastPickedActor.GetProperty().DeepCopy(self.LastPickedProperty)if self.LastPickedActor == self.NewPickedActor:self.NewPickedActor.GetProperty().DeepCopy(self.LastPickedProperty)self.LastPickedActor=Noneelse:# Save the property of the picked actor so that we can# restore it next timeself.LastPickedProperty.DeepCopy(self.NewPickedActor.GetProperty())# 高亮选中球体,并显示边缘self.NewPickedActor.GetProperty().SetColor(colors.GetColor3d('Red'))self.NewPickedActor.GetProperty().SetDiffuse(1.0)self.NewPickedActor.GetProperty().SetSpecular(0.0)self.NewPickedActor.GetProperty().EdgeVisibilityOn()# 保存最后一个选中的actorself.LastPickedActor = self.NewPickedActorself.OnLeftButtonDown()returndef main():# 创建render和windowrenderer = vtk.vtkRenderer()renderer.SetBackground(colors.GetColor3d('SteelBlue'))renwin = vtk.vtkRenderWindow()renwin.AddRenderer(renderer)renwin.SetSize(640, 600)renwin.SetWindowName('HighlightPickedActor')# 建立interactor(交互操作)interactor = vtk.vtkRenderWindowInteractor()interactor.SetRenderWindow(renwin)# 交互操作方法style = MouseInteractorHighLightActor()style.SetDefaultRenderer(renderer)interactor.SetInteractorStyle(style)randomSequence = vtk.vtkMinimalStandardRandomSequence()randomSequence.SetSeed(8775070)# 添加球体for i in range(NUMBER_OF_SPHERES):source = vtk.vtkSphereSource()# random position and radiusx = randomSequence.GetRangeValue(-5.0, 5.0)randomSequence.Next()y = randomSequence.GetRangeValue(-5.0, 5.0)randomSequence.Next()z = randomSequence.GetRangeValue(-5.0, 5.0)randomSequence.Next()radius = randomSequence.GetRangeValue(0.5, 1.0)randomSequence.Next()source.SetRadius(radius)source.SetCenter(x, y, z)source.SetPhiResolution(11)source.SetThetaResolution(21)mapper = vtk.vtkPolyDataMapper()mapper.SetInputConnection(source.GetOutputPort())actor = vtk.vtkActor()actor.SetMapper(mapper)r = randomSequence.GetRangeValue(0.4, 1.0)randomSequence.Next()g = randomSequence.GetRangeValue(0.1, 1.0)randomSequence.Next()b = randomSequence.GetRangeValue(0.6, 1.0)randomSequence.Next()actor.GetProperty().SetDiffuseColor(r, g, b)actor.GetProperty().SetDiffuse(.8)actor.GetProperty().SetSpecular(.5)actor.GetProperty().SetSpecularColor(colors.GetColor3d('White'))actor.GetProperty().SetSpecularPower(10.0)renderer.AddActor(actor)# 运行interactor.Initialize()renwin.Render()interactor.Start()if __name__ == '__main__':main()

http://www.ds6.com.cn/news/42548.html

相关文章:

  • wordpress 小工具居中苏州seo网站公司
  • 浙江省网站重点学科建设全网热搜关键词排行榜
  • 做网站怎么引用字体重庆百度小额贷款有限公司
  • 寻找手机网站建设百度网址安全中心怎么关闭
  • 弹幕网站怎么做济南网站建设公司选济南网络
  • 怀柔住房和城乡建设委员会网站网络营销课程主要讲什么内容
  • 网站开发软件手机版百度关键词推广
  • 重庆网站建设重庆零臻科技价百度的网址
  • 佛山个人网站建设seo专业培训学费多少钱
  • 简述商业网站建设的流程网站怎么制作教程
  • 微信小程序wordpressseo营销外包
  • wordpress 图片下加文字seo百度刷排名
  • html5 门户网站模版用广州seo推广获精准访问量
  • 成都做网站爱站网关键词
  • 公司网络组建设计与方案seo优化工具软件
  • 做网站企业如何开发网站平台
  • wordpress支持论坛电商seo优化是什么意思
  • 网站开发工程师岗位说明书最近国际新闻大事20条
  • 政府 社区网站建设网络公司优化关键词
  • 可以做外链的网站平台小红书搜索关键词排名
  • 云主机 小型网站网络销售怎么找客源
  • 如何把做的网站放到百度上seo关键技术有哪些
  • 如何鉴别网站有没有做301重定向北京效果好的网站推广
  • 深圳做网站平台维护的公司一元手游平台app
  • 网站建设403seo优化怎么做
  • 网站建设设计图片惠州关键词排名提升
  • 吴江建设局网站打不开了成人计算机培训机构哪个最好
  • salient wordpress 下载怎么样关键词优化
  • 聊城网站建设潍坊深圳网站建设服务
  • 建设通银行官方网站高质量网站外链平台