开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 0

cadgit-dev/vtkplotter

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
vtkplotter
/
examples
/
tutorial.py
vtkplotter
/
examples
/
tutorial.py
tutorial.py 5.96 KB
一键复制 编辑 原始数据 按行查看 历史
marcomusy 提交于 2019年12月03日 01:33 +08:00 . 4.11
#!/usr/bin/env python
#
"""
####################################################
#
# Quick tutorial.
# Check out more examples in directories:
# examples/basic
# examples/advanced
# examples/volumetric
# examples/simulations
# examples/other
#
#####################################################
"""
from __future__ import division, print_function
from random import uniform as u
from vtkplotter import *
print(__doc__)
# Declare an instance of the class
vp = Plotter()
# Load a vtk file as a Actor(vtkActor) and visualize it.
# (The actual mesh corresponds to the outer shape of
# an embryonic mouse limb at about 11 days of gestation).
# Choose a tomato color for the internal surface of the mesh.
vp.load(datadir+"270.vtk").c("aqua").bc("tomato")
vp.show() # picks what is automatically stored in python list vp.actors
# Press Esc to close the window and exit python session, or q to continue
#########################################################################################
# Load a vtk file as a vtkActor and visualize it in wireframe style
act = vp.load(datadir+"290.vtk").wireframe()
vp.show() # picks what is automatically stored in vp.actors
# vp.show(act) # same: store act in vp.actors and draws act only
# wire=1 is equivalent to VTK command: act.GetProperty().SetRepresentationToWireframe()
#########################################################################################
# Load 3 actors assigning each a different color,
# by default use their file names as legend entries.
# No need to use any variables, as actors are stored internally in vp.actors:
vp = Plotter(title="3 shapes")
vp.load(datadir+"250.vtk", c=(1, 0.4, 0), alpha=0.3)
vp.load(datadir+"270.vtk", c=(1, 0.6, 0), alpha=0.3)
vp.load(datadir+"290.vtk", c=(1, 0.8, 0), alpha=0.3)
print("Loaded vtkActors: ", len(vp.actors))
vp.show()
#########################################################################################
# Draw a spline through a set of points:
vp = Plotter(title="Example of splines through random points", verbose=0)
pts = [(u(0, 2), u(0, 2), u(0, 2) + i) for i in range(8)] # build python list of points
vp += Points(pts, r=10) # add the actor points to the internal list of actors to be shown # create the vtkActor
for i in range(10):
sp = Spline(pts, smooth=i/10, degree=2).color(i)
sp.legend("smoothing " + str(i/10.0))
vp += sp
vp.show(viewup="z", axes=1, interactive=1) # show internal list of actors
#########################################################################################
# Draw a cloud of points each one with a different color
# which depends on the point position itself.
# No need to instantiate the Plotter class:
rgb = [(u(0, 255), u(0, 255), u(0, 255)) for i in range(5000)]
pts = Points(rgb, c=rgb, alpha=0.8)
show(pts, bg="w", axes=0)
#########################################################################################
# Increase the number of points in a vtk mesh using subdivide()
# and show both before and after the cure in two separate renderers defined by shape=(1,2)
vp = Plotter(shape=(1, 2), axes=False)
a1 = vp.load(datadir+"beethoven.ply", alpha=1)
coords1 = a1.getPoints()
pts1 = Points(coords1, r=4, c="g").legend("#points = " + str(len(coords1)))
vp.show(a1, pts1, at=0)
a2 = a1.clone().subdivide(method=0) # Increasing the number of points of the mesh
coords2 = a2.getPoints()
pts2 = Points(coords2, r=1).legend("#points = " + str(len(coords2)))
vp.show(a2, pts2, at=1, interactive=True)
########################################################################################
# Draw a bunch of simple objects on separate parts of the rendering window:
# split window to best accommodate 9 renderers
vp = Plotter(N=9, title="basic shapes", axes=0, bg="white") # split window in 9 frames
# each object can be moved independently
vp.sharecam = False
vp.show(Arrow([0, 0, 0], [1, 1, 1]), at=0)
vp.show(Line([0, 0, 0], [1, 1, 1]), at=1)
vp.show(Points([[0, 0, 0], [1, 1, 1]]), at=2)
vp.show(Text("Hello!", pos=(0, 0, 0)), at=3)
vp.show(Sphere(), at=4)
vp.show(Cube(), at=5)
vp.show(Torus(), at=6)
vp.show(Spring(), at=7)
vp.show(Cylinder(), at=8, interactive=1)
########################################################################################
# Draw a bunch of objects from various mesh formats. Loading is automatic.
vp = Plotter(shape=(3, 3), bg="white") # split window in 3 rows and 3 columns
vp.sharecam = False # each object can be moved independently
vp.show(datadir+"beethoven.ply", at=0, axes=0) # dont show axes, add a ruler
vp.show(datadir+"cow.byu", at=1, zoom=1.15) # make it 15% bigger
vp.show(datadir+"limb.pcd", at=2)
vp.show(datadir+"ring.gmsh", at=3)
vp.show(datadir+"images/dog.jpg",at=4) # 2d images can be loaded the same way
vp.show(datadir+"shuttle.obj", at=5)
vp.show(datadir+"man.vtk", at=6, axes=2) # show negative axes from (0, 0, 0)
vp.show(datadir+"teapot.xyz", at=7, axes=3) # hide negative axes
vp.show(datadir+"pulley.vtu", at=8, interactive=True)
########################################################################################
# Draw the same object with different surface textures
# (in vtkplotter/textures, alternatibvely a jpg/png file can be specified)
vp = Plotter(shape=(3, 3), verbose=0, axes=0)
mat = ["aqua", "gold2", "metal1", "ivy", "paper", "blue", "white2", "wood3", "wood7"]
for i, mname in enumerate(mat): # mname can be any jpeg file
sp = vp.load(datadir+"beethoven.ply").texture(mname).legend(mname)
vp.show(sp, at=i)
vp.show(interactive=1)
#########################################################################################
# Cut a set of shapes with a plane that goes through the
# point at x=500 and has normal (0, 0.3, -1).
# Wildcards can be used to load multiple files or entire directories:
vp = Plotter(title="Cut a surface with a plane", verbose=0)
vp.load(datadir+"2*0.vtk")
for a in vp.actors:
a.c("orange").bc("aqua")
a.cutWithPlane(origin=(500, 0, 0), normal=(0, 0.3, -1))
vp.show(axes=1)
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

暂无描述
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cadgit-dev/vtkplotter.git
git@gitee.com:cadgit-dev/vtkplotter.git
cadgit-dev
vtkplotter
vtkplotter
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /