显示图像

#include <vtkActor.h>
#include <vtkCellArray.h>
#include <vtkLine.h>
#include <vtkLineSource.h>

#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkTubeFilter.h>/*
* This example creates a tube around a line.
* This is helpful because when you zoom the camera,
* the thickness of a line remains constant,
* while the thickness of a tube varies.
* */int main(int, char* [])
{vtkNew<vtkNamedColors> colors;// Create a linevtkNew<vtkLineSource> lineSource;lineSource->SetPoint1(1.0, 0.0, 0.0);lineSource->SetPoint2(0.0, 1.0, 0.0);double center[3] = { (lineSource->GetPoint1()[0] + lineSource->GetPoint2()[0]) / 2, (lineSource->GetPoint1()[1] + lineSource->GetPoint2()[1]) / 2, (lineSource->GetPoint1()[2] + lineSource->GetPoint2()[2]) / 2 };vtkNew<vtkLineSource> line;line->SetPoint1(1.0, 0.0, 0.0);line->SetPoint2(center);// Create a mapper and actorvtkNew<vtkPolyDataMapper> lineMapper;lineMapper->SetInputConnection(lineSource->GetOutputPort());vtkNew<vtkActor> lineActor;//lineActor->GetProperty()->SetColor(1.0,1.0,1.0);lineActor->GetProperty()->SetLineWidth(1);lineActor->SetMapper(lineMapper);vtkNew<vtkPolyDataMapper> lineMapper1;lineMapper1->SetInputConnection(line->GetOutputPort());vtkNew<vtkActor> lineActor1;//lineActor1->GetProperty()->SetColor(1.0, 1.0, 1.0);lineActor1->GetProperty()->SetLineWidth(1);lineActor1->SetMapper(lineMapper1);// Create a tube (cylinder) around the linevtkNew<vtkTubeFilter> tubeFilter;tubeFilter->SetInputConnection(line->GetOutputPort());tubeFilter->SetRadius(.025); // default is .5tubeFilter->SetNumberOfSides(50);tubeFilter->Update();// Create a mapper and actorvtkNew<vtkPolyDataMapper> tubeMapper;tubeMapper->SetInputConnection(tubeFilter->GetOutputPort());vtkNew<vtkActor> tubeActor;tubeActor->GetProperty()->SetOpacity(0.5); // Make the tube have some transparency.tubeActor->SetMapper(tubeMapper);// Create a renderer, render window, and interactorvtkNew<vtkRenderer> renderer;vtkNew<vtkRenderWindow> renderWindow;renderWindow->AddRenderer(renderer);renderWindow->SetWindowName("TubeFilter");vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;renderWindowInteractor->SetRenderWindow(renderWindow);// Add the actor to the scenerenderer->AddActor(tubeActor);renderer->AddActor(lineActor);renderer->AddActor(lineActor1);renderer->SetBackground(colors->GetColor3d("DarkSlateGray").GetData());// Render and interactrenderWindow->Render();renderWindowInteractor->Start();return EXIT_SUCCESS;
}

vtk绘制三维穿刺针相关推荐

  1. matplotlib绘制三维轨迹图

    1. 绘制基本三维曲线 # import necessary module from mpl_toolkits.mplot3d import axes3d import matplotlib.pypl ...

  2. python绘制三维轨迹_Python学习(一) —— matplotlib绘制三维轨迹图

    在研究SLAM时常常需要对其输出的位姿进行复现以检测算法效果,在ubuntu系统中使用Python可以很好的完成相关的工作. 一. Ubuntu下Python的使用 在Ubuntu下使用Python有 ...

  3. 在线作图|2分钟在线绘制三维CCA图

    ​三维CCA 典型相关分析(Canonical Correlation Analysis)是研究两组变量之间相关关系的一种多元统计方法,它能够揭示出两组变量之间的内在联系.冗余分析(redundanc ...

  4. R语言绘制三维散点图

    以下是scatterplot3d.Plot3D.rgl包绘制三维散点图的小示例. [Iris数据集] scatterplot3d包绘制三维散点图 #scatterplot3d 包,详情 ?scatte ...

  5. R语言使用persp函数绘制三维图像实战(3D):自定义3D图、图像旋转、添加轴标签

    R语言使用persp函数绘制三维图像实战(3D):自定义3D图.图像旋转.添加轴标签 目录

  6. cufflinks基于dataframe数据绘制三维散点图(3d scatter plot)

    cufflinks基于dataframe数据绘制三维散点图(3d scatter plot) 查看df.iplot对应的各种自定义参数,在jupyter notebook中输入如下信息: df.ipl ...

  7. Python可视化matplotlib绘制三维可视化图形(Three-Dimensional)

    Python可视化matplotlib绘制三维可视化图形(Three-Dimensional) Matplotlib最初设计时只考虑二维可视化绘图.大约在1.0版本发布的时候,在Matplotlib的 ...

  8. 利用Axes3D绘制三维性能曲面

    简 介: 绘制二维函数的3D曲面图可以帮助我们更好理解函数内所蕴含的规律.Axes3D是matplotlib中的绘制函数.利用surface, countour,countourf等可以很好的显示函数 ...

  9. Matlab 绘制三维立体图(以地质异常体为例)

    Matlab 绘制三维立体图(以地质异常体为例) 参考文章: (1)Matlab 绘制三维立体图(以地质异常体为例) (2)https://www.cnblogs.com/yangwenbo214/p ...

最新文章

  1. windows7安dns服务器_在Windows 7 上安装DNS服务器bind9方法详解
  2. Python内置数据结构及其复杂度
  3. 特征选择与特征权重区别
  4. 快速建立自己的个人网站!五款建站程序
  5. NIO学习--缓冲区
  6. 程序员面试金典 - 面试题 05.02. 二进制数转字符串(浮点型 转 二进制小数,乘2取整)
  7. C#学习常用方法(3000)---Foreach ,in
  8. 提取PCA变换后的图像的各主成分(matlab代码)
  9. 关于Stringbuffer的需要注意的几点
  10. 免费的身份证归属地查询接口
  11. USB Server助力广汽埃安U盾远程安全管控
  12. python图片转文字easyocr_EasyScreenOCR - 图片文字识别工具
  13. 中国朝代历史,名字的简介
  14. 用Python编程语言来实现阿姆斯特朗数的检查
  15. 推荐5个超级实用的 Python 模块,不知道就out啦!
  16. 【凝水成冰】记学生事务系统的结构化
  17. PTA航空公司VIP客户查询c++版——山东科技大学
  18. outlook从服务器中恢复已删除项目,Outlook 邮件误删,请问能否恢复?谢谢
  19. AD18系统设置界面各层详解
  20. v-for与v-if可以一起使用吗?如果同时使用v-for和v-if会存在什么样的问题?

热门文章

  1. Validate的使用
  2. 种植牙好不好?该怎么选择?
  3. iOS-申请邓白氏编码的超详细流程介绍(2017.06.12)
  4. 微服务中常用的限流算法(一)
  5. Java Web新闻发布系统02(系统功能)
  6. 如何实施企业采购战略?
  7. 身为程序员——你还不知道这十几个网站?
  8. netbios 协议以及返回值
  9. 转自【帮助中心】 C币的相关规则
  10. 绝对布局,setLayout(null)