首页 > 其他分享 >VTK 实例61:点云重建(表面重建)

VTK 实例61:点云重建(表面重建)

时间:2023-08-16 09:01:25浏览次数:41  
标签:rw VTK contourRender vtkSmartPointer 61 pointRender 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 <vtkPolyDataReader.h>
  8 #include <vtkPolyData.h>
  9 #include <vtkSurfaceReconstructionFilter.h>
 10 #include <vtkContourFilter.h>
 11 #include <vtkVertexGlyphFilter.h>
 12 #include <vtkPolyDataMapper.h>
 13 #include <vtkActor.h>
 14 #include <vtkRenderer.h>
 15 #include <vtkCamera.h>
 16 #include <vtkRenderWindow.h>
 17 #include <vtkRenderWindowInteractor.h>
 18 #include <vtkProperty.h>
 19 
 20 int main()
 21 {
 22     vtkSmartPointer<vtkPolyDataReader> reader =
 23         vtkSmartPointer<vtkPolyDataReader>::New();
 24     reader->SetFileName("C:\\Users\\Administrator\\Desktop\\VTK2\\hellovtk\\vtk_图像处理学习\\第六章_图像处理\\data\\fran_cut.vtk");
 25     reader->Update();
 26 
 27     vtkSmartPointer<vtkPolyData> points =
 28         vtkSmartPointer<vtkPolyData>::New();
 29     points->SetPoints(reader->GetOutput()->GetPoints()); //获得网格模型中的几何数据:点集
 30 
 31     vtkSmartPointer<vtkSurfaceReconstructionFilter> surf =
 32         vtkSmartPointer<vtkSurfaceReconstructionFilter>::New();
 33     surf->SetInputData(points);
 34     surf->SetNeighborhoodSize(20);
 35     surf->SetSampleSpacing(0.005);
 36     surf->Update();
 37 
 38     vtkSmartPointer<vtkContourFilter> contour =
 39         vtkSmartPointer<vtkContourFilter>::New();
 40     contour->SetInputConnection(surf->GetOutputPort());
 41     contour->SetValue(0, 0.0);
 42     contour->Update();
 43     //
 44     vtkSmartPointer <vtkVertexGlyphFilter> vertexGlyphFilter =
 45         vtkSmartPointer<vtkVertexGlyphFilter>::New();
 46     vertexGlyphFilter->AddInputData(points);
 47     vertexGlyphFilter->Update();
 48     vtkSmartPointer<vtkPolyDataMapper> pointMapper =
 49         vtkSmartPointer<vtkPolyDataMapper>::New();
 50     pointMapper->SetInputData(vertexGlyphFilter->GetOutput());
 51     pointMapper->ScalarVisibilityOff();
 52 
 53     vtkSmartPointer<vtkActor> pointActor =
 54         vtkSmartPointer<vtkActor>::New();
 55     pointActor->SetMapper(pointMapper);
 56     pointActor->GetProperty()->SetColor(1, 0, 0);
 57     pointActor->GetProperty()->SetPointSize(4);
 58 
 59     vtkSmartPointer<vtkPolyDataMapper> contourMapper =
 60         vtkSmartPointer<vtkPolyDataMapper>::New();
 61     contourMapper->SetInputData(contour->GetOutput());
 62     vtkSmartPointer<vtkActor> contourActor =
 63         vtkSmartPointer<vtkActor>::New();
 64     contourActor->SetMapper(contourMapper);
 65     ///
 66     double pointView[4] = { 0, 0, 0.5, 1 };
 67     double contourView[4] = { 0.5, 0, 1, 1 };
 68 
 69     vtkSmartPointer<vtkRenderer> pointRender =
 70         vtkSmartPointer<vtkRenderer>::New();
 71     pointRender->AddActor(pointActor);
 72     pointRender->SetViewport(pointView);
 73     pointRender->SetBackground(1, 1, 1);
 74 
 75     vtkSmartPointer<vtkRenderer> contourRender =
 76         vtkSmartPointer<vtkRenderer>::New();
 77     contourRender->AddActor(contourActor);
 78     contourRender->SetViewport(contourView);
 79     contourRender->SetBackground(0, 1, 0);
 80 
 81     pointRender->GetActiveCamera()->SetPosition(0, -1, 0);
 82     pointRender->GetActiveCamera()->SetFocalPoint(0, 0, 0);
 83     pointRender->GetActiveCamera()->SetViewUp(0, 0, 1);
 84     pointRender->GetActiveCamera()->Azimuth(30);
 85     pointRender->GetActiveCamera()->Elevation(30);
 86     pointRender->ResetCamera();
 87     contourRender->SetActiveCamera(pointRender->GetActiveCamera());
 88 
 89     vtkSmartPointer<vtkRenderWindow> rw =
 90         vtkSmartPointer<vtkRenderWindow>::New();
 91     rw->AddRenderer(pointRender);
 92     rw->AddRenderer(contourRender);
 93     rw->SetSize(640, 320);
 94     rw->SetWindowName("3D Surface Reconstruction ");
 95     rw->Render();
 96 
 97     vtkSmartPointer<vtkRenderWindowInteractor> rwi =
 98         vtkSmartPointer<vtkRenderWindowInteractor>::New();
 99     rwi->SetRenderWindow(rw);
100     rwi->Initialize();
101     rwi->Start();
102 
103     return 0;
104 }

标签:rw,VTK,contourRender,vtkSmartPointer,61,pointRender,New,include,重建
From: https://www.cnblogs.com/ybqjymy/p/17632975.html

相关文章

  • 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......
  • ARC161
    ARC161A排序后直接奇偶分类地填即可#include<bits/stdc++.h>usingnamespacestd;constintMAXN=2e5+5;intn;inta[MAXN];intb[MAXN];intmain(){//freopen("date.in","r",stdin);//freopen("date.out","w",stdout......
  • Oracle 重建口令文件
    介绍在管理Oracle的过程中,极少数情况会遇到口令文件的丢失,导致数据库无法正常使用。这时,就需要用到orapw命令来重建口令文件了。语法ORAPWDFILE=filename[PASSWORD=password][ENTRIES=numusers][FORCE={Y|N}][IGNORECASE={Y|N}]参数说明:FILE必选参数,口令文件的名称PASSWORD......
  • 『题解』ABC261Ex Game on Graph
    题目链接震惊!这个题竟然被神犇szs放进了博弈论里!我真的没看出来除了题面还有哪里像博弈论(也许是因为我菜)。转移方式很显然,按照题面说的做就行了。那么正解也就呼之欲出了。但是我知道大家都会正解,就是魔改的堆优化Dijkstra,所以我想说的是一种歪解,以及它是歪解的原因。歪解......
  • 20230616_京良路西延近况3
    京良路西延最新拆迁情况3良路西段工程备受咱房山居民关注杂谈君也是经常来到施工现场实探近日,这条交通要道又有最新进展了~目前变化比较大的就是丰台贺照云村北侧这段儿施工围挡近日已经安装到位了施工预留了一条村民出行小路施工围挡内停放了一台施工机械工人师傅......
  • 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......