当前位置:网站首页>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;
}
边栏推荐
- 多商户商城系统功能拆解17讲-平台端订单列表
- Brief introduction and use of mqtt entry level
- [leetcode] 1331. Array sequence number conversion
- 468产品策划与推广方案(150份)
- TDengine 助力西门子轻量级数字化解决方案
- Thoughts on the construction of some enterprise data platforms
- 企鹅一面:为什么不建议使用SELECT * ?
- The 35 required questions in MySQL interview are illustrated, which is too easy to understand
- (function(global,factory){
- Getting started with scottplot tutorial: getting and displaying values at the mouse
猜你喜欢

Many "double first-class" universities have launched the research guarantee and prediction name!

7月29日 ApacheCon|Apache Pulsar 在 vivo 的探索与实践 即将开播

数字化转型安全问题频发,山石网科助力数字政府建设
C # 7 methods to obtain the current path
![[thread safety] what risks may multithreading bring?](/img/79/112ab7e586b0bceb296dfddb2728be.png)
[thread safety] what risks may multithreading bring?

Redis configuration file explanation
![[ecmascript6] other new interface features](/img/da/377f93d83b6722bf250d270e4eea28.png)
[ecmascript6] other new interface features
Excel VBA 开发过程中遇到的一些问题,解决方案,持续更新

ZABBIX distributed

【七夕】七夕孤寡小青蛙究极版?七夕节最终章!
随机推荐
unittest执行runTestCase提示<_io.TextIOWrapper name=‘<stderr>‘ mode=‘w‘ encoding=‘utf-8‘>解决方案
Use of formdata object, VAR formdata=new formdata()
TDengine 助力西门子轻量级数字化解决方案
The 35 required questions in MySQL interview are illustrated, which is too easy to understand
Swiftui layout - alignment
(function(global,factory){
Second class exercise
Several methods of opening URL in swiftui view
Langjing Technology (Trax China) "robot +ai" opens the era of Chinese retail meta universe
多线程顺序运行有几种方法?
How to perform batch operations in core data
OKR and grad
在 SwiftUI 视图中打开 URL 的若干方法
【七夕】七夕孤寡小青蛙究极版?七夕节最终章!
Focus on differentiated product design, intelligent technology efficiency improvement and literacy education around new citizen Finance
1st pre class exercise
Excel VBA 免密查看VBE加密代码
Create a table under swiftui with table
How does core data save data in SQLite
58子站安居,经纪人营销管理平台登录接口加密逆向