当前位置: 首页 > 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.xdnf.cn/news/235945.html

相关文章:

  • Java大师成长计划之第8天:Java线程基础
  • 树状结构转换工具类
  • 沙箱逃逸-通过题解了解沙箱逃逸
  • Flow Matching 是什么?
  • 如何做表征对齐?
  • Kettle下载安装教程
  • C# 异步详解
  • 探索MySQL InnoDB:事务、日志与锁的奥秘
  • 从实列中学习linux shell5: 利用shell 脚本 检测硬盘空间容量,当使用量达到80%的时候 发送邮件
  • MCP 自定义python实现server服务,支持离线调用和远程接口访问形式
  • 【IP101】图像处理基础:从零开始学习颜色操作(RGB、灰度化、二值化、HSV变换)
  • Kaamel白皮书:OpenAI 在安全方向的实践
  • Vulkan 学习(16)---- 使用 VertexBuffer
  • Python魔法函数深度解析
  • 关于epoch、batch_size等参数含义,及optimizer.step()的含义及数学过程
  • pinia实现数据持久化插件pinia-plugin-persist-uni
  • 10、属性和数据处理---c++17
  • 突破SQL注入字符转义的实战指南:绕过技巧与防御策略
  • 《Ultralytics HUB:开启AI视觉新时代的密钥》
  • Stack--Queue 栈和队列
  • 前端基础之《Vue(13)—重要API》
  • Dify Agent节点的信息收集策略示例
  • 【效率提升】Vibe Coding时代如何正确使用输入法:自定义短语实现Prompt快捷输入
  • windows系统 压力测试技术
  • Github开通第三方平台OAuth登录及Java对接步骤
  • ES使用之查询方式
  • 空域伦理与AI自主边界的系统建构
  • 《冰雪传奇点卡版》:第二大陆介绍!
  • Java 手写jdbc访问数据库
  • 代理脚本——爬虫