pcl学习笔记

c++中点云体积测量

2019-03-29  本文已影响0人  阁楼No1

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);
}

结果如下


运行结果
上一篇下一篇

猜你喜欢

热点阅读