加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
c.py 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
dmisdm 提交于 2020-10-18 06:44 . first
import vtk
def main():
# Create points on a sphere
sphereSource = vtk.vtkSphereSource()
sphereSource.Update()
colors = vtk.vtkNamedColors()
polydata = vtk.vtkPolyData()
polydata.SetPoints(sphereSource.GetOutput().GetPoints())
splatter = vtk.vtkGaussianSplatter()
splatter.SetInputData(polydata)
splatter.SetSampleDimensions(50,50,50)
splatter.SetRadius(0.5)
splatter.ScalarWarpingOff()
surface = vtk.vtkContourFilter()
surface.SetInputConnection(splatter.GetOutputPort())
surface.SetValue(0,0.01)
# Create a mapper and actor
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(surface.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# Visualize
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(actor)
renderer.SetBackground(colors.GetColor3d("white"))
renderWindow.Render()
renderWindowInteractor.Start()
if __name__ == '__main__':
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化