news 2026/9/2 19:21:45

FilledPolygon切割一个三维模型并用颜色填充其横截面

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
FilledPolygon切割一个三维模型并用颜色填充其横截面

一:主要的知识点

1、说明

本文只是教程内容的一小段,因博客字数限制,故进行拆分。主教程链接:vtk教程——逐行解析官网所有Python示例-CSDN博客

2、知识点纪要

本段代码主要涉及的有①切割模型并用颜色填充横截面


二:代码及注释

import vtkmodules.vtkRenderingOpenGL2 from vtkmodules.vtkCommonColor import vtkNamedColors from vtkmodules.vtkCommonDataModel import vtkPlane, vtkPolyData from vtkmodules.vtkFiltersSources import vtkSphereSource from vtkmodules.vtkFiltersCore import vtkCutter, vtkFeatureEdges, vtkStripper from vtkmodules.vtkRenderingCore import ( vtkActor, vtkPolyDataMapper, vtkProperty, vtkRenderWindow, vtkRenderWindowInteractor, vtkRenderer ) def main(): colors = vtkNamedColors() sphere = vtkSphereSource() sphere.SetRadius(50) sphere.SetThetaResolution(100) sphere.SetPhiResolution(100) # cubeMapper = vtkPolyDataMapper() # cubeMapper.SetInputConnection(cube.GetOutputPort()) plane = vtkPlane() plane.SetOrigin(20, 0, 0) plane.SetNormal(1, 0, 0) cutter = vtkCutter() cutter.SetCutFunction(plane) cutter.SetInputConnection(sphere.GetOutputPort()) cutter.Update() # FeatureEdges = vtkFeatureEdges() # FeatureEdges.SetInputConnection(cutter.GetOutputPort()) # FeatureEdges.BoundaryEdgesOn() # FeatureEdges.FeatureEdgesOff() # FeatureEdges.ManifoldEdgesOff() # FeatureEdges.NonManifoldEdgesOff() # FeatureEdges.Update() cutStrips = vtkStripper() cutStrips.SetInputConnection(cutter.GetOutputPort()) cutStrips.Update() cutPoly = vtkPolyData() cutPoly.SetPoints(cutStrips.GetOutput().GetPoints()) cutPoly.SetPolys(cutStrips.GetOutput().GetLines()) cutMapper = vtkPolyDataMapper() cutMapper.SetInputData(cutPoly) backface = vtkProperty() backface.SetColor(colors.GetColor3d('Gold')) cutActor = vtkActor() cutActor.SetMapper(cutMapper) cutActor.GetProperty().SetColor(colors.GetColor3d('Yellow')) cutActor.GetProperty().SetEdgeColor(colors.GetColor3d('Red')) cutActor.GetProperty().SetLineWidth(2) cutActor.GetProperty().EdgeVisibilityOn() # cutActor.GetProperty().SetOpacity(0.7) cutActor.SetBackfaceProperty(backface) ren = vtkRenderer() ren.AddActor(cutActor) # Add renderer to renderwindow and render renWin = vtkRenderWindow() renWin.AddRenderer(ren) renWin.SetSize(600, 400) renWin.SetWindowName('FilledPolygon') iren = vtkRenderWindowInteractor() iren.SetRenderWindow(renWin) ren.SetBackground(colors.GetColor3d('DarkSlateGray')) ren.GetActiveCamera().SetPosition(223, -122, -91) renWin.Render() camera = ren.GetActiveCamera() camera.SetPosition(151.519511, 12.795117, -223.586044) camera.SetFocalPoint(12.518283, 1.963242, 7.618042) camera.SetViewUp(0.740690, -0.523767, 0.420769) camera.SetDistance(269.988889) camera.SetClippingRange(175.347580, 366.490816) camera.Zoom(1.5) iren.Start() if __name__ == '__main__': main()
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/3 0:55:55

通达信资金流量对比指标公式

{}总额:AMOUNT; 买:IF(OC AND (C-REF(C,1))/REF(C,1)*100>9.8,AMOUNT,AMOUNT/((H-L)*2-Abs(O-C))*(C-L)); 买%:买/AMOUNT*100; 流进:AMOUNT*买%/10000000000; 流出:AMOUNT/100000000-流进; 净流:流进-流出; 总额3:SUM(AMOUNT,3); 流进3:SUM(流进,3); 流出3:SUM(流出,3); 净流…

作者头像 李华
网站建设 2026/9/3 1:23:18

一文看懂openapi-python-client生成的SDK和openai-python库的风格差异

本文由「大千AI助手」原创发布,专注用真话讲AI,回归技术本质。拒绝神话或妖魔化。搜索「大千AI助手」关注我,一起撕掉过度包装,学习真实的AI技术! 两者在底层原理(都支持同步/异步、都基于强类型模型、都对…

作者头像 李华
网站建设 2026/9/2 15:47:49

Ubuntu24.04 日常运维合集

食用指南 本文汇总在工作过程中遇到的Ubuntu24.04操作系统运维问题,以便不时之需,每个Q对于一个问题。 Q1. 重置密码 环境:Virtual Box 开机获取鼠标焦点后立即长按 Shift 键: 然后按 e 进入编辑模式,将 “ro quiet …

作者头像 李华
网站建设 2026/9/2 23:30:25

工业零代码平台是什么?能做什么?

低零代码(No-Code)是可视化应用开发工具,通过拖拽组件、配置参数快速构建应用,降低技术门槛。工业零代码平台是一种专为工业领域设计的应用开发工具,无需编写代码即可通过可视化配置快速构建定制化应用系统。其核心价值在于降低技…

作者头像 李华
网站建设 2026/9/3 5:05:32

四大顶流蛋白质预测模型实战指南:从部署到测试全流程解锁

四大顶流蛋白质预测模型实战指南:从部署到测试全流程解锁 蛋白质结构与功能的精准预测是生物信息学领域的核心难题,也是药物研发、疾病机制解析的关键突破口。随着AI技术的爆发,ESM2、ScanNet、RFdiffusion、RoseTTAFold-All Atom等前沿模型…

作者头像 李华
网站建设 2026/9/2 16:38:17

MindSpore 2.0 函数式编程与Ascend图模式加速指南

在昇腾(Ascend)计算产业生态中,MindSpore作为核心AI框架,其最大的优势在于“端边云协同”以及与Ascend硬件的深度融合。对于开发者而言,从MindSpore 1.x的面向对象编程过渡到MindSpore 2.x的函数式编程(Fun…

作者头像 李华