VTK中Wights功能的实现需要两个部分的协作:

  1. 事件处理,继承于 vtkAbstractWight 类
  2. 描述几何特征,继承于 vtkWightRespresentation
vtkContourWidget 简介
用一个点集创建一个轮廓。
该类常常用于选取一个点集,绘制点之间的连线。最后一个点的选取决定了,轮廓是闭合的还是是开放的。
vtkContourRepresentation 这个类负责所有点的位置,连线的计算,以及轮廓的操作,点、线的绘制。
关于这个respresentation;
监听事件
   LeftButtonPressEvent - triggers a Select event
   RightButtonPressEvent - triggers a AddFinalPoint event
   MouseMoveEvent - triggers a Move event
   LeftButtonReleaseEvent  - triggers an EndSelect event
   Delete key event - triggers a Delete event
   Shift + Delete key event - triggers a Reset event
还有一些其他的事件
继承图

利用 vtkContourWidget 画一个闭合区域取点原则:最后一个和第一个结点重合
示例
#include <vtkSmartPointer.h>
// To setup the ContourWidget and its representation:
#include <vtkContourWidget.h>
#include <vtkProperty.h>
#include <vtkOrientedGlyphContourRepresentation.h>
// To create the geometry:
#include <vtkPolyData.h>
#include <vtkCellArray.h>
#include <vtkPoints.h>
#include <vtkMath.h>
// Usual VTK pipeline elements:
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleTrackballCamera.h>int main( int argc, char *argv[] )
{// Create the contour widgetvtkSmartPointer<vtkContourWidget> contourWidget = vtkSmartPointer<vtkContourWidget>::New();// Override the default representation for the contour widget to customize its lookvtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRepresentation =vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();contourRepresentation->GetLinesProperty()->SetColor(1, 0, 0); // Set color to redcontourWidget->SetRepresentation(contourRepresentation);// Generate a set of points arranged in a circleint numPts = 10;vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();for (int i = 0; i < numPts; i++){// Create numPts points evenly spread around a circumference of radius 0.1const double angle = 2.0*vtkMath::Pi()*i/numPts;points->InsertPoint(static_cast<vtkIdType>(i), 0.1*cos(angle), 0.1*sin(angle), 0.0 );}// Create a cell array to connect the points into meaningful geometryvtkIdType* vertexIndices = new vtkIdType[numPts+1];for (int i = 0; i < numPts; i++) { vertexIndices[i] = static_cast<vtkIdType>(i); }// Set the last vertex to 0; this means the last line segment will join the 19th point (vertices[19])// with the first one (vertices[0]), thus closing the circle.vertexIndices[numPts] = 0;vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();lines->InsertNextCell(numPts+1, vertexIndices);// Create polydata to hold the geometry just created, and populate itvtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();polydata->SetPoints(points);polydata->SetLines(lines);// Create the renderer to visualize the scenevtkSmartPointer<vtkRenderer> renderer =  vtkSmartPointer<vtkRenderer>::New();renderer->SetBackground(0.1, 0.2, 0.4);            // Set a dark blue background (default is black)// Create the GUI window to hold the rendered scenevtkSmartPointer<vtkRenderWindow> renderWindow =   vtkSmartPointer<vtkRenderWindow>::New();renderWindow->AddRenderer(renderer);// Create the events manager for the renderer windowvtkSmartPointer<vtkRenderWindowInteractor> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();interactor->SetRenderWindow(renderWindow);// Use the "trackball camera" interactor style, rather than the default "joystick camera"vtkSmartPointer<vtkInteractorStyleTrackballCamera> style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();interactor->SetInteractorStyle(style);// Set up the contour widget within the visualization pipeline just assembledcontourWidget->SetInteractor(interactor);contourWidget->On();                           // Turn on the interactor observercontourWidget->Initialize(polydata);std::cout << "the number of nodes is " << contourRepresentation->GetNumberOfNodes() << std::endl;// you can get node world position of one node by GetNthNodeWorldPosition(pointID, double_pos[3]) renderer->ResetCamera();                      // Reposition camera to fit the scene elementsinteractor->Initialize();// Start the interactioninteractor->Start();return EXIT_SUCCESS;
}
暂时还没有想到还有什么,可能之后再补充吧

