【VTK三维重建-体绘制】第五期 vtkLODProp3D

很高兴在雪易的CSDN遇见你 

VTK技术爱好者 QQ:870202403


前言

本文分享VTK中体绘制中的vtkLODProp3D对象,希望对各位小伙伴有所帮助!

感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步!

你的点赞就是我的动力(^U^)ノ~YO

  


1. vtkLODProp3D

        vtkLODProp3D与vtkVolume用法类似,两者均继承自vtkProp3D。但vtkLODProp3D支持多个Mapper、Property和Texture对象,并由它选择Mapper对象实现绘制。例如,当绘制一个数据量非常大的不规则网格数据时,可以添加一个vtkPolyDataMapper来渲染一个表面模型,作为最低级别分辨率的渲染;然后将数据采样为vtkImageData数据,并添加一个vtkVolumeTextureMapper3D进行体绘制,作为一个中等级别渲染;最后通过ZSweep技术(vtkUnstructureGridVolumeZSWeepMapper)渲染原始数据,作为最高级别的渲染。vtkLODProp3D在渲染过程中,会为每一个Mapper估计一个渲染时间,并选择一个最优的实现渲染。

        其重要参数有:

1.1 获取边界包围盒

  /*** Standard vtkProp method to get 3D bounds of a 3D prop*/double* GetBounds() VTK_SIZEHINT(6) override;void GetBounds(double bounds[6]) { this->vtkProp3D::GetBounds(bounds); }

1.2 添加不同级别的Mapper

  //@{/*** 添加不同级别的的映射器、属性、背面属性、纹理和渲染时间。* 属性和纹理字段可以设置为NULL(其他方法包含在不允许NULL变量的脚本访问中)。* time字段可以设置为0.0,表示没有提供渲染时间的初始猜测。* 返回的整数值是一个ID,稍后可以使用该ID删除该LOD,或者将其设置为所选LOD。* Add a level of detail with a given mapper, property, backface property,* texture, and guess of rendering time.  The property and texture fields* can be set to NULL (the other methods are included for script access* where null variables are not allowed). The time field can be set to 0.0* indicating that no initial guess for rendering time is being supplied.* The returned integer value is an ID that can be used later to delete* this LOD, or set it as the selected LOD.*/int AddLOD(vtkMapper* m, vtkProperty* p, vtkProperty* back, vtkTexture* t, double time);int AddLOD(vtkMapper* m, vtkProperty* p, vtkTexture* t, double time);int AddLOD(vtkMapper* m, vtkProperty* p, vtkProperty* back, double time);int AddLOD(vtkMapper* m, vtkProperty* p, double time);int AddLOD(vtkMapper* m, vtkTexture* t, double time);int AddLOD(vtkMapper* m, double time);int AddLOD(vtkAbstractVolumeMapper* m, vtkVolumeProperty* p, double time);int AddLOD(vtkAbstractVolumeMapper* m, double time);int AddLOD(vtkImageMapper3D* m, vtkImageProperty* p, double time);int AddLOD(vtkImageMapper3D* m, double time);//@}

1.3 获取LOD数量及当前Index

  //@{/*** Get the current number of LODs.*/vtkGetMacro(NumberOfLODs, int);//@}//@{/*** Get the current index, used to determine the ID of the next LOD that is* added.  Useful for guessing what IDs have been used (with NumberOfLODs,* without depending on the constructor initialization to 1000.*/vtkGetMacro(CurrentIndex, int);//@}

1.4 删除指定Index的LOD

  /*** Delete a level of detail given an ID. This is the ID returned by the* AddLOD method*/void RemoveLOD(int id);

1.5 获取指定Index的属性

  //@{/*** Methods to set / get the property of an LOD. Since the LOD could be* a volume or an actor, you have to pass in the pointer to the property* to get it. The returned property will be NULL if the id is not valid,* or the property is of the wrong type for the corresponding Prop3D.*/void SetLODProperty(int id, vtkProperty* p);void GetLODProperty(int id, vtkProperty** p);void SetLODProperty(int id, vtkVolumeProperty* p);void GetLODProperty(int id, vtkVolumeProperty** p);void SetLODProperty(int id, vtkImageProperty* p);void GetLODProperty(int id, vtkImageProperty** p);//@}

