반응형
* Visual Studio 빌드
- 소스: https://github.com/daviddoria/PoissonReconstruction
- kazhdan 원본 소스(https://github.com/mkazhdan/PoissonRecon)를 vtk에서 작동가능하게 함
- VTK Poisson Reconstruction을 작동하기 위해서는 vertex normal이 계산되어야 함
- vtk 9.3에서는 vtkPCANormalEstimation 이용해서 vertex normal 생성
- vtk 9.3 이전 버전에서는 vtkPolyDataNormals 이용해서 vertex normal 생성
- vertex normal 자료형은 vtkDoubleArray가 아닌 vtkFloatArray으로 해야 VTK Poisson Reconstruction 작동함
*예제 코드
#include <vtkSmartPointer.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkXMLPolyDataWriter.h>
#include "vtkPoissonReconstruction.h"
int main(int argc, char *argv[])
{
if ( argc < 4 )
{
cout << "PoissonReconstruction takes 3 arguments: " << endl;
cout << "1-Input file (*.vtp)" << endl;
cout << "2-Depth" << endl;
cout << "3-Output file (*.vtp)" << endl;
return EXIT_FAILURE;
}
std::string inputFileName = argv[1]; //"horsePoints.vtp";
std::string outputFileName = argv[3]; //"horse.vtp";
int depth = atoi(argv[2]);
vtkSmartPointer< vtkXMLPolyDataReader > reader =
vtkSmartPointer< vtkXMLPolyDataReader >::New();
reader->SetFileName( inputFileName.c_str() );
reader->Update();
vtkSmartPointer< vtkPoissonReconstruction > poissonFilter =
vtkSmartPointer< vtkPoissonReconstruction >::New();
poissonFilter->SetDepth(depth);
poissonFilter->SetInputConnection( reader->GetOutputPort() );
poissonFilter->Update();
vtkSmartPointer< vtkXMLPolyDataWriter > writer =
vtkSmartPointer< vtkXMLPolyDataWriter >::New();
writer->SetInputConnection( poissonFilter->GetOutputPort() );
writer->SetFileName( outputFileName.c_str() );
writer->Update();
return EXIT_SUCCESS;
}
반응형
'VTK' 카테고리의 다른 글
VTK Non Manifold Face 삭제 코드 (0) | 2024.05.28 |
---|