【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,一经查实,立即删除!

相关文章

机器学习中异常值的处理方式

背景 3Sigma、Z-Score、box plot、Grubbs假设检验四种分布异常值检验方法可以帮助在数据中识别异常值&#xff0c;而在机器学习中&#xff0c;异常值的检测对模型性能和结果的准确性具有重要影响。 3 Sigma法&#xff1a; 原理&#xff1a;通过计算数据的均值和标准差&#xff…

力扣labuladong——一刷day84

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、力扣743. 网络延迟时间 前言 Dijkstra 算法&#xff08;一般音译成迪杰斯特拉算法&#xff09;无非就是一个 BFS 算法的加强版&#xff0c;它们都是从二叉…

(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…

12.2 【Screen配置】khronos模块配置

一,khronos配置配置简介 khronos部分的配置用于指定与Khronos相关的库和参数(例如EGL和WFD库)。 在graphics.conf配置文件中,khronos部分指定GPU和显示驱动程序。只有在系统需要这两种类型的驱动程序之一或两者时,才需要在配置文件中包含此部分。khronos部分由begin khr…

使用169.254开头的IP地址

介绍&#xff1a; 在计算机网络中&#xff0c;当设备无法通过DHCP服务器获取有效的IP地址时&#xff0c;它会尝试使用自动私有IP地址&#xff08;APIPA&#xff09;来分配一个本地链接的IP地址。APIPA地址范围从169.254.0.1到169.254.255.254。这篇文档将介绍关于使用以169.254…

主板部件

▶1.主要部件 主板是计算机的重要部件&#xff0c;主板由集成电路芯片、电子元器件、电路系统、各种总线插座和接口组成&#xff0c;目前主板标准为ATX。主板的主要功能是传输各种电子信号&#xff0c;部分芯片负责初步处理一些外围数据。不同类型的CPU,需要不同主板与之匹配。…

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

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

docker镜像仓库详解(Docker Registry)

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

【卡梅德生物】杂交瘤技术、噬菌体展示技术和兔单B细胞技术制备兔单抗的对比

兔单克隆抗体技术的演进经历了杂交瘤技术、噬菌体展示技术和单B细胞技术三个关键阶段。这些技术的不断进步推动了兔单克隆抗体技术的优化&#xff0c;显著提高了抗体的生产效率、特异性和适用范围。在科研和医药领域&#xff0c;兔单克隆抗体技术因其不断发展的特性而取得了令人…

Java IO流(三)-字节流缓冲流

1字节缓冲区流 1.1 字节缓冲流概述 字节缓冲流&#xff1a; ​ BufferOutputStream&#xff1a;缓冲输出流​ BufferedInputStream&#xff1a;缓冲输入流 构造方法&#xff1a; ​ 字节缓冲输出流&#xff1a;BufferedOutputStream(OutputStream out)​ 字节缓冲输入流&…

Nginx 中 return 和 rewrite 跳转

目录 1.return 跳转 2.rewrite 跳转 如果把https的s去掉&#xff0c;就相当于去访问80端口了&#xff0c;https默认找的是443端口&#xff0c;而80端 口对应的网站我们设置了默认网站&#xff0c;所以如果你删掉了s再访问&#xff0c;就看到我们的默认网站了 我们想要的效果…

LeetCode 1154. 一年中的第几天:2023年最后一道每日一题

【LetMeFly】1154.一年中的第几天&#xff1a;2023年最后一道每日一题 力扣题目链接&#xff1a;https://leetcode.cn/problems/day-of-the-year/ 给你一个字符串 date &#xff0c;按 YYYY-MM-DD 格式表示一个 现行公元纪年法 日期。返回该日期是当年的第几天。 示例 1&…

Python办公自动化 – 定时邮件提醒和音视频文件处理

Python办公自动化 – 定时邮件提醒和音视频文件处理 以下是往期的文章目录&#xff0c;需要可以查看哦。 Python办公自动化 – Excel和Word的操作运用 Python办公自动化 – Python发送电子邮件和Outlook的集成 Python办公自动化 – 对PDF文档和PPT文档的处理 Python办公自动化…

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

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

100个python代码大全详细介绍

1.输出Hello World print("Hello World!")2.计算两个数的和 num1 5 num2 7 sum num1 num2 print("The sum of", num1, "and", num2, "is", sum)3.判断一个数是否是正数 num 10 if num > 0:print("Positive number&quo…

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

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