1.6 设置/获取Mapper

  //@{/*** Methods to set / get the mapper of an LOD. Since the LOD could be* a volume or an actor, you have to pass in the pointer to the mapper* to get it. The returned mapper will be NULL if the id is not valid,* or the mapper is of the wrong type for the corresponding Prop3D.*/void SetLODMapper(int id, vtkMapper* m);void GetLODMapper(int id, vtkMapper** m);void SetLODMapper(int id, vtkAbstractVolumeMapper* m);void GetLODMapper(int id, vtkAbstractVolumeMapper** m);void SetLODMapper(int id, vtkImageMapper3D* m);void GetLODMapper(int id, vtkImageMapper3D** m);//@}/*** Get the LODMapper as an vtkAbstractMapper3D.  It is the user's* respondibility to safe down cast this to a vtkMapper or vtkVolumeMapper* as appropriate.*/vtkAbstractMapper3D* GetLODMapper(int id);

1.7 获取Backface属性

  //@{/*** Methods to set / get the backface property of an LOD. This method is only* valid for LOD ids that are Actors (not Volumes)*/void SetLODBackfaceProperty(int id, vtkProperty* t);void GetLODBackfaceProperty(int id, vtkProperty** t);//@}

1.8 获取纹理

  //@{/*** Methods to set / get the texture of an LOD. This method is only* valid for LOD ids that are Actors (not Volumes)*/void SetLODTexture(int id, vtkTexture* t);void GetLODTexture(int id, vtkTexture** t);//@}

1.9 EnableLOD

  //@{/*** Enable / disable a particular LOD. If it is disabled, it will not* be used during automatic selection, but can be selected as the* LOD if automatic LOD selection is off.*/void EnableLOD(int id);void DisableLOD(int id);int IsLODEnabled(int id);//@}

1.10 设置LOD的级别

  //@{/*** 设置特定LOD的级别。当选择一个LOD进行渲染时,因为它在分配的时间内具有最大的渲染时间,* 然后检查所有LOD,看看是否有任何LOD可以渲染得更快,但具有较低(更高分辨率/更好)的级别。* 该数量为双精度,以确保可以插入2和3之间* Set the level of a particular LOD. When a LOD is selected for* rendering because it has the largest render time that fits within* the allocated time, all LOD are then checked to see if any one can* render faster but has a lower (more resolution/better) level.* This quantity is a double to ensure that a level can be inserted* between 2 and 3.*/void SetLODLevel(int id, double level);double GetLODLevel(int id);double GetLODIndexLevel(int index);//@}

1.11 获取指定Index的LOD渲染时间

  //@{/*** Access method that can be used to find out the estimated render time* (the thing used to select an LOD) for a given LOD ID or index.* Value is returned in seconds.*/double GetLODEstimatedRenderTime(int id);double GetLODIndexEstimatedRenderTime(int index);//@}

1.12 开启/关闭自动选择渲染的LOD

  //@{/*** 开启/关闭自动选择LOD。默认为开启。* 如果它是关闭的,那么无论呈现时间或所需的更新速率如何,都会呈现SelectedLODID。* Turn on / off automatic selection of LOD.* This is on by default. If it is off, then the SelectedLODID is* rendered regardless of rendering time or desired update rate.*/vtkSetClampMacro(AutomaticLODSelection, vtkTypeBool, 0, 1);vtkGetMacro(AutomaticLODSelection, vtkTypeBool);vtkBooleanMacro(AutomaticLODSelection, vtkTypeBool);//@}

1.13 设置选择的ID

  //@{/*** Set the id of the LOD that is to be drawn when automatic LOD selection* is turned off.*/vtkSetMacro(SelectedLODID, int);vtkGetMacro(SelectedLODID, int);//@}

1.14 返回对象

  //@{/*** For some exporters and other other operations we must be* able to collect all the actors or volumes. These methods* are used in that process.*/void GetActors(vtkPropCollection*) override;void GetVolumes(vtkPropCollection*) override;//@}

