首页 > 其他分享 >VTK 实例58:三角剖分(表面重建)

VTK 实例58:三角剖分(表面重建)

时间:2023-08-16 09:02:30浏览次数:36  
标签:58 剖分 VTK pointsActor vtkSmartPointer renderer renderWindow New include

 1 #include <vtkAutoInit.h>
 2 VTK_MODULE_INIT(vtkRenderingOpenGL2);
 3 VTK_MODULE_INIT(vtkRenderingFreeType);
 4 VTK_MODULE_INIT(vtkInteractionStyle);
 5 
 6 #include <vtkSmartPointer.h>
 7 #include <vtkProperty.h>
 8 #include <vtkPoints.h>
 9 #include <vtkPolyData.h>
10 #include <vtkPointData.h>
11 #include <vtkDelaunay2D.h>
12 #include <vtkMath.h>
13 #include <vtkPolyDataMapper.h>
14 #include <vtkActor.h>
15 #include <vtkRenderWindow.h>
16 #include <vtkRenderer.h>
17 #include <vtkRenderWindowInteractor.h>
18 #include <vtkVertexGlyphFilter.h>
19 
20 int main(int, char *[])
21 {
22     unsigned int gridSize = 10;
23     vtkSmartPointer<vtkPoints> points =
24         vtkSmartPointer<vtkPoints>::New();
25     for(unsigned int x = 0; x < gridSize; x++)
26     {
27         for(unsigned int y = 0; y < gridSize; y++)
28         {
29             points->InsertNextPoint(x, y, vtkMath::Random(0.0, 3.0));
30         }
31     }
32 
33     vtkSmartPointer<vtkPolyData> polydata =
34         vtkSmartPointer<vtkPolyData>::New();
35     polydata->SetPoints(points);
36 
37     vtkSmartPointer<vtkDelaunay2D> delaunay =
38         vtkSmartPointer<vtkDelaunay2D>::New();
39     delaunay->SetInputData(polydata);
40     delaunay->Update();
41 
42     vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
43         vtkSmartPointer<vtkVertexGlyphFilter>::New();
44     glyphFilter->SetInputData(polydata);
45     glyphFilter->Update();
46 
47     vtkSmartPointer<vtkPolyDataMapper> pointsMapper =
48         vtkSmartPointer<vtkPolyDataMapper>::New();
49     pointsMapper->SetInputData(glyphFilter->GetOutput());
50 
51     vtkSmartPointer<vtkActor> pointsActor =
52         vtkSmartPointer<vtkActor>::New();
53     pointsActor->SetMapper(pointsMapper);
54     pointsActor->GetProperty()->SetPointSize(3);
55     pointsActor->GetProperty()->SetColor(1,0,0);
56 
57     vtkSmartPointer<vtkPolyDataMapper> triangulatedMapper =
58         vtkSmartPointer<vtkPolyDataMapper>::New();
59     triangulatedMapper->SetInputData(delaunay->GetOutput());
60 
61     vtkSmartPointer<vtkActor> triangulatedActor =
62         vtkSmartPointer<vtkActor>::New();
63     triangulatedActor->SetMapper(triangulatedMapper);
64 
65     vtkSmartPointer<vtkRenderer> renderer =
66         vtkSmartPointer<vtkRenderer>::New();
67     renderer->AddActor(pointsActor);
68     renderer->AddActor(triangulatedActor);
69     renderer->SetBackground(1.0, 1.0, 1.0);
70 
71     vtkSmartPointer<vtkRenderWindow> renderWindow =
72         vtkSmartPointer<vtkRenderWindow>::New();
73     renderWindow->AddRenderer(renderer);
74 
75     vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
76         vtkSmartPointer<vtkRenderWindowInteractor>::New();
77     renderWindowInteractor->SetRenderWindow(renderWindow);
78 
79     renderWindow->SetSize(640, 320);
80     renderWindow->Render();
81     renderWindow->SetWindowName("PolyDataDelaunay2D");
82     renderWindow->Render();
83 
84     renderWindowInteractor->Start();
85 
86     return EXIT_SUCCESS;
87 }

标签:58,剖分,VTK,pointsActor,vtkSmartPointer,renderer,renderWindow,New,include
From: https://www.cnblogs.com/ybqjymy/p/17632971.html

相关文章

  • VTK 实例59:加入边界限制的三角剖分(表面重建)
    1#include<vtkAutoInit.h>2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkRenderingFreeType);4VTK_MODULE_INIT(vtkInteractionStyle);56#include<vtkSmartPointer.h>7#include<vtkProperty.h>8#include&......
  • VTK 实例60:等值面提取(表面重建)
    1#include<vtkAutoInit.h>2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkRenderingFreeType);4VTK_MODULE_INIT(vtkInteractionStyle);56#include<vtkSmartPointer.h>7#include<vtkMarchingCubes.h>8#include<......
  • VTK 实例61:点云重建(表面重建)
    1#include<vtkAutoInit.h>2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkRenderingFreeType);4VTK_MODULE_INIT(vtkInteractionStyle);56#include<vtkSmartPointer.h>7#include<vtkPolyDataReader.h>8#inc......
  • VTK 实例62:点云配准
    1#include<vtkAutoInit.h>2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkRenderingFreeType);4VTK_MODULE_INIT(vtkInteractionStyle);56#include<vtkPoints.h>7#include<vtkSmartPointer.h>8#include<......
  • VTK 实例63:纹理映射
    1#include<vtkAutoInit.h>2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkRenderingFreeType);4VTK_MODULE_INIT(vtkInteractionStyle);56#include<vtkSmartPointer.h>7#include<vtkRenderWindowInteractor.h>8#inc......
  • cf 583 B. Robot's Task(模拟)
    链接:http://codeforces.com/problemset/problem/583/B//求改变的方向次数//直接模拟题目是从1开始所以从左到右从右到左#include<stdio.h>#include<algorithm>usingnamespacestd;inta[1000+10];intvis[1000+10];intmain(){intn,t=0;scanf("%d",&n);......
  • VTK 实例45:理想低通滤波器(频域处理)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkImageIdealLowPass.h>8#include&l......
  • VTK 实例46:巴特沃斯低通滤波器(频域处理)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkImageButterworthLowPass.h>8#incl......
  • VTK 实例47:理想高通滤波器(频域处理)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkImageIdealHighPass.h>8#include&......
  • VTK 实例48:巴沃斯特高通滤波器(频域处理)
    1#include"vtkAutoInit.h"2VTK_MODULE_INIT(vtkRenderingOpenGL2);3VTK_MODULE_INIT(vtkInteractionStyle);45#include<vtkSmartPointer.h>6#include<vtkImageData.h>7#include<vtkImageButterworthHighPass.h>8#inc......