pcl中點云體積測量杠袱,代碼如下:
#include <iostream>
#include <vtkPLYReader.h>
#include <vtkTriangleFilter.h>
#include <vtkSmartPointer.h>
#include <vtkMassProperties.h>
using namespace std;
int main(int argc, char** argv)
{
string inputFilename = "E:/PointCloud/data/blade.ply";
//vtkSmartPointer<vtkPLYWriter> writer = vtkSmartPointer<vtkPLYWriter>::New();
vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
reader->SetFileName(inputFilename.c_str());
reader->Update();
vtkSmartPointer<vtkTriangleFilter> tri = vtkSmartPointer<vtkTriangleFilter>::New();
tri->SetInputData(reader->GetOutput());
tri->Update();
vtkSmartPointer<vtkMassProperties> poly = vtkSmartPointer<vtkMassProperties>::New();
poly->SetInputData(tri->GetOutput());
poly->Update();
double vol = poly->GetVolume();
double area = poly->GetSurfaceArea();
cout << "體積為:" << vol << endl;
cout << "表面積為:" << area << endl;
system("pause");
return (0);
}
結果如下