1.15 开始/关闭自动拾取LOD

  //@{/*** 开启/关闭自动Pick的LOD。默认是开启的。* 如果它是关闭的,那么无论呈现时间或所需的更新速率如何,都会呈现SelectedLODID。* Turn on / off automatic selection of picking LOD.* This is on by default. If it is off, then the SelectedLODID is* rendered regardless of rendering time or desired update rate.*/vtkSetClampMacro(AutomaticPickLODSelection, vtkTypeBool, 0, 1);vtkGetMacro(AutomaticPickLODSelection, vtkTypeBool);vtkBooleanMacro(AutomaticPickLODSelection, vtkTypeBool);//@}

1.16 设置选择Pick的LOD Index

  //@{/*** Set the id of the LOD that is to be used for picking when automatic* LOD pick selection is turned off.*/void SetSelectedPickLODID(int id);vtkGetMacro(SelectedPickLODID, int);//@}

注意:vtkVolumeTextureMapper3D在9.0.3及以后的版本中已不存在,由vtkOpenGLGPUVolumeRayCastMapper代替。

2. 示例

      

#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkLODProp3D.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyData.h>
#include <vtkSphereSource.h>
#include <vtkCallbackCommand.h>
#include <vtkProperty.h>void RefreshCallback( vtkObject* vtkNotUsed(caller),long unsigned int vtkNotUsed(eventId),void* clientData,void* vtkNotUsed(callData) )
{vtkSmartPointer<vtkLODProp3D> lodProp = static_cast<vtkLODProp3D*>(clientData);std::cout << "Last rendered LOD: " << lodProp->GetLastRenderedLODID() << std::endl;
}int main (int, char *[])
{// High res spherevtkSmartPointer<vtkSphereSource> highResSphereSource = vtkSmartPointer<vtkSphereSource>::New();int res = 100;highResSphereSource->SetThetaResolution(res);highResSphereSource->SetPhiResolution(res);highResSphereSource->Update();vtkSmartPointer<vtkPolyDataMapper> highResMapper = vtkSmartPointer<vtkPolyDataMapper>::New();highResMapper->SetInputConnection(highResSphereSource->GetOutputPort());// Low res spherevtkSmartPointer<vtkSphereSource> lowResSphereSource = vtkSmartPointer<vtkSphereSource>::New();vtkSmartPointer<vtkPolyDataMapper> lowResMapper = vtkSmartPointer<vtkPolyDataMapper>::New();lowResMapper->SetInputConnection(lowResSphereSource->GetOutputPort());vtkSmartPointer<vtkProperty> propertyLowRes = vtkSmartPointer<vtkProperty>::New();propertyLowRes->SetDiffuseColor(0.89, 0.81, 0.34);propertyLowRes->SetInterpolationToFlat();vtkSmartPointer<vtkProperty> propertyHighRes = vtkSmartPointer<vtkProperty>::New();propertyHighRes->SetDiffuseColor(1.0, 0.3882, 0.2784);propertyHighRes->SetInterpolationToFlat();vtkSmartPointer<vtkLODProp3D> prop = vtkSmartPointer<vtkLODProp3D>::New();prop->AddLOD(lowResMapper, propertyLowRes, 0.0);prop->AddLOD(highResMapper, propertyHighRes, 0.0);std::cout << "There are " << prop->GetNumberOfLODs() << " LODs" << std::endl;// A renderer and render windowvtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();renderWindow->AddRenderer(renderer);//prop->SetAllocatedRenderTime(1e-6,renderer);prop->SetAllocatedRenderTime(1e-10,renderer);// An interactorvtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();renderWindowInteractor->SetRenderWindow(renderWindow);// Add the actors to the scenerenderer->AddActor(prop);vtkSmartPointer<vtkCallbackCommand> refreshCallback =vtkSmartPointer<vtkCallbackCommand>::New();refreshCallback->SetCallback (RefreshCallback);refreshCallback->SetClientData(prop);renderWindow->AddObserver(vtkCommand::ModifiedEvent,refreshCallback);renderWindow->Render();// Begin mouse interactionrenderWindowInteractor->Start();return EXIT_SUCCESS;
}

结论:

感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步!

你的赞赏是我的最最最最大的动力(^U^)ノ~YO

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/597100.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

