当前位置: 首页 > 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.bjxfkj.com.cn/article/107029.html

相关文章:

  • 网站建设新际关键词推广操作
  • 我国政府网站建设情况最新国内新闻50条简短
  • 团中央建设的未成年人专属网站发稿媒体平台
  • 网站图怎么做会高清图片谷歌网站收录提交入口
  • 网站开发语言哪种简单厦门网站综合优化贵吗
  • 产品经理兼职做网站报酬百度推广代理查询
  • 石家庄网站建设推广电话军事网站大全军事网
  • 常州商城网站制作公司建立网站需要什么
  • 微信公众号免费制作成微网站网络销售怎么做才能做好
  • 网站开发框架的作用金融网站推广圳seo公司
  • 网站图片怎么做altgoogle官方下载安装
  • 营销型网站外包站长论坛
  • 百度一下做网站最新中央人事任免
  • 北京南昌网站制作seo零基础教学视频
  • 网站搭建设计方案沧州网站优化公司
  • 九天智能建站软件赣州seo唐三
  • 星巴克营销策划方案西安百度seo代理
  • 网站排名优化如何做今天新闻头条
  • 免费logo图片生成器网址深圳搜索优化排名
  • 为什么政府网站总是做的很垃圾推广自己产品的文案
  • Wordpress在中国建站篮网目前排名
  • 进出口贸易网站制作seo算法培训
  • 专门做恐怖电影的网站发帖效果好的网站
  • 哪个网站上做ppt比较好个人开发app可以上架吗
  • centos做网站168推广网
  • 豫建设标 网站成都搜索优化整站优化
  • 网站建设的目标关键词包括哪些内容
  • 贵阳做网站seo宁波网站建设网站排名优化
  • 网站开发公司的选择营销渠道有哪几种
  • 怎样做浏览的网站不被发现脚本外链平台