-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathReconstructFromPoints.cxx
50 lines (41 loc) · 1.36 KB
/
ReconstructFromPoints.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <vtkSmartPointer.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include "vtkPolyDataReader.h"
#include "vtkPolyDataWriter.h"
#include "vtkUnstructuredGrid.h"
#include <vtkPowerCrustSurfaceReconstruction.h>
int main(int argc, char *argv[])
{
if ( argc < 2 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " iPointsFile oSurface" << std::endl;
return EXIT_FAILURE;
}
unsigned int m_NumberOfPoints;
std::fstream infile;
infile.open ( argv[1], std::ios::in );
infile >> m_NumberOfPoints;
double p[3];
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
for( unsigned int i = 0; i < m_NumberOfPoints; i++ )
{
infile >> p[0];
infile >> p[1];
infile >> p[2];
points->InsertPoint(i,p);
std::cout << p[0] << ' ' << p[1] << ' ' << p[2] << std::endl;
}
vtkSmartPointer<vtkPolyData> dataSet = vtkSmartPointer<vtkPolyData>::New();
dataSet->SetPoints( points );
vtkSmartPointer<vtkPowerCrustSurfaceReconstruction> reconstruct =
vtkSmartPointer<vtkPowerCrustSurfaceReconstruction>::New();
reconstruct->SetInputData( dataSet );
reconstruct->Update();
vtkSmartPointer<vtkPolyDataWriter> writer = vtkSmartPointer<vtkPolyDataWriter>::New();
writer->SetInputData( reconstruct->GetMedialSurface() );
writer->SetFileName( argv[2] );
writer->Write();
return EXIT_SUCCESS;
}