(Java企业 / 公司项目)Nacos的怎么搭建多环境配置?(含相关面试题)(二)

上一篇讲了一个单体服务中配置&#xff0c;传统的Nacos配置但是在微服务架构当中肯定都是多环境下配置&#xff0c;比如生产环境&#xff0c;dev测试环境等等。 第一种方式模拟开始&#xff1a; 首先展示在生产环境中nacos如何配置&#xff0c;在模块下新建一个配置文件&…

达梦数据库安装超详细教程(小白篇)

文章目录 达梦数据库一、达梦数据库简介二、达梦数据库下载三、达梦数据库安装1. 解压2. 安装 四、初始化数据库五、DM管理工具 达梦数据库 一、达梦数据库简介 ​ 达梦数据库管理系统是达梦公司推出的具有完全自主知识产权的高性能数据库管理系统&#xff0c;简称DM。 达梦数…

本地站点通过主备冗余专线连接上云

本地站点通过主备冗余专线连接上云 您可以使用两条物理专线以主备方式将本地数据中心IDC&#xff08;Internet Data Center&#xff09;接入阿里云。采用主备接入方式时&#xff0c;正常情况下仅主用线路在进行流量转发。阿里云按照您配置的健康检查的发包时间间隔探测主用线路…

【Midjourney】AI绘画新手教程(一)登录和创建服务器,生成第一幅画作

一、登录Discord 1、访问Discord官网 使用柯學尚网&#xff08;亲测非必须&#xff0c;可加快响应速度&#xff09;访问Discord官方网址&#xff1a;https://discord.com 选择“在您的浏览器中打开Discord” 然后&#xff0c;注册帐号、购买套餐等&#xff0c;在此不做缀述。…

uniapp+echarts开发APP版本教程

需求 需要在uniappecharts展示图表功能&#xff0c;是APP版本&#xff0c;不是小程序。找了好多教程都乱七八糟的&#xff0c;无法实现。以下是效果图 教程 1、安装插件 HBuilder安装echarts插件&#xff0c;插件地址如下。安装完成后在uni_modules/lime-echart文件夹下 ht…

微信小程序+前后端开发学习材料

目录结构 全局文件 1.app.json 文件 用来对微信小程序进行全局配置&#xff0c;决定页面文件的路径、窗口表现、设置网络超时时间、设置多 tab 等。文件内容为一个 JSON 对象。 1.1 page用于指定小程序由哪些页面组成&#xff0c;每一项都对应一个页面的 路径&#xff08;含文…

docker镜像仓库详解(Docker Registry)

本片文章主要是对docker的镜像仓库进行了详解。其中包含了一些常用了 docker 指令&#xff0c;通过举例进行详解。也详细解释了镜像仓库的工作机制和常见的镜像仓库。也实际拉去和运行了一些镜像。希望本篇文章会对你有所帮助&#xff01; 文章目录 一、什么是Docker Registry …

网工内推 | 事业单位、上市公司网工,五险一金补贴多

01 中科中山药物创新研究院 招聘岗位&#xff1a;网络工程师 职责描述&#xff1a; 1.负责信息化网络数据安全&#xff0c;加固网络安全、渗透测试、风险评估、漏洞扫描、风险管理和风险评估方法。对防火墙、IDS、IPS、蜜罐、防DDOS、VPN等设备的运行管理&#xff1b; 2.负责机…

CodeWave智能开发平台--03--目标:应用创建--01模板创建依赖问题修改

摘要 本文是网易数帆CodeWave智能开发平台系列的第03篇&#xff0c;主要介绍了基于CodeWave平台文档的新手入门进行学习&#xff0c;实现一个完整的应用&#xff0c;本文主要完成模板创建时的依赖问题解决。 CodeWave智能开发平台的03次接触 CodeWave参考资源 网易数帆Code…

脚本接收参数,执行shell指令

洗礼 上午开完会&#xff0c;5个小时内丧失思考行动能力&#xff0c;10个小时内不敢说话&#xff0c;深刻把握会议精神&#xff0c;反省自己。因为经常用到脚本执行任务&#xff0c;所以记录一下一些常用的脚本接收参数&#xff0c;执行shell指令。 python脚本 Python脚本是…

