VTK practicing the Road 56: Advanced graphics elementary operations _ surface reconstruction (3D point cloud surface reconstruction)

1. point cloud reconstruction

Although Delaunay triangulation algorithm can be implemented mesh surface reconstruction, but its application is mainly split in two-dimensional, three-dimensional space having problems in mesh generation. Because the three-dimensional point cloud surface reconstruction, Delaunay condition is not satisfied, not only on the determination of the maximum and minimum angle of diagonal switching criterion is not established, and the circumscribed circle Delaunay triangulation-based criterion can not guarantee the quality of the mesh.
VTKSurfaceReconstructionFilter is to achieve an implicit method for surface reconstruction, i.e. seen as a curved surface contour signed distance function from the inside and outside surfaces of opposite sign worth, and the zero set is also desired curved surface. This method requires meshing point cloud data, and then estimating the direction of a tangent plane for each point and each point to the nearest tangent plane approximate distance from the surface. Thus the volume data to obtain a symbol distance. In this way, we can use VTKContourFilter to extract zero isosurface to obtain the corresponding grid.
Face using point cloud data grid face surface reconstruction examples are as follows:
[cpp]  view plain  copy
  1. #include <vtkAutoInit.h>  
  2. VTK_MODULE_INIT(vtkRenderingOpenGL);  
  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("fran_cut.vtk");  
  25.     reader->Update();  
  26.   
  27.     vtkSmartPointer<vtkPolyData> points =  
  28.         vtkSmartPointer<vtkPolyData>::New();  
  29.     points->SetPoints(reader->GetOutput()->GetPoints()); // get the mesh geometry data: set of points  
  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. }  

When using VTKSurfaceReconstructionFilter, mainly related to two parameters, respectively using the function SetNeighborhoodSize () and SetSampleSpacing () set.
SetNeighborhoodSize: Set the number of points in the neighborhood; which is used to estimate the points in the neighborhood of each point of the local cut plane. The default number of points in the neighborhood of 20, capable of handling most of the reconstruction. The more the number of set, the longer the time-consuming calculation. When the cloud point where Uneven distribution, consider increasing the value.
SetSampleSpacing: meshing for setting a denser grid spacing, with a small spacing, grid, generally default value 0.05.
The output of the embodiment as shown below:

2. See data

1.《C++ primer》
2.《The VTK User’s Guide – 11thEdition》

3. Zhang Xiaodong, Luo fire spirit. VTK graphic image development of advanced [M]. Machinery Industry Press, 2015.

Turn: https: //blog.csdn.net/shenziheng1/article/details/54880915

Intelligent Recommendation

PCL point cloud surface reconstruction--resampling

Some errors are generated when measuring smaller objects. Direct reconstruction will make the surface unsmooth or vulnerable. In order to build a complete model, the surface needs to be smoothed and t...

[Speed ​​reading of point cloud papers] Point cloud high quality 3D surface reconstruction

Point cloud PCL free knowledge planet, speed reading of point cloud papers. Title: Local Implicit Grid Representations for 3D Scenes Author: Chiyu "Max" Jiang1,2 Avneesh Sud Planet ID: parti...

VTK 3D reconstruction Volume rendering Surface rendering Surface cutting Manual cutting

VTK 3D reconstruction Volume rendering Surface rendering Surface cutting Manual cutting Sectional framework MFC, VTK content C++, platform independent I wrote it a few years ago, but I used VTK 5.10 b...

VTK series 58_vtk triangulation (surface reconstruction)

Example 58: Triangular section (surface reconstruction) VTK series directory: 1 VTK basic concept 2 VTK image processing 3 VTK graphics processing 4 VTK body painting...

Open3D Surface Reconstruction Surface Reconstruction

Surface reconstruction surface reconstruction In many cases, we want to generate dense 3D geometry, Triangle Mesh. However, we can only get non -structured point clouds from multi -view points or deep...

More Recommendation

PCL 3D reconstruction VTK DELANAY point cloud grid

The three -dimensional reconstruction of Dianyun mainly includes: delaunay - MC - Poisson - Stich - Level set The grid is mainly used in computer graphics, including triangle and four -corner grids. M...

PCL study notes - point cloud surface reconstruction (1)

I. Surface reconstruction based on polynomial smooth point cloud and normal estimation This section describes normal estimation, point cloud smoothing, and data resampling based on Moving Least Square...

PCL study notes - point cloud surface reconstruction (3)

3. Rapid triangulation of disordered point clouds This example describes how to use the greedy projection triangulation algorithm to triangulate a directed point cloud by first projecting a directed p...

PCL point cloud and depth map transformation and surface reconstruction

background: Sometimes the point cloud data we obtain is obtained from a viewpoint. In order to use the calculation method related to the depth map to improve efficiency, we need to convert the point c...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top