VTK-Wight 之 vtkContourWidget简介相关推荐

  1. java vtk 三维_[WPF VTK]三维图形开发基础(四)

    0.条条大路 前面介绍的使用WPF自己撰写算法实现点数据的三角划分以图实现轮廓的三维重构. 但简单的算法以及不加其他处理效果不佳,对于点数据的三角划分在查阅了一些论文后发现有: 基于图的最短路径.De ...

  2. 【医学图像处理】 8 VTKITK软件开发平台

    VTK&ITK 1 VTK简介 2 ITK简介 1 VTK简介   VTK(The Visualization ToolKit): 可视化的开源工具包.可自由使用的图像处理和可视化的三维计算机 ...

  3. PCL第三方库:Eigen, Flann , Qhull, VTK, Boost简介

    前言: PCL作为机器人软件的一个基础类库,融合了基础结构.算法和三维显示.其大量使用第三方库,使用了Boost.Eigen.Flann.VTK.Boost.CUdnn等. 第一预备役:Boost   ...

  4. PCL(Point Cloud Library)的第三方库简介(boost,eigen,flann,vtk,qhull)

    PCL因为融合了大量的第三方开源库,导致学习成本升高~在学习之前我们不妨了解一下这些库都是干嘛的,以便有的放矢,在之后更好的使用 boost: C++的标准库的备用版,擅长从数学库到智能指针,从模板元 ...

  5. vtk相机_C#开发PACS医学影像三维重建(一)使用VTK重建3D影像

    VTK简介: VTK是一个开源的免费软件系统,主要用于三维计算机图形学.图像处理和可视化.Vtk是在面向对象原理的基础上设计和实现的,它的内核是用C++构建的. 因为使用C#语言开发,而VTK是C++ ...

  6. python入门基础教程02 Python简介

    02 Python简介 Python简介 Python是一种解释型.面向对象.动态数据类型的高级程序设计语言,属于应用层软件.自从20 世纪90 年代初Python语言诞生至今,它逐渐被广泛应用于处理 ...

  7. VTK:小部件之ContourWidget

    VTK:小部件之ContourWidget VTK:小部件之ContourWidget 代码 ContourWidget.cxx VTK:小部件之ContourWidget 代码 ContourWid ...

  8. Matplotlib 中文用户指南 1 简介

    简介 原文:Introduction 译者:飞龙 协议:CC BY-NC-SA 4.0 Matplotlib 是一个用于在 Python 中绘制数组的 2D 图形库.虽然它起源于模仿 MATLAB®[ ...

  9. 《从问题到程序:用Python学编程和计算》——1.2 Python语言简介

    本节书摘来自华章计算机<从问题到程序:用Python学编程和计算>一书中的第1章,第1.2节,作者 裘宗燕,更多章节内容可以访问云栖社区"华章计算机"公众号查看. 1. ...

  10. 开源项目推荐:OpenGL/Vulkan/Cairo/Skia/angle/VTK/OpenVG/MyPaint/GIMP/Krita/Pencil2D/inkspace/enve等绘图库或画图软件

    绘图引擎简介 Windows环境下二维绘图引擎有多种选择:GDI.GDI+.DirectDraw.Qt/QPainter.Agg.Cairo.skia.Direct2D.Direct3D.OpenGL ...

最新文章

  1. linux 没有那个文件或目录_基于CentOS8Linux运维教程-Linux文件目录管理笔记
  2. 如何写好和创作经济学论文?
  3. 兰州理工大学计算机考研真题,2017年兰州理工大学计算机与通信学院893计算机操作系统考研题库...
  4. win服务器系统程序原因分析
  5. shiro 散列加盐(salt) 次数的效果
  6. webrtc agc matlab,c++ WebRTC AGC(自动增益控制)
  7. 十年架构师:我是这样手写Spring的,用300行代码体现优雅之道
  8. python 按条件选择行和列数据_小白学数据结构-排序算法Python(冒泡、选择、快速、希尔等等)...
  9. 清空文件夹里面的所有文件和文件夹
  10. linux分区合并不损坏系统,不损坏数据的情况下 linux磁盘如何扩展 LVM格式
  11. html页面转换pdf.txt
  12. 实验教学管理系统 c语言程序代写源码下载
  13. C++编写程序:输入三角形的三边,判断三角形的类型。
  14. outlook服务器邮件满了怎么办,Outlook邮箱不能接收邮件提示邮件箱已满怎么办?
  15. word文档通配符换行_PDF如何转化成Word文档?
  16. 微信支付:appid 与 openId 不配
  17. HTML5 新的 Input 类型
  18. 10分钟用Python制作恋爱日志!
  19. ROS2机器人操作系统简介2021英文字幕版本
  20. 数据库系统--码,超码,候选码,主属性,非主属性,主码,全码,外码基本概念

热门文章

  1. 【Github资源大汇总】 - 王朋
  2. wnmp支持php文件,Windows下配置nginx+php(wnmp)
  3. ThreeJs基础代码段(五)飘扬的旗帜
  4. Thinkphp 5.1安装
  5. STM32 I2S学习(一)
  6. 使用经典的基本播放命令和 MML 创建 MIDI 文件
  7. rx全家桶使用博客网址
  8. Widows下安装SCALA
  9. 微信平台注册APP签名获取方法
  10. matlab入门教程ppt,[2018年最新整理]matlab入门PPT教程.ppt