当前位置:网站首页>VTK vtkcontourwidget extracts regions of interest
VTK vtkcontourwidget extracts regions of interest
2022-07-28 14:52:00 【Love the west wind】
vtkContourWidget brief introduction
It is mainly used to represent a point set , There are connections between point sets , Adjacent point , Not any point . The selection of the last point determines , Is the outline closed or open .
Use scenarios :
It can usually be used to extract regions of interest ; See the picture

official demo
#include <vtkCellArray.h>
#include <vtkContourWidget.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkMath.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkOrientedGlyphContourRepresentation.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
int main(int /* argc */, char* /* argv */[])
{
vtkNew<vtkNamedColors> colors;
// Create the contour widget
vtkNew<vtkContourWidget> contourWidget;
// Override the default representation for the contour widget to customize its
// look
vtkNew<vtkOrientedGlyphContourRepresentation> contourRepresentation;
contourRepresentation->GetLinesProperty()->SetColor(
colors->GetColor3d("Red").GetData());
contourWidget->SetRepresentation(contourRepresentation);
// Generate a set of points arranged in a circle
int numPts = 10;
vtkNew<vtkPoints> points;
for (int i = 0; i < numPts; i++)
{
// Create numPts points evenly spread around a circumference of radius 0.1
const 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 geometry
vtkIdType* 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;
vtkNew<vtkCellArray> lines;
lines->InsertNextCell(numPts + 1, vertexIndices);
// Create polydata to hold the geometry just created, and populate it
vtkNew<vtkPolyData> polydata;
polydata->SetPoints(points);
polydata->SetLines(lines);
// Create the renderer to visualize the scene
vtkNew<vtkRenderer> renderer;
renderer->SetBackground(colors->GetColor3d("MidnightBlue").GetData());
// Create the GUI window to hold the rendered scene
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowName("ContourWidget");
renderWindow->SetSize(600, 600);
// Create the events manager for the renderer window
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(renderWindow);
// Use the "trackball camera" interactor style, rather than the default
// "joystick camera"
vtkNew<vtkInteractorStyleTrackballCamera> style;
interactor->SetInteractorStyle(style);
// Set up the contour widget within the visualization pipeline just assembled
contourWidget->SetInteractor(interactor);
contourWidget->On(); // Turn on the interactor observer
contourWidget->Initialize(polydata);
renderer->ResetCamera(); // Reposition camera to fit the scene elements
// Start the interaction
renderWindow->Render();
interactor->Start();
return EXIT_SUCCESS;
}
边栏推荐
- Switch the cloud synchronization status of core data in real time
- [线程安全问题] 多线程到底可能会带来哪些风险?
- [ecmascript6] async and await
- Interviewer: what are the usage scenarios of ThreadLocal? How to avoid memory leakage?
- Afnetworking crash course
- 八、picker用法 下拉框选择效果
- The second pre class exercise
- Chi square distribution and gamma function
- 看了就会的 Rainbond 入门教程
- Why can the anonymous functions of JQ access the methods inside
猜你喜欢

2022 high altitude installation, maintenance, removal of examination question bank and online simulated examination

C语言中浮点数据类型(你学废了吗)

2022 melting welding and thermal cutting examination questions and online simulation examination

Hcip day 11

Getting started with scottplot tutorial: getting and displaying values at the mouse

Analysis of thrift serialization protocol

It's so hot that solar power can't take off? Hello, head
![[ecmascript6] other new interface features](/img/da/377f93d83b6722bf250d270e4eea28.png)
[ecmascript6] other new interface features

基于 MinIO 对象存储保障 Rancher 数据

数字化转型安全问题频发,山石网科助力数字政府建设
随机推荐
Unittest executes runtestcase prompt <_ io. Textiowrapper name= '< stderr>' mode=W encoding=UTF-8 > solution
MQTT入门级简单介绍与使用
@Solution to DS ('slave') multi data source compatible transaction problem
js的实例化方式
Second class exercise
Ability to add class @published for custom attribute wrapper types
Chi square distribution and gamma function
OKR and grad
C# 读取ini文件、键值对操作
Hand in hand from 0 to a "Nuggets special attention" Google plug-in, 5000 words detailed vue3 responsive principle, the advantages, disadvantages and choices of several cache read-write schemes, flyin
Afnetworking crash course
文件批量重命名工具Bulk Rename Utility
C # read INI file and key value pair operation
Digital transformation security issues occur frequently, and Shanshi Netcom helps build a digital government
It's so hot that solar power can't take off? Hello, head
2022 safety officer-a certificate operation certificate examination question bank simulated examination platform operation
String转为long 类型报错原因:要转为long必须是int、double、float型[通俗易懂]
国产数据库的红利还能“吃”多久?
35道MySQL面试必问题图解,这样也太好理解了吧
10、 Timestamp