vercel部署Gemini pro

一、注册一个vercel账号&#xff08;这个东西类似于第三方的github pages&#xff0c;能部署github中的项目&#xff09; 二、注册结束后&#xff0c;填写github的账号&#xff08;需要事先在该github账号中fork一个gemini的repository&#xff09; 三、babaohuang/GeminiPro…

阶段十-分布式-Redis01

第一章 Redis入门 1.1 节 什么是NoSql型数据库 NoSQL ,泛指非关系型的数据库, NoSQL Not Only SQL,它可以作为关系型数据库的良好补充。 NoSQL 不依赖业务逻辑方式存储&#xff0c;而以简单的key-value模式存储。因此大大的增加了数据库的扩展能力。NoSQL与SQL数据库区别对比如…

CMake入门教程【核心篇】包含目录(include_directories)

&#x1f608;「CSDN主页」&#xff1a;传送门 &#x1f608;「Bilibil首页」&#xff1a;传送门 &#x1f608;「本专栏容」&#xff1a;CMake入门教程 &#x1f608;「动动你的小手」&#xff1a;点赞&#x1f44d;收藏⭐️评论&#x1f4dd; 文章目录 1. 基本用法2. 添加单个…

快手推荐算法工程师三面回顾

快手三次技术面试一次HR面试的简单回顾&#xff0c;希望对大家有所启发。 一面 面试官一上来就让写算法题&#xff0c;第一个是计算岛屿数量&#xff0c;第二个是最长回文字串。 然后就是介绍自己的论文。对于论文的工作&#xff0c;面试官只是在问关于论文的问题&#xff0…

【PCB专题】Allegro封装更新焊盘

在PCB封装的绘制中&#xff0c;有时会出现需要更新焊盘的情况。比如在制作封装的过程中发现焊盘做的不对而使用PAD_Designer重新更新了焊盘。 那在PCB中如何更新已经修改过的焊盘呢&#xff1f; 打开封装&#xff0c;选择Tools->Padstack->Refresh... 选择Refresh all …

中国FinOps现状调查报告(2023)》亮点解读

今年以来&#xff0c;我们举办了多期FinOps的专题分享&#xff0c;邀请了美图、腾讯、B站、趣丸、知乎等厂商和行业专家&#xff0c;分享他们在FinOps领域的经验。我们也发现越来越多的人对FinOps产生了浓厚的兴趣&#xff0c;而且FinOps的成熟度也在逐渐提升。 降本增效&…

关键字:instanceof关键字

在 Java 中&#xff0c;instanceof关键字用于检查一个对象是否是某个特定类或其子类的实例。它的语法如下&#xff1a; 其中&#xff0c;Object是要检查的对象&#xff0c;Class是要检查的类或接口。 instanceof关键字的返回值是一个布尔值&#xff0c;如果对象Object是类Cla…

Docker介绍、常用命令、项目部署

什么是Docker 简单说&#xff1a;Docker就是一个虚拟机&#xff0c;专业说&#xff1a;它是一个开源的容器平台。它和我们常用的VMware有很多相似的地方。 名词解释 镜像/images 由本体打包出来的文件。并不是文件本身&#xff0c;但是具有该文件的功能。举个不太贴切的例子&…

Android Matrix剪切clipPath缩放scale图片postTranslate圆形放大镜,Kotlin(2)

Android Matrix剪切clipPath缩放scale图片postTranslate圆形放大镜&#xff0c;Kotlin&#xff08;2&#xff09; 在 Android Matrix剪切clipPath缩放scale图片postTranslate圆形放大镜&#xff0c;Kotlin&#xff08;1&#xff09; Android Matrix剪切clipPath缩放scale图片po…

LCR 174. 寻找二叉搜索树中的目标节点

解题思路&#xff1a; 二叉搜索树一般采用中序遍历&#xff08;从小到大排列&#xff09;。 class Solution {int res, cnt;public int findTargetNode(TreeNode root, int cnt) {this.cnt cnt;dfs(root);return res;}void dfs(TreeNode root) {if(root null) return;dfs(ro…