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

Learning vtkjs之ImplicitBoolean

隐式函数布尔操作

介绍

vtkImplicitBoolean 允许对隐式函数(如平面、球体、圆柱体和盒子)进行布尔组合。操作包括并集、交集和差集。可以指定多个隐式函数(所有函数都使用相同的操作进行组合)。

支持的操作:‘UNION’(<=0),‘INTERSECTION’(=1),‘DIFFERENCE’(>=2)

效果

在这里插入图片描述

核心代码

主要是隐式函数添加,然后执行操作,可视化是需要借助vtkSampleFunction来采样的

	const lCylCut = vtkImplicitBoolean.newInstance({operation: Operation.UNION,functions: [cyl, pLeft],});const rCylCut = vtkImplicitBoolean.newInstance({operation: Operation.INTERSECTION,});rCylCut.addFunction(lCylCut);rCylCut.addFunction(pRight);

完整逻辑

 	const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({background: [0, 0, 0],rootContainer: vtkContainerRef.current,});const renderer = fullScreenRenderer.getRenderer();const renderWindow = fullScreenRenderer.getRenderWindow();const actor = vtkActor.newInstance();renderer.addActor(actor);const mapper = vtkMapper.newInstance();actor.setMapper(mapper);// Build pipeline. Boolean together some implicit functions and then sample, isosurface themconst pLeft = vtkSphere.newInstance({center: [-6.0, 0, 0],radius: 0.8,});const pRight = vtkPlane.newInstance({normal: [1, 0, 0],origin: [5, 0, 0],});const cyl = vtkCylinder.newInstance({radius: 0.5,center: [0, 0, 0],axis: [1, 0, 0],});const lCylCut = vtkImplicitBoolean.newInstance({operation: Operation.UNION,functions: [cyl, pLeft],});const rCylCut = vtkImplicitBoolean.newInstance({operation: Operation.INTERSECTION,});rCylCut.addFunction(lCylCut);rCylCut.addFunction(pRight);const sample = vtkSampleFunction.newInstance({implicitFunction: rCylCut,sampleDimensions: [100, 100, 100],modelBounds: [-7.5, 7.5, -1, 1, -1, 1],});const mCubes = vtkImageMarchingCubes.newInstance({ contourValue: 0.0 });// Connect the pipeline propermCubes.setInputConnection(sample.getOutputPort());mapper.setInputConnection(mCubes.getOutputPort());renderer.resetCamera();renderWindow.render();

全部代码都放到github上了
新坑_Learning vtkjs_git地址
关注我,我持续更新vtkjs的example学习案例

也欢迎各位给我提意见,技术交流~

大鸿

WeChat : HugeYen
WeChat Public Account : BIM树洞

做一个静谧的树洞君

用建筑的语言描述IT事物;

用IT的思维解决建筑问题;

共建BIM桥梁,聚合团队。

本学习分享资料不得用于商业用途,仅做学习交流!!如有侵权立即删除!!

http://www.dtcms.com/a/166277.html

相关文章:

  • 脏读、不可重复读、幻读示例
  • Clang-Tidy协助C++编译期检查
  • 在Windows系统上如何用Manifest管理嵌入式项目
  • 《Python实战进阶》No45:性能分析工具 cProfile 与 line_profiler
  • 架构进阶:72页集管IT基础设施蓝图设计方案【附全文阅读】
  • 软考中级-软件设计师 数据库(手写笔记)
  • 算法-冒泡排序
  • Ecology中拦截jquery.ajax请求接口后的数据
  • 【免费数据】2000-2020年中国4km分辨率逐日气象栅格数据(含9个气象变量)
  • windows11 编译 protobuf-3.21.12 c++
  • 大连理工大学选修课——机器学习笔记(4):NBM的原理及应用
  • 机器学习|通过线性回归了解算法流程
  • 制作一款打飞机游戏35:生成系统
  • YOLO视觉模型可视化训练与推理测试工具
  • 分享高德地图获取矢量面的方法和python脚本
  • BI平台是什么意思?一文讲清BI平台的具体应用!
  • 线性微分方程与非线性微分方程
  • Windows查看和修改IP,IP互相ping通
  • 智能机器人在物流行业的应用:效率提升与未来展望
  • 【QT】编写第一个 QT 程序 对象树 Qt 编程事项 内存泄露问题
  • 【SystemC初认识】SystemC是什么?有哪些主要组件?如何简单使用?
  • Java高阶程序员学习计划(详细到天,需有一定Java基础)
  • TimeDistill:通过跨架构蒸馏的MLP高效长期时间序列预测
  • LeRobot 项目部署运行逻辑(四)——control_robot.py
  • 使用 Spring Data Redis 实现 Redis 数据存储详解
  • L35.【LeetCode题解】转置矩阵(C语言)
  • 11.Spring Boot 3.1.5 中使用 SpringDoc OpenAPI(替代 Swagger)生成 API 文档
  • 2025.4.28 Vue.js 学习笔记
  • Rancher 2.6.3企业级容器管理平台部署实践
  • 百家号等新媒体私信入口是否可以聚合到企业微信的客服